[FFmpeg-devel] [PATCH 3/4 v2] ffmpeg: move A/V non-streamcopy initialization to a later point

Jan Ekström jeebjp at gmail.com
Mon Sep 14 23:10:27 EEST 2020


On Mon, Sep 14, 2020 at 12:33 AM Jan Ekström <jeebjp at gmail.com> wrote:
>
> - For video, this means a single initialization point in do_video_out.
> - For audio we unfortunately need to do it in two places just
>   before the buffer sink is utilized (if av_buffersink_get_samples
>   would still work according to its specification after a call to
>   avfilter_graph_request_oldest was made, we could at least remove
>   the one in transcode_step).
>
> Other adjustments to make things work:
> - As the AVFrame PTS adjustment to encoder time base needs the encoder
>   to be initialized, so it is now moved to do_{video,audio}_out,
>   right after the encoder has been initialized. Due to this,
>   the additional parameter in do_video_out is removed as it is no
>   longer necessary.
> ---

Diff between v1 and v2 follows:

- Basically fixed issues in the comments I had written down.

Jan

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 5425ba245d..8874da9268 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -4664,14 +4656,15 @@ static int transcode_step(void)
          * transcode_from_filter just down the line) peeks. Peeking already
          * puts one frame "ready to be given out", which means that any
          * update in filter buffer sink configuration afterwards will not
-         * help us.
+         * help us. And yes, even if it would be utilized,
+         * av_buffersink_get_samples is affected, as it internally utilizes
+         * the same early exit for peeked frames.
          *
-         * And yes, even av_buffersink_get_samples is affected,
-         * As it internally utilizes the same early exit for peeked frames.
-         * In other words, if either av_buffersink_get_samples with
-         * avfilter_graph_request_oldest will start playing ball, or we add
-         * our own audio buffering to handle frame size mismatches, both of
-         * these early exits can be gotten rid of.
+         * In other words, if avfilter_graph_request_oldest would not make
+         * further filter chain configuration or usage of
+         * av_buffersink_get_samples useless (by just causing the return
+         * of the peeked AVFrame as-is), we could get rid of this additional
+         * early encoder initialization.
          */
         if (av_buffersink_get_type(ost->filter->filter) == AVMEDIA_TYPE_AUDIO)
             init_output_stream_wrapper(ost, NULL, 1);


More information about the ffmpeg-devel mailing list