Skip to content

Instantly share code, notes, and snippets.

@TJC
Last active January 27, 2021 07:19
Show Gist options
  • Save TJC/57f9a21a8100814527a897b748791163 to your computer and use it in GitHub Desktop.
Save TJC/57f9a21a8100814527a897b748791163 to your computer and use it in GitHub Desktop.
Re-encode OSX screen recording mov files to a tenth of their size
#!/bin/bash
# Requires ffmpeg - brew install ffmpeg
if [[ -z "$1" ]]; then
echo "Usage: $0 Screen\\ Recording\\ at\\ 2021-01-21.mov"
exit 1
fi
basefilename=$(basename "$1" .mov)
outputname="$basefilename.mp4"
nice ffmpeg \
-i "$1" \
-tune animation \
-c:v libx264 -preset medium -profile:v high -pix_fmt yuv420p -level 4.2 -crf 24 \
-c:a aac -profile:a aac_main -ab 128k \
"$outputname"
#!/bin/bash
# Runs ffmpeg in Docker, meaning you don't need to have installed ffmpeg natively
if [[ -z "$1" ]]; then
echo "Usage: $0 Screen\\ Recording\\ at\\ 2021-01-21.mov"
exit 1
fi
SRC=$(readlink -f "$1")
basefilename=$(basename "$1" .mov)
outputname="$basefilename.mp4"
docker container run -u 1000 --rm -v "$PWD:/mnt" \
-v "$SRC:/input.mov:ro" \
alfg/ffmpeg ffmpeg \
-i "/input.mov" \
-tune animation \
-c:v libx264 -preset medium -profile:v high -pix_fmt yuv420p -level 4.2 -crf 24 \
-c:a aac -profile:a aac_main -ab 128k \
"/mnt/$outputname"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment