Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a PNG (alpha) file and a video file. I want to create a video in which the first track is the image and the second track is the video (PNG over video). The problem is that the PNG doesn't preserves transparency.

I need create a watermark (PNG) in a separate track with ffmpeg over video track.

ffmpeg -i base.mov -i logo.png -map 0 -map 1 output.mov
share|improve this question

The syntax to add a watermark is slightly different. You need video filters for that, which come bundled with FFmpeg already.

I'm not sure you can add a transparent watermark to a separate track. The reason is that the image itself (the PNG "stream") needs to be turned into an actual video track (e.g. with x264) – and since video encoders don't support transparency at this stage, you won't get a transparent image.


The following will add logo.png to base.mov in the upper right corner. You can use the following parameters to determine the position – in my example, I just placed it ten pixels away from the border:

  • main_w (main video width)
  • main_h (main video height)
  • overlay_w (overlay video width)
  • overlay_h (overlay video hieght)

The filter command would then be:

movie='logo.png' [logo]; [in][logo] overlay=main_w-overlay_w-10:10 [out]

Turning this into a complete FFmpeg command:

ffmpeg -i base.mov -vf "movie='logo.png' [logo]; [in][logo] overlay=main_w-overlay_w-10:10 [out]" -c:v libx264 -crf 20 out.mov

The -c:v libx264 -crf 20 parameters determine the output video codec and its quality (where CRF will probably be from 19 to 24, depending on which quality you want; lower is better).

There's a rather good blog post on that subject here: How to watermark a video using FFmpeg. It goes into positioning details.

share|improve this answer
    
Thank you very much. I needed the watermark is on a track (stream) separately in order to enable or disable it with quicktime pro. – tostaky May 29 '12 at 11:27
1  
You can try to create a combined video again after adding the overlay. ffmpeg -i base.mov -i with-logo.mov -map 0 -map 1 -c:v copy -c:a copy output.mov, but this will of course double the video size. I'm not aware of any other solution. – slhck May 29 '12 at 11:29
    
I need dont double the video size... thanks!! – tostaky May 29 '12 at 12:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .