Skip to content

Instantly share code, notes, and snippets.

@lassic
Created December 16, 2013 12:37
Show Gist options
  • Select an option

  • Save lassic/7986345 to your computer and use it in GitHub Desktop.

Select an option

Save lassic/7986345 to your computer and use it in GitHub Desktop.
Overlay JPG (watermark) image over video in a semi-transparent way using command line tools on OSX (imagemagick, ffmpeg). (I wish the ffmpeg overlay filter would support an alpha parameter, figuring out how to use the blend filter to achieve this was a bit too much for newbie in ffmpeg world).
#!/bin/bash
infile=vid.mp4
outfile=out.mp4
wmfile=wm.jpg
wmfilepng=stwm.png
alpha="70%"
# convert (imagemagick) image to semi-transparent
convert "$wmfile" -alpha set -channel A -evaluate set "$alpha" "$wmfilepng"
# scale and overlay watermark in upper right corner
args=(
-v debug
-filter_complex "[1:v]scale=96:-1[wat];[0:v][wat]overlay=main_w-overlay_w-10:10[outv]"
-map "[outv]"
-map 0:a
-y
)
ffmpeg -i "$infile" -i "$wmfilepng" "${args[@]}" "$outfile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment