You want to concatenate. Three methods are available- demuxer filter and protocol; and filter would usually work for you.
See this:
http://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20concatenate%20%28join,%20merge%29%20media%20files
You could create a movie file from the image file first, of appropriate duration. Of course, the issue with filter concatenate is that audio and video streams have to match, which means you might have to mux in a wav (?) file to the end logo movie file.
Could you please help me to understand the overlay settings?
The overlay
filter takes two arguments: the x and y position of the top left corner of the image.
In this command:
overlay=10:main_h-overlay_h-10
The top left x position is 10, and the top left y position is determined by the “outer” / main image's height main_h
and the height of the overlaid image (overlay_h
), then additionally subtracting 10 pixels to add a little space from the edge.
If you're unsure what these coordinates mean or how to determine them, perhaps you need to draw them on a sheet of paper.
How to set the height and width of the logo?
You can use the scale
filter:
ffmpeg -i inputvideo.mp4 -i watermarklogo.png -filter_complex "\
[1:v]scale=200:100[v1];[0:v][v1]overlay[outv]
\" -map "[outv]" output.mp4
Here, the second input video (1:v
) is scaled to 200⨉100 pixels and then labeled as 1v
. It's then used in the overlay
filter.
How to find the coordinates of the location where to launch the logo? By trying/guessing? Is there a way to find them?
That depends on your application, but generally you need to know your input video size and the size of the logo. FFmpeg cannot guess where to place the logo for you. If you want to place it somewhere in the corner, the given examples should however suffice, assuming that the logo is not too big.
Best Answer
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 beforefade
.This will display the logo at x,y position 10,10 for 30 seconds followed by a 1 second fade out.