Here’s how to watermark your video with ffmpeg by adding text
Recently I had to watermark a few videos and instead of using a program to edit all of the videos manually, I decided to use ffmpeg which is far faster and more effective when you want the same result over and over.
Here’s how the command looks, then I’ll explain in it in detail:
ffmpeg -i my-video.mp4 -y -vf "drawtext=text='my watermark':x=100:y=400:fontfile=./fonts/Poppins/Poppins-Black.ttf:fontsize=100:email@example.com" watermarked.mp4
Here’s the breakdown:
-i my-video.mp4simply the input video.
-ymeans we want to override any existing videos with the same output name.
-vfhere is where we add the watermark with this filter option. Each parameter is separated by a colon
:so you can specify multiple filter options.
drawtext=text='my watermark'this is the text we want to display as the watermak.
x=100means the watermark will be pushed 100 pixels from the left.
y=400means the watermark will be pushed 400 pixels from the top.
fontfile=./fonts/Poppins/Poppins-black.ttfthis is a font I’ve downloaded from google fonts and it’s called poppins. You need to add that font to the same folder and write down the exact font you want to use. This is optional, you can skip this parameter for the default font.
fontsize=100that’s the font size. It will be 100 pixels tall. You can try a bunch of values and see what works for you.
firstname.lastname@example.org means the font will be white AND it will have an opacity of 0.2. The opacity can be from 1 (fully visible) to 0 (fully transparent).
watermarked.mp4that’s the output file name.
Now if you want to add multiple watermark texts, you have to make some changes and use
-filter_complex instead of
-vf like the in following example:
ffmpeg -i my-input-video.mp4 -y -filter_complex "drawtext=text='first watermark':x=200:y=400:fontsize=100:email@example.com[one];[one]drawtext=text='second watermark':x=200:y=800:fontsize=100:firstname.lastname@example.org" watermarked.mp4