@@ -1858,6 +1858,9 @@ static int mkv_write_header(AVFormatContext *s)
} else
mkv->mode = MODE_MATROSKAv2;
+ if (mkv->is_dash && s->nb_streams != 1)
+ return AVERROR(EINVAL);
+
if (mkv->mode != MODE_WEBM ||
av_dict_get(s->metadata, "stereo_mode", NULL, 0) ||
av_dict_get(s->metadata, "alpha_mode", NULL, 0))
@@ -2773,7 +2776,7 @@ static const AVOption options[] = {
{ "cluster_size_limit", "Store at most the provided amount of bytes in a cluster. ", OFFSET(cluster_size_limit), AV_OPT_TYPE_INT , { .i64 = -1 }, -1, INT_MAX, FLAGS },
{ "cluster_time_limit", "Store at most the provided number of milliseconds in a cluster.", OFFSET(cluster_time_limit), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, FLAGS },
{ "dash", "Create a WebM file conforming to WebM DASH specification", OFFSET(is_dash), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
- { "dash_track_number", "Track number for the DASH stream", OFFSET(dash_track_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 127, FLAGS },
+ { "dash_track_number", "Track number for the DASH stream", OFFSET(dash_track_number), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 127, FLAGS },
{ "live", "Write files assuming it is a live stream.", OFFSET(is_live), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ "allow_raw_vfw", "allow RAW VFW mode", OFFSET(allow_raw_vfw), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ "write_crc32", "write a CRC32 element inside every Level 1 element", OFFSET(write_crc), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
When creating dash streams, the track number is externally prescribed and not derived from the number of streams in the AVFormatContext. Up until now, a track number of zero was allowed, although this is an illegal track number; furthermore, it was not checked whether the number of tracks for a file using an explicit track number was more than one, as such a file would be invalid (it would be impossible to tell to which track a block belongs if different tracks share the same track number). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- Using 0 as dash_track_number could lead to an access to mkv->last_track_timestamp[-1] (before said field was moved to mkv_track). libavformat/matroskaenc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)