Skip to content

Instantly share code, notes, and snippets.

@fsalehpour
Last active April 25, 2024 17:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fsalehpour/0cae06d8698c652f3c62d944d8ece9a4 to your computer and use it in GitHub Desktop.
Save fsalehpour/0cae06d8698c652f3c62d944d8ece9a4 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