movenc: fix segfault with chapter tracks
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 2 Apr 2012 15:00:20 +0000 (17:00 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 2 Apr 2012 15:00:20 +0000 (17:00 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/movenc.c

index dd14a08..73b6c66 100644 (file)
@@ -2887,7 +2887,7 @@ static int mov_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
 
     if (!size) return 0; /* Discard 0 sized packets */
 
 
     if (!size) return 0; /* Discard 0 sized packets */
 
-    if (trk->entry)
+    if (trk->entry && pkt->stream_index < s->nb_streams)
         frag_duration = av_rescale_q(pkt->dts - trk->cluster[0].dts,
                                      s->streams[pkt->stream_index]->time_base,
                                      AV_TIME_BASE_Q);
         frag_duration = av_rescale_q(pkt->dts - trk->cluster[0].dts,
                                      s->streams[pkt->stream_index]->time_base,
                                      AV_TIME_BASE_Q);