How to add the logo for the first 30 seconds in a video with ffmpeg


I'm trying to add my logo for the first 30 seconds in a video with ffmpeg. I have a video called d1.mp4 and a logo called logo.png.

When the video starts, the watermark should be at the top left or top right corner of the video and disappear after 30 seconds.

Can you please show me how to add it?

Best Answer

ffmpeg -i in.mp4 -framerate 30000/1001 -loop 1 -i logo.png -filter_complex
  "[1:v] fade=out:st=30:d=1:alpha=1 [ov]; [0:v][ov] overlay=10:10 [v]" -map "[v]"
  -map 0:a -c:v libx264 -c:a copy -shortest out.mp4

This assumes that the logo is a single still image with an alpha channel and you want to overlay it over a video with a frame rate of 30000/1001 (NTSC rate). Change the -framerate to match your input video if it is different. If your logo is a video then omit -framerate 30000/1001 -loop 1. If the logo does not have an alpha channel, add one by inserting e.g. format=yuva420p, immediately before fade.

This will display the logo at x,y position 10,10 for 30 seconds followed by a 1 second fade out.