[FFmpeg-devel] [PATCH] libavformat/mov: FMp4 Fixes duration calculation for individual streams on videos where crash occurs.

Anthony Bajoua anthonybajoua at meta.com
Wed Apr 23 03:50:57 EEST 2025


Both the audio and video sidx boxes at the end point to a range corresponding to the final mdat atom. Since there is no mfra following the final mdat when recording crashes, current logic sets the flag frag_index.complete flag on the penultimate sidx atom since it points to the end of the file. Results in underreporting duration by ffprobe and libavformat for one of the streams.

Signed-off-by: Anthony Bajoua <anthonybajoua at meta.com<mailto:anthonybajoua at meta.com>>
---
libavformat/mov.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 452690090c..36a60cab65 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -6150,7 +6150,8 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom)
             }
         }

-        c->frag_index.complete = 1;
+        if (offset == 0)
+            c->frag_index.complete = 1;
     }

     return 0;
--
2.49.0




More information about the ffmpeg-devel mailing list