I’m a Mac user by way of Linux. From the time I was in college around 2008 to up until the beginning of 2015, my primary computer ran various versions of Linux. My favorite was Linux Mint. Prior to using Linux as my desktop OS I had been using it on various web servers for a few years. I love Linux. There are so many distributions to choose from, each with its own quirks, benefits and methodology.
After using Linux for so long I became accustomed to being able to do certain things quickly and easily, especially from the command line. One of the things that made me hesitate about the jump to Mac was that many of those tools and programs I loved weren’t as easily available. I was never interested in downloading source and compiling it. Most distributions of Linux come with something called a package manager. This software knows about internet-based repositories of software and can download and install them on your computer with a few simple commands. The biggest benefit of installing software this way is that if one package depends on another, you don’t have to know what the other package is. The package manager will automatically download and install any dependencies.
So in moving to a Mac, what am I to do? One of my favorite little command line programs on Linux was FFmpeg. Got a movie in this format but want it in that format? FFmpeg can do it. Want to trim some movie clip down, flip the video in the x-axis and add a watermark? FFmpeg can do it. FFmpeg can do anything, and it’s command line based, so there isn’t a lot of fluff meaning that it’s pretty fast.
Over the weekend I had shot a 10 second mpeg-4 video with my phone that I wanted to convert into an animated GIF to share with some friends. In Linux, I’d just fire up FFmpeg and get it done in a few minutes, but my Mac didn’t have FFmpeg. I didn’t want to try to compile the source myself. That would take forever. I must’ve been out of luck, right?
Wrong. See, there are other people out there like me who love the package managers in Linux, but also use Macs. To that end, they’ve created a number of package managers that work on Mac. One of the best and most well known is MacPorts. Installation of MacPorts can take some time because in addition to installing it, you’ll need to install Xcode since MacPorts relies on the C compiler that comes with Xcode. Once all that’s set up though, you’ll be a regular command line captain!
Now that I have MacPorts, how do I get my precious FFmpeg? The first thing to do is make sure that MacPorts itself is up to date and has all the latest software repositories. This is done with the “selfupdate” command. In a terminal window you’d type:
`sudo port selfupdate`
MacPorts will then run through a bunch of things to update itself. Once that’s done, you can tell it to install FFmpeg using this command:
`sudo port install ffmpeg`
It will show you all the dependencies it will need to download, compile and install in order to use FFmpeg. Once you confirm, just sit back and let it work its magic. After a few minutes, everything will be downloaded, compiled and installed. You can now use FFmpeg just as you would on Linux.
To convert my .mp4 to an animated GIF I used the following command:
`ffmpeg -i movie.mp4 -pix_fmt rgb24 animated.gif`
Voila! That command is the bare minimum to get you an animated GIF, and there are lots of other options available. For example, I needed to make the resulting GIF as small as possible, so I trimmed the clip, reduced the color space, lowered the frame rate, etc.
To see what other packages are available through MacPorts you can visit their site and browse or search through the repository. Generally speaking though, the most popular Linux packages are almost always available under the same name as their Linux counterparts. Happy porting!