When creating DASH streams, the TrackNumber is externally prescribed and not derived from the number of streams in the AVFormatContext. Up until now, a TrackNumber of zero was allowed, although this is invalid.
Furthermore, it was not checked whether the number of tracks for a file using an explicit TrackNumber 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 TrackNumber). Besides that, use the MAX_TRACKS macro for the maximum of dash_track_number. Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com> --- libavformat/matroskaenc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 27c419954b..b9bfd34756 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2642,6 +2642,9 @@ static int mkv_init(struct AVFormatContext *s) track->track_num = mkv->is_dash ? mkv->dash_track_number : nb_tracks; } + if (mkv->is_dash && nb_tracks != 1) + return AVERROR(EINVAL); + if (nb_tracks > MAX_TRACKS) { av_log(s, AV_LOG_ERROR, "%u > "AV_STRINGIFY(MAX_TRACKS)" tracks (excluding attachments)" @@ -2704,7 +2707,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, MAX_TRACKS, 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 }, -- 2.20.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".