问题
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.
回答1:
You can refer to the exit code or exit status.
Example using Bash and ffprobe
:
ffprobe brokeninput.mp4; echo $?
Result:
1
A non-zero result indicates the command failed which most likely correlates to a bad input.
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:
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 $?
来源:https://stackoverflow.com/questions/58815980/how-can-i-tell-if-a-video-file-is-corrupted-ffmpeg