[FFmpeg-user] How can I make ffmpeg stop on broken input?

Werner Robitza werner.robitza at gmail.com
Mon Mar 25 20:42:51 CET 2013


I have a file that's corrupted. When encoding it, the h264 decoder reports
an error, but ffmpeg still continues to encode and produces an output file
that is encoded until where the error occurs.

I consider this a failed encoding process, but ffmpeg still exits without
error.

Can I make ffmpeg stop on that, or otherwise reliably check for an encoding
process where something went wrong?

Thanks

---

ffmpeg -y -i ~/Downloads/in.mp4 -an out.mp4 && echo success || echo failed
ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Mar 18 2013 21:59:35 with Apple LLVM version 4.2
(clang-425.0.24) (based on LLVM 3.2svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2 --enable-shared
--enable-pthreads --enable-gpl --enable-version3 --enable-nonfree
--enable-hardcoded-tables --enable-avresample --cc=cc --host-cflags=
--host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame
--enable-libxvid --enable-libvorbis --enable-libfdk-aac
--enable-libopenjpeg
--extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1/include/openjpeg-1.5 '
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/werner/Downloads/in.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 19529845
    compatible_brands: mp42isom
    creation_time   : 2013-03-20 21:45:43
  Duration: 00:02:04.62, start: 0.000000, bitrate: 605 kb/s
    Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo,
fltp, 64 kb/s
    Metadata:
      creation_time   : 2013-03-20 21:45:43
      handler_name    : Sound Media Handler
    Stream #0:1(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p,
720x480 [SAR 40:33 DAR 20:11], 983 kb/s, 29.97 fps, 29.97 tbr, 30k tbn,
59.94 tbc
    Metadata:
      creation_time   : 2013-03-20 21:45:43
      handler_name    : Video Media Handler
[libx264 @ 0x7fdf7401f600] using SAR=40/33
[libx264 @ 0x7fdf7401f600] using cpu capabilities: MMX2 SSE2Fast SSSE3
FastShuffle SSE4.2 AVX
[libx264 @ 0x7fdf7401f600] profile High, level 3.0
[libx264 @ 0x7fdf7401f600] 264 - core 125 - H.264/MPEG-4 AVC codec -
Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1
ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00
mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11
fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2
sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0
constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1
weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40
intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0
qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 19529845
    compatible_brands: mp42isom
    encoder         : Lavf54.63.104
    Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p,
720x480 [SAR 40:33 DAR 20:11], q=-1--1, 30k tbn, 29.97 tbc
    Metadata:
      creation_time   : 2013-03-20 21:45:43
      handler_name    : Video Media Handler
Stream mapping:
  Stream #0:1 -> #0:0 (h264 -> libx264)
Press [q] to stop, [?] for help
Truncating packet of size 3544 to 682872kB time=00:01:08.03 bitrate=
707.0kbits/s
[h264 @ 0x7fdf74d52600] AVC: nal size 3534
    Last message repeated 1 times
[h264 @ 0x7fdf74d52600] no frame!
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fdf74018e00] stream 1, offset 0x8ffccb:
partial file
/Users/werner/Downloads/in.mp4: Invalid data found when processing input
frame= 2154 fps=131 q=-1.0 Lsize=    6167kB time=00:01:11.80 bitrate=
703.5kbits/s
video:6143kB audio:0kB subtitle:0 global headers:0kB muxing overhead
0.388752%
[libx264 @ 0x7fdf7401f600] frame I:9     Avg QP:19.18  size: 18753
[libx264 @ 0x7fdf7401f600] frame P:906   Avg QP:24.16  size:  4973
[libx264 @ 0x7fdf7401f600] frame B:1239  Avg QP:29.51  size:  1303
[libx264 @ 0x7fdf7401f600] consecutive B-frames: 16.1% 10.8% 32.5% 40.7%
[libx264 @ 0x7fdf7401f600] mb I  I16..4: 35.6% 43.5% 20.9%
[libx264 @ 0x7fdf7401f600] mb P  I16..4:  5.3%  5.2%  1.0%  P16..4: 37.0%
13.0%  4.5%  0.0%  0.0%    skip:34.0%
[libx264 @ 0x7fdf7401f600] mb B  I16..4:  0.3%  0.3%  0.1%  B16..8: 40.4%
 3.8%  0.5%  direct: 0.7%  skip:54.0%  L0:49.1% L1:46.1% BI: 4.8%
[libx264 @ 0x7fdf7401f600] 8x8 transform intra:45.2% inter:71.1%
[libx264 @ 0x7fdf7401f600] coded y,uvDC,uvAC intra: 34.0% 47.8% 11.5%
inter: 8.8% 10.0% 0.2%
[libx264 @ 0x7fdf7401f600] i16 v,h,dc,p: 41% 18%  9% 32%
[libx264 @ 0x7fdf7401f600] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 16% 23%  4%
 5%  6%  4%  6%  4%
[libx264 @ 0x7fdf7401f600] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 20% 16%  4%
 5%  6%  5%  5%  3%
[libx264 @ 0x7fdf7401f600] i8c dc,h,v,p: 52% 15% 28%  6%
[libx264 @ 0x7fdf7401f600] Weighted P-Frames: Y:3.1% UV:1.7%
[libx264 @ 0x7fdf7401f600] ref P L0: 68.2% 12.8% 15.0%  3.9%  0.0%
[libx264 @ 0x7fdf7401f600] ref B L0: 90.1%  8.9%  1.0%
[libx264 @ 0x7fdf7401f600] ref B L1: 95.2%  4.8%
[libx264 @ 0x7fdf7401f600] kb/s:700.07
success


More information about the ffmpeg-user mailing list