Skip to content

Instantly share code, notes, and snippets.

@schocco
Created March 27, 2015 11:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schocco/21981bc00c37c851e3ca to your computer and use it in GitHub Desktop.
Save schocco/21981bc00c37c851e3ca to your computer and use it in GitHub Desktop.
remove letterbox border with ffmpeg
#!/bin/bash
# autodetect crop size
crop=`ffmpeg -i $1 -t 1 -vf cropdetect -f null - 2>&1 | awk '/crop/ { print $NF }' | tail -1`
# cut string from "crop=1280:528:0:0" to "crop=1280:528"
crop=`echo "${crop%:*}"`
crop=`echo "${crop%:*}"`
echo "detected crop fromat: $crop"
echo "input: $1"
echo "output: $2"
date ; read -t 5 -p "Hit ENTER or wait five seconds" ; date
ffmpeg -i $1 -crf 13 -acodec copy -vf $crop -y $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment