FFmpeg视频过滤器损坏了mp4文件 [英] FFmpeg video filters corrupt mp4 file

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

问题描述

我正在尝试使用FFmpeg将视觉过滤器添加到mp4文件.

I am trying to add visual filters to mp4 files using FFmpeg.

我尝试了很多过滤器,但是其中有4个工作正常,其中只有1个工作完美.我在Android application中使用它们,但是我在windows cmd上使用FFmpeg尝试了相同的命令行,结果是相同的.带有3个过滤器的.mp4无法被许多玩家使用,Androids mediaplayer也无法播放.我仍然可以在VLC和具有许多法典的播放器上播放损坏"的文件,但我需要它们完美地工作.

I have tried many filters, but 4 of them worked out of which only 1 worked worked perfectly. I am using them in an Android application, but I tried the same command lines on windows cmd using FFmpeg and the result is same. With 3 filters the .mp4 is unplayable by many players and also Androids mediaplayer. I can still play the "corrupt" files on VLC and players that have many codex`s, but I need them to work perfectly.

唯一可以正常使用的过滤器是Black and White,命令是(已经尝试过-vf-filter_complex):

The only filter working as intended is Black and White and the command is (have tried both -vf and -filter_complex):

-i origin.mp4 -filter_complex hue=s=0 blackWhite.mp4

其他3个是SepiaVintageNegative

"colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131",  "curves=vintage", "curves=negative"

由于我无法在此处上传视频文件,因此我添加了3个文件的链接:原始视频文件,黑白过滤文件(有效),老式文件(无效).

Since I cannot upload video files here, I have added a link of 3 files, the original video file, black/white filtered file (that works), vintage file (that does not work).

Dropbox-视频文件链接

推荐答案

曲线和colorchannelmixer滤镜仅适用于RGB像素,因此FFmpeg可以根据需要预先转换视频.

The curves and colorchannelmixer filters only work on RGB pixels so FFmpeg converts the video beforehand, if required.

当使用典型的H.264编码器保存到MP4时,ffmpeg将转换为YUV颜色编码,但会选择最高保真度像素格式,对于RGB源,该格式为YUV 4:4:4.此格式与大多数播放器不兼容.解决方法是手动强制输出YUV 4:2:0.在输出文件名之前添加-pix_fmt yuv420p.

When saving to MP4 using a typical H.264 encoder, ffmpeg will convert to YUV color encoding but pick the highest fidelity pixel format which, for a RGB source, is YUV 4:4:4. This format is not compatible with most players. Solution is to manually force YUV 4:2:0 output. Add -pix_fmt yuv420p just before the output filename.

这篇关于FFmpeg视频过滤器损坏了mp4文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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