Watermarking Videos from the Command Line with FFMPEG Filters

FFMPEG filters provide a powerful way to programmatically enhance or alter videos, and it’s fairly simple to add a watermark to a video using the overlay filter. The easiest way to install ffmpeg is to download a pre-built binary for your specific platform. Then you don’t have to worry about including and installing all the right dependencies and codecs you will be using.

Here’s a short video I took while mountain biking that we’ll be working with.

Once you have ffmpeg installed, adding a watermark is as easy as passing your existing source through an overlay filter like so:

ffmpeg -i birds.mp4 -i watermark.png -filter_complex "overlay=10:10" birds1.mp4

Basically, we’re passing in the original video, and an overlay image as inputs, then passing it through the filter, and saving the output as birds1.mp4.

We specify a specific position of the overlay in pixels – 10:10 puts the video 10 pixels from the top and 10 pixels from the right. (x:y coordinates)

Here is our result:

In some cases you might not know the exact dimensions of the videos you’ll be watermarking. Fortunately, there are variables you can use to better position your watermark depending on the size of the video. These variables include:

  • main_h – the video’s height
  • main_w – the video’s width
  • overlay_h – the overlay’s height
  • overlay_w – the overlay’s width

Using these variable we can position the watermark right in the center of the video like so:

ffmpeg -i birds.mp4 -i watermark.png \
-filter_complex "overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2" birds2.mp4

If we wanted to add branding or a watermark to the clip but not cover the existing video, we can use the pad filter to add some padding to our clip, and then position our watermark over the padding like so:

ffmpeg -i birds.mp4 -i watermark2.png \
-filter_complex "pad=height=ih+40:color=#71cbf4,overlay=(main_w-overlay_w)/2:main_h-overlay_h" \

Once you start getting the hang of this, you can even animate your overlays!

ffmpeg -i birds.mp4 -i watermark.png \
-filter_complex "overlay='if(gte(t,1), -w+(t-1)*200, NAN)':(main_h-overlay_h)/2" birds4.mp4

That’s it! Simple. Please leave comments below if you have any questions!

28 thoughts on “Watermarking Videos from the Command Line with FFMPEG Filters

  1. Donnie Reply

    Hi, thanks for this tutorial.

    How can i use this filter

    “ffmpeg -i birds.mp4 -i watermark2.png \
    -filter_complex “pad=height=ih+40:color=#71cbf4,overlay=(main_w-overlay_w)/2:main_h-overlay_h” \

    top, bottom, left and right together-same time.

    • Kevin Sloan Post authorReply

      Hey Donnie, so you would just extend the height, and width of the video and move the original input into position like so:

      ffmpeg -i birds.mp4 -i watermark2.png -filter_complex "pad=height=ih+80:width=iw+80:x=40:y=40:color=violet" birds5.mp4

      This is adding 80 pixels to both the height and width, and then moving the video down and over 40 pixels.

  2. Stephen Reply

    This is a great tutorial. Thank you Kevin!

    Is there a way to add a unique serial number on the video as well as the watermark?

    Thank you,

  3. Luis Reply

    Hey Kevin, ths is great but i have this error:

    Input #0, png_pipe, from ‘fb.png’:
    Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, rgba, 20×20, 25 tbr, 25 tbn, 25 tbc
    Cannot find a matching stream for unlabeled input pad 1 on filter Parsed_overlay_1

    Can you help me on this?

  4. Pingback: Bulk Video Watermark Software?

  5. mulvya Reply

    Hi Kevin,

    You might be able to help me out with the problem I’m facing.

    I have an animated watermark, which is a Quicktime video with alpha. I want to overlay it multiple times over the source. So, the watermark initially appears at the start, then again at 10 minutes. Then, at 30 minutes. And finally towards the end. These intervals could change.

    The crude solution would be a complex filtergraph where I do this in multiple passes, whereby I perform the first overlay, then pass the output to the next chain and do the 2nd one and so forth. This seems to be a pretty lossy method. Is there a way to do this in one pass? The other method would be to first split the video, then overlay each segment, and then concat the results. Your thoughts?


    • Kevin Sloan Post authorReply

      ffmpeg -i input.mp4 -i watermark.png -filter_complex "[0:v][1:v] overlay=10:10:enable='between(t,1,2)'" output.mp4

      • Marco Reply

        Hallo, can you use more different watermarks on different time with on ffmpeg process? I tried this but doesn’t work:
        ffmpeg -i input.mp4 -i watermark.png -filter_complex “[0:v][1:v] overlay=10:10:enable=’between(t,1,2)'” -i watermark2.png -filter_complex “[0:v][1:v] overlay=10:10:enable=’between(t,8,13)'” output.mp4

  6. Pingback: How to Watermark Images and Videos

  7. amit Reply


    i have problem regarding while i am recording video from android device and if it is recorded in portrait mode,
    then when i apply mov atom using below command:

    ffmpegnew -i “C:\Users\Amit\Desktop\Portrait.mp4” -codec copy -map 0 -movflags +faststart “C:\Users\Amit\Desktop\output.mp4”

    it perfectly add mov atom at begining and also video remain in portrait mode but as soon as i add watermark
    using below command :

    ffmpeg -filter_complex overlay=main_w-overlay_w-10:overlay_h+30 -vsync 2 -y -i “C:\Users\Amit\Desktop\output.mp4” -i “C:\Users\Amit\Desktop\Icon-60.png” “C:\Users\Amit\Desktop\Iput2.mp4”

    it will rotate video in landscape mode .. so how to prevent this i want it as it is in portrait mode.

    could you help me to solve it?


  8. Sammy Reply

    Hi Kevin,

    I have an overlay with an animation that I want to add to an image. How would I go about adding the video as opposed to just a simple image?


    • Kevin Sloan Post authorReply

      In the simplest case, just swap out the image for another video file. Assuming you don’t need to scale it, it would look like this:
      ffmpeg -i video1.mp4 -i watermark.mp4 -filter_complex "overlay=100:100" birds1.mp4

      ffmpeg is amazing…

  9. Bill Reply

    Hi Kevin,

    Thanks so much for your amazing guide! I’m using an adapted version of your last command to make an overlay rise up from the bottom corner of an image. I want it to stop once the full image is onscreen. The command that I am currently using is: ffmpeg -i input.mp4 -i wm.png -filter_complex “overlay=0:’if(gte(t,1), (main_h-(t-1)*125),NAN)” out.mp4

  10. Michael Reply

    Hi Kevin,

    Very useful instructions!

    I have some videos that I would like to add a floating text watermark (floating from left to right) every 1/4 part of the video, so that it would appear 3 times.

    Any idea how I can do this?

    Thanks in advance!


  11. Gorka Reply

    Hello , I would like to watermark an audio file at a specific time on a Video file and afterwards I would like to decode the audio file. Any idea on how to do that ?

  12. kami Reply

    How do I add the code tags when uploading video watermark images to be added for this code

  13. Pingback: How to watermark a video?

  14. Anupam Reply

    Hi Kevin, I am not able to see main video using following command:

    ffmpeg -y -rtbufsize 100M -f gdigrab -framerate 20 -offset_x 0 -offset_y 0 -video_size 1250×750 -draw_mouse 1 -i desktop -f dshow -i video=”Integrated Camera”:audio=”Internal Microphone (Conexant SmartAudio HD)” -filter_complex “[1:v]scale=100:100 [ovrl]; [1:v][ovrl]overlay=(main_w-overlay_w):main_h-overlay_h[v]” -map “[v]” -c:v libx264 -r 20 -preset ultrafast -tune zerolatency -crf 30 -pix_fmt yuv420p -map 1:a -c:a libmp3lame “D:\today.mp4”

    can you please correct me what I am doing wrong.

    • Suspense Reply

      command1.append(filename + ” -filter_complex [0:v]transpose=2,setpts=PTS-STARTPTS[bg];[1:v]overlay=5:H-h-5:format=rgb;[2:v]scale=150:150:-1,drawbox=0:0:149:149:color=Violet,setpts=PTS-STARTPTS[fg];[bg][fg]overlay=W-w-10:H-h-10:eof_action=pass[out]”);

  15. Deepakannan Balu Reply

    Hi how do i enlarge the water mark image .I want the watermark logo should cover the video screen .For eg: If i am having a watermark logo for 10*10 (height and width).Now I want to expand the watermark logo to 50*50(height and width)

  16. Amit Reply

    Thanks for posting such a valuable information.
    Can you please let me know how should be stop sliding text at any position using ffmpeg
    Currently its just moving from left to right.

Leave a Reply

Your email address will not be published. Required fields are marked *