I'm trying to use ffmpeg to achieve the following: x.jpg = a file that is 540x540 in size. Gradient.png = a 540x960 image that has a gradient of semi transparency (which starts with dark blue with no transparency in the top and then gradually becomes transparent in the bottom) example of Gradient.png attached
The goal is to end up with a jpg that is 540x960, where x.jpg is in the bottom 540x540 of the frame and the Gradient.png is laid on top of it. Because Gradient.png is larger, this seems to pose a problem.
I tried:
ffmpeg.exe -i x.jpg -i Gradient.png -filter_complex overlay=0:480 -c:v png -pix_fmt rgba out.png
Which just creates a 540x540 frame, so doesn't work. Feels close though. If I new how to enlarge the "canvas" this could have maybe worked.
I tried.
ffmpeg.exe -i Gradient.png -i x.jpg -filter_complex overlay=0:480 -c:v png -pix_fmt rgba out.png
Which does create a 540x960 frame but Gradient.png is not on top of 1.jpg, the opposite is happening here, so I don't get the effect of the semi transparency shown on top of x.jpg like I need.
Any help will be highly appreciated
Edit: I was able to do it in 2 steps. ffmpeg -i x.jpg -vf "scale=540:960:force_original_aspect_ratio=decrease,pad=540:960:(ow-iw)/2:(oh-ih)" -c:v png -pix_fmt rgba out.jpg ffmpeg -i out.jpg -i Gradient.png -filter_complex overlay=0:0 OUT2.jpg
If someone can come up with a way to do it in one step, it'll be great.
CodePudding user response:
Just need to pad the JPEG first.
ffmpeg -i x.jpg -i Gradient.png -filter_complex "[0]pad=540:960:0:oh-ih[x];[x][1]overlay=0:0" -c:v png -pix_fmt rgba out.png