使用ffmpeg快速检查目录内视频文件的完整性 [英] Quickly check the integrity of video files inside a directory with ffmpeg

查看:266
本文介绍了使用ffmpeg快速检查目录内视频文件的完整性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在拼命寻找一种方便的方法来检查包含文件夹的特定目录中 .mp4 文件的完整性..mp4 文件和文件夹的名称都包含空格、特殊字符和数字.

I'm desperately searching for a convenient method to check the integrity of .mp4 files inside a specific directory with folders in it. Both the names of the .mp4 files and the folders contain spaces, special characters and numbers.

我已经找到了一个正确的 ffmpeg 命令来快速识别损坏的 .mp4 文件,取自 此处:ffmpeg -v error -i filename.mp4 -map 0:1 -f null - 2>error.log

I've already found a proper ffmpeg command to quickly identify a damaged .mp4 file, taken from here: ffmpeg -v error -i filename.mp4 -map 0:1 -f null - 2>error.log

如果创建的 error.log 包含一些条目,则该文件显然已损坏.相反将是一个空的 error.log.

If the created error.log contains some entries, then the file is obviously corrupted. The opposite would be an empty error.log.

下一步是将此命令应用于文件夹及其子文件夹中的每个 .mp4 文件.一些指南,例如此处这里,确实描述了如何递归地应用 ffmpeg 命令,但我的编码技能有限,所以因此我找不到组合这些命令来获得以下内容的方法:

The next step would be to apply this command to every .mp4 file within the folder and its subfolders. Some guides, like here and here, do describe how to apply a ffmpeg command recursively, but my coding skills are limited, so therefore I can't find a way to combine these commands to get the following:

一种使用上述 ffmpeg 命令(递归地)测试文件夹内所有 .mp4 文件的方法,它应该创建 .log 文件,仅当视频文件确实包含错误(读取有一些内容)并且它应该继承名称损坏的文件,以了解哪个文件已损坏.

A way to test all .mp4 files inside a folder (recursively) with the aforementioned ffmpeg command, that should create .log files, only if a video file does contain errors (read has some content) and it should inherit the name of the broken file, to know which file is corrupted.

使用 Ubuntu Gnome 15.10.

Using Ubuntu Gnome 15.10.

推荐答案

试试这个命令:

find . -name "*.mp4" -exec ffmpeg -v error -i "{}" -map 0:1 -f null - 2>error.log ;

find 命令递归地查找当前目录中与给定模式对应的所有文件:"*.mp4".-exec 之后是您要为所有文件运行的命令."{}" 替换当前文件的名称,其中引号允许文件名中有空格.命令必须以 ; 结尾.

The find command finds all files in the current directory recursively which correspond to the given pattern: "*.mp4". After -exec comes the command you want to run for all files. "{}" substitutes the name of the current file, where the quotes allow spaces in file names. The command has to end with ;.

上面的代码只生成了一个日志文件,无法知道是哪个文件被破坏了.要为每个 .mp4 文件创建单独的 .log 文件,您可以再次使用 {} 符号:

The code above generates only one log file, which makes it impossible to know which file was broken. To instead create separate .log files for each of the .mp4 files, you can use the {} symbol one more time:

find . -name "*.mp4" -exec sh -c "ffmpeg -v error -i '{}' -map 0:1 -f null - 2>'{}.log'" ;

这篇关于使用ffmpeg快速检查目录内视频文件的完整性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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