[FFmpeg-devel] [PATCH 2/6] avformat: remove uneeded avio_flush() calls from the end of write_header functions

Marton Balint cus at passwd.hu
Mon Jan 6 02:01:42 EET 2020



On Sun, 5 Jan 2020, Martin Storsjö wrote:

> On Sun, 5 Jan 2020, Marton Balint wrote:
>
>> The IO context is flushed by libavformat/mux.c after writing the header by 
>> calling
>> avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_UNKNOWN), so this
>> change should have no effect at all.
>> 
>> Signed-off-by: Marton Balint <cus at passwd.hu>
>
> If I read avio_write_marker correctly, it won't do an implicit flush on these 
> calls unless the user actually has set the s->write_data_type function 
> pointer - which only is set when used by direct API users.
>
> So for normal cases, if I read it correctly, one can't assume 
> avio_write_marker implies a flush in general.

Yes, you are right, I missed that too... I believe the patch is still 
correct if I fix the commit message:

avformat: remove avio_flush() calls from the end of write_header functions

To make it consistent with other muxers.

The user can still control the generic flushing behaviour after 
write_header (same way as after packets) using the -flush_packets option, 
the default typically means to flush unless a non-streamed file output is 
used.

Therefore this change should have no adverse effect on streaming, even if 
it is assumed that the first packet has a clean buffer, so small seekbacks 
within the output buffer work even when the IO context is not seekable.

Thanks,
Marton


More information about the ffmpeg-devel mailing list