macOS comes with some powerful tools out of the box. Press Shift+Cmd+5
and you’re ready to record
the screen, with or without audio. That is neat. Once you’re done a recording is stored on
your Desktop, and you’re free to share it with friends and family. Unless..
Sometimes you have a lot to tell. A modern Macbook screen resolution makes your recording grow quite fast. I like to drop my stuff directly to Slack. But I don’t have the patience (nor the upload limit) big enough to handle gigabytes.
QuickTime Player allows you to Export As the recording to a more reasonable format (720p for example). However, this process is slow, and the downscaled video size is still too big to be easily shareable. But there’s an alternative, enter ffmpeg.
Once installed you can just
ffmpeg -i input.mov -vcodec libx264 -crf 24 -vf scale=1280:-1 output.mov
The resulting output.mov file is 720p. On a Macbook M1 Pro a 63 minute recording was processed in less than 10 minutes, and it took the file size from 5.3GB down to 170MB.
Depending on which screen you record you may encounter the following error when using the
scale:1280:-1
argument:
[libx264 @ 0x14af05170] height not divisible by 2 (1280x831)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 -
maybe incorrect parameters such as bit_rate, rate, width or height
I record mostly on the 14" screen. According to ffmpeg the recording resolution is:
Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive),
3548x2304, 6772 kb/s, 51.34 fps, 60 tbr, 6k tbn (default)
After some trial and error I landed on the following value: scale=1280:826
. This keeps the aspect
ratio close to original.
I also dropped the following into my zsh config for an easy access:
downscale () {
local input=${1:-input.mov}
local output=${2:-output.mov}
local scale=${3:-1280:826}
ffmpeg -i ${input} -vcodec libx264 -crf 24 -vf scale=${scale} ${output}
}
Don’t you love it when a plan comes together?