Skip to content

Instantly share code, notes, and snippets.

@mrcoles
Created April 5, 2019 01:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mrcoles/06f84671f553897bc868df4ee2fb8497 to your computer and use it in GitHub Desktop.
Script for cropping iPhone X screen recordings with ffmpeg
#!/usr/bin/env bash
DIMS_SHORT="886:1576:0:104"
DIMS_TALL="886:1816:0:104"
INFILE=
OUTFILE=
DIMS="$DIMS_TALL"
print_usage() {
echo ""
echo "Usage: bash crop-video.sh -i <infile> -o <outfile> [-s]"
echo " -i <infile>: the path to the video you want to crop"
echo " -o <outfile>: the path to where you want to save the video"
echo " -s: specify if you want to make the video shorter (insta story: $DIMS_SHORT), otherwise defaults to $DIMS_TALL"
}
while getopts 'i:o:s' flag; do
case "${flag}" in
i) INFILE="${OPTARG}" ;;
o) OUTFILE="${OPTARG}" ;;
s) DIMS="${DIMS_SHORT}" ;;
*) print_usage
exit 1 ;;
esac
done
if [ ! -f "$INFILE" ]; then
echo "Input file does not exist: $INFILE"
print_usage
exit 1
fi
ffmpeg -i "$INFILE" -vf "crop=$DIMS" "$OUTFILE"
@mrcoles
Copy link
Author

mrcoles commented Apr 5, 2019

Video Cropping

Designed for iPhone X screen recordings—to remove the system tray and optionally remove more from the bottom.

Installation

See https://gist.github.com/mrcoles/51530f33c16f7f54e8fc74f478d243a2

Running the script

Using the Terminal App, navigate to wherever this script lives and then run it, e.g., if it lives in a folder on your desktop called "compressor":

cd ~/Desktop/compressor/
bash crop-video.sh -i file.mp4 -o cropped-file.mp4 -s

(Use the "-s" flag to crop shorter, e.g., remove the bottom of Instagram stories. Remove the "-s" to include the full bottom.)

You will now have a cropped-file.mp4 file cropped and ready to go! ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment