diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 92df6cbef1..aa979eab6e 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -613,9 +613,11 @@ static int mkv_write_tracks(AVFormatContext *s) put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag->value); } - if (default_stream_exists) { + // The default value for TRACKFLAGDEFAULT is 1, so add element + // if we need to clear it. + if (default_stream_exists && !(st->disposition & AV_DISPOSITION_DEFAULT)) put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGDEFAULT, !!(st->disposition & AV_DISPOSITION_DEFAULT)); - } + if (st->disposition & AV_DISPOSITION_FORCED) put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGFORCED, 1);