如何从脚本验证视频文件? [英] How can I validate a video file from a script?

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

问题描述

我的服务器上有很多视频文件.还原后,我注意到几个文件的校验和发生了变化.由于我没有所有文件的校验和,因此我想编写一个脚本来验证文件的完整性.对于归档文件( tar t unzip -t rar t 等)或图像( convert image.jpg/tmp/test.png).

I have a server with lots of video files. After a restore, I noticed that the checksum of a couple of files changed. Since I don't have checksums for all files, I wanted write a script to verify the file integrity. It's simple for archives (tar t, unzip -t, rar t, etc) or images (convert image.jpg /tmp/test.png).

我需要通过哪些选项传递给 mplayer vlc 或Linux上的任何其他视频工具,以实现相同的效果(即无需观看即可验证文件内容整个视频)?

Which options do I need to pass to mplayer or vlc or any other video tool on Linux to achieve the same effect (i.e. validate the file contents without having to watch the whole video)?

推荐答案

听起来您要执行的操作是:

It sounds like what you want to do is:

mplayer -vo null -ao null input.file

,然后解析输出和返回值,以查看它是否可以实际播放&解码流.这将花费一些时间(但比实时要快).如果您想要更快的速度,这里还有一些建议:

and then parse the output and return value to see if it could actually play & decode the stream. This will take some time (but be faster than realtime). If you want something even faster, here are some more suggestions:

一个简单的事情就是要做一个

One easy thing is going to be to do an

mplayer -identify -vo null -ao null

在文件上,然后解析输出并查看看起来合理的返回值.

on the file, and then parse the output and look at the return value for something that looks reasonable.

关于校验和不正确,将很难知道这对您的媒体播放器(mplayer,vlc,图腾等)是否是个问题.一个好的媒体播放器可以容忍许多位或字节级别的错误,而对最终的回放影响很小.看到非常严格的媒体播放器时,如果出现格式错误或编解码器&不正确,就会退出.包装字节.

With respect to the checksums being incorrect, it's going to be hard to know if this is an issue for your media player or not (mplayer, vlc, totem, etc.). A good media player will tolerate many bit or byte level errors with little impact on the resulting playback. A very strict media player will exit when it sees malformed or incorrect codec & wrapper bytes.

要验证包装器(容器)字节,您可以执行类似

To verify the wrapper (container) bytes, you could do something like

mencoder -ovc copy -oac copy input.file -o output.file

问题在于,mencoder将要创建一个.avi文件进行输出.如果您输入的是.avi,则效果很好.

The problem is that mencoder will want to create an .avi file for output. If your inputs are .avi, then this will work great.

您可以运行类似的ffmpeg命令行,如下所示:

You can run a similar ffmpeg commandline, like this:

ffmpeg -acodec copy -vcodec copy input.file output.file

如果文件是.mp4文件,则可能需要看一下mp4box( http://www.videohelp.com/tools/mp4box )来执行类似的任务.Matroska工具也适用于这种情况.( http://www.matroska.org/)

If the files are .mp4 files, you might want to take a look at mp4box ( http://www.videohelp.com/tools/mp4box ) for doing a similar task. The matroska tools are also good for this kind of thing. ( http://www.matroska.org/ )

这篇关于如何从脚本验证视频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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