August 20, 2020

Stop separating your 4k content

Updates to the streaming brain paired with a small python scriptmean you no longer have to separate your 4k content in your library.

Stop separating your 4k content

If, like me you have been curating a library with the highest resolution versions of your content as possible and you share this media with people outside of your home you have probably searched the net for how to organise your media.

I'm here to tell you that the days of having to keep a separate library or even split versions of your films are over.

I already explained how I used to handle all my 4k content back here, so check that out if you want a little context as to where I'm coming from.

But this was still quite a manual and involved process as it required me to manually update the poster art for both my collections. I'm not sure what prompted me to test this today but it's taken me on  a journey of discovery that I wasn't expecting.

What am I proposing?

Stop separating your 4k films. Leave them in your main library with the rest of your content. I keep the actual files in a separate folder on my hard drive, but they are both mapped into Plex under a single library.

This goes against all advice from everyone, what are you talking about?

Trust me, I'm just as surprised as you are. So I'm going to take you through my testing so you can come on this journey with me.

Unraid 6.8.3
Binhex-PlexPass Docker
Plex Media Server Version

iPhone 11 Pro Max (Version 7.4)
Plex Web (tested in Brave Browser, Win 10)
Plex Web (tested in Chromium Edge Win 10)
Plex Windows (Version
Nvidia Shield Pro 2017
Xbox one S
LG WebOS 1 ~ 2015 (1080p display)
LG WebOS 2 ~ 2017 (4k display)

Test Film: 12 Strong (2018)
4k: Codec HEVC, Bitrate 48257 kbps
1080p: Codec H264, Bitrate 35620 kbps

The film must show in plex as single item, you should have the little blue box indicating duplicated content.

How the files appear in Plex, note the duplicate icon in the top corner.

On each client play the film with your normal settings. Assuming in the same network as the server you are set up to play the maximum quality possible, with direct play enabled if the device supports it.

The results here are what I would expect since this was one of the things that the streaming robot introduced. If your device can direct play the 4k file, it will play the 4k version of the film. If it doesn't support 4k content then it will play the 1080p version of the film. This has been around for a while so nothing new here.

Now where things get interesting is when you start to force a transcode of these files. To test this, I set my clients quality to max out at 3mbps 720p in the settings to simulate an external user and played the file again.

Every single one of my clients received a transcoded file, all of them transcoded the 1080p version of the file.

This is big news, as this indicated that we no longer need to separate the 4k files from our 1080p files and Plex will intelligently select the file to transcode.

But what about the films where you only have a 4k version available? Plex will have no choice to transcode that file.

Yes, this is still a potential issue. The best way around this would be to simply not share any of the files where there is only a single 4k file. But there is no way for plex to do this automatically. I'm sure it may come at some point but until then we need to come up with a work-around.

Here's my solution. I modified the script that I already had to split and label my films (Thanks u/spazatk for the original.) I have modified this script to add the label, 'Transcodable' to all films that have a 1080p or lower resolution copy. These films get tagged regardless of whether there is a 4k version or not. For films that only have a 4k version, they don't get tagged. The script will also look for films that once had a <1080p version but don't any more, if it finds one, it will remove the 'Transcodable' tag.

To run the script to hide 4k content from your users where they are no HD versions of your films you will need a PC that can run the script on a schedule. If you are using Unraid, you can use a docker container such as Chronos to run it on a schedule, otherwise anything that can run python would work.

Step 1.
Clone the repo to your server -
Install python and pip

sudo apt install python3 python3-pip

Step 2.
edit the config.ini file

PLEX_URL = https://yourplexurl:32400
TOKEN = <token>

Enter your information here

Step 3.
install the requirements
pip3 install -r requirements.txt

Step 4.
Run the script

This can and will take a while if you have a large library.

From there, go into your users settings and under restrictions only allow the tag 'Transcodable' And they will only be able to see films your server can transcode.