Skip to content

Instantly share code, notes, and snippets.

@pplux
Created August 28, 2020 14:14
Show Gist options
  • Save pplux/4bacbb196eaf71d7ebb41e46ecc5477a to your computer and use it in GitHub Desktop.
Save pplux/4bacbb196eaf71d7ebb41e46ecc5477a to your computer and use it in GitHub Desktop.
Script to use ffmpeg to watermark a video
#!/bin/bash
VIDEO="video.mp4"
IMAGE="logo.png"
SIZE=200
OUTPUT="output.mp4"
OFFSET_X=50
OFFSET_Y=50
while getopts v:i:o:s:x:y: option
do case "${option}"
in
v) VIDEO=${OPTARG};;
s) SIZE=${OPTARG};;
i) IMAGE=${OPTARG};;
o) OUTPUT=${OPTARG};;
x) OFFSET_X=${OPTARG};;
y) OFFSET_Y=${OPTARG};;
esac
done
if [ "$#" -lt 1 ]; then
echo "$0 usage:"
echo " $0 [-v videoInput] [-o videoOutput] [-i image] [-s imageSize] [-x offsetX] [-y offsetY]"
echo " -v videInput (default=$VIDEO)"
echo " -o videOutput (default=$OUTPUT)"
echo " -i Image (Logo) (default=$IMAGE)"
echo " -s Image Size (Horizontal) (default=$SIZE)"
echo " -x Offset X (default=$OFFSET_X)"
echo " -y Offset Y (default=$OFFSET_Y)"
exit -1
fi
FILTER="[1]scale=${SIZE}:-1:[img];[0][img] overlay=main_w-overlay_w-${OFFSET_X}:main_h-overlay_h-${OFFSET_Y}"
ffmpeg -i $VIDEO -i $IMAGE -filter_complex "${FILTER}" $OUTPUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment