I use this command.
ffmpeg -i Input.mp4 -i logo.png -c:v h264_nvenc -filter_complex "[0:v]scale=-1:720[video];[1:v][video]scale2ref=(iw/ih)*ih/8/sar:ih/8[wm][base];[base][wm]overlay=10:10" output.mp4
But what does this mean?
scale2ref=(iw/ih)*ih/8/sar:ih/8
To understand the -filter_complex language, it is essential to read this small chapter of the ffmpeg docs.
You can put the filter description also into a file and use -filter_complex_script <file>.
Compare the filter to a function. The parameters are separated by :. By-position just value, else dictionary-style name=value. To start the parameter list, you use =, too.
The actual data goes via labels [<inlabel>]<filter>[<outlabel>].
Within a chain of filters (separated by ,), labels are not necessary.
Chains are separated by ;.
ffmpeg -filters | grep scale2ref
would give you the in and out channels for the scale2ref filter (VV->VV),
i.e. 2 videos, in and out.
ffmpeg -help filter=scale2ref gives you info on the parameters of the filter.
The order of the parameters is not so obvious, as in this case w is followed by width.
But w and width are the same. So the actual order is width,height of output.
(iw/ih)*ih/8/sar:ih/8 is thus width=(iw/ih)*ih/8/sar:height=ih/8.
To know what variables are predefined/preset for a filter, you need to look into the docs or even better into the source code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With