Terminal 101: Converting Videos
Posted 10/29/2012 at 1:31pm
| by Cory Bohon
Every Monday, we'll show you how to do something new and simple with Apple's built-in command line application. You don't need any fancy software, or a knowledge of coding to do any of these. All you need is a keyboard to type 'em out!
Proving that the Terminal is great for many different tasks (not just those that are text-based), we’ll show you just how easy it can be to convert videos to various formats using the freely available ffmpeg command line program. With the fast ffmpeg program, you can convert between new and even archaic video formats with relative ease. Continue reading and we’ll show you how.
Installing ffmpeg
To install ffmpeg, you’ll need either Mac Ports or Homebrew as the ffmpeg program is not installed on Macs by default. Depending on the package manager you’ll be using, you’ll type one of the following commands into the terminal to start the installation process.

For Homebrew, type:
brew install ffmpeg
For MacPorts, type:
sudo port install ffmpeg
The installation process will take a few minutes as the program is downloaded, built, and installed onto your Mac. If you get an error from Homebrew or MacPorts, you may need to update them by issuing one of the following commands.
To update Homebrew, type:
brew update
To update MacPorts, type:
sudo port selfupdate
Converting Between Video Formats

The ffmpeg program will be able to convert between wav, mpeg/mpg, avi, mov, mp3, mp4, and many more. For a full list of supported formats, type the following command into the terminal:
ffmpeg -formats
To convert one file into another, we’ll use the following basic syntax:
ffmpeg -i file.avi newfile.mp4
You’ll replace “file.avi” with the name and extension of the file that you will be inputting, and replace “newfile.mp4” with the name and extension of the file that you will be outputting.

The program will go to work, converting the video into your specified format. As the conversion process is going on, you’ll see new lines printed to the terminal with information on the encoding process. When done, the terminal will return command, and the outputted video file will be available in the same directory where the command was executed.

Cory Bohon is a freelance technology writer, indie Mac and iOS developer, and amateur photographer. Follow this article's author, Cory Bohon on Twitter.