[FFmpeg-trac] #9580(avcodec:new): WebVTT decoder processes an invalid input file without complaining, producing a tuncated output

FFmpeg trac at avcodec.org
Tue Jan 4 13:53:49 EET 2022


#9580: WebVTT decoder processes an invalid input file without complaining,
producing a tuncated output
---------------------------------+--------------------------------------
             Reporter:  Lise     |                     Type:  defect
               Status:  new      |                 Priority:  normal
            Component:  avcodec  |                  Version:  git-master
             Keywords:  webvtt   |               Blocked By:
             Blocking:           |  Reproduced by developer:  0
Analyzed by developer:  0        |
---------------------------------+--------------------------------------
 If there is an error in the input WebVTT file, ffmpeg just processes the
 file until the error, without any warnings. The result is a truncated
 output file.

 How to reproduce:

 Input file (the line with 'why?' makes the file an invalid webvtt I
 guess):

 {{{
 WEBVTT

 00:01.000 --> 00:04.000
 - Never drink liquid nitrogen.

 why?

 00:05.000 --> 00:09.000
 - It will perforate your stomach.
 - You could die.
 }}}

 Command and console output:

 {{{

 ffmpeg -v 9 -loglevel 99 -i invalid.vtt -c copy truncated.vtt

 ffmpeg version N-105057-g68d0a7e446-20220103 Copyright (c) 2000-2022 the
 FFmpeg developers
   built with gcc 11.2.0 (crosstool-NG 1.24.0.498_5075e1f)
   configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static
 --pkg-config=pkg-config --cross-prefix=x86_64-ffbuild-linux-gnu-
 --arch=x86_64 --target-os=linux --enable-gpl --enable-version3 --disable-
 debug --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype
 --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig
 --enable-libvorbis --enable-opencl --enable-libpulse --enable-libvmaf
 --enable-libxcb --enable-xlib --enable-amf --enable-libaom --enable-
 avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac
 --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme
 --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus
 --enable-mbedtls --enable-librist --enable-libtheora --enable-libvpx
 --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb
 --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg
 --enable-libopenmpt --enable-librav1e --enable-librubberband --disable-
 schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1
 --enable-libtwolame --enable-libuavs3d --enable-libdrm --enable-vaapi
 --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-
 libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-
 libxvid --enable-libzimg --enable-libzvbi --extra-
 cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread
 --extra-ldexeflags=-pie --extra-libs='-ldl -lgomp' --extra-
 version=20220103
   libavutil      57. 13.100 / 57. 13.100
   libavcodec     59. 15.102 / 59. 15.102
   libavformat    59. 12.100 / 59. 12.100
   libavdevice    59.  1.100 / 59.  1.100
   libavfilter     8. 21.100 /  8. 21.100
   libswscale      6.  1.102 /  6.  1.102
   libswresample   4.  0.100 /  4.  0.100
   libpostproc    56.  0.100 / 56.  0.100
 Splitting the commandline.
 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 'invalid.vtt'.
 Reading option '-c' ... matched as option 'c' (codec name) with argument
 'copy'.
 Reading option 'truncated.vtt' ... matched as output url.
 Finished splitting the commandline.
 Parsing a group of options: global .
 Applying option v (set logging level) with argument 9.
 Successfully parsed a group of options.
 Parsing a group of options: input url invalid.vtt.
 Successfully parsed a group of options.
 Opening an input file: invalid.vtt.
 [NULL @ 0x55bc88dfa8c0] Opening 'invalid.vtt' for reading
 [file @ 0x55bc88dfb1c0] Setting default whitelist 'file,crypto,data'
 Probing webvtt score:100 size:145
 [webvtt @ 0x55bc88dfa8c0] Format webvtt probed with size=2048 and
 score=100
 [webvtt @ 0x55bc88dfa8c0] Before avformat_find_stream_info() pos: 70 bytes
 read:145 seeks:0 nb_streams:1
 [webvtt @ 0x55bc88dfa8c0] All info found
 [webvtt @ 0x55bc88dfa8c0] stream 0: start_time: NOPTS duration: NOPTS
 [webvtt @ 0x55bc88dfa8c0] format: start_time: NOPTS duration: NOPTS
 (estimate from bit rate) bitrate=0 kb/s
 [webvtt @ 0x55bc88dfa8c0] After avformat_find_stream_info() pos: 70 bytes
 read:145 seeks:0 frames:0
 Input #0, webvtt, from 'invalid.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 truncated.vtt.
 Applying option c (codec name) with argument copy.
 Successfully parsed a group of options.
 Opening an output file: truncated.vtt.
 [file @ 0x55bc88e007c0] Setting default whitelist 'file,crypto,data'
 Successfully opened the file.
 Output #0, webvtt, to 'truncated.vtt':
   Metadata:
     encoder         : Lavf59.12.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.5kbits/s speed=N/A
 size=       0kB time=00:00:01.00 bitrate=   0.5kbits/s speed=6.33e+03x
 video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: 110.000000%
 Input file #0 (invalid.vtt):
   Input stream #0:0 (subtitle): 1 packets read (30 bytes);
   Total: 1 packets (30 bytes) demuxed
 Output file #0 (truncated.vtt):
   Output stream #0:0 (subtitle): 1 packets muxed (30 bytes);
   Total: 1 packets (30 bytes) muxed
 [AVIOContext @ 0x55bc88e00a40] Statistics: 63 bytes written, 0 seeks, 1
 writeouts
 0 frames successfully decoded, 0 decoding errors
 [AVIOContext @ 0x55bc88e03580] Statistics: 145 bytes read, 0 seeks
 }}}

 Output file:

 {{{
 WEBVTT

 00:01.000 --> 00:04.000
 - Never drink liquid nitrogen.
 }}}

 So we can see in the output that only 70 of 145 bytes were processed,
 that's the file until the error:

 {{{
 Before avformat_find_stream_info() pos: 70 bytes read:145
 }}}

 Maybe that is how it's supposed to work, but a warning or error message
 would be helpful here.
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9580>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list