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!

70 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.

  17. fab Reply

    One of the most valuable stuff about ffmpeg watermark all around since years Kevin!!

  18. Azhar Reply

    Output file #0 does not contain any stream , Please help me I am sruck into this

  19. bigs Reply

    Hi Kevin-

    Thanks for the information above it has helped me accomplish watermarking my videos. I do have one question/concern about file output size. When I watermark a video, it significantly changes the overall size of the video. My test watermark image is 46 KB and on a 1 hour video that is originally 2.3 GB it turns into a video that is 2.9 GB. That seems like a lot for such a small image. Is this correct or am I maybe doing something wrong? Below is a sample of the command I am using:

    ffmpeg -i input.mkv -i image.png -filter_complex “overlay=W-w-25:H-h-25:enable=’lt(mod((t\),900),30)'” output.mkv

    The above command places a watermark in the lower right corner for 30 seconds every 15 minutes. It just seems odd to me that the watermark would add that much to the overall size. Thanks again.

      • bigs Reply

        “Streamcopy requested for output stream 0:0, which is fed from a complex filtergraph. Filtering and streamcopy cannot be used together.”

  20. Achmad Aliyudin Reply

    I use this code on php using php exec

    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

    but it give error, but if I use this

    ffmpeg -i birds.mp4 -i watermark.png \
    -filter_complex “overlay=5:5” birds4.mp4

    it’s wrok fine

  21. raj Reply

    this code not working for me

    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

  22. mohammad Reply

    How can I create a transparency watermark to video and moving from top to bottom or left to right?

  23. Long Reply

    I have a trouble that I want to merge 3 scaled image and 1 mp4 video into a video. Just like camtasia. 3 images that I scaled and overlay somewhere on the video. The output is a video that has 3 images on.

    Thank you for helping.

    I have a command like that. But I dont know how to make it work with background is video and 2 image on it. ffmpeg -i “C:\Users\dangk\Desktop\Videos\Anh Mo – Anh Khang.mp4” -i “C:\Users\dangk\Desktop\Image_MG_8277.Jpeg” -i “C:\Users\dangk\Desktop\Image\giphy.gif” -filter_complex [1]scale=320:240[b];[2]scale=120:80[w];[b][w]overlay=5:H-h-5‌​[v] -map “[v]” “C:\Users\dangk\Desktop\Image\output.mp4”

  24. Son Reply

    It seems decrease video’s quality.
    How can I keep original parameters ?
    I used -vcodec copy -acodec copy but unsuccessful!

  25. robert Reply

    can u help me?
    i need a command for insert logo in live channel


  26. Hiren Patel Reply


    O want to set image on my video as a overly, It set but not on same position where i have put.
    Please help me.


  27. Serguei Kireev Reply

    sweet, thanks for the info. it doesn’t like to work for live streaming though, am i correct? so far i can make output a file yes, but cannot do rtmp live output for some reason… says incorrect parameters

  28. Rajendra Reply

    Thanks a lot of the nice tutorial.

    I have a querry, where i suppose to save campaign_frame.png. Because when i try to overlay frame over the video i am getting below error:

    ffmpeg4android Check if input file exists: campaign_frame.png

  29. tuanna Reply

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


    my videos resolution always different, 2k,4k,hd,420

    but intro png always hd.
    auto resize my image all on video ?

  30. Dipankar Reply

    The movement of the image should not be a straight line but it is a bezier curve.

  31. Manjula T Reply

    -i D:\car.jpg -i D:\car.jpg -i D:\car.jpg -filter_complex \”[1:v] scale = 400:500[sc1];[2:v] scale = 20:10[sc2];[3:v] scale = 40:50[sc3];[0:v][sc1] overlay = 50:100:enable = ‘between(t,6,8)'[tmp1];[tmp1][sc2] overlay = 100:150:enable=’between(t,10,12)'[tmp2];[tmp2][sc3] overlay = 120:180:enable=’between(t,14,18)’

    NReco.VideoConverter.FFMpegConverter wrap = new FFMpegConverter();

    Am yusing above command in ffmpegconverter

    Now i need to pause my video durin watermark is overlayed

    thank you

  32. Joshua Pinter Reply

    This was super helpful to understanding the basics, thank you.

    Quick tip: to have some transparency in your watermark, just edit the .png file, adjust the opacity to 50% or whatever you like, and then re-save that .png file.

    Works great!

  33. Jenny Reply

    I use the filter “overlay=’if(gte(t,1),-w+(t-1)*100,NAN)’:(main_h-overlay_h)/2” in my video. but I find that the image doesn’t move constantly, I don’t know the reason, Do you know how it comes the result? Thank U.

  34. Jenny Reply

    it’s me again. the last comment means that the image does’t move smoothly.how it comes that?

  35. Anthony Reply

    I’m using the Tokbox technology on my app which offers live video chat interactions, how would I go about adding a watermark to a live video chat? My hope is to watermark the video feed on both sides of the call so if either person tries to capture and share the contents of their video chat, it will be branded and watermarked and that way it would be easily detectable. Is this possible using the methods offered above and if not, is there another way I might achieve this? Thanks for your time and help.

  36. VJ Reply

    Whats the degradation in the quality of the video on using this overly filter, how can I use GPU to render a watermark at the time of rendering rather than transcoding which I believe this overlay component needs and hence affects the perceived quality of the video due to the propagation of quantization errors.

  37. michael Reply

    HI, can you help me out putting a wateramark on my videos using this. I have a dedicated server (CentOS6) with lighttpd with FFmpeg that converts uploaded media so it can be played on the website. Only problem, everyone can steel those videos. Can you please do this because I do not really know how to.
    Site is already functional only the watermark has to be added. Of course I will pay you $100 for your time.

  38. Kinde Reply

    Please help how to add filters to the code
    $shel = shell_exec(“$ffmpeg_b -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -s 640×360 -crf 24 $video_output_full_path_360 2>&1”);

  39. VIjay Reply

    i am adding watermark on video using ffmpeg

    inputCode = new String[]{FileUtils.getFFmpeg(this), “-r”, String.valueOf((30.0f / application.getSecond())), “-f”, “concat”,
    “-safe”, “0”, “-i”, r0.getAbsolutePath(), “-i”, FileUtils.frameFile.getAbsolutePath(),
    “-i”, audioFile.getAbsolutePath(), “-filter_complex”, “overlay= 0:0”, “-strict”, “experimental”,
    “-r”, String.valueOf((30.0f / application.getSecond())), “-t”, String.valueOf(toatalSecond), “-c:v”, “libx264”, “-preset”,
    “ultrafast”, “-pix_fmt”, “yuv420p”, “-ac”, “2”, “-i”,FileUtils.watermark.getAbsolutePath(), “-filter_complex”,
    “overlay=main_w-overlay_w-10:10”, videoPath};

    r0.getAbsolutePath()=video input

    i want to add watermark and frame..both but it not work

  40. Vinesh Chauhan Reply

    Hi, Thanks For Great Tutorial About FFMPEG. i want to overlay image on video on particulate position. i have another activity for user where user can set position of image on video. i got position and pass it to “overlay” attribute to ffmpeg but it works for only one device in another device it is not set properly. position is not perfect.any suggestion or solution for it.

  41. C James Reply

    Hello. I’m looking for help adding a watermark to a web script, In it’s ../ajax/ffmpeg-submit.php file it has several lines similar to this:
    $shell = shell_exec(“$ffmpeg_b -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=640:-2 -crf 26 $video_output_full_path_360 2>&1”);

    Could you help me with an example of how to modify that line of code (to add the ability to watermark the web script’s uploading videos)?
    with the image “watermark1.png?
    any help will be greatly appreciated

  42. Pingback: High performance video edit in Python – PythonCharm

  43. Zohaib Islam Reply

    Hi..How to set width and height of water mark same as the width and height of video..actually i want to add frame to whole video.

  44. Brandon Reply

    Watermark ALL of your .mp4 videos at once.

    Put in a folder:
    1) ALL of the videos you want to have watermarked
    2) a new folder named “newfiles”
    3) ffmpeg
    4) your watermark image named “watermark.png” (sized same as video)
    5) batch file named “watermark.bat”

    Batch file command:

    for %%a in (“*.mp4”) do ffmpeg -i “%%a” -i watermark.png -filter_complex “overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2” -codec:a copy “newfiles\%%~na.mp4”


    Kindly, Brandon

    Change (“*.mp4”) variable to match video extension type.
    Change “newfiles\%%~na.mp4” variable to match output folder.

  45. Dave The Busker UK Reply

    Despite being an old thread, this tip still works wonderfully.

    I was asked to add a simple watermark to a video for someone and this has done the trick just right, gave me all the information I needed to run off some samples so we could settle on a format for the watermark.

    Thank you.


    [ For reference I’m using Linux Mint XFCE 19.1 ]

  46. Frank Reply

    Thanks for your great article, I would like to recommend the VeryUtils Photo Watermark Command Line software, it supports command line operation, you can use it to batch add watermarks to all of your photos at one time, include a folder and sub-directories recursively, I hope this software will useful to you.

  47. Vikas Patil Reply

    How we can two water markers (images) on video? one while be in background and other will be in centre of video? for every frame.

Leave a Reply

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