Skip to content

Instantly share code, notes, and snippets.

@minkione
Forked from fsalehpour/watermark.bash
Created April 25, 2024 17:46
Show Gist options
  • Save minkione/c066354a52f9b62b2df936e0b32c0ad6 to your computer and use it in GitHub Desktop.
Save minkione/c066354a52f9b62b2df936e0b32c0ad6 to your computer and use it in GitHub Desktop.
Script to add a scrolling watermark and scaling a video in one go using `ffmpeg`
#!/bin/bash
dir=$(pwd)
(cd $1
mkdir -p output
for i in *
do
output="output/$(echo $i | sed 's/\..*$/\.mp4/')"
T=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$i")
HEIGHT=$(ffprobe -v error -show_entries stream=height -of default=noprint_wrappers=1:nokey=1 "$i")
ffmpeg -i "$dir/logo.png" -y -v quiet -vf scale=-1:$HEIGHT/12 "$dir/scaled.png"
ffmpeg -i "$i" -i "$dir/scaled.png" -filter_complex "overlay=((W-w)/$T)*t:100,scale=-1:240" "$output"
done
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment