FFmpeg video filters corrupt mp4 file
Asked Answered
E

1

1

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

Erelia answered 12/9, 2018 at 13:4 Comment(0)
H
3

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.

Homosexual answered 12/9, 2018 at 13:53 Comment(1)
Or append format=yuv420p to the end of your filterchain. I generally prefer to keep all of the filtering within the filterchain instead of using the legacy -pix_fmt option.Rattish

© 2022 - 2024 — McMap. All rights reserved.