FFmpeg Filters For Watermarks Animations, Padding, Positioning & Opacity.
In this post I will be showing you how to do some complex filters with ffmpeg to add watermarks to your videos.
Recently this was integrated in to the S3Bubble desktop app to easily add watermarks to your videos if you havent seen the app yet go ahead and try it out here.
https://s3bubble.com/aws-encoding-desktop-app/
We wanted to allow users to added watermarks to their videos at different position also be able to add an opacity if needed. We also added the ability to animated the watermarks and loop throughout the video all commands used are shown below.
Any questions get in touch.
Top left no opacity padding 5
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "overlay=x=5:y=5" output.mp4
Top left with padding 25 and opacity
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.1[logo];[0][logo]overlay=x=25:y=25" output.mp4
Top right no opacity padding 5
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "overlay=x=main_w-overlay_w-5:y=5" output.mp4
Top right with padding 30 and opacity
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.1[logo];[0][logo]overlay=x=main_w-overlay_w-30:y=30" output.mp4
Bottom left no opacity padding 5
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "overlay=x=5:y=main_h-overlay_h-5" output.mp4
Bottom left with padding 30 and opacity
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.1[logo];[0][logo]overlay=x=30:y=main_h-overlay_h-30" output.mp4
Bottom right no opacity padding 5
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "overlay=x=main_w-overlay_w-5:y=main_h-overlay_h-5" output.mp4
Bottom right with padding 30 and opacity
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.1[logo];[0][logo]overlay=x=main_w-overlay_w-30:y=main_h-overlay_h-30" output.mp4
Centered no opacity
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "overlay=x=main_w/2-overlay_w/2:y=main_h/2-overlay_h/2" output.mp4
Centered with opacity
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.1[logo];[0][logo]overlay=x=main_w/2-overlay_w/2:y=main_h/2-overlay_h/2" output.mp4
Animated top left to right
ffmpeg -y -i input.mp4 -loop 1 -i watermark.png -filter_complex "overlay=x='if(gte(t,0), ((W+w)/5)*mod(t,5)-h, NAN)':y=5:shortest=1" output.mp4
Animated top left to right with opacity
ffmpeg -y -i input.mp4 -loop 1 -i watermark.png -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.1[logo];[0][logo]overlay=x='if(gte(t,0), ((W+w)/5)*mod(t,5)-h, NAN)':y=5:shortest=1" output.mp4
Animated center left to right
ffmpeg -y -i input.mp4 -loop 1 -i watermark.png -filter_complex "overlay=x='if(gte(t,0), ((W+w)/5)*mod(t,5)-h, NAN)':y=main_h/2-overlay_h/2:shortest=1" output.mp4
Animated center left to right with opacity
ffmpeg -y -i output.mp4 -loop 1 -i watermark.png -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.1[logo];[0][logo]overlay=x='if(gte(t,0), ((W+w)/5)*mod(t,5)-h, NAN)':y=main_h/2-overlay_h/2:shortest=1" output.mp4
Animated bottom left to right
ffmpeg -y -i input.mp4 -loop 1 -i watermark.png -filter_complex "overlay=x='if(gte(t,0), ((W+w)/5)*mod(t,5)-h, NAN)':y=main_h-overlay_h-5:shortest=1" output.mp4
Animated bottom left to right with opacity
ffmpeg -y -i input.mp4 -loop 1 -i watermark.png -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.1[logo];[0][logo]overlay=x='if(gte(t,0), ((W+w)/5)*mod(t,5)-h, NAN)':y=main_h-overlay_h-5:shortest=1" output.mp4
You can also do this process with text using the draw filter
ffmpeg -y -i intro.mp4 -vf drawtext="fontfile=/Users/picca/Desktop/Montserrat/Montserrat-Black.ttf: \ text='I love s3bubble media streaming app': fontcolor=white: fontsize=24: box=1: boxcolor=black@0.5: \ boxborderw=5: x='if(gte(t,0), ((W+w)/5)*mod(t,5)-h, NAN)':y=20" -codec:a copy output.mp4