FFmpeg video filters corrupt mp4 file

别等时光非礼了梦想. 提交于 2020-01-06 08:00:47

问题


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

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.

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

The other 3 are Sepia, Vintage and Negative

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

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 - video files link


回答1:


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

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.



来源:https://stackoverflow.com/questions/52295933/ffmpeg-video-filters-corrupt-mp4-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!