Some quick notes on considering re-encoding a media library. My Plex movie library is around 1 TB right now. I recently learned about AV1, a next-generation encoder for video files.

I tested locally with Handbrake and saw great results:

“AV1 encoding is awesome. Default preset with Handbrake takes a 6.78GB file and outputs at 1.22GB. 18% the file size. Totally indistinguishable to my eyes. My Mac Studio can re-encode at 120fps, so going to work my whole Plex library through this in the next couple weeks.” (tweet)

Napkin math: 1 TB library, we could conservatively guess 50% of the library is worth re-encoding1. That’s 500 GB of media, which could, at an average 80% filesize reduction, be reduced to 100 GB. That’s about 40% savings in total on my media library. Pretty impressive!

But I decided not to do it. Here’s why.

Space isn’t at a premium

I future-proofed my ⟐ NAS that this media library is hosted on. It’s a 32 TB TrueNAS Mini X, and I’m only using about 20% of the available storage. I’m not constrained at the moment. Not even close! If I save 400 GB of space re-encoding this media, I’ve basically freed up 1% of my hard drive. Sure, it’s cool, but it’s not exactly a priority at the moment.

AV1 isn’t broadly supported

AV1 is a new codec. You can get Apple TVs, my primary streaming device, to support AV1 files using a custom profile, but that’s just one device. I don’t want to have to worry about every device being able to support direct play for these videos2.

h.264 (or h.265 - more on that shortly) is much more broadly supported, particularly for direct play. If I embrace AV1, I’m going to have low-level worry all the time that a video isn’t going to be able to reliably play. That might change in a few years, but we’re not there yet.

What about h.265?

The successor to h.264 is broadly supported, offers file-size savings, and is implemented as a different encoder flag in Handbrake, ffmpeg, etc. So it would be trivial to switch over to it.

At this point, I began to wonder - is this even worth it? Did I get nerdsniped and didn’t even realize it? I checked my media folder to see how many files I had that were disproportionately larger than anything else in my library; say, 10GB or more:

find /Volumes/media -type f -size +10G \
  -exec ls -lh {} \; | sort -k5 -hr

There was only four videos. One of them was 20GB, and the rest were barely 15-20% over the 10GB marker. Is it really worth me re-encoding an entire library when almost every video I have is 1/250th of a percentage of my available hard drive space?

OK, I had been nerd-sniped. So I decided not to pull the plug. But I learned some interesting things along the way.

Tdarr looks quite cool

Tdarr is a distributed transcoding system for Windows/Linux/Mac. You can use it to watch a library and re-encode videos using an interesting flow/plugin system.

I set up a flow (GitHub gist) which I ended up not using, but did work correctly. It does the following:

  1. Filters out existing re-encodings (anything in vp9 or av1)
  2. Checks the video width to find resolution
  3. Pushes to Handbrake using the correct encoding settings to transcode into AV1

Pretty impressive tool! Even cooler is the distributed part. My TrueNAS is not very powerful. It’s an OK CPU that happens to have a huge amount of storage behind it. My Mac Studio, on the other hand, is very fast. It’s an M2 Ultra with 64GB of RAM. It would be awesome to set it up for transcoding.

By default, Tdarr has no problem with this. You can plug in the URL/port config of wherever your master Tdarr node is running - on my NAS, in this case - and then configure any other node to handle the actual transcoding.

This is all quite cool, and if I had a library where I needed to do a substantial amount of transcoding, I would absolutely use it. It’s just overkill for my use-case.

Footnotes

  1. Not every file is going to be worth re-encoding. We should only target high-quality - basically excessively encoded - media files. For me, that was a bitrate anywhere in the 4-6MB/s range for 1080/4k videos.

  2. Direct play is a must-have for me. My Plex server, which used to run on my Mac Studio, now runs directly on my NAS. That means I can’t use the awesome M-Series chips for transcoding. In fact, transcoding at all is a no-go.