How to scale and position watermark to scale?

2020-02-29 23:40发布

问题:

I'm scaling a video and applying a watermark like so:

ffmpeg -ss 0:0:0.000 -i video.mp4 -y -an -t 0:0:10.000
 -vf \"[in]scale=400:316[middle]\" -b:v 2000k -r 20
 -vf 'movie=watermark.png,pad=400:316:0:0:0x00000000 [watermark];[middle] [watermark]overlay=0:0[out]'
 out.flv

However, the applied watermark seems to be scaled to the original video size rather than the smaller scaled video size.

This command line worked on ffmpeg version 0.8.6.git and now behaves differently after an upgrade to version N-52381-g2288c77.

How do I get it to work again?


Update 2013-04-26:
I now have tried to use the overlay filter's X and Y parameters instead of padding without success.

回答1:

Answered by ubitux on the FFmpeg IRC:

Use scale and overlay in a single -filter_complex chain, like so:

ffmpeg -y -ss 0 -t 0:0:30.0 -i 'video.mp4' -i '/watermark.png'
 -filter_complex "[0:0] scale=400:225 [wm]; [wm][1:0] overlay=305:0 [out]"
 -map "[out]" -b:v 896k -r 20 -an 
 'out.flv'

Also load the watermark via -i rather than the movie filter.