Do you want to add a logo or and overlay to a video file? This article describes how you can do this using FFmpeg.

How it works

In this example we’re using a PNG file for the logo (can also be a video). You can also work here with transparency (in my case a transparent background). For the “merging” process we can use the FFmpeg filter called “overlay“.

Overlay one video on top of another.

It takes two inputs and has one output. The first input is the “main” video on which the second input is overlaid.

Sounds easy, right?

FFmpeg basics

FFmpeg is easy to use: The first input is our video file, the second one the logo. At the end we declare a output file name.

./ffmpeg -i video.mp4 -i logo.png output-video.mp4

Adding the overlay filter

Now we need to add the overlay filter for the merging process:

./ffmpeg -i video.mp4 -i logo.png -filter_complex "overlay=x=10:y=10" output-video.mp4

The parameter “filter_complex” allows us to use filter with multiple input or outputs. As value we define the x and y position for the overlay (here an offset of 10 pixel from the top left corner).

Positioning the overlay

The logo in the example above has the position in the top left corner with an additional offset of 10 pixel from the x and y position. We can use here also a formula for calculating the position. The variables main_w, main_h, overlay_w and overlay_h helps us here.

If we want to position the logo on the top right position we need to calculate the new offset.


Here we use the width of the video (main_w; 1920 pixel on a full HD video) reducing by the logo size (overlay_w; 100 pixel of the logo width) and add an additional offset of 10 pixel.