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.

So to limit Handbrake a bit—which would slow rendering to 5-10 fps but also not cook my lap—I added threads=2 to the 'Additional Options' field in Handbrake's Video settings:

Handbrake threads=2 setting in video encoding options for x264

It seems that for x265, the setting you may need is pools=2 instead of threads=2, but I haven't tested that (the 'smart' TV on which I'm trying to play back the file might be too old to support H.265 and I'm too lazy to encode a file and test it, or to find the TV's model number and look up the specs).

Now the CPU is happily distributing the load amongst the four performance cores and keeping the SoC down at a more sane 85°C average:

85 degrees celcius SoC temperature on M2 MacBook Air

(The menu bar stats thing is called iStat Menus.)

And yes, I could just play back the file from my laptop straight to the TV, but that would require I dig around to find a USB-C to HDMI adapter, since this M2 MacBook Air only has ThunderBolt 4 USB Type C ports.

Maybe I should've just gotten an M1 Max MacBook Pro instead. It has a fan, built-in HDMI, and for good measure, a built-in SD card reader so I could skip carrying around a separate dongle for that too!

Comments

Any reason you didn’t try the videotoolbox encoder instead? It uses hardware transcoding instead of software, and would likely result in significantly lower CPU usage and thus heat.

Nice tip. I've been busily buying and ripping UltraHD content since your video series. My internet (10Mbps) is too slow to stream good quality, and this is a nice way to see movies that warrant 4K, in 4K.

Since the ripping process is so much faster than the transcoding process, I've switched to using HandBrakeCLI for transcoding. It just sits there and monitors an mkv folder on my NAS, and when it sees something that's completed ripping it will start transcoding. This lets me put multiple computers in the house (my small army of raspberry pis, a Mac mini, and my laptop, for example) on the job. Being able to limit threads, I expect, will reduce the memory footprint which will help out with the raspberry pis quite a bit.

Have you testing using the hardware encoder instead of using the CPU encoder? It might produce similar output with lower CPU usage. Use the videotoolbox option to use the HW encoder.

I think it would be nice to stick the process to the efficiency Cores.