Guide: Automate MP4 FFMPEG video encoding as an Automator Service

Last modified on:

If you frequently find yourself needing to encode files, you can speed this process up by adding a service. You can then transcode your files by right clicking, hovering over the services option, and then selecting your encoding service. Could it get any easier? No.

Get started:

First of all make sure you have ffmpeg installed. You can do this by following my guide here.

  1. Launch the Automator.app
  2. Select File > New to create a new service with service receives files or folders in any application
  3. Add a Run Shell Script action from the Action library
  4. Set Pass input: to as arguments (top right dropdown of the Shell script action window)
  5. Within the script, replace echo with the script below to transcode video to MP4. (You can tailor this script for any common transcode or repackage job, such as mkv to mp4).
  6. Save your workflow as a service.
Automator Service FFMPEG video

The MP4 encode script:

for f in "$@"
do
/opt/local/bin/ffmpeg -i "$f" -c:v libx264 -crf 20 -c:a 
ac -q:a 100 "${f%.*}.mp4"
done

Tips

Change the CRF value of the above code to a higher figure for a lower quality encode (or vice-versa). For instance, you could create a high quality encode service and a low quality encode service.

You can also encode WMV from MP4 using the following code:

ffmpeg -i input.mp4 -q:a 2 -q:v 2 -vcodec msmpeg4 -acodec wmav2 output.wmv

Published on

in

by

Tags:

3 responses to “Guide: Automate MP4 FFMPEG video encoding as an Automator Service”

  1. europeancataclism avatar

    Great article, and very useful! One question though. When I install ffmpeg, where is it installed? I checked bin but couldn’t find it. And since I need the path to the ffmpeg… Thanks.

  2. Oliver Jobson avatar

    glad you found it useful.

    I think it is installed in ‘/opt/local/bin’ on my machine.

  3. Jonathan avatar

    Thanks for this, this is exactly what I was looking for. Works like a charm

Leave a Reply

Your email address will not be published. Required fields are marked *