Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#2405 closed defect (fixed)

FFmpeg does not error out in case of empty output

Reported by: Clément Bœsch Owned by:
Priority: normal Component: ffmpeg
Version: git-master Keywords: image2
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

If a corrupted image fails at re-encoded, ffmpeg still exits zero.

Get a PNG:

☭ ./ffmpeg -i tests/lena.pnm -y lena.png
ffmpeg version N-51308-g0177228 Copyright (c) 2000-2013 the FFmpeg developers
  built on Mar 26 2013 14:45:00 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-fontconfig --enable-libfreetype --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora --enable-x11grab --enable-libopenjpeg --enable-libass --enable-libmodplug --enable-libv4l2 --cc=colorgcc --samples=/home/ubitux/fate-samples --prefix=/tmp/ffinstall --disable-runtime-cpudetect --enable-libcelt --enable-libopencv --enable-frei0r --enable-libcaca --enable-libiec61883 --enable-libopencore-amrwb --enable-libopencore-amrnb --enable-libopus --enable-libpulse --enable-libspeex --enable-openal --enable-libopencv
  libavutil      52. 22.101 / 52. 22.101
  libavcodec     55.  1.100 / 55.  1.100
  libavformat    55.  0.100 / 55.  0.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 48.105 /  3. 48.105
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, image2, from 'tests/lena.pnm':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: ppm, rgb24, 256x256, 25 tbr, 25 tbn, 25 tbc
Output #0, image2, to 'lena.png':
  Metadata:
    encoder         : Lavf55.0.100
    Stream #0:0: Video: png, rgb24, 256x256, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (ppm -> png)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A    
video:177kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.012156%

Corrupt it:

☭ ls -l lena.png
-rw-r--r-- 1 ubitux ubitux 177K Mar 26 15:57 lena.png
☭ dd if=lena.png of=in.png bs=150K count=1
1+0 records in
1+0 records out
153600 bytes (154 kB) copied, 0.000522418 s, 294 MB/s
☭ ls -l in.png
-rw-r--r-- 1 ubitux ubitux 150K Mar 26 15:57 in.png

Re-encode it:

☭ ./ffmpeg -i in.png out.png
ffmpeg version N-51308-g0177228 Copyright (c) 2000-2013 the FFmpeg developers
  built on Mar 26 2013 14:45:00 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-fontconfig --enable-libfreetype --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora --enable-x11grab --enable-libopenjpeg --enable-libass --enable-libmodplug --enable-libv4l2 --cc=colorgcc --samples=/home/ubitux/fate-samples --prefix=/tmp/ffinstall --disable-runtime-cpudetect --enable-libcelt --enable-libopencv --enable-frei0r --enable-libcaca --enable-libiec61883 --enable-libopencore-amrwb --enable-libopencore-amrnb --enable-libopus --enable-libpulse --enable-libspeex --enable-openal --enable-libopencv
  libavutil      52. 22.101 / 52. 22.101
  libavcodec     55.  1.100 / 55.  1.100
  libavformat    55.  0.100 / 55.  0.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 48.105 /  3. 48.105
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[png @ 0x1b22760] chunk too big
Input #0, image2, from 'in.png':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgb24, 256x256, 25 tbr, 25 tbn, 25 tbc
Output #0, image2, to 'out.png':
  Metadata:
    encoder         : Lavf55.0.100
    Stream #0:0: Video: png, rgb24, 256x256, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (png -> png)
Press [q] to stop, [?] for help
[png @ 0x1b22760] chunk too big
Error while decoding stream #0:0: Operation not permitted
frame=    0 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.00 bitrate=N/A    
video:0kB audio:0kB subtitle:0 global headers:0kB muxing overhead -inf%
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
☭ echo $?
0
☭ ls -l out.png
ls: cannot access out.png: No such file or directory

Using -err_detect explode does not help either. Also, the file isn't even created. This behavior causes trouble when scripting.

Change History (4)

comment:1 by Carl Eugen Hoyos, 11 years ago

Does this only happen for the image2 muxer or for all output files?

comment:2 by Michael Niedermayer, 11 years ago

comment:3 by Clément Bœsch, 11 years ago

Keywords: image added
Resolution: fixed
Status: newclosed

Seems to do the trick. Someone can re-open the ticket if necessary.

comment:4 by Carl Eugen Hoyos, 10 years ago

Keywords: image2 added; image removed
Note: See TracTickets for help on using tickets.