Bizarre - PMS transcoding

Server Version#: 1.20.2.3343
Player Version#: Web, AppleTV, etc

I’ve run into a bizarre issue with Plex for remote users.

I always aim for a bitrate of 10 Mbps or below for my shared movie content, to ensure that most clients can direct play it. (I use Handbrake.) Under Plex Web --> Quality, I’ve set it to “12 Mbps, 1080p.”

This only happens for some movies. The best way to explain what’s happening is by example, so I’ll use Once Upon a Time in Hollywood as the example.

As it’s currently encoded, the file is is less than 7 Mbps. If I “get info” from within Plex, it shows as “6592 kbps.”

When I attempt to play the file remotely either via the AppleTV Plex app or via the web app, the server transcodes the file. If I look under “Technical Details” in the AppleTV Plex app, while the movie is playing, it says both video and audio are being transcoded, and under “Transcode Reason,” it says “Not enough bandwidth for direct play of this item. Required bandwidth is 40642kbps and only 12000kbps is available.”

40642 kbps??? Where is that number coming from? Why does PMS and/or the Plex playback app think the bitrate is anything other than the actual bitrate of 6592 kbps?

As I mentioned before, this is happening with several, but not all, movies. The numbers are different depending on the movie, but in all cases Plex thinks the required bitrate is much, much higher than the actual bitrate of the file being streamed.

As you can imagine, this unnecessary forced transcoding is reducing the number of simultaneous movies that can be served.

Any ideas?

1 Like

I’ve done a little bit more checking, at it turns out most movies exhibit a similar problem, with Plex thinking they require much more bandwidth than they really do. I only noticed it with some of them, because the 12 Mbps limit allows many of them to direct play anyway, even with the ‘inflated’ reported bitrate. For example, many modern movies shot with digital movie cameras have very low noise and compress extremely well, so they might be only 3 or 4 mbps. Plex still thinks they require much higher bandwidth than they actually do (such as 10 or 11 Mbps). But because 10 or 11 mbps is less than the 12 Mbps limit I set, they direct play.

I hope this makes sense.

1 Like

As you’re discovering, video bitrates are hugely variable. A still scene requires almost no bits; a scene with fast action may need 10x the median.

This makes the “Average Bitrate” of a file very misleading.

Plex analyzes files to identify the moment-by-moment bitrate throughout the video. Plex also knows the buffer size of each client. It uses these together to calculate the streaming bandwidth requirements.

When you look at a file’s info in Plex, bitrate is the file average. But if you look at the XML, requiredBandwidths shows how much bandwidth is needed to accommodate bitrate bursts at different buffer sizes. Before a file is analyzed, a fudge factor multiplier is used.

Handbrake’s “Average Bitrate” mode controls the total file size, not moment-to-moment bitrate. A file produced with “Constant Quality” and “Average Bitrate” modes will have the same peaks and valleys in bitrate. “Average Bitrate” mode is how you create a file that’s the perfect total size for a CD or DVD, not how you target a streaming bandwidth.

If you are targeting specific bandwidth, and want to pre-encode your video, one option is to use Plex’s built-in Optimizer presets. They tightly control bandwidth & required buffer sizes to maximize video quality for specific bandwidth settings.

If you want to encode for specific streaming bandwidth yourself, there’s an exhaustive thread about it here:

Here’s a picture from that thread, because I like pictures.

This is an encoding without any buffer rate control performed. The peaks are 6x the average.

Volts – thank you for your quick reply.

Okay, so for many years I’ve been using the constant quality (RF) slider in Handbrake to try to strike a balance between file size and quality, coming down a little bit on the side of small file sizes because my server storage space was sort of limited.

A few months back I upgraded my storage such that I don’t have to be quite so careful about file size, and so I’ve been bumping the RF slider a little more toward the quality end, figuring bigger file sizes aren’t as worrisome as before. I was still checking the overall average bitrate with the idea that I wanted to keep the encoded files below 10 Mbps.

I guess that’s why I never noticed the ‘unnecessary’ transcoding behavior before – the RF slider was pushed just enough in the low file size direction that my peak bitrate was staying below 12 Mbps. But now that I’ve been bumping the RF slider in the other direction, the peaks are getting much higher than before, even as the averages are still alright.

Setting all that aside for a minute… it seems strange to me that Plex would use the peak transient bitrate to decide whether a file can be streamed without transcoding. If the overall average bitrate is well below the bandwidth limit, then certainly a modern client like the Apple TV 4K can handle buffering a direct play video enough to handle the transient peaks when they happen. Heck, you could pre-buffer the entire movie on that client if you wanted.

That said, it should be possible to use the constant quality slider in Handbrake, but set a hard upper limit for peak bitrate. I’ll have to dig into the advanced options, I guess…

Yup.

Every device will download as fast as it can, as much as it can, until the buffer is full. That can be the entire movie. Or it can mean a turtle-and-hare race between download and playback. As long as the buffer bucket is never emptied, playback continues.

It’s not really about “modern”, except that “modern” is a proxy for “buffer size”. My TV has a big enough buffer that on lower-bitrate content, I can stop, upgrade, and restart my Plex Server without interrupting playback.

Plex knows that different clients have different buffer sizes, too. So at a given bandwidth, a specific video might work for one client (big buffer) but not for another (small buffer).

It’s called “CRF+VBV”. Look at vbv-maxrate and vbv-bufsize.

And it’s exactly the recommended approach. Not just by me! Or @plexyChip from that thread! It’s what the Plex Optimizer presets use, too. And the x264 & x265 codec devs specifically recommend it for streaming.

Volts – Thank you! I guess I’m going to have to re-encode some movies. The bulk of my library is probably fine, at least judging by the half dozen or so older titles I’ve checked. It’s only the stuff I’ve encoded in the past few months that have such big peak requirements.

Based on a little bit of research, it looks like I can set vbv-maxrate to 14,000 without causing trouble for too many clients. If one of my family members is using a really old client, I’m okay with the server transcoding for them. But I’d like the bulk of what I’m serving to be direct play.

Thanks again for your help…

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.