如何判断ffmpeg是否错误? [英] How to tell if ffmpeg errored or not?

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

问题描述

情况: 我正在使用ffmpeg(通过.net)保存视频文件.我可以从ffmpeg获取输出,但是我不知道如何自定义输出以获得更好的结果.

The Situation: I'm using ffmpeg (via .net) to save video files. I can get the output from ffmpeg but I dont know how can I customize the output to have better result.

我的问题: 我的问题是,成功操作和失败操作之间没有一定的区别.

My Problem: My problem is, there is no certain difference between successful and failed operation.

最后一条成功线:

视频:1006kB音频:134kB字幕:0全局标头:0kB混合开销0.943510%

video:1006kB audio:134kB subtitle:0 global headers:0kB muxing overhead 0.943510%

最后一行失败

c:\ x \ test-9-8/30/2012-9:29:56-AM.mp4:无效的参数

c:\x\test-9-8/30/2012-9:29:56-AM.mp4: Invalid argument

rtmp://cdn.tv/cdn-live39/定义/stream01:发生未知错误

rtmp://cdn.tv/cdn-live39/definst/stream01: Unknown error occurred

我的问题: 是否有一个选项(或命令行参数)添加某种返回代码(200:成功,500:错误等)

My Question: Is there an option (or command line parameter) to add some sort of return code (200: success, 500: error, etc)

谢谢!

PS:我看到了这个主题如何判断ffmpeg是否出错? ,但最后一行之前/之后没有数字.我认为最新版本已经没有编号了.

PS: I saw this topic How to tell if ffmpeg errored? but there is no number before/after last line. I think the last version doesnt have number anymore.

推荐答案

我知道这已经很老了,但是当我偶然发现并没有其他可靠的答案并且经过更多测试后,发现该问题:

I know this is very old but as i came across and found no other reliable answer and after some more testing:

检查返回0的建议通常是一个很好的建议-但在所有情况下都无济于事.检查文件是否存在的另一个想法也很好-但同样-在所有情况下都无济于事.

The suggestion with checking for return of 0 is in general a good advice - but does not help in all cases. The other idea with checking if the file exists is also good - but again - does not help in all cases.

例如,当输入文件是带有嵌入式封面的mp3文件时-ffmpeg会(在我的测试中)使用此图片并将其提取为(不可用的)视频文件.

For example when the input file is a mp3 file that has an embedded cover - then ffmpeg does (in my tests) use this image and extracts that one as an (unusable) video file.

我现在要做的是具有调试级别的输出,并分析它以获得复用包的数量.

What i do now is to have debug level output and parse it for the number of muxed packets.

ffmpeg -i "wildlife.mp4" -c:v copy -an -sn "out.mp4" -y -loglevel debug 2> wildlife.txt

我用正则表达式搜索以下文本:
Output stream .+ (video): [0-9][0-9]+ packets muxed \([0-9][0-9]+ bytes\)

With a regex i search for this text:
Output stream .+ (video): [0-9][0-9]+ packets muxed \([0-9][0-9]+ bytes\)

(这假设每个视频都包含9个以上的数据包-当然可以针对非常短的视频进行优化).

(this assumes that every video has more than 9 packets - could of course be optimized for really short videos).

当然,对于RTMP或其他设置,输出可能会有所不同,但我认为解析完整的输出流是唯一的选择.

Of course for RTMP or other settings the output may differ but i think to parse the full output stream is the only option.

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

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