7

I am trying to find out if a video file is corrupted or not.

I am using FFmpeg to transcode a video file. However, when it gets to a file that not playable and is damaged, it stops running.

I want to know if there is a way to output the FFmpeg command into a text file and then be able to tell which file is corrupted from the text file.

When I run FFmpeg on one of the corrupted vide, I find this information.

  built with gcc 9.1.1 (GCC) 20190807
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 35.100 / 56. 35.100
  libavcodec     58. 56.101 / 58. 56.101
  libavformat    58. 32.104 / 58. 32.104
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.102 /  7. 58.102
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000020052a58c00] moov atom not found
FoodXP_2019_11_07__19_29_00.mp4: Invalid data found when processing input

is the only value Invalid data found when processing input that states if it is damaged?

My goal is to be able to determine, which files are corrupted by reading from the output text file.

I cannot find all the information from online, is there any other value that I can use when looking at the text file.

2 Answers 2

15

You can refer to the exit code or exit status.

Example using Bash and ffprobe:

ffprobe brokeninput.mp4; echo $?

Example result of failure:

1

A non-zero result indicates the command failed which most likely correlates to a bad input (or the file was not found).

ffprobe is used instead of ffmpeg for the above example because ffmpeg always returns a non-zero value due to the At least one output file must be specified "error" when simply running ffmpeg -i input.mp4.

Of course media files are complicated, so although a probe may result in 0 (success) it doesn't mean the file is valid. However, in the specific case of your moov atom not found error that's probably all you need to do.

If you want to take additional steps you can test demuxing. This uses the null muxer and no output file is created.

ffmpeg -i input.mp4 -c copy -f null -; echo $?

And the most robust (and time consuming) test includes decoding:

ffmpeg -i input.mp4 -f null -; echo $?
2
  • ffprobe returns dyld: Library not loaded: /usr/local/opt/x264/lib/libx264.160.dylib error
    – alper
    Nov 19, 2020 at 19:15
  • @alper Not really related to this particular Q/A topic. Recommend asking a new question.
    – llogan
    Nov 19, 2020 at 19:18
-2

A wrapper for the ffmpeg command in the form of a GUI-based Python program to batch scan video files in a selected directory for integrity; assessing if the files are healthy or corrupt. This is based on the command: ffmpeg -v error -i file.avi -f null - 2>error.log

https://github.com/nhershy/CorruptVideoFileInspector

2
  • not sure why anyone would go through the hassle and risk of using a UI to accomplish what would otherwise have been done faster and better before the repo cloned. Regardless, this doesn't answer the question. Feb 15 at 6:16
  • on a more charitable note, instead of decoding the entire file by default you'd be better off using a series of increasingly thorough tests. if you can't probe it, it's broken. if you can't demux it, it's also broken. if you only care about missing frames, you can dump those and more with ffprobe. decode as a last resort. otherwise as the user what to look for. Feb 15 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.