Can I record my Mac screen via a keyboard shortcut?

Solution 1:

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