Skip to content

Instantly share code, notes, and snippets.

@MartyLake
Created March 14, 2024 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartyLake/01c42a805e144f759d9b4c4e4cb3e8c4 to your computer and use it in GitHub Desktop.
Save MartyLake/01c42a805e144f759d9b4c4e4cb3e8c4 to your computer and use it in GitHub Desktop.
convert ffmpeg video to vertical with overlay
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
set -x
FILTERGRAPH="[0:v]pad=iw:2*trunc(iw*16/18):(ow-iw)/2:(oh-ih)/2[padded];[padded]scale=1080:1920[resized];[resized][1:v]overlay"
echo "nullscr,$FILTERGRAPH,nullsink" | graph2dot
false
for f in $(find input -type f); do
if [ ! -f "$f" ]; then
continue
fi
converted=output${f#input}.mp4
if [ -f "$converted" ]; then
echo "$converted already exist. skipping"
continue
fi
ffmpeg -i "$f" -i Untitled.png -filter_complex "$FILTERGRAPH" -c:v libx264 -crf 18 -map 0:a:0 "$converted"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment