[FFmpeg-devel] [PATCH] movenc: fix crashes if a stream is empty.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Feb 12 12:06:23 CET 2012


For some reason this always happens with -f ismv.
See trac issue #996.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 libavformat/movenc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index dcc0d76..b17a42a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -286,6 +286,8 @@ static unsigned compute_avg_bitrate(MOVTrack *track)
 {
     uint64_t size = 0;
     int i;
+    if (!track->track_duration)
+        return 0;
     for (i = 0; i < track->entry; i++)
         size += track->cluster[i].size;
     return size * 8 * track->timescale / track->track_duration;
@@ -1941,7 +1943,8 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov,
         mov->tracks[i].time = mov->time;
         mov->tracks[i].track_id = i+1;
 
-        build_chunks(&mov->tracks[i]);
+        if (mov->tracks[i].entry)
+            build_chunks(&mov->tracks[i]);
     }
 
     if (mov->chapter_track)
-- 
1.7.9



More information about the ffmpeg-devel mailing list