Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 0/1] avformat/concatdec: fix seek with dts
@ 2024-01-26 17:14 Nicolas Gaullier
  2024-01-26 17:14 ` [FFmpeg-devel] [PATCH] " Nicolas Gaullier
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Gaullier @ 2024-01-26 17:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nicolas Gaullier

I have a bunch of patches about probing and making better concatdec, this is the first one.
Unfortunately, this is mostly about heuristics and find_stream_info things no one like very much.

This first patch seems very straightforward: there is already an heuristic in fftools for seeking,
and the same one is required when opening a file indirectly through concatdec.
(I can share a sample to reproduce the issue, but this is very commonplace).

fate results is updated for one test that uses lavf.ts (two "inpoint" directives in the script, thus two modified blocks).
Note: more packets are read but they are usually trimmed through segment_time_metadata etc.

Nicolas Gaullier (1):
  avformat/concatdec: fix seek with dts

 libavformat/concatdec.c                       | 17 +++++++-
 tests/ref/fate/concat-demuxer-simple2-lavf-ts | 40 ++++++++++++++++++-
 2 files changed, 54 insertions(+), 3 deletions(-)

-- 
2.30.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [FFmpeg-devel] [PATCH] avformat/concatdec: fix seek with dts
  2024-01-26 17:14 [FFmpeg-devel] [PATCH 0/1] avformat/concatdec: fix seek with dts Nicolas Gaullier
@ 2024-01-26 17:14 ` Nicolas Gaullier
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Gaullier @ 2024-01-26 17:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Nicolas Gaullier

Use same heuristic as in fftools.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
---
 libavformat/concatdec.c                       | 17 +++++++-
 tests/ref/fate/concat-demuxer-simple2-lavf-ts | 40 ++++++++++++++++++-
 2 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index ffa8ade25b..96de9117fe 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -384,7 +384,22 @@ static int open_file(AVFormatContext *avf, unsigned fileno)
     if ((ret = match_streams(avf)) < 0)
         return ret;
     if (file->inpoint != AV_NOPTS_VALUE) {
-       if ((ret = avformat_seek_file(cat->avf, -1, INT64_MIN, file->inpoint, file->inpoint, 0)) < 0)
+        int64_t seek_timestamp = file->inpoint;
+        if (!(cat->avf->iformat->flags & AVFMT_SEEK_TO_PTS)) {
+            int dts_heuristic = 0;
+            int i;
+            for (i=0; i<cat->avf->nb_streams; i++) {
+                const AVCodecParameters *par = cat->avf->streams[i]->codecpar;
+                if (par->video_delay) {
+                    dts_heuristic = 1;
+                    break;
+                }
+            }
+            if (dts_heuristic) {
+                seek_timestamp -= 3*AV_TIME_BASE / 23;
+            }
+        }
+        if ((ret = avformat_seek_file(cat->avf, -1, INT64_MIN, seek_timestamp, seek_timestamp, 0)) < 0)
            return ret;
     }
     return 0;
diff --git a/tests/ref/fate/concat-demuxer-simple2-lavf-ts b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
index 548cab01c6..329b42fbe9 100644
--- a/tests/ref/fate/concat-demuxer-simple2-lavf-ts
+++ b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
@@ -126,6 +126,24 @@ audio|0|177970|1.977444|177970|1.977444|2351|0.026122|209|N/A|K__
 audio|0|180321|2.003567|180321|2.003567|2351|0.026122|209|N/A|K__
 video|1|174764|1.941822|171164|1.901822|3600|0.040000|12678|347800|___|MPEGTS Stream ID|224
 video|1|178364|1.981822|174764|1.941822|3600|0.040000|24711|361336|K__
+video|1|125182|1.390911|121582|1.350911|3600|0.040000|12398|254552|___|MPEGTS Stream ID|224
+video|1|128782|1.430911|125182|1.390911|3600|0.040000|13455|267336|___|MPEGTS Stream ID|224
+audio|0|99515|1.105722|99515|1.105722|2351|0.026122|209|308508|K__|MPEGTS Stream ID|192
+audio|0|101866|1.131844|101866|1.131844|2351|0.026122|209|N/A|K__
+audio|0|104217|1.157967|104217|1.157967|2351|0.026122|209|N/A|K__
+audio|0|106568|1.184089|106568|1.184089|2351|0.026122|209|N/A|K__
+audio|0|108919|1.210211|108919|1.210211|2351|0.026122|209|N/A|K__
+audio|0|111270|1.236333|111270|1.236333|2351|0.026122|209|N/A|K__
+audio|0|113621|1.262456|113621|1.262456|2351|0.026122|209|N/A|K__
+audio|0|115972|1.288578|115972|1.288578|2351|0.026122|209|N/A|K__
+audio|0|118323|1.314700|118323|1.314700|2351|0.026122|209|N/A|K__
+audio|0|120674|1.340822|120674|1.340822|2351|0.026122|209|N/A|K__
+audio|0|123025|1.366944|123025|1.366944|2351|0.026122|209|N/A|K__
+audio|0|125376|1.393067|125376|1.393067|2351|0.026122|209|N/A|K__
+audio|0|127727|1.419189|127727|1.419189|2351|0.026122|209|N/A|K__
+audio|0|130078|1.445311|130078|1.445311|2351|0.026122|209|N/A|K__
+video|1|132382|1.470911|128782|1.430911|3600|0.040000|13836|281624|___|MPEGTS Stream ID|224
+video|1|135982|1.510911|132382|1.470911|3600|0.040000|12163|295912|___|MPEGTS Stream ID|224
 video|1|139582|1.550911|135982|1.510911|3600|0.040000|12692|311516|___|MPEGTS Stream ID|224
 video|1|143182|1.590911|139582|1.550911|3600|0.040000|10824|325052|___|MPEGTS Stream ID|224
 video|1|146782|1.630911|143182|1.590911|3600|0.040000|11286|336144|___|MPEGTS Stream ID|224
@@ -142,10 +160,28 @@ audio|0|153588|1.706533|153588|1.706533|2351|0.026122|209|N/A|K__
 audio|0|155939|1.732656|155939|1.732656|2351|0.026122|209|N/A|K__
 video|1|150382|1.670911|146782|1.630911|3600|0.040000|12678|347800|___|MPEGTS Stream ID|224
 video|1|153982|1.710911|150382|1.670911|3600|0.040000|24711|361336|K__
+video|1|146782|1.630911|143182|1.590911|3600|0.040000|12755|98700|___|MPEGTS Stream ID|224
+video|1|150382|1.670911|146782|1.630911|3600|0.040000|12023|111860|___|MPEGTS Stream ID|224
+audio|0|124200|1.380000|124200|1.380000|2351|0.026122|208|152844|K__|MPEGTS Stream ID|192
+audio|0|126551|1.406122|126551|1.406122|2351|0.026122|209|N/A|K__
+audio|0|128902|1.432244|128902|1.432244|2351|0.026122|209|N/A|K__
+audio|0|131253|1.458367|131253|1.458367|2351|0.026122|209|N/A|K__
+audio|0|133604|1.484489|133604|1.484489|2351|0.026122|209|N/A|K__
+audio|0|135955|1.510611|135955|1.510611|2351|0.026122|209|N/A|K__
+audio|0|138306|1.536733|138306|1.536733|2351|0.026122|209|N/A|K__
+audio|0|140657|1.562856|140657|1.562856|2351|0.026122|209|N/A|K__
+audio|0|143008|1.588978|143008|1.588978|2351|0.026122|209|N/A|K__
+audio|0|145359|1.615100|145359|1.615100|2351|0.026122|209|N/A|K__
+audio|0|147710|1.641222|147710|1.641222|2351|0.026122|209|N/A|K__
+audio|0|150061|1.667344|150061|1.667344|2351|0.026122|209|N/A|K__
+audio|0|152412|1.693467|152412|1.693467|2351|0.026122|209|N/A|K__
+audio|0|154763|1.719589|154763|1.719589|2351|0.026122|209|N/A|K__
+video|1|153982|1.710911|150382|1.670911|3600|0.040000|14098|124268|___|MPEGTS Stream ID|224
+video|1|157582|1.750911|153982|1.710911|3600|0.040000|13329|139120|___|MPEGTS Stream ID|224
 video|1|161182|1.790911|157582|1.750911|3600|0.040000|12135|155852|___|MPEGTS Stream ID|224
 video|1|164782|1.830911|161182|1.790911|3600|0.040000|12282|168448|___|MPEGTS Stream ID|224
 video|1|168382|1.870911|164782|1.830911|3600|0.040000|24786|181420|K__|MPEGTS Stream ID|224
 video|1|171982|1.910911|168382|1.870911|3600|0.040000|17440|206988|___|MPEGTS Stream ID|224
 video|1|175582|1.950911|171982|1.910911|3600|0.040000|15019|224848|___|MPEGTS Stream ID|224
-0|mp2|unknown|audio|[3][0][0][0]|0x0003|s16p|44100|1|mono|0|0|N/A|0/0|0/0|1/90000|0|0.000000|N/A|N/A|64000|N/A|N/A|N/A|N/A|89|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this is stream 0
-1|mpeg2video|4|video|[2][0][0][0]|0x0002|352|288|0|0|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|1|N/A|25/1|25/1|1/90000|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|60|22|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this is stream 1|CPB properties|0|0|0|49152|-1
+0|mp2|unknown|audio|[3][0][0][0]|0x0003|s16p|44100|1|mono|0|0|N/A|0/0|0/0|1/90000|0|0.000000|N/A|N/A|64000|N/A|N/A|N/A|N/A|117|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this is stream 0
+1|mpeg2video|4|video|[2][0][0][0]|0x0002|352|288|0|0|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|1|N/A|25/1|25/1|1/90000|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|68|22|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this is stream 1|CPB properties|0|0|0|49152|-1
-- 
2.30.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-26 17:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-26 17:14 [FFmpeg-devel] [PATCH 0/1] avformat/concatdec: fix seek with dts Nicolas Gaullier
2024-01-26 17:14 ` [FFmpeg-devel] [PATCH] " Nicolas Gaullier

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git