Right now I overlay a transparent PNG over a video first converting them both to the same size, but would love to just have it scale within the same command. Here’s the command now:
ffmpeg -y -i video.mp4 -i overlay.png -filter_complex 'overlay[out],amix=inputs=1,pan=stereo:c0=c0:c1=c1' -map '[out]' output.mp4
The best command should also permit a video that does not have an audio track and still overlay the PNG.
Use
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
The scale2ref
scales the first input (to the filter) to the size of the second. The input pad indexes 0
, and 1
refer to the first and 2nd input to FFmpeg, as that count begins from zero.
-map 0:a?
- the ?
tells FFmpeg to map the audio contingently i.e. if present. I have removed the amix
since a) filters within a filter complex can't be contingent and b) there's only one input so there's nothing to 'mix'.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments