FFmpeg is a powerful command-line tool that can be used for a variety of video editing tasks. One of the most common use cases for FFmpeg is adding a watermark to a video. A watermark is an image or text that is overlaid on top of a video to indicate ownership or branding. Watermarks are often used by content creators and companies to protect their intellectual property and prevent unauthorized use or distribution of their videos.
Adding a watermark to a video using FFmpeg is a straightforward process that can be accomplished with just a few commands. The tool allows you to specify the position, opacity, and size of the watermark to ensure that it doesn't interfere with the main video content. Whether you are a content creator looking to protect your work or a company looking to promote your brand, adding a watermark to your videos using FFmpeg is an effective and efficient way to achieve your goals.
How to add a transparent watermark using FFmpeg? #
Start by creating a transparent PNG image file of your watermark. You can use an image software like Photoshop or GIMP to create a transparent background and add your watermark image. Alternatively, you can use Canva. Canva is a free online solution to produce images and graphics.
Open a terminal or command prompt and navigate to the directory where your video file (input_video.mp4
) and watermark image (watermark.png
) are located. The following command will add the watermark to the video and write a new file called output_video.mp4
:
ffmpeg -i input_video.mp4 -i watermark.png -filter_complex "overlay=10:10" output_video.mp4
Of course, you can replace the names of your video file, watermark.png
, and output_video.mp4
as needed.
The
overlay
option in the filter_complex section of the command specifies the position of the watermark. In this example, the watermark will be placed 10 pixels from the top left corner of the video.To make the watermark transparent, add the "blend" option to the filter_complex section of the command, like this:
ffmpeg -i input_video.mp4 -i watermark.png -filter_complex "overlay=10:10:enable='between(t,0,20)',blend=all_mode='overlay':all_opacity=0.7" output_video.mp4
The "blend" option will blend the watermark with the video using the overlay
mode and set the opacity of the watermark to 0.7 (70%). You can adjust the opacity value to make the watermark more or less transparent.
By the way, be sure to check out how to record your screen from Bash if you are using FFmpeg a lot.
Position of the Watermark #
Centered Watermark #
To place the watermark in the center of the video, use the following overlay
option in the FFmpeg command:
overlay=(W-w)/2:(H-h)/2
In this option, W
and H
represent the width and height of the video, and w
and h
represent the width and height of the watermark. The (W-w)/2
and (H-h)/2
expressions calculate the X
and Y
coordinates to place the watermark in the center of the video.
Top Left Watermark #
To place the watermark in the top left corner of the video, use the following overlay
option:
overlay=10:10
Here the "10:10" represents the X
and Y
coordinates to place the watermark in the top left corner of the video. You can adjust the values to move the watermark to a different position.
Top Right Position #
The watermark can be placed in the top right corner of the video using the following FFmpeg overlay
option in the command:
overlay=W-w-10:10
In this option, W-w-10:10
represents the X
and Y
coordinates to place the watermark in the top right corner of the video. The W-w-10
expression calculates the X
coordinate by subtracting the width of the watermark and 10 pixels from the width of the video.
Bottom Left Position #
To position the watermark in the bottom left corner of the video, use the following FFmpeg overlay
:
overlay=10:H-h-10
10:H-h-10
represents the X
and Y
coordinates to place the watermark in the bottom left corner. The H-h-10
expression calculates the Y
coordinate by subtracting the height of the watermark and 10 pixels from the height of the video.
Bottom Right Watermark #
To place the watermark in the bottom right corner of the video, use the following overlay
option in the FFmpeg command:
overlay=W-w-10:H-h-10
In this option, W-w-10:H-h-10
represents the X
and Y
coordinates to place the watermark in the bottom right corner of the video. The W-w-10
and H-h-10
expressions calculate the X
and Y
coordinates by subtracting the width and height of the watermark and 10 pixels from the width and height of the video, respectively.
Of course, you can adjust the position of the watermark by changing the values in the overlay
option of the FFmpeg command.
Conclusion #
In conclusion, adding a watermark to a video using FFmpeg is a simple process that can be achieved. By following the steps outlined above, you can add a transparent watermark to your video in just a few minutes. Make sure to protect your content from being used without permission and also promote your brand, company, or website.
🙏🙏🙏
Since you've made it this far, sharing this article on your favorite social media network would be highly appreciated 💖! For feedback, please ping me on Twitter.
Published