From: Nicolas Gaullier <nicolas.gaullier@cji.paris> To: ffmpeg-devel@ffmpeg.org Cc: Nicolas Gaullier <nicolas.gaullier@cji.paris> Subject: [FFmpeg-devel] [PATCH] avformat/demux: Add more retries to get more stream durations Date: Fri, 2 Feb 2024 19:07:19 +0100 Message-ID: <20240202180719.784910-1-nicolas.gaullier@cji.paris> (raw) The number of extra retries to get more than a single duration is currently limited to 1 (see commit 77a0df4b5). This patch raises this number of retries to 3 (amongst the overall 6 max retries). Exemple: this sample requires 3 retries to get all durations: http://samples.ffmpeg.org/archive/extension/ts/ mpegts+mpeg2video+ac3++mpegts_multiple_ts_packets_pmt_pid_0x50.ts Moreover, when an mpegts file is cleany cut at a precise pts independantly for audio and video, it results in a big gap between the last video packet and the last audio packet. And above the probing benefits themselves, having all durations is somewhat recommanded for using concatdec, and even required when using concatdec with streamcopy. Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris> --- libavformat/demux.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/demux.c b/libavformat/demux.c index 6f640b92b1..f489868d34 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -1742,6 +1742,7 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic) #define DURATION_MAX_READ_SIZE 250000LL #define DURATION_MAX_RETRY 6 +#define MORE_DURATIONS_MAX_RETRY 3 /* only usable for MPEG-PS streams */ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) @@ -1753,6 +1754,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) int is_end; int64_t filesize, offset, duration; int retry = 0; + int retry_get_more_durations = 0; /* flush packet queue */ ff_flush_packet_queue(ic); @@ -1783,7 +1785,6 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) /* XXX: may need to support wrapping */ filesize = ic->pb ? avio_size(ic->pb) : 0; do { - is_end = found_duration; offset = filesize - (DURATION_MAX_READ_SIZE << retry); if (offset < 0) offset = 0; @@ -1833,7 +1834,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) } /* check if all audio/video streams have valid duration */ - if (!is_end) { + if (found_duration) { is_end = 1; for (unsigned i = 0; i < ic->nb_streams; i++) { const AVStream *const st = ic->streams[i]; @@ -1846,6 +1847,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) } } } while (!is_end && + (!found_duration || ++retry_get_more_durations <= MORE_DURATIONS_MAX_RETRY) && offset && ++retry <= DURATION_MAX_RETRY); -- 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".
reply other threads:[~2024-02-02 18:17 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240202180719.784910-1-nicolas.gaullier@cji.paris \ --to=nicolas.gaullier@cji.paris \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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