Force Max quality fix for 4K #80
Replies: 1 comment
-
I've come across a new problem with this. Originally I wanted to only force Max quality if the client was not set to stream at original quality. In studying the behavior for Android it seemed the best way to do this was to detect if directPlay=0 and directStream=1, this is the behavior for Android. In studying the behavior of iOS and the Xbox it seems that directPlay and directStream are both set to 0 whether you limit your remote streaming bitrate or you explicitly choose to transcode. So this would only work with Android. |
Beta Was this translation helpful? Give feedback.
-
I originally posted this as an issue not even realizing there was discussion forums.
I thought I'd share this with you guys in case anyone was wondering. The reverse proxy I use is caddy as it's very easy but I'll give examples for both Caddy and nginx.
In my time studying this I could never figure out why forcing max quality would cause 4K media to transcode. If passing thru as a transparent proxy this created an issue, redirecting the decision end point to a 403 if the videoBitrate was 200,000 worked as a fix for most media but I would constantly end up in the same predicament, some 4K media for some reason would start to transcode and eventually fail. The fix I found was to create routes based on query parameters. In this first example I pass on the query to replex if the videoBitrate parameter is not 200,000 (this is the bitrate the Plex app requests if you are playing back either original quality or 4K) AND if directStream is 1 and directPlay is 0, I do this so that users who have not set their client to play at original quality are forced to play at original quality but users who DO have their clients set to original quality are not punished and are allowed to transcode, all other traffic is passed directly to Plex:
example.net {
handle /video/:/transcode/universal/decision* {
@forceMaxStream {
not query maxVideoBitrate=200000
query directStream=1
not query directPlay=1
}
reverse_proxy @forceMaxStream localhost:3001
reverse_proxy localhost:32400
}
reverse_proxy localhost:3001
}
If you only wanted to pass original quality/4K queries to Plex you could do this
example.net {
handle /video/:/transcode/universal/decision* {
@4k {
query maxVideoBitrate=200000
}
reverse_proxy @4k localhost:32400
reverse_proxy localhost:3001
}
reverse_proxy localhost:3001
}
Here's what a similar nginx config would look like:
server {
listen 80;
server_name example.com;
location ~* ^/video/:/transcode/universal/decision.*$ {
if ($arg_maxVideoBitrate = 200000) {
proxy_pass http://localhost:32400;
}
proxy_pass http://localhost:3001;
}
location / {
proxy_pass http://localhost:3001;
}
Other necessary Nginx configurations like proxy settings, etc.
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}
Beta Was this translation helpful? Give feedback.
All reactions