ffmpeg -i video.mp4 -i logo.png -filter_complex "[0:v][1:v]overlay" \
-codec:a copy out.mp4
To understand this command you need to know what a stream specifier is and reading the Introduction to FFmpeg Filtering will help. [0:v]
refers to the video stream(s) of first input (video.mp4
), and [1:v]
refers to the video stream of the second input (logo.mp4
). This is how you can tell overlay
what inputs to use. You can omit [0:v][1:v]
, and overlay
will still work, but it is recommended to be explicit and not rely on possibly unknown defaults.
By default the logo will be placed in the upper left.
Using -codec:a copy
will stream copy the audio. This simply re-muxes the audio instead of re-encoding it. Think of it as a "copy and paste" of the audio.
Moving the logo
This example will move the logo 10 pixels to the right, and 10 pixels down:
ffmpeg -i video.mp4 -i logo.png -filter_complex "[0:v][1:v]overlay=10:10" \
-codec:a copy out.mp4
This example will move the logo 10 pixels from the right side and 10 pixels down:
ffmpeg -i video.mp4 -i logo.png -filter_complex \
"[0:v][1:v]overlay=main_w-overlay_w-10:10" -codec:a copy out.mp4
main_w
refers to the width of the "main" input (the background or [0:v]
), and overlay_w
refers to the width of the "overlay" input (the logo or [1:v]
). So, in the example, this can be translated to overlay=320-90-10:10
or overlay=220:10
.
Timing the overlay
Some filters can handle timeline editing which allows you to use arithmetic expressions to determine when a filter should be applied. Refer to ffmpeg -filters
to see which filters support timeline editing.
This example will show the logo until 30 seconds:
ffmpeg -i video.mp4 -i logo.png -filter_complex \
"[0:v][1:v]overlay=10:10:enable=between(t\,0\,30)" -codec:a copy out.mp4
If you want to fade the logo refer to mark4o's answer.
my video name is d1.mp4 and my logo name is logo.png ,thank you.. – iwocan – 2013-12-04T20:52:36.823
Then what does
ffmpeg -i d1.mp4 -i logo.png
show? Please just enter that command and show us what the output is. When asking questions aboutffmpeg
, you should always include as many details as possible about what video/audio material you have, what you already tried, and the full command line output of everything you have tried. – slhck – 2013-12-04T21:16:29.607here's what i get on my cmd screen . http://pastebin.com/bPCnhXh2
– iwocan – 2013-12-04T21:27:53.743