Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set opacity/transparency of overlay using ffmpeg?

Tags:

ffmpeg

I am making an app where I need to overlay two video files one above the other using ffmpeg. I tried various commands but all it does is merging a video.

like image 239
Ria Mehta Avatar asked Jan 27 '26 16:01

Ria Mehta


1 Answers

Basic method is

ffmpeg -i in1 -i in2 -filter_complex
       "[1]format=yuva444p,colorchannelmixer=aa=0.5[in2];[0][in2]overlay"
       out

where 0.5 sets 50% transparency for the 2nd input. The format filter is needed to make sure that the 2nd video has an alpha channel.

To resize in2 to match in1, use

ffmpeg -i in1 -i in2 -filter_complex
       "[1]format=yuva444p,colorchannelmixer=aa=0.5[in2];
        [in2][0]scale2ref[in2][in1];[in1][in2]overlay"
       out
like image 119
Gyan Avatar answered Jan 29 '26 11:01

Gyan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!