Record the Mac screen via a keyboard shortcut

screen capture

I trade futures and other things, which requires me to be watching a number of things very closely while I'm actively considering or managing a trade. I'd like to be more diligent about documenting all my trades, my thought processes in the moment, etc. but doing so while trading is pretty much impossible. And trying to remember everything later is definitely impossible. So I'd like to begin recording myself when I'm being active in the markets.

This is easy to do – Quicktime can do it natively even – but I would like to assign recording the screen to a keyboard shortcut so I can just fire it off in an instant when I need to, and hit another keystroke when I'm done. This is the problem I haven't found a good solution to.

I already own ScreenFlow, and it has a keyboard shortcut for recording. Unfortunately Screenflow produces absolutely enormous files, that then require you to export them from Screenflow in order to actually save them somewhere.

Ideally I'm looking for a Mac app that:

  1. Can initiate a recording of the screen (and my microphone for narration, I don't really care about camera) via a keyboard shortcut.
  2. Produces reasonable file sizes (and to that end, allowing me to record at a greatly reduced frame rate would be great… 1 FPS even would work fine for my needs)
  3. Outputs to standard formats, preferably .mp4 or .m4v
  4. Works on macOS Sierra on a 2011 iMac

Recording system audio would be an additional plus, but is not absolutely required.

EDIT: On exploring a bit, it turns out that Automator already has a command for New Screen Recording! This is great, with one problem. Quicktime opens a small window and requires you to click the little red "Record" button, to actually initiate recording. I can't find any way to do this via a keyboard shortcut. If all else fails I could applescript the click to specific coordinates, but I would love to find a "less heavy-handed" way to start the recording process without requiring a mouse click. Any ideas anyone?

Best Answer

Included is the source for an AppleScript droplet that can be used to transcode video files.

You'll need a modern installation of ffmpeg, such as the one you can get by installing HomeBrew and running "brew ffmpeg".

This conversion has not been optimized for speed, but rather for quality.

No deletion of source files has been included in this configuration.

You won't need the autocropping. You probably won't want the conversion to 6-channel AC3 audio.

Most things you drop on this will probably end up with a greater file size after transcoding, but this will show you how a droplet for converting video might be configured.

I've got a bunch of these, but this will process most anything you download from YouTube, I think. If you can get hold of a non-copy-encrypted .m2ts file from a Blu-Ray (like the one MakeMKV can give you), that may best show you what this can do.

property temppath : "/private/tmp/"
property startnum : 0
property newline : ASCII character 10
property tmpfile : "/tmp/execme.command"

on open the_items
    my convert_Video(the_items)
end open

on convert_Video(the_items)
set theshellscript to ""
repeat with the_item in the_items
    set the_item to the_item as alias
    try
        tell application "Finder"
            set sost to (container of the_item) as string
        end tell
        set pos_filepath to POSIX path of sost
    end try
    set this_filepath to (the_item as string)

    if last character of this_filepath is ":" then
        tell me to set it_is_a_folder to true
    else
        set it_is_a_folder to false
    end if
    set thesourcename to (name of (info for the_item))
    set namepart to (name extension of (info for the_item))
    set the_source_file to POSIX path of this_filepath
    --display dialog the_source_file
    --set thesourcename to replace_chars(thesourcename, " ", "_")
    set newname to replace_chars(thesourcename, namepart, "m4v")
    set autocrop to (do shell script "/usr/local/bin/ffmpeg -i" & space & (quoted form of the_source_file) & space & "-t 44 -vf cropdetect -f null - 2>&1 | awk '/crop/ { print $NF }' | tail -1")
    try
        set theshellscript to the theshellscript & "/usr/local/bin/ffmpeg" & space & "-i" & space & (quoted form of the_source_file) & space & "-pix_fmt yuv420p -c:v libx264 -preset slow -tune film -vf \"" & autocrop & "\" -c:a ac3 -ac 6 -ab 640k -crf 18 -x264opts keyint=40:bitrate=2400:qpmin=8:qpmax=28:qpstep=4" & space & (quoted form of (pos_filepath & newname)) & ";/bin/echo '

==========================

" & newname & space & "FINISHED!" & "

==========================

';"
            on error onerr
                activate
                display dialog onerr
            end try

end repeat
set theshellscript to theshellscript & "mv" & space & (quoted form of tmpfile) & space & (quoted form of (POSIX path of (path to trash)))
do shell script "echo " & quoted form of theshellscript & " > " & tmpfile
repeat
    try
        do shell script "chmod +x " & tmpfile
        do shell script "open -a Terminal.app" & space & tmpfile
        exit repeat
    on error
        delay 1
    end try
end repeat
end convert_Video

on replace_chars(this_text, _bad, _good)
    set AppleScript's text item delimiters to the _bad
    set the item_list to every text item of this_text
    set AppleScript's text item delimiters to the _good as string
    set this_text to the item_list as string
    set AppleScript's text item delimiters to ""
    return this_text
end replace_chars

on run
    set the_items to ((choose folder) as list)
    convert_Video(the_items)
end run