Skip to content

Instantly share code, notes, and snippets.

@cs01
Created August 22, 2022 18:30
Show Gist options
  • Save cs01/d3aec9b691174696f266e2e4d26a37d5 to your computer and use it in GitHub Desktop.
Save cs01/d3aec9b691174696f266e2e4d26a37d5 to your computer and use it in GitHub Desktop.
#!/bin/bash
while getopts ":i:o:t:" opt; do
case $opt in
i) input="$OPTARG"
;;
o) output="$OPTARG"
;;
t) text="$OPTARG"
;;
\?) echo "Invalid option -$OPTARG" >&2
exit 1
;;
esac
case $OPTARG in
-*) echo "Option $opt needs a valid argument"
exit 1
;;
esac
done
[[ -z "$input" ]] && echo "Must specify -i for input file" && exit
[[ -z "$output" ]] && echo "Must specify -o for output file" && exit
[[ -z "$text" ]] && echo "Must specify -t for text" && exit
ffmpeg -i $input -vf "drawtext=text=$text:x=(w-text_w)/2:y=(h-text_h)/2:fontsize=30:fontcolor=white:box=1:boxcolor=white@0.5: boxborderw=5'" -codec:a copy $output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment