[FFmpeg-cvslog] avformat/matroskaenc: Don't implicitly mark WebVTT in WebM as English

Andreas Rheinhardt git at videolan.org
Thu Apr 2 21:48:41 EEST 2020

ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sat Jan 18 02:19:46 2020 +0100| [da4ba2431c92017379a0bd0b3c0fb74ce6093f09] | committer: Andreas Rheinhardt

avformat/matroskaenc: Don't implicitly mark WebVTT in WebM as English

Writing the language of WebVTT in WebM proceeded differently than the
language of all other tracks: In case no language was given, it does not
write anything instead of "und" (for undefined). Because the default
value of the Language element in WebM (that inherited it from Matroska)
is "eng" (for English), any such track will actually be flagged as

Doing it this way goes back to commit 509642b4 (the commit adding
support for WebVTT) and no reason for this has been given in the commit
message or in the discussion about this patch on the mailing list; the
best I can think of is this: the WebM wiki contains "The srclang attribute
is stored as the Language sub-element." Someone unfamiliar with default
values in Matroska/WebM could interpret this as meaning that no Language
element should be written if the language is unknown. And this is wrong
and this commit changes it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=da4ba2431c92017379a0bd0b3c0fb74ce6093f09

 libavformat/matroskaenc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index d3075d7ec4..07652d69f1 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1121,11 +1121,8 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
     if ((tag = av_dict_get(st->metadata, "title", NULL, 0)))
         put_ebml_string(pb, MATROSKA_ID_TRACKNAME, tag->value);
     tag = av_dict_get(st->metadata, "language", NULL, 0);
-    if (mkv->mode != MODE_WEBM || par->codec_id != AV_CODEC_ID_WEBVTT) {
-        put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag && tag->value ? tag->value:"und");
-    } else if (tag && tag->value) {
-        put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag->value);
-    }
+    put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE,
+                    tag && tag->value ? tag->value : "und");
     // The default value for TRACKFLAGDEFAULT is 1, so add element
     // if we need to clear it.

More information about the ffmpeg-cvslog mailing list