Creating screen recordings on macOS doesn’t have to be difficult, time consuming or expensive. You may be surprised to learn that pre-installed applications and tools in macOS can be used to quickly create high quality screen recordings and animated screenshots of your Mac, iPhone and iPad.
QuickTime Player, which ships with macOS out of the box, includes built-in screen recording functionality. If you’re looking to create and share a short screen capture that does not require advanced video editing, QuickTime is an ideal solution.
To create a new screen recording, open QuickTime Player, and select File > New Screen Recording or use the ⌘ ⌥ N keyboard shortcut.
If you frequently need to create screen recordings, the following shell function may be used to quickly initiate a new recording:
##
# Create a new screen recording of the frontmost window of an application
# Note: Assistive access must be enabled for "automated start" to work
##
function rec {
# Enable Do Not Distrub before recording
dnd on
# Get bounds of application window
process="$1"
if [ -n "$process" ]; then
read x y dx dy <<<$(osascript <<ASCRIPT
# Janky way to ensure the correct window is selected
# as activating the application may cause window index
# to change, and System Events process windows cannot be
# selected by ID
tell application "${process}"
set w to window 1
# Bring target application to front
activate
set i to index of w
end tell
set AppleScript's text item delimiters to " "
tell application "System Events" to tell process "${process}"
set window_bounds to {position, size} of window i
get window_bounds as text
end tell
ASCRIPT
)
# Record
offset="$2"
screencapture -p -v \
-R$((x-offset)),$((y-offset)),$((dx+2*offset)),$((dy+2*offset))
fi
}
This script also uses dnd
(which controls macOS’s Do Not Disturb mode from the command line). You may install this script command:
brew tap joeyhoer/homebrew-extras
brew install dnd --HEAD
Tip: This script use the screencapture
command to define the recording window bounds. Because of this, the active screen recording may only be stopped by interrupting the command line using the
⌃
C
keyboard shortcut.
The QuickTime screen recorder has options that can be set both through the GUI and on the command line.
# Set recording quality
# High: MGCompressionPresetHighQuality
# Maximum: MGCompressionPresetMaximumQuality
defaults write com.apple.QuickTimePlayerX MGRecordingCompressionPresetIdentifier -string 'MGCompressionPresetMaximumQuality'
# Show mouse clicks in screen recordings
defaults write com.apple.QuickTimePlayerX MGScreenRecordingDocumentShowMouseClicksUserDefaultsKey -bool true
QuickTime provides some very basic, easy-to-use video editing functions like trimming and clipping. Unfortunately, more advanced functions like changing the video dimensions and speed are not available, and QuickTime can only export videos in predefined formats (which are not optimized for sharing).
Optimizing with Automator
It is possible, however, to automatically optimize screen recordings for sharing by using an Automator workflow. Automator, another application that ships with macOS by default, is a very powerful tool that allows you to easily automate actions on your machine.
To run a script automatically whenever a new file is added to a particular folder, use Automator to create a new Folder Action. Once you’ve opened a new Folder Action, select a folder where you will save your video files to (I use ~/Movies/
). In the Library panel locate the Filter Finder Items action (found within the Files & Folders actions), and drag-and-drop the action into the workflow. You now have the ability to filter out files that you do not wish to optimize. I filter by files created today, of type movie, with a mov
file extension. Next, locate the Run Shell Script action (found within the Utilities actions), ensure input is passed as arguments, and in the body of the action, call the automated script you wish to run on the files.
The following script uses gifv
to create an optimized video file that is half the resolution and 2.5× faster than the original video. This can significantly reduce file size, and make the video file easier to share.
source $HOME/.exports
export PATH=$PATH:/usr/local/bin:/usr/local/var/rbenv/shims
# Optimize videos at double speed and half resolution
# Minimum resolution
min_res=480
gifv -p "trunc(max(min($min_res\,iw)\,iw/2)/2)*2:-2" -s 2.5 "$1"
gifv
gifv
is a command-line wrapper around ffmpeg
that converts video files and GIF
s into videos optimized for GIF
-like playback on the web.
The gifv
tool was based on two “competing formats”, imgur’s GIFV
and gfycat’s GFY
(both pronounced “jiffy”). Essentially, these “formats” are wrappers around compressed video files (h.264 encoded MP4s or WebMs).
Whenever possible, video files should be preferred to GIF
s, as video codecs offer superior compression, which results in smaller filesizes, better quality, and includes built-in playback controls.
Installation
Install gifv
, add the script above to your ~/bin/
directory and install the Automator Folder Action workflow below by downloading it and moving it to ~/Library/Workflows/Applications/Folder Actions
. Once you have the Folder Action in place, you must enable Folder Actions and assign the action to a folder. To do this, open the Folder Actions Setup
app, check the box next to “Enable Folder Actions”, add a folder you wish to apply the action to (I chose the user’s Movies
folder), and add the script as seen in the screenshot below.
All videos created by QuickTime, saved to ~/Movies/
will be automatically optimized.
Other Tools
gifify
Some services do not allow video files to be used, but do accept animated GIF
s. In these cases, you can use gifify
to convert the video file to an animated GIF
.
The version of gifify
linked above if a fork of Jonathan Clem’s gifify
which provides some additional options such as reversed and parametric (or patrol) playback, as well as a number of different options for quality and compression/generation speed.
Another option is to use the node package of the same name, which offers even more options.