From fa103ca5ad5b17e4a6162c3e166134bd7d89c254 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Mon, 18 Aug 2014 14:05:52 -0300 Subject: [PATCH] qtdemux: avoid crashing on dash streams DASH/fragmented moov might have no samples as those are carried in moof fragments. Avoid crashing or failing the stream because of that. --- gst/isomp4/qtdemux.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index e9fed02639..d8532822b4 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -9053,14 +9053,16 @@ qtdemux_prepare_streams (GstQTDemux * qtdemux) } /* parse the initial sample for use in setting the frame rate cap */ - while (sample_num == 0) { + while (sample_num == 0 && sample_num < stream->n_samples) { if (!qtdemux_parse_samples (qtdemux, stream, sample_num)) break; ++sample_num; } - stream->first_duration = stream->samples[0].duration; - GST_LOG_OBJECT (qtdemux, "stream %d first duration %u", - stream->track_id, stream->first_duration); + if (stream->n_samples > 0 && stream->stbl_index > 0) { + stream->first_duration = stream->samples[0].duration; + GST_LOG_OBJECT (qtdemux, "stream %d first duration %u", + stream->track_id, stream->first_duration); + } } return ret;