[FFmpeg-devel] [PATCH] avformat/movenc: disallow buggy flags combination

Gyan Doshi ffmpeg at gyani.pro
Mon May 26 15:46:04 EEST 2025


Usage of hybrid_fragmented and faststart together can result in files with
loss of sync and bitstream parsing errors upon playback.
---
 libavformat/movenc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 4bc8bd1b2a..9392ba5370 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -7731,6 +7731,12 @@ static int mov_init(AVFormatContext *s)
                       FF_MOV_FLAG_FRAG_EVERY_FRAME))
         mov->flags |= FF_MOV_FLAG_FRAGMENT;
 
+    if (mov->flags & FF_MOV_FLAG_HYBRID_FRAGMENTED &&
+        mov->flags & FF_MOV_FLAG_FASTSTART) {
+        av_log(s, AV_LOG_ERROR, "Setting both hybrid_fragmented and faststart is not supported.\n");
+        return AVERROR(EINVAL);
+    }
+
     /* Set other implicit flags immediately */
     if (mov->flags & FF_MOV_FLAG_HYBRID_FRAGMENTED)
         mov->flags |= FF_MOV_FLAG_FRAGMENT;
-- 
2.49.0



More information about the ffmpeg-devel mailing list