Created
April 5, 2019 01:34
Star
You must be signed in to star a gist
Script for cropping iPhone X screen recordings with ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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":
(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! ✨