Automating Handbrake

#1

Can AppleScript or Automator be used to eject a disk “after” Handbrake has run (i.e. A disk has been processed a DVD)?

#2

I think you could use a shell script command to eject a disk - drutil.

drutil tray eject

But I’m not sure if there is a way to trigger that from Handbrake.

So, flipping that around, if we’re already on the command line, perhaps you could script Handbrake to run from there using a shell script to control everything rather than Handbrake to trigger a subsequent action.

FWIW, both AppleScript and Automator are capable of triggering a shell script.

#3

I had Handbrake set up with an AppleScript (or maybe an Automator action?) that did this, and sent a notification to my phone via IFTTT. I did have it working for ejecting the disk at one stage, but I had to remove it because it ran after every chapter, so for something like a series it wouldn’t work. But maybe someone cleverer than I found a way around this. :blush:

#4

In the spirit of full disclosure. I want to let everyone on this thread know that “I” don’t know how to script anything but I’m trying to learn.

#5

I have handbrake scripted to automatically convert mkv files in a specific folder using Hazel and bash script. I use MakeMKV to convert my personal blu ray first. You could edit it using the link to Handbrake CLI to automatically scan a disc and convert the file and then possibly use the “drutil tray eject” command suggested by @sylumer.

$1 is the first argument passed into the bash script which in my case is the mkv file I’m editing. The script takes in mkv file, uses Handbrake CLI and a prebuilt preset I have in the GUI version of handbrake and outputs that file with the same name plus (1080p) at the end. It then moves that new file into a new directory.

I know it’s not exactly what you are looking for, but perhaps it can help.

#!/bin/bash    
filename=$(basename "$1")
filename=${filename%.*}
converting_directory="/Users/user.name/Movies/Discs Rips/1080p/"
output_directory="/Users/user.name/Movies/MP4 Rips/"
converting_filenameHD="$converting_directory$filename (1080p).m4v"

    /Applications/Utilities/HandBrakeCLI/HandBrakeCLI --preset-import-gui -Z "My Presets/H.265 10 Bit" -i "$1" -o "$converting_filenameHD"

    mv "$converting_filenameHD" "$output_directory"