Homebrew logo

Dumb Question Corner – Do I Need Homebrew?

Ryan Winkler wrote in:

I’ve heard you mention Homebrew on the show and I’m not sure if I need it. What is it and do I need it?

This is a great question. The answer, in short, is, maybe, maybe not. Let’s walk through what Homebrew is, and what kinds of fun things you can do with it so you can decide if it might be fun for you.

Open Source Packages

To understand Homebrew, let’s take a step back and talk about open source packages. Open Source is a term that describes tools and applications that people write and then give away under a variety of different licenses. The licenses vary from allowing you to use, modify and distribute for commercial purposes without attribution to more restrictive licenses that maybe say you can’t modify and you have to give attribution but you can use it for commercial purposes.

Often open source tools come as pretty little installer dmg files you double click like an expensive application, and often commercial applications include open-source components. But there’s a vast layer of interesting tools and applications you may never have heard of that you can play with that are accessible via a different path.

Homebrew is a way of accessing open source tools via the command line, also known to Mac users as the Terminal. Here’s an example. Most people at some time or another have had a piece of audio or video that’s in the wrong format. They need an app to transcode from one format to another. Maybe it’s an audio file from aiff to mp3, or a video from mov to mp4. Every single one of these apps uses an open source library called ffmpeg to accomplish this task.

I think I’ll slide over into some examples to explain how I got hooked on Homebrew and the tools available through it.

How I Got Hooked Originally

Many years ago in my corporate job, I ran a little project to start a podcasting network inside the company. I was the boss of the other two people on the project so they did the technical work creating the database and the web app to make it happen. It was kind of hokey and there was bureaucracy slathered all over it, but eventually, my little team of three including me got a passable service created. It was audio-only.

But then the audience wanted video podcasts as well. That didn’t look like too hard of a problem but the bureaucrats weighed in and announced that they wanted a still shot of the company logo stitched onto the front of every video distributed via our podcast network. By this time, I had changed jobs and was a technical fellow instead of a boss lady.

I went to the guy who had written the original code and told him about this new requirement, and he said, “You do it.” It was probably the harshest symbol of my loss of positional power, but that’s a whole ‘nother story.

Now, remember I was a mechanical engineer with a Master’s in Kinematics, so a reasonably bright fellow, but I wasn’t a programmer. I decided to take on this challenge.

I started by learning all about codecs. Codec stands for coder/decoder. I then learned about the difference between a codec and a container. Codecs have things like bit rate and sample rate inside them for example. A container is the name you see on the outside of an encoded audio/video file, while the codec is how exactly it was encoded. I’m going to stop there because the subject is a rat hole of epic proportions.

I did discover that there was this little library, our little friend ffmpeg, that would encode and decode videos and audios. More importantly, it could stitch files together. This was the tool I needed to add a still frame to the front end of a video and export a whole new video. I figured out how to find the dimensions of the video so the right still frame size was stitched on the front. I also learned that given the right parameters passed to ffmpeg, I could export the file without transcoding the video again which meant I might be able to do this with no loss in quality.

I’ll not walk any further down memory lane here, but I did, in the end, succeed in stitching that darn company logo still frame to the front of every video we produced. The project overall wasn’t really a success but I learned a heck of a lot because of that formerly obedient employee saying, “You do it.”

Back when I did all this work, downloading the ffmpeg library required me to install what are called dependencies. I did have a wicked smart former employee of mine do the heavy lifting here because it’s basically the 7th circle of h – e – double – toothpicks to go through the dependencies.

And that’s actually where Homebrew comes into play. Install Homebrew using a single Terminal command available over at brew.sh first. Sit there with your hands folded politely until the text stops scrolling on-screen.

Now you type the incredibly complex command, brew install ffmpeg. Again with the politely-folded hands until it’s spitting nonsense on the screen and now you have ffmpeg. Takes about 30 seconds for each command versus literally hours and hours we spent fighting dependencies in the old days.

Now that doesn’t probably explain why you might want/need to use Homebrew, because I’d have to answer the question of whether you needed ffmpeg.

My ID3 Editor Script

I can only think to answer by example. I did need ffmpeg again and this example was for the podcast. I use a tool called ID3Editor to add my ID3 tags to the Chit Chat Across the Pond episodes. This tool adds my name, the name of the show, the name of the episode, the year, the album artwork and the genre as podcast.

The tool can save some of those items since they’re consistent from week to week, but there are some pieces that have to be done manually. For about 5 years I entered those fields manually every single week but one day I got tired of it and decided to do something about it.

I wrote a little bash shell script to create my very own ID3 Editor. It took me a while to figure it out but I determined early on that I could use our old friend ffmpeg to change things like the image and my name and the podcast name and my license. The entire script, without comments or line feeds to make it more readable, is 15 lines long.

Sure I spent weeks writing it, and sure it only saves me about 45 seconds a week to use my own tool, but those weeks writing it were fun and I learned a lot, and every time I use my little script I’m happy instead of irritated.

Love Me a Drop Shadow

Here’s another example that doesn’t involve ffmpeg. I think a slight drop shadow on an image really makes it stand out on the plain, white background of a web page. Years ago I found a little app called Drop Shadow from Del Sol Software that would let me drag an image onto it and boom, the image would have a drop shadow. I could modify the color of the shadow and the thickness of the shadow. It was glorious. Pretty much every image on podfeet.com from that era was shadowed with Drop Shadow.

Sadly, Del Sol Software disappeared, which made their app useless over time. In 2016, I had started to get my programming chops sharpened with Bart’s help and I figured out how to write my own DropShadow app. I used Homebrew to download a command line tool called ImageMagick from imagemagick.org/….

To install ImageMagick, I used the command brew install imagemagick and I was in business. The only problem with ImageMagick was that it has so many options available to play with. I eventually found some code online that was close to what I wanted, modified it to set my angle, color, thickness, and opacity of my shadow.

I then dropped it into an Automator Action, and my own personal DropShadow tool was ready for action … if you’ll forgive the play on words. Of course I wrote this all up in a blog post called DropShadow App Made With Automator and ImageMagick.

It sounds really hard and complicated but once you get over the idea that taking other peoples’ open source code and modifying it is not immoral, it’s actually not that hard to write scripts. I do make sure to put a comment in my own code saying who I “borrowed” the code from in case I ever distribute something I wrote.

There’s a funny punchline to this story of my DropShadow app. I was very proud of it and used it for years, but then I got to know Helma from the Netherlands who is a student of the Programming By Stealth series. She happens to be crazy good at CSS, or Cascading Style Sheets. She explained that I could non-destructively add a drop shadow to my images simply by styling them with CSS.

She had me create a style and then I just call it with a little code I plopped into MarsEdit, the tool I use for blogging. Now I have 100% consistency across all images if I choose to drop shadow them. If I ever change my mind on what I want that drop shadow to look like, I can change them all with a few touches of the keys.

Reinstalling Mac App Store Apps with Homebrew

And then there was the awesome tip brought to us by the inimitable Knightwise in January of 2018. He explained how you can Reinstall Mac App Store Apps from the Command Line starting with our little friend Homebrew. He showed us the terribly complex command, brew install mas to start the process.

From there he explained that you can list all of the Mac App Store apps you have installed on your Mac with the command mas list. This list includes a unique identifying number for each application. In equally mystical language, given this list with its numbers, you can later install any of those apps on another app or the same Mac after a nuke and pave by typing mas install followed by the unique number.

And of course there’s a blog post all about that on podfeet.com/…

Python and Teslas

Here’s another one – remember how I figured out how to get a good 360 video out of the 180 separate videos per hour my Tesla creates? I didn’t write the code that did that, but I did have to have the lovely and memorable ffmpeg installed in order for it to work.

CakeBrew

There’s a little tool that might make Homebrew just a little less intimidating, and it’s called CakeBrew from cakebrew.com/…. With CakeBrew you can access the repository for Homebrew with a graphical user interface instead of the command line. One of the things I really like about CakeBrew is that it shows me all of the installed formulae (that’s the dependencies and libraries and everything I use). I like it because I did not have to install all this stuff myself! There’re 69 separate formulae in there and I only asked for a couple of them; everything else came along on its own.

Bottom Line

I’m glad my former subordinate challenged me to figure out the video stitching on my own. I’m glad I learned about ffmpeg and about how annoying chasing down dependencies are. I’m that I learned about Homebrew so I didn’t have to fight dependencies anymore. I’m glad I figured out how to use what learned about ffmpeg from work helped me create my own ID3 Editor. I love that I learned about ImageMagick from Bart and that I learned how to make a bash script so I could make my own little app to make my drop shadows. I love that I learned more about CSS from Helma and found a better way to add my drop shadows. I was so proud that I was able to get my Tesla video out, partially because of ffmpeg from Homebrew.

It’s this constant desire to improve how I do things and learn new tools to do them that makes creating the podcast and blog so darn much fun.

So do you need Homebrew? Maybe, maybe not. But if you can figure out something you want to do that requires a command-line interface to get to it, you might just find a place in your heart for Homebrew like I did.


Addendum

YouTube downloader extracting audio from Ryans review
Downloading Ryan’s Audio Using youtube-dl from the Command Line

After I posted the article, Knightwise commented on Facebook that of COURSE you need Homebrew. He pointed out one of his favorite command-line tools that he gets from Homebrew, and that’s a YouTube downloader. The command to get it is of course simple, brew install youtube-dl.

Knightwise was nice enough to link to an article he wrote on knightwise.com/… where he narrows down the options for the reader. I installed youtube-dl and I was overwhelmed with the options so his web page on it was super useful.

In order to prove to Ryan that he really does need Homebrew, I decided to do a meta example. Remember last week when Ryan did the review of the iDevices switch? When he originally sent it to me, it was just the video. I had to ask him for a separate audio file. He extracted it and sent it over to me.

But with KnightWise’s instructions, I was able to extract the audio myself from Ryan’s YouTube link!

youtube-dl --extract-audio --audio-format wav https://youtu.be/C1iY5XQYv8s

Of course you can use youtube-dl to actually download videos, not just extract the audio. I know some videos are protected so this won’t always work, but for those that do allow downloads, it sure is useful when you want a quick and simple way to download a video.

2 thoughts on “Dumb Question Corner – Do I Need Homebrew?

  1. Anonymous - November 1, 2019

    This is fantastic!

    Thank you for taking the time to help me better understand Homebrew, also thank you for helping me, “get over the idea that taking other peoples’ open source code and modifying it is not immoral”. I have always had an aversion to adjusting someone else’s code.

    You ROCK!

    Ryan

  2. Allister - November 3, 2019

    Just last week I found an old newsreel on YouTube on a very interesting subject but as well as being very low quality it was stretched to a 16:9 aspect ratio when the original was 4:3. I fixed the problem by using youtube-dl to download it and then Handbrake (based on ffmpeg) to fix the aspect.

Leave a Reply

Your email address will not be published.

Scroll to top