Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg how to put color overlay over video

I want to put a color overlay (blue, red or green or hex value) over a video giving it a Instagram filter like effect.

I think it should be in the lines of:

ffmpeg -i video.mp4 -i "red.png" -filter_complex "blend=all_mode='screen':all_opacity=0.7" output.mp4

or maybe with all_mode=overlay

But I get an error:

First input link top parameters (SAR 0:1) do not match the corresponding second input link bottom parameters (SAR 1:1).

I also tried with lutrgb=r=1.5, but that didn't give it a red color (it takes the red away).

What am i doing wrong ?

like image 528
flieks Avatar asked Dec 09 '22 00:12

flieks


1 Answers

The two inputs must share the same dimensions and SAR. You can either use the setsar filter to set the same SAR or you can avoid using an image file completely by using color:

ffmpeg -i video.mp4 -f lavfi -i "color=red:s=1280x720" -filter_complex "blend=shortest=1:all_mode=overlay:all_opacity=0.7" output.mp4

Where s=1280x720 is the size of the input video frame.

The color has the [0x|#]RRGGBB[AA] format.


Update:

If you still have issues with the input video SAR try to explicitly set it using the setsar filter:

ffmpeg -i video.mp4 -f lavfi -i "color=red:s=1280x720" \
-filter_complex "[0:v]setsar=sar=1/1[s];\
[s][1:v]blend=shortest=1:all_mode=overlay:all_opacity=0.7[out]" \
-map [out] -map 0:a output.mp4
like image 132
aergistal Avatar answered Dec 28 '22 11:12

aergistal