Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFMPEG combining image, mp3, and logo watermark

I thought this would work but I'm getting errors.

ffmpeg -loop 1 -i "ARTWORK.jpg" -filter_complex "overlay=80:0" -i "MUSIC.mp3" -i "WATERMARK.gif" -filter_complex "overlay=10:350" -s 640x480 -shortest -vcodec libx264 -acodec aac -strict experimental -movflags faststart "CONVERTED.mp4"

If I do not put the -filter_complex "overlay=80:0" part (to place the artwork "in the middle") it works, but the artwork does not center (it is a 480x480 jpeg)

The error i am getting is

Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_overlay_0

It has something to do with there being 2 filter complex parts but both are necessary so not sure how to "label" them?

like image 603
b747fp Avatar asked Oct 31 '22 18:10

b747fp


1 Answers

Update: what the OP wanted to achieve was to be able to position two overlays. The obvious answer in this case is you to use a third input as the main input, for example a black frame:

 ffmpeg -f lavfi -i color=black:800x600 -i <image1> -i <image2> -i <audio> -filter_complex 'overlay=...,overlay=' <output>

An overlay filters needs two inputs: the main input and the superimposed input.

You have only 2 image inputs and so you cannot use two overlay filters in the same command since it would require a third visual stream. That's why is says it cannot find a matching stream.

For example you can use two overlay filters to add two different logos to a video:

ffmpeg -i input -i logo1 -i logo2 -filter_complex 'overlay=...,overlay=' output

In your case the main input is the artwork and watermark is the overlay which needs to be positioned in a single overlay.

Take a look at the documentation because there are some parameters that might help you achieve your goal no matter the input size. See the main and overlay input width and height: main_w, main_h, overlay_w, overlay_h.

Example usage (overlay at 10px from lower-right bottom corner):

overlay=main_w-overlay_w-10:main_h-overlay_h-10

like image 146
aergistal Avatar answered Nov 08 '22 05:11

aergistal