Use Matroska document version 2 for WebM files if possible.

Google's plugin for the Internet Explorer refuses to play
files with another document version.

Fixes ticket #3583.
(cherry picked from commit ab21acecc7)
This commit is contained in:
Carl Eugen Hoyos 2014-05-12 18:12:28 +02:00
parent 03c5ccb4ee
commit c5a2c26c55
1 changed files with 13 additions and 3 deletions

View File

@ -1057,7 +1057,7 @@ static int mkv_write_header(AVFormatContext *s)
AVIOContext *pb = s->pb;
ebml_master ebml_header, segment_info;
AVDictionaryEntry *tag;
int ret, i;
int ret, i, version = 2;
if (!strcmp(s->oformat->name, "webm")) mkv->mode = MODE_WEBM;
else mkv->mode = MODE_MATROSKAv2;
@ -1065,7 +1065,12 @@ static int mkv_write_header(AVFormatContext *s)
if (s->avoid_negative_ts < 0)
s->avoid_negative_ts = 1;
for (i = 0; i < s->nb_streams; i++)
if (mkv->mode != MODE_WEBM ||
av_dict_get(s->metadata, "stereo_mode", NULL, 0) ||
av_dict_get(s->metadata, "alpha_mode", NULL, 0))
version = 4;
for (i = 0; i < s->nb_streams; i++) {
if (s->streams[i]->codec->codec_id == AV_CODEC_ID_ATRAC3 ||
s->streams[i]->codec->codec_id == AV_CODEC_ID_COOK ||
s->streams[i]->codec->codec_id == AV_CODEC_ID_RA_288 ||
@ -1077,6 +1082,11 @@ static int mkv_write_header(AVFormatContext *s)
avcodec_get_name(s->streams[i]->codec->codec_id));
return AVERROR_PATCHWELCOME;
}
if (s->streams[i]->codec->codec_id == AV_CODEC_ID_OPUS ||
av_dict_get(s->streams[i]->metadata, "stereo_mode", NULL, 0) ||
av_dict_get(s->streams[i]->metadata, "alpha_mode", NULL, 0))
version = 4;
}
mkv->tracks = av_mallocz(s->nb_streams * sizeof(*mkv->tracks));
if (!mkv->tracks)
@ -1088,7 +1098,7 @@ static int mkv_write_header(AVFormatContext *s)
put_ebml_uint (pb, EBML_ID_EBMLMAXIDLENGTH , 4);
put_ebml_uint (pb, EBML_ID_EBMLMAXSIZELENGTH , 8);
put_ebml_string (pb, EBML_ID_DOCTYPE , s->oformat->name);
put_ebml_uint (pb, EBML_ID_DOCTYPEVERSION , 4);
put_ebml_uint (pb, EBML_ID_DOCTYPEVERSION , version);
put_ebml_uint (pb, EBML_ID_DOCTYPEREADVERSION , 2);
end_ebml_master(pb, ebml_header);