Opened 21 months ago

Last modified 13 months ago

#9064 new defect

WebVTT decoder truncates files with STYLE blocks

Reported by: Roderich Schupp Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: webvtt
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

If a webvtt file contains STYLE blocks, 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).

Note: This may be related to #8684, though the sample webvtt attached there is invalid.

How to reproduce:

$ ffmpeg -y -v 9 -loglevel 99 -i sample_in.vtt -c copy sample_out.vtt
ffmpeg version 4.3.1-5 Copyright (c) 2000-2020 the FFmpeg developers

built with gcc 10 (Debian 10.2.0-15)
configuration: --prefix=/usr --extra-version=5 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --disable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=5 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --disable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-liblensfun --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100

Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-i' ... matched as input url with argument 'sample_in.vtt'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option 'sample_out.vtt' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option v (set logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input url sample_in.vtt.
Successfully parsed a group of options.
Opening an input file: sample_in.vtt.
[NULL @ 0x5569603be0c0] Opening 'sample_in.vtt' for reading
[file @ 0x5569603beb80] Setting default whitelist 'file,crypto,data'
Probing webvtt score:100 size:362
[webvtt @ 0x5569603be0c0] Format webvtt probed with size=2048 and score=100
[webvtt @ 0x5569603be0c0] Before avformat_find_stream_info() pos: 55 bytes read:362 seeks:0 nb_streams:1
[webvtt @ 0x5569603be0c0] All info found
[webvtt @ 0x5569603be0c0] stream 0: start_time: NOPTS duration: NOPTS
[webvtt @ 0x5569603be0c0] format: start_time: NOPTS duration: NOPTS (estimate from bit rate) bitrate=0 kb/s
[webvtt @ 0x5569603be0c0] After avformat_find_stream_info() pos: 55 bytes read:362 seeks:0 frames:0
Input #0, webvtt, from 'sample_in.vtt':

Duration: N/A, bitrate: N/A

Stream #0:0, 0, 1/1000: Subtitle: webvtt

Successfully opened the file.
Parsing a group of options: output url sample_out.vtt.
Applying option c (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: sample_out.vtt.
[file @ 0x5569603c4140] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
Output #0, webvtt, to 'sample_out.vtt':

Metadata:

encoder : Lavf58.45.100
Stream #0:0, 0, 1/1000: Subtitle: webvtt

Stream mapping:

Stream #0:0 -> #0:0 (copy)

Press [q] to stop, ? for help
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
No more output streams to write to, finishing.
size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (sample_in.vtt):

Input stream #0:0 (subtitle): 0 packets read (0 bytes);
Total: 0 packets (0 bytes) demuxed

Output file #0 (sample_out.vtt):

Output stream #0:0 (subtitle): 0 packets muxed (0 bytes);
Total: 0 packets (0 bytes) muxed

Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x5569603c43c0] Statistics: 0 seeks, 1 writeouts
[AVIOContext @ 0x5569603c6fc0] Statistics: 362 bytes read, 0 seeks

Attachments (2)

sample_in.vtt (362 bytes ) - added by Roderich Schupp 21 months ago.
(input) sample WebVTT file with STYLE blocks
sample_out.vtt (7 bytes ) - added by Roderich Schupp 21 months ago.
(output) result of "ffmpeg -i sample_in.vtt -c copy sample_out.txt"

Download all attachments as: .zip

Change History (3)

by Roderich Schupp, 21 months ago

Attachment: sample_in.vtt added

(input) sample WebVTT file with STYLE blocks

by Roderich Schupp, 21 months ago

Attachment: sample_out.vtt added

(output) result of "ffmpeg -i sample_in.vtt -c copy sample_out.txt"

comment:1 by anonymous_coward, 13 months ago

I proposed a patch to fix this (and also write STYLE blocks out), but it has had no traction. Feel free to pile in on the thread.

https://patchwork.ffmpeg.org/project/ffmpeg/patch/CA+_k4RJ1CNriPbhxxzLf1O6V1VuP2OXch3E8LqOsMNSRUyEnTw@mail.gmail.com/

Note: See TracTickets for help on using tickets.