Quickly Compress Video Files on macOS

When you record your videos with Quicktime and you end up with 1.7 GB of a file, how do you shrink that?!

I’ve been using this process for a couple of years now to optimise the output size of my demo videos, to make it easier to share them in presentations, and to keep my Mac tidier.

Installation

  1. Install Homebrew
 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

 Enter your password for sudo access (no need to run sudo on the command itself.

2. Run “brew install ffmpeg”

(I had to also do xcode-select –install)

3. Run “nano ~/.bash_profile”

Paste the below into the profile, hit CTRL + O, Enter to save and CTRL + X to exit.

movc () {
    ffmpeg -i $1 -c:v libx264 -preset fast "${1%.mov}"-opt.mov
    newname="${1%.mov}"-opt.mov
    origsize=`du -k "$1" | cut -f1`
    newsize=`du -k $newname | cut -f1`

    echo  -e '\n'$1   $origsize"KB"
    echo  $newname   $newsize"KB"
}

mp4c () {
  ffmpeg -i $1 -c:v libx264 -preset fast "${1%.mp4}"-opt.mp4
  newname="${1%.mp4}"-opt.mp4
  origsize=`du -k "$1" | cut -f1`
  newsize=`du -k $newname | cut -f1`

  echo  -e '\n'$1   $origsize"KB"
  echo  $newname   $newsize"KB"
}

mpgc () {
    ffmpeg -i $1 -c:v libx264 -preset fast "${1%.mpg}"-opt.mpg
    newname="${1%.mpg}"-opt.mpg
    origsize=`du -k "$1" | cut -f1`
    newsize=`du -k $newname | cut -f1`

    echo  -e '\n'$1   $origsize"KB"
    echo  $newname   $newsize"KB"

4. Run “source ~/.bash_profile”

5. run “nano ~/.bashrc”

Paste in the below, hit CTRL + O, Enter to save and CTRL + X to exit.

if [ -f ~/.bash_profile ]; then
  . ~/.bash_profile
fi

Usage

Open up terminal, navigate to where your mov, mp4 or mpg file is.

for mov, use

movc “file name”

for mp4, use

mp4c “file name”

for mpg, use

mpgc “file name”

This will then run through the process, and when its finished you’ll see the output like below

2112 – First Workforce Demo.mp4 1703972KB

2112 – First Workforce Demo-opt.mp4 180228KB

Quite a considerable reduction

Many thanks to Robert Terakedis for the initial details on this a couple of years ago!

Leave a Reply

Your email address will not be published. Required fields are marked *