Commit 7dc0de42ba for ffmpeg
commit 7dc0de42ba09d2d7d11be5c6b9cad71151f800b6
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date: Thu Nov 26 20:41:06 2026 -0600
avformat/segment: flush the muxer before dropping its headers
With write_header_trailer disabled, the headers are written to a null
context that is then closed. A muxer holding its headers, as the Ogg
muxer does until it knows the start trim of an Opus link, then wrote
them to the first segment. Flush it first, as is done when the headers
go to segment_header_filename.
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 2011b9437e..676661613e 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -859,8 +859,11 @@ static int seg_write_header(AVFormatContext *s)
}
if (!seg->write_header_trailer || seg->header_filename) {
+ /* Write out what the muxer holds of the headers. */
+ ret = av_write_frame(oc, NULL);
+ if (ret < 0)
+ return ret;
if (seg->header_filename) {
- av_write_frame(oc, NULL);
ff_format_io_close(oc, &oc->pb);
} else {
close_null_ctxp(&oc->pb);