How to overlay a transparent PNG image over a video using FFmpeg?

​​I have a transparent PNG image and a video, and I want to overlay the image on the video, is there any way I can achieve this using FFmpeg?

1 Like

Try this I hope this may solve your problem:

ffmpeg -y -i video.mp4 -i overlay.png
-filter_complex "[1][0]scale2ref[i][m];[m][i]overlay[v]"
-map "[v]" -map 0:a? -ac 2 output.mp4

Or you can refer:

Thanks

Hey, Thanks Divyesh!

I tried that solution, but gave me errors: At 0x7fd95155c140, the AVFilterGraph initial threading error. At 0x7fd95155c140, the AVFilterGraph Filter creation error: ‘null’ Unable to open filters!

What should I do now? :worried:

Try this:

Overlaying an image on a video is very easy with FFmpeg, FFmpeg provides an overlay filter with parameters like x & y which allows you to adjust the position of the image on the video, and w & h allows you to control dimensions (width and height) of the overlayed image. Also, if you want to change the transparency of your PNG use geq filter FFmpeg which allows you to apply a generic equation to each pixel.

Consider the following command as an example.
ffmpeg -i video.mp4 -i image.png -filter_complex "[1:v]format=argb,geq=a=1.0*alpha(X,Y)[trp];[0:v][trp]overlay=x=100:y=100:w=600:h=600" -c:v libx264 output.mp4\