From: Stefano Sabatini <stefasab@gmail.com> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Cc: Nicolas Gaullier <nicolas.gaullier@cji.paris> Subject: Re: [FFmpeg-devel] [PATCH v5 1/1] avformat/demux: Add duration_probesize AVOption Date: Thu, 28 Mar 2024 20:11:44 +0100 Message-ID: <ZgXA8H6cYfIuBfVd@mariano> (raw) In-Reply-To: <20240328175736.161733-2-nicolas.gaullier@cji.paris> On date Thursday 2024-03-28 18:57:36 +0100, Nicolas Gaullier wrote: > Yet another probesize used to get the durations when > estimate_timings_from_pts is required. It is aimed at users interested > in better durations probing for itself, or because using > avformat_find_stream_info indirectly and requiring exact values: for > concatdec for example, especially if streamcopying above it. > The current code is a performance trade-off that can fail to get video > stream durations in a scenario with high bitrates and buffering for > files ending cleanly (as opposed to live captures): the physical gap > between the last video packet and the last audio packet is very high in > such a case. > > Default behaviour is unchanged: 250k up to 250k << 6 (step by step). > Setting this new option has two effects: > - override the maximum probesize (currently 250k << 6) > - reduce the number of steps to 1 instead of 6, this is to avoid > detecting the audio "too early" and failing to reach a video packet. > Even if a single audio stream duration is found but not the other > audio/video stream durations, there will be a retry, so at the end the > full user-overriden probesize will be used as expected by the user. > > Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris> > --- > doc/APIchanges | 3 +++ > doc/formats.texi | 19 ++++++++++++++++++- > libavformat/avformat.h | 16 ++++++++++++++-- > libavformat/demux.c | 13 ++++++++----- > libavformat/options_table.h | 1 + > libavformat/version.h | 2 +- > 6 files changed, 45 insertions(+), 9 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index aa102b4925..f709db536d 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 > > API changes, most recent first: > > +2024-03-28 - xxxxxxxxxx - lavf 61.3.100 - avformat.h > + Add AVFormatContext.duration_probesize. > + > 2024-03-27 - xxxxxxxxxx - lavu 59.10.100 - frame.h > Add AVSideDataDescriptor, enum AVSideDataProps, and > av_frame_side_data_desc(). > diff --git a/doc/formats.texi b/doc/formats.texi > index 69fc1457a4..3fe7fa9d8d 100644 > --- a/doc/formats.texi > +++ b/doc/formats.texi > @@ -225,9 +225,26 @@ Specifies the maximum number of streams. This can be used to reject files that > would require too many resources due to a large number of streams. > > @item skip_estimate_duration_from_pts @var{bool} (@emph{input}) > -Skip estimation of input duration when calculated using PTS. > +Skip estimation of input duration if it requires an additional probing for PTS at end of file. > At present, applicable for MPEG-PS and MPEG-TS. > > +@item duration_probesize @var{integer} (@emph{input}) > +Set probing size, in bytes, for input duration estimation when it actually requires > +an additional probing for PTS at end of file (at present: MPEG-PS and MPEG-TS). > +It is aimed at users interested in better durations probing for itself, or indirectly > +because using the concat demuxer, for example. > +The typical use case is an MPEG-TS CBR with a high bitrate, high video buffering and > +ending cleaning with similar PTS for video and audio: in such a scenario, the large > +physical gap between the last video packet and the last audio packet makes it necessary > +to read many bytes in order to get the video stream duration. > +Another use case is where the default probing behaviour only reaches a single video frame which is > +not the last one of the stream due to frame reordering, so the duration is not accurate. > +Setting the duration_probesize has a performance impact even for small files because the probing > +size is fixed. nit++: setting the @option{duration_probesize} or ... setting this option > +Default behaviour is a general purpose trade-off, largely adaptive: the probing size may range from > +250000 up to 16M, but it is not extended to get streams durations at all costs. I'm a bit concerned if we should really mention these values, since they are currently hardcoded and this might result in inconsistent documentation in case of update (probably we can only mention that it is adaptive therefore avoiding to expose the internal thresholds). > +Must be an integer not lesser than 1, or 0 for default behaviour. > + [...] Looks good to me otherwise, thanks. _______________________________________________ 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".
prev parent reply other threads:[~2024-03-28 21:37 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-28 17:57 [FFmpeg-devel] [PATCH v5 0/1] " Nicolas Gaullier 2024-03-28 17:57 ` [FFmpeg-devel] [PATCH v5 1/1] " Nicolas Gaullier 2024-03-28 19:11 ` Stefano Sabatini [this message]
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=ZgXA8H6cYfIuBfVd@mariano \ --to=stefasab@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=nicolas.gaullier@cji.paris \ /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