diff mbox

[FFmpeg-devel] lavf/matroska: Also support WebVTT in Matroska

Message ID CAB0OVGqVyhM5C4JjysCGe4Aj9QgX7gS7Ftk4i_bUTWfAJqY6VQ@mail.gmail.com
State New
Headers show

Commit Message

Carl Eugen Hoyos March 11, 2019, 11:35 p.m. UTC
Hi!

Attached patch is supposed to fix HandBrake issue 1964, FFmpeg
currently fails to identify WebVTT in Matroska (only webm is supported
as container). I don't have the original sample to test though.

Please comment, Carl Eugen

Comments

Andreas Rheinhardt March 12, 2019, 6:17 a.m. UTC | #1
Carl Eugen Hoyos:
> Hi!
> 
> Attached patch is supposed to fix HandBrake issue 1964, FFmpeg
> currently fails to identify WebVTT in Matroska (only webm is supported
> as container). I don't have the original sample to test though.
> 
> Please comment, Carl Eugen
The way WebVTT is stored in Matroska is different from the way it is
stored in WebM: The Matroska way uses an optional BlockAdditional to
store the information that would be contained at the beginning of the
subtitle payload (the actual data of the Block inside the BlockGroup)
in WebM, namely the stuff that ends up as
AV_PKT_DATA_WEBVTT_IDENTIFIER and AV_PKT_DATA_WEBVTT_SETTINGS side
data. It also contains another form of information, namely WebVTT
Comment Blocks (for which no side data has been defined yet). Your
patch would export this data as part of a general
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL and not as its components. This
is suboptimal.

- Andreas
diff mbox

Patch

From d4cdbc94e4adf8ee4b1f576b60c0e743f9f8928f Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Tue, 12 Mar 2019 00:32:59 +0100
Subject: [PATCH] lavf/matroska: Also support WebVTT in Matroska.

Fixes HandBrake issue #1964.
---
 libavformat/matroska.c    |    1 +
 libavformat/matroskadec.c |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroska.c b/libavformat/matroska.c
index 4d18d14..adcd67c 100644
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -68,6 +68,7 @@  const CodecTags ff_mkv_codec_tags[]={
     {"S_TEXT/UTF8"      , AV_CODEC_ID_SUBRIP},
     {"S_TEXT/UTF8"      , AV_CODEC_ID_TEXT},
     {"S_TEXT/ASCII"     , AV_CODEC_ID_TEXT},
+    {"S_TEXT/WEBVTT"    , AV_CODEC_ID_WEBVTT},
     {"S_TEXT/ASS"       , AV_CODEC_ID_ASS},
     {"S_TEXT/SSA"       , AV_CODEC_ID_ASS},
     {"S_ASS"            , AV_CODEC_ID_ASS},
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 0e3a689..0d7b0bd 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3428,7 +3428,8 @@  static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf
             if (res)
                 goto end;
 
-        } else if (st->codecpar->codec_id == AV_CODEC_ID_WEBVTT) {
+        } else if (   st->codecpar->codec_id == AV_CODEC_ID_WEBVTT
+                   && strcmp(track->codec_id, "S_TEXT/WEBVTT")) {
             res = matroska_parse_webvtt(matroska, track, st,
                                         data, lace_size[n],
                                         timecode, lace_duration,
-- 
1.7.10.4