FFmpeg - Add logo to video

By xngo on June 8, 2019

In FFmpeg, the way to place your logo picture is to use the -filter_complex parameter and defining the position by setting the overlay coordinate. Below are examples showcasing Subscribe logo in different locations.

Simple example with specific location

Put subscribe.png 10 pixels from the top and 10 pixels from the left.

ffmpeg -y -i VIDEO.mp4 -i subscribe.png -filter_complex "overlay=10:10" OUT_1.mp4

OUT_1

Logo in the center

Put subscribe.png in the center.

ffmpeg -y -i VIDEO.mp4 -i subscribe.png \
    -filter_complex "overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2" \
        OUT_CENTER.mp4
    # main_h: The video height.
    # main_w: The video width.
    # overlay_h: The overlay(logo) height.
    # overlay_w: The overlay(logo) width.

OUT_CENTER

Logo at top-left corner

Put subscribe.png at the top left corner.

ffmpeg -y -i VIDEO.mp4 -i subscribe.png \
    -filter_complex "overlay=x=main_w*0.01:y=main_h*0.01" \
        OUT_TOP_LEFT.mp4

OUT_TOP_LEFT

Logo at top-right corner

Put subscribe.png at the top right corner.

ffmpeg -y -i VIDEO.mp4 -i subscribe.png \
    -filter_complex "overlay=x=main_w-overlay_w-(main_w*0.01):y=main_h*0.01" \
        OUT_TOP_RIGHT.mp4

OUT_TOP_RIGHT

Logo at bottom-left corner

Put subscribe.png at the bottom left corner.

ffmpeg -y -i VIDEO.mp4 -i subscribe.png \
    -filter_complex "overlay=x=main_w*0.01:y=main_h-overlay_h-(main_h*0.01)" \
        OUT_BOTTOM_LEFT.mp4

OUT_BOTTOM_LEFT

Logo at bottom-right corner

Put subscribe.png at the bottom right corner.

ffmpeg -y -i VIDEO.mp4 -i subscribe.png \
    -filter_complex "overlay=x=main_w-overlay_w-(main_w*0.01):y=main_h-overlay_h-(main_h*0.01)" \
        OUT_BOTTOM_RIGHT.mp4

OUT_BOTTOM_RIGHT

Reference

  • https://gist.github.com/bennylope/d5d6029fb63648582fed2367ae23cfd6

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.