PMS Misidentifying Video Profile Level for 1080p videos, results in unnecessary transcoding

PMS thinks some videos are High@Level 5 or 5.1 when they are High@Level 4.

This happens with Blu-ray rips I’ve processed with Handbrake. DVD rips are OK.

This causes transcoding during playback, as my Amazon Fire Stick Gen 1 and Amazon Fire TV Gen 2 are rated to High@4.1.

This happens with PMS 1.11.0.4666 on Windows 10, NVIDIA Shield TV, and Synology 918+. Also PMS 1.9.260 in Plex Cloud.
Plex client v6.12.

Info for one movie below, but happens with all Blu-ray rips.

Any ideas?

Thanks.


Plex XML & Media Info attached.

Picture of TV Screen showing transcode reason (PMS = Plex Cloud, Client v6.12 on AFTV Stick Gen 1)

PMS Media Info

Correction: Only happens with AFTV Stick Gen 1. AFTV Gen 2 has H.264 Max Level = 5.1, so it does direct play the movie.

Technically Plex is right here. Max ref frames for L4.1 @ 1920x800 is 5, your file has 15 which puts it at L5.

Either handbrake isn’t passing the level requested to x264 during the encode, or ref is being overridden.

Interesting. I was experimenting with increasing the reference frames to try and increase compression. I have not seen anything (Handbrake docs, Wikipedia H264 info) that mentions a maximum number of reference frames for a given level.

The Handbrake preset I’ve been using sets the profile to High@4.0. Adjusting Reference Frames on the Advanced tab doesn’t change the encoder level. The “x264 Encoder Options” section still shows level=4.0.

Do you have a reference? I’d like to read up on it. I’ll search w/ Google, but if you’ve something handy…

Looks like I may end up re-encoding a few movies.

Thanks.

I did a couple quick test encodes w/ Handbrake.

Using a blu-ray rip (1920x800), set profile & level = Auto on Video tab.

Reference Frames = 5 results in a High@L4 video.
Reference Frames = 6 results in a High@L5 video.

Found a handy calculator:
H264 Maximum References Frames
It doesn’t show the math behind the calculation, but it does match up with what @tobytl wrote and w/ the above quick tests.

It’s kind of hidden, it used to be listed in parenthesis in the levels table in the h264/avc wikipedia page.

But it’s a consequence of the MaxDPB and MaxDPBMbs (DPB = decoded picture buffer, the number of decoded frames kept in the buffer which can be referenced).

Ref: en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Decoded_picture_buffering

From that article, the formula is capacity = min(floor(MaxDpbMbs / (PicWidthInMbs * FrameHeightInMbs)), 16)

MaxDpbMbs for L4/L4.1 is 32,768. PicWidthInMbs = ceil(1920/16) = 120. FrameHeightInMbs = ceil(800/16) = 50.

32,768 / (120 * 50) = 5.461333333 So the floor is 5.

Thanks! Greatly appreciated. Cheers.