[FFmpeg-devel] [PATCH] avformat/webvttdec: Fix WebVTT decoder truncating files at first STYLE block

Roderich Schupp roderich.schupp at gmail.com
Tue Jan 12 18:49:37 EET 2021


Bug-ID: 9064

The webvtt decoder truncates the file at the first such block.
Since these blocks typically occur at the top of the webvtt file, this results
in an empty file (except for the WEBVTT header line).

Reason is that at STYLE block neither parses as a valid cue block nor
is it skipped like the WEBVTT (i.e. header) or NOTE blocks, hence
decoding stops.

Solution is to add STYLE to list of skipped blocks. And while we're at it, add REGION, too.
---
 libavformat/webvttdec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/webvttdec.c b/libavformat/webvttdec.c
index 8d2fdfe..5a982dd 100644
--- a/libavformat/webvttdec.c
+++ b/libavformat/webvttdec.c
@@ -89,10 +89,12 @@ static int webvtt_read_header(AVFormatContext *s)
         p = identifier = cue.str;
         pos = avio_tell(s->pb);
 
-        /* ignore header chunk */
+        /* ignore header, NOTE, STYLE and REGION chunks */
         if (!strncmp(p, "\xEF\xBB\xBFWEBVTT", 9) ||
             !strncmp(p, "WEBVTT", 6) ||
-            !strncmp(p, "NOTE", 4))
+            !strncmp(p, "NOTE", 4) ||
+            !strncmp(p, "STYLE", 5) ||
+            !strncmp(p, "REGION", 6))
             continue;
 
         /* optional cue identifier (can be a number like in SRT or some kind of
-- 
2.30.0



More information about the ffmpeg-devel mailing list