Handbrake + libdvdcss + Mac M1

How do I get Handbrake to work on a new Mac with an M1 chip?

  1. Download and install Handbrake.
  2. Brew install libdvdcss
    1. Install Homebrew if you haven’t already
    2. Type: brew install libdvdcss into your terminal and hit return/enter (formulae here).
  3. Copy libdvdcss.d.dylib to /usr/local/lib
    1. From within terminal type: ls /opt/homebrew/Cellar/libdvdcss and hit return/enter.
    2. Make note of what is shown there (for me, it was 1.4.3)
    3. Next, confirm that you have a /usr/local/lib directory by typing the following into your terminal: ls /usr/local and hitting return/enter.
    4. If you don’t have it, type sudo mkdir /usr/local/lib and hit return/enter (you will be asked for your password, enter it and hit return/enter).
    5. Finally, copy libdvdcss.d.dylib into your /usr/local/lib directory by typing in the following: sudo cp libdvdcss/1.4.3/lib/libdvdcss.2.dylib /usr/local/lib and hitting return/enter. NOTE: Make sure you replace “1.4.3” with whatever you found in step 2 if you found something other than “1.4.3”.
    6. Open Handbrake and try to rip a DVD (it should work!).
Commands needed to install and move libdvdcss in Terminal on Mac

If you’re interested in how I figured this out, read on!

I recently migrated to a new Macbook Pro with an M1 chip. I wanted to use Handbrake to rip some DVDs I purchased to stream on my plex server. Things were not a straightforward as they used to be. Handbrake gave the following error: “Copy-Protected sources are not supported.

It turns out that on new Macbook Pros with the new Apple Silicon M1 chip, Homebrew now installs to /opt/homebrew/Cellar instead of /usr/local/lib. So Handbrake isn’t able to find the requisite libdvdcss install.

I looked around online for quite some time and never found a solution that worked for me, so I did some digging.

I downloaded the code for handbrake and found where it is looking for libdvdcss.2.dylib:

VSCode with Homebrew code showing location Homebrew expects libdvdcss.2.dylib

Then I figured out that Homebrew installs to somewhere other than /usr/local/lib on Apple Silicon:

Homebrew installation documentation…

After that it was just a matter of moving the libdvdcss.2.dylib file installed by Homebrew to a place where Handbrake could actually find it. Handbrake is looking specifically for that file rather than just the Homebrew package, so moving the whole package over (as described here) didn’t actually work for me. I had to dig down into the actual package itself and grab the dylib file and move it over.

Viola! Now I can continue ripping in History Channel WW2 Documentarie DVDs like some kind of Boomer 😆.

Homebrew home screen with Battle 360 Season 1 Disk 1 successfully decoded by Handbrake.
JavaScript npm modules

Import JSON in Node in ESM Modules

Node 16.15 added support for importing JSON modules using the new assert { type: 'json' } syntax.

This is great news if you develop npm modules that need to be consumed both client and server side (or even just server side).

There’s a catch though… As of this writing it is a bit tricky to get working in Jest, and RollupJS just flat-out doesn’t support it (and the import assertions plugin also doesn’t work consistently).


Patent: Discrepancy Resolution Processor and Methods for Implementing the Same

This is a patent I was issued for a system I wrote while on the prototyping team at Salesforce.

While we were creating prototypes, Sketch would often export SVGs that (once loaded in the browser) had invalid html with weird artifacts and didn’t quite match up with what the designer was seeing in Sketch. The PNG files that Sketch exported would match. So what I did was created a Sketch plugin that would export both an SVG and a PNG, and then load the SVG inside of a browser (Puppeteer), clean up the HTML, take a screenshot, and compare the screenshot to the PNG (using ImageMagick). Depending on what it saw, it would make further modifications to the code within the SVG file (then Puppeteer, screenshot) and compare the modified SVG file to the PNG file, and notify the designer about the outcome.