How to automatically upload videos encoded with Apple Compressor

Apple Compressor is a great tool for transcoding video and audio files, and includes options for automatically posting to sites like YouTube, Vimeo, and Facebook. However, if you want to upload to a video hosting platform that doesn’t have a Compressor “Action” you’ll need to create your own Automator workflow and upload via an API.

In this example I’ll be posting to Wistia.com, a video hosting platform that I highly recommend. I’ve been using it for a few years, the free plan allows for creating an API token for uploading, and it has very helpful documentation.

Heres an overview of what the final Automator workflow will look like. If you are well versed in Automator and just wanted to copy and paste the code, I’ve included that first. Below that, you can find a basic explanation of the entire workflow, and learn how to use it with Compressor.

“Run Shell Script” Action

“Run JavaScript” Action

Full Walkthrough

Create an Automator Workflow

Automator is a built-in application that allows you to create “workflows” to help with repetitive tasks on your Mac. Essentially, it takes an input, runs an Action based on that input, and returns a result. You can chain these Actions together to create powerful workflows.

The Compressor Action we’ll be using is called “Run Automator Workflow” so the first step will be to open Automator on your Mac and create a new workflow.

“Run Shell Script” Action

The first Action we need to create is called “Run Shell Script.” Make sure to select Shell: bin/bash and Pass input: as arguments

Then paste in the following code:

The above code is using the curl command to upload the video being exported from Compressor to the Wistia API. When you choose the “Run Automator Workflow” Action in Compressor, it is passing the path of the exported file to an Automator Workflow. So in this case, we can grab that path using:

This requires an API token to the video hosting provider of your choice. If you’d like to use the Wistia API they provide documentation here.

Optional Next Steps

Technically the “Run Shell Script” Action is all you will need to upload to Wistia after Compressor finishes encoding, however I recommend creating a way to update yourself on the status of the upload. If you have your email setup using Apple Mail, you can easily send yourself a message with the final upload status.

Or, if you want to skip the email step and create a simple log that get saved to your $HOME directory, you can do something like this:

Parse JSON Response with “Run JavaScript” Action

The first step in creating the email workflow will be to parse the response that the Wistia API has sent back to us. Luckily Wistia sends back JSON in the response body, and provides documentation on the data structure we can expect for a successful upload, as well as possible errors.

For this task we can use a “Run JavaScript” Action in Automator, and pass in the following code:

This allows us to easily parse the JSON response using the JavaScript JSON.parse() function. Sure it’s possible to keep everything in the first shell script and parse the JSON there, but Automator makes it so much easier to just handle this with a dedicated JSON parser.

To make it clear what the Run JavaScript Action is doing, we are taking the input from the previous Automator Action, which was a JSON object, passing it to the run() function, and returning an output called status.

Whatever we return from this function will be passed to the input of the next Automator Action.

Use “New Mail Message” and “Send Outgoing Messages” Actions to create and send an email.

The final step in the Automator workflow is to take the value of status returned from the previous Action, and pass it to the body of an email using the “New Mail Message” Action. Make sure to fill in the email address and subject fields to ensure that the status message gets passed to the email body.

Then just add the “Send Outgoing Messages” Action to send your email.

Now you can hit file → save to make the Workflow available to Compressor.

Using the Automator Workflow in Compressor

Once you’ve saved the Automator Workflow, you can finally add it to your Compressor project. To do this, just click on the clip you’re exporting, and in the Job tab scroll all the way down to the “Action” section. Set the “When done:” button to Run Automator Workflow, and choose your Workflow file.

Select your encode settings and click Start Batch. Once Compressor has finished encoding your video, it will run the Automator Workflow you created.

The final email you create and send will look something like this:

This workflow is a great option for when you have hours of video files to encode overnight, and you need to make sure a client can watch them first thing in the morning. So now that you’ve uploaded your video, go watch it!

Wait, did I only make this tutorial to prove that I was good at skateboarding in 2016?

Software Developer and Video/Post Production Professional. Recent graduate of Flatiron School.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store