Before we can get to using the script, we’ll need a few things installed already:

  • HandbrakeCLI – if you’ve ever converted a DVD to a digital format, you’ve probably heard of Handrake. This is just the simpler, stripped down, command-line only version of it’s bigger, GUI powered brother.
  • FFMPEG – the swiss army knife of digital media conversion. Stephen Jungels has agreat how-to guide on FFMPEG for OS X, or it’s also available through many package managers such as MacPorts and Homebrew.
  • FFMPEG2Theora – converting videos to Ogg Theora couldn’t possibly be simpler.

Now that we have the tools, the script ties it all together. Grab a copy of it from my gist over on Github and save it locally, remembering the path (I use a scripts folder in my home directory). We need to make the script executable if it already isn’t. From the commandline:

  1.  chmod +x /path/to/html5video.sh

And now we’re ready to go. Run the script, passing a single variable – the path to a video you’d like to convert:

  1. /path/to/html5video.sh sample-video.mov

The script will create a “converted” directory in the same directory as the video passed if it needs to or just use an existing “converted” directory. It will then run the video through Handbrake, outputting an H.264 encoded mp4 file at the same height and width as the original file and with an average video bitrate of 900kbps. Once that’s complete it will run that video through the ffmpeg2theora converting, outputting an Ogg file for use in Firefox and then finally the script will run it through FFMPEG to generate the WebM file. [credit goes to Viget Alum @ http://viget.com/extend/quickly-converting-to-html5-video]