[FFmpeg-devel] [PATCH]Allow last mov chunk to have an arbitrary number of samples

Carl Eugen Hoyos cehoyos at ag.or.at
Thu Dec 1 17:33:42 CET 2011


Hi!

Attached patch fixes ticket 673 for me. The number of samples in the last 
chunk (5760) can be divided through the number of samples in one MP3 frame 
(1152) but not through samples_per_frame (5760). A stricter check would be to 
try to divide by samples in one frame, but I am not sure how to find out the 
number of samples per frame for an arbitrary codec.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/mov.c b/libavformat/mov.c
index e940427..6355814 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1761,7 +1761,8 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
             unsigned count, chunk_count;
 
             chunk_samples = sc->stsc_data[i].count;
-            if (sc->samples_per_frame && chunk_samples % sc->samples_per_frame) {
+            if (i != sc->stsc_count - 1 &&
+                sc->samples_per_frame && chunk_samples % sc->samples_per_frame) {
                 av_log(mov->fc, AV_LOG_ERROR, "error unaligned chunk\n");
                 return;
             }


More information about the ffmpeg-devel mailing list