Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#4370 closed defect (fixed)

transcoding a broken source may result in success even with -xerror

Reported by: Andreas Cadhalpun Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

This problem was reported as Debian bug 780344 [1].

Using ffmpeg for programmatic detection of broken files (using the '-xerror' option) doesn't always work, because the program sometimes exits with 0, even when errors decoding some part of the input occured.

How to reproduce:

% ffmpeg -xerror -v 9 -loglevel 99 -i ./Mill_CPU_for_Humans_-_Part_2.mp4 -f null /dev/null ; echo $?
ffmpeg version 2.6.1-1 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --prefix=/usr --extra-version=1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libwavpack --enable-libwebp --enable-libxvid --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzvbi --enable-libzmq --enable-frei0r --enable-libvpx --enable-libx264 --enable-libsoxr --enable-gnutls --enable-openal --enable-libopencv --enable-librtmp --enable-libx265
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Splitting the commandline.
Reading option '-xerror' ... matched as option 'xerror' (exit on error) 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 file with argument './Mill_CPU_for_Humans_-_Part_2.mp4'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'null'.
Reading option '/dev/null' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option xerror (exit on error) with argument 1.
Applying option v (set logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input file ./Mill_CPU_for_Humans_-_Part_2.mp4.
Successfully parsed a group of options.
Opening an input file: ./Mill_CPU_for_Humans_-_Part_2.mp4.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xb8e5e0] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xb8e5e0] ISO: File Type Major Brand: mp42
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xb8e5e0] Before avformat_find_stream_info() pos: 322624 bytes read:345903 seeks:0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xb8e5e0] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xb8e5e0] After avformat_find_stream_info() pos: 571520 bytes read:587940 seeks:0 frames:14
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './Mill_CPU_for_Humans_-_Part_2.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2013-11-19 11:10:06
  Duration: 00:17:25.41, start: 0.000000, bitrate: 189 kb/s
    Stream #0:0(und), 13, 1/50: Video: h264 (High) (avc1 / 0x31637661), yuv420p(left), 1280x720, 1/50, 1118 kb/s, 25 fps, 25 tbr, 50 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und), 1, 1/44100: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 191 kb/s (default)
    Metadata:
      creation_time   : 2013-11-19 11:10:26
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
Successfully opened the file.
Parsing a group of options: output file /dev/null.
Applying option f (force format) with argument null.
Successfully parsed a group of options.
Opening an output file: /dev/null.
Successfully opened the file.
detected 4 logical cores
[graph 0 input from stream 0:0 @ 0xb8fde0] Setting 'video_size' to value '1280x720'
[graph 0 input from stream 0:0 @ 0xb8fde0] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 0xb8fde0] Setting 'time_base' to value '1/50'
[graph 0 input from stream 0:0 @ 0xb8fde0] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0xb8fde0] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0xb8fde0] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0xb8fde0] w:1280 h:720 pixfmt:yuv420p tb:1/50 fr:25/1 sar:0/1 sws_param:flags=2
[AVFilterGraph @ 0xb83dc0] query_formats: 3 queried, 2 merged, 0 already done, 0 delayed
[graph 1 input from stream 0:1 @ 0xe58140] Setting 'time_base' to value '1/44100'
[graph 1 input from stream 0:1 @ 0xe58140] Setting 'sample_rate' to value '44100'
[graph 1 input from stream 0:1 @ 0xe58140] Setting 'sample_fmt' to value 'fltp'
[graph 1 input from stream 0:1 @ 0xe58140] Setting 'channel_layout' to value '0x3'
[graph 1 input from stream 0:1 @ 0xe58140] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
[audio format for output stream 0:1 @ 0xb79cc0] Setting 'sample_fmts' to value 's16'
[audio format for output stream 0:1 @ 0xb79cc0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:1'
[AVFilterGraph @ 0xb8e000] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto-inserted resampler 0 @ 0xe5ad80] ch:2 chl:stereo fmt:fltp r:44100Hz -> ch:2 chl:stereo fmt:s16 r:44100Hz
Output #0, null, to '/dev/null':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    encoder         : Lavf56.25.101
    Stream #0:0(und), 0, 1/25: Video: rawvideo (I420 / 0x30323449), yuv420p(left), 1280x720, 1/25, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc56.26.100 rawvideo
    Stream #0:1(und), 0, 1/44100: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s (default)
    Metadata:
      creation_time   : 2013-11-19 11:10:26
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
      encoder         : Lavc56.26.100 pcm_s16le
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
  Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[null @ 0xd69c80] Encoder did not produce proper pts, making some up.
[h264 @ 0xe1d6a0] AVC: nal size 5421ime=00:02:24.56 bitrate=N/A    
    Last message repeated 1 times
[h264 @ 0xe1d6a0] no frame!
[output stream 0:0 @ 0xb91720] EOF on sink link output stream 0:0:default.
[output stream 0:1 @ 0xe585a0] EOF on sink link output stream 0:1:default.
No more output streams to write to, finishing.
frame= 3678 fps=286 q=0.0 Lsize=N/A time=00:02:27.42 bitrate=N/A    
video:345kB audio:25396kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (./Mill_CPU_for_Humans_-_Part_2.mp4):
  Input stream #0:0 (video): 3679 packets read (20961343 bytes); 3678 frames decoded; 
  Input stream #0:1 (audio): 6349 packets read (3538366 bytes); 6349 frames decoded (6501376 samples); 
  Total: 10028 packets (24499709 bytes) demuxed
Output file #0 (/dev/null):
  Output stream #0:0 (video): 0 frames encoded; 3678 packets muxed (353088 bytes); 
  Output stream #0:1 (audio): 6349 frames encoded (6501376 samples); 6349 packets muxed (26005504 bytes); 
  Total: 10027 packets (26358592 bytes) muxed
10031 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0xb8ddc0] Statistics: 24822333 bytes read, 4 seeks
0

The problem seems to be caused by threading, because adding '-threads 1' works around it:

% ffmpeg -threads 1 -xerror -v 9 -loglevel 99 -i ./Mill_CPU_for_Humans_-_Part_2.mp4 -f null /dev/null ; echo $?
ffmpeg version 2.6.1-1 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --prefix=/usr --extra-version=1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libwavpack --enable-libwebp --enable-libxvid --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzvbi --enable-libzmq --enable-frei0r --enable-libvpx --enable-libx264 --enable-libsoxr --enable-gnutls --enable-openal --enable-libopencv --enable-librtmp --enable-libx265
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Splitting the commandline.
Reading option '-threads' ... matched as AVOption 'threads' with argument '1'.
Reading option '-xerror' ... matched as option 'xerror' (exit on error) 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 file with argument './Mill_CPU_for_Humans_-_Part_2.mp4'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'null'.
Reading option '/dev/null' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option xerror (exit on error) with argument 1.
Applying option v (set logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input file ./Mill_CPU_for_Humans_-_Part_2.mp4.
Successfully parsed a group of options.
Opening an input file: ./Mill_CPU_for_Humans_-_Part_2.mp4.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1c30680] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1c30680] ISO: File Type Major Brand: mp42
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1c30680] Before avformat_find_stream_info() pos: 322624 bytes read:345903 seeks:0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1c30680] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1c30680] After avformat_find_stream_info() pos: 571520 bytes read:587940 seeks:0 frames:14
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './Mill_CPU_for_Humans_-_Part_2.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2013-11-19 11:10:06
  Duration: 00:17:25.41, start: 0.000000, bitrate: 189 kb/s
    Stream #0:0(und), 13, 1/50: Video: h264 (High) (avc1 / 0x31637661), yuv420p(left), 1280x720, 1/50, 1118 kb/s, 25 fps, 25 tbr, 50 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und), 1, 1/44100: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 191 kb/s (default)
    Metadata:
      creation_time   : 2013-11-19 11:10:26
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
Successfully opened the file.
Parsing a group of options: output file /dev/null.
Applying option f (force format) with argument null.
Successfully parsed a group of options.
Opening an output file: /dev/null.
Successfully opened the file.
detected 4 logical cores
[graph 0 input from stream 0:0 @ 0x1c1b920] Setting 'video_size' to value '1280x720'
[graph 0 input from stream 0:0 @ 0x1c1b920] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 0x1c1b920] Setting 'time_base' to value '1/50'
[graph 0 input from stream 0:0 @ 0x1c1b920] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x1c1b920] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x1c1b920] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x1c1b920] w:1280 h:720 pixfmt:yuv420p tb:1/50 fr:25/1 sar:0/1 sws_param:flags=2
[AVFilterGraph @ 0x1eff040] query_formats: 3 queried, 2 merged, 0 already done, 0 delayed
[graph 1 input from stream 0:1 @ 0x1dc62c0] Setting 'time_base' to value '1/44100'
[graph 1 input from stream 0:1 @ 0x1dc62c0] Setting 'sample_rate' to value '44100'
[graph 1 input from stream 0:1 @ 0x1dc62c0] Setting 'sample_fmt' to value 'fltp'
[graph 1 input from stream 0:1 @ 0x1dc62c0] Setting 'channel_layout' to value '0x3'
[graph 1 input from stream 0:1 @ 0x1dc62c0] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
[audio format for output stream 0:1 @ 0x1dc6fa0] Setting 'sample_fmts' to value 's16'
[audio format for output stream 0:1 @ 0x1dc6fa0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:1'
[AVFilterGraph @ 0x1c1bcc0] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto-inserted resampler 0 @ 0x1dc90c0] ch:2 chl:stereo fmt:fltp r:44100Hz -> ch:2 chl:stereo fmt:s16 r:44100Hz
Output #0, null, to '/dev/null':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    encoder         : Lavf56.25.101
    Stream #0:0(und), 0, 1/25: Video: rawvideo (I420 / 0x30323449), yuv420p(left), 1280x720, 1/25, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc56.26.100 rawvideo
    Stream #0:1(und), 0, 1/44100: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s (default)
    Metadata:
      creation_time   : 2013-11-19 11:10:26
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
      encoder         : Lavc56.26.100 pcm_s16le
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
  Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[null @ 0x1e80840] Encoder did not produce proper pts, making some up.
[h264 @ 0x1c32dc0] AVC: nal size 5421me=00:02:24.07 bitrate=N/A    
[h264 @ 0x1c32dc0] no frame!
Error while decoding stream #0:0: Invalid data found when processing input
[AVIOContext @ 0x1c2fa40] Statistics: 24822333 bytes read, 0 seeks
Conversion failed!
1

The sample is available at [2].

1: https://bugs.debian.org/780344
2: http://ge.tt/2L51cAC2/v/0

Change History (2)

comment:1 by Andreas Cadhalpun, 9 years ago

Resolution: fixed
Status: newclosed

comment:2 by Carl Eugen Hoyos, 9 years ago

Version: 2.6git-master
Note: See TracTickets for help on using tickets.