Message ID | tencent_AA558BE20D385F2FB591B8E21A3F06E80006@qq.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel] flvenc: flush after write header | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | success | Make fate finished |
> 2021年10月28日 下午2:32,Lingjiang Fang <vacingfang@foxmail.com> 写道: > > keep align with movenc, or it seems a little weired when debug > --- > libavformat/flvenc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c > index 3f24c7e192..f4798dc9a6 100644 > --- a/libavformat/flvenc.c > +++ b/libavformat/flvenc.c > @@ -767,6 +767,8 @@ static int flv_write_header(AVFormatContext *s) > flv_write_codec_header(s, s->streams[i]->codecpar, 0); > } > > + avio_flush(pb); > + > flv->datastart_offset = avio_tell(pb); > return 0; > } > -- > 2.29.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". > LGTM Thanks Steven Liu
On Thu, 28 Oct 2021 20:50:05 +0800 Steven Liu <lq@chinaffmpeg.org> wrote: ping for review or apply :) > > > > 2021年10月28日 下午2:32,Lingjiang Fang <vacingfang@foxmail.com> > > 写道: > > > > keep align with movenc, or it seems a little weired when debug > > --- > > libavformat/flvenc.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c > > index 3f24c7e192..f4798dc9a6 100644 > > --- a/libavformat/flvenc.c > > +++ b/libavformat/flvenc.c > > @@ -767,6 +767,8 @@ static int flv_write_header(AVFormatContext *s) > > flv_write_codec_header(s, s->streams[i]->codecpar, 0); > > } > > > > + avio_flush(pb); > > + > > flv->datastart_offset = avio_tell(pb); > > return 0; > > } > > -- > > 2.29.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". > > > > LGTM > > Thanks > > Steven Liu > > _______________________________________________ > 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". Regards, Lingjiang Fang
On Thu, 28 Oct 2021, Steven Liu wrote: > > >> 2021年10月28日 下午2:32,Lingjiang Fang <vacingfang@foxmail.com> 写道: >> >> keep align with movenc, or it seems a little weired when debug >> --- >> libavformat/flvenc.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c >> index 3f24c7e192..f4798dc9a6 100644 >> --- a/libavformat/flvenc.c >> +++ b/libavformat/flvenc.c >> @@ -767,6 +767,8 @@ static int flv_write_header(AVFormatContext *s) >> flv_write_codec_header(s, s->streams[i]->codecpar, 0); >> } >> >> + avio_flush(pb); >> + >> flv->datastart_offset = avio_tell(pb); >> return 0; >> } >> -- >> 2.29.2 >> > > LGTM No, please don't apply this. We intentionally move in the other direction; every explicit avio_flush() is a potential performance bottleneck, and we've been working on reducing the number of extra avio_flush() calls. When streaming, where latency is relevant, the libavformat generic code already flushes automatically after the header and after each packet. When latency is not relevant, we explicitly want to avoid extra avio_flush() because each of them cause extra writes (that otherwise could be buffered). You can also set the option "-flush_packets 1" (or "-fflags flush_packets") to make the generic code flush when relevant. See e.g. the flush_if_needed() function in libavformat/mux.c. // Martin
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 3f24c7e192..f4798dc9a6 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -767,6 +767,8 @@ static int flv_write_header(AVFormatContext *s) flv_write_codec_header(s, s->streams[i]->codecpar, 0); } + avio_flush(pb); + flv->datastart_offset = avio_tell(pb); return 0; }