transcoding

Limiting Handbrake threads to prevent throttling on M2 Macbook Air

Due to a recent surgery, I've been recovering at a location outside my home for a few weeks. I brought all my media with me on a spare hard drive, but one movie I had ripped but never transcoded wouldn't play on the 'Smart' TV here.

It seems to do okay with some H.264 profiles, but not the one for this 4K Blu-Ray rip. Therefore, I thought I'd transcode the file so it would play.

I also wanted to do other work on my laptop—in my lap. And unfortunately for Apple's latest M2 MacBook Air, there's no fan or heat sink to keep the M2 SoC cool.

And that meant the temperature around the top middle of the keyboard—and the bottom middle of the laptop—got quite uncomfortably hot with Handbrake's default settings, which would max out the CPU during the transcoding process.

I could encode anywhere between 10-18 fps at 4K resolution with x264, but the SoC temperature rose to 105°C and was uncomfortably hot within a minute or so.

Batch transcode a folder of videos with Handbrake's CLI

I've used Handbrake for years, to transcode practically any video file—including ripped DVDs and Blu-Rays—so I can watch the videos on practically any device. It's especially helpful for .mkv files, which can have a hodgepodge of video formats inside, and are notoriously difficult to play back, especially on older or more locked down playback devices.

But Handbrake's achilles heel, as a GUI-first application, is in a lack of easy batch operation. You can queue videos up one at a time, which is nice, but more recently, as I've ripped more TV seasons onto my NAS, I've wanted to transcode 5, 10, or 20 files at a time.

Enter HandBrakeCLI. Assuming you're on a Mac and installed Handbrake already (e.g. with brew install --cask handbrake), download HandBrakeCLI, mount the downloaded disk image, and copy the executable into a system path:

sudo cp /Volumes/HandBrakeCLI-1.5.1/HandBrakeCLI /usr/local/bin/

Then you can use it to loop over an entire directory—even recursively—and transcode all the video files within.

How to download an MP4 from YouTube, every time

I use yt-dlp to download videos off YouTube quite frequently. I'll use the videos as reference, and I often use it to grab the VOD for one of my livestreams, since there's no simpler way (I'm not going to dig through the bowel's of YouTube's UI to try to download one of my own videos...).

But I also can't handle the default .webm videos in all my video editing tools natively, and transcoding is annoying. So I've settled on the following yt-dlp command to first try to pull a native MP4 version off YouTube, and failing that, transcode to MP4 immediately after downloading:

yt-dlp -S res,ext:mp4:m4a --recode mp4 https://www.youtube.com/watch?v=dQw4w9WgXcQ

And if you weren't aware, yt-dlp does an excellent job pulling video files from other sites as well, should the need arise.

How I rip DVDs and Blu-Rays into my Mac (2022 Edition)

It's been more than a decade since I wrote Ripping Movies from Blu-Ray, HD-DVD and DVD, Getting them onto Apple TV, iPad, iPhone, etc.. Heck, back then I didn't write everything as a 'blog post'—that was labeled as an 'article' :P

In a surprising twist of fate, we went from a somewhat more centralized online media situation back then (basically, Netflix) to a hellscape of dozens of streaming services today. And in many cases, older movies can only be found as used and/or pirated DVDs on eBay!

Thus, I'm writing a fresh guide to how I rip DVDs and Blu-Ray discs into my Mac, then transcode them with Handbrake. Heck, some people who are deeper into the r/datahoarder rabbit hole even have dedicated transcoding servers so they can generate optimal archival copies in 4K, 1080p, etc. akin to how YouTube and other online platforms set up their files!

But for me, the basic process goes: