如何判断视频文件是否损坏?FFmpeg? [英] How can I tell if a video file is corrupted? FFmpeg?

查看:487
本文介绍了如何判断视频文件是否损坏?FFmpeg?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试确定视频文件是否损坏.

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

我正在使用 FFmpeg 对视频文件进行转码.但是,当它到达不可播放且已损坏的文件时,它将停止运行.

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.

我想知道是否可以将FFmpeg命令输出到文本文件中,然后能够从文本文件中分辨出哪个文件已损坏.

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.

当我在其中一个损坏的视频上运行FFmpeg时,我会找到此信息.

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

是唯一的值在处理输入时发现无效数据说明其是否损坏的?

我的目标是能够通过读取输出文本文件来确定哪些文件已损坏.

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.

推荐答案

您可以参考退出代码或退出状态.

You can refer to the exit code or exit status.

使用Bash和 ffprobe 的示例:

Example using Bash and ffprobe:

ffprobe brokeninput.mp4; echo $?

失败的示例结果:

1

非零结果表示命令失败,很可能与错误的输入(或未找到文件)相关.

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

ffprobe 而不是 ffmpeg ,因为 ffmpeg 总是由于 At而返回非零值必须指定至少一个输出文件错误"只需运行 ffmpeg -i input.mp4 .

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.

当然,媒体文件很复杂,因此尽管探测可能会导致 0 (成功),但这并不意味着文件有效.但是,在您的 moov原子未找到错误的特定情况下,这可能就是您需要做的全部事情.

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 $?

这篇关于如何判断视频文件是否损坏?FFmpeg?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆