Default All Clients to Max Internet Streaming

Yeah it appears to be transcoding to original, which is weird. Sometimes it’s just the audio but if I manually change to original it direct plays the audio (same client etc)

I’ll have a play about with your nginx parameters thanks!

I understand Plex is working on this problem, but I don’t understand why Plex can’t just set the default to 4Mbps or something higher than the current 2Mbps default? Isn’t that just a simple data point change?

1 Like

Yep, simple data point. Use the nginx script to drop the stream parameters and forget about them fixing it. lol.

Hi… thanks for sharing… Does it need to include those lines for each device ? or is there a way to do it for all devices at all ? thanks

Try this:

# Force original bitrate
if ($http_user_agent ~ (^|.*)) { set $tempargs ${args}-TEMP; }
if ($tempargs ~ (^|.*)&directStream=0(.*)-TEMP) { set $tempargs $1&directStream=1$2-TEMP; }
if ($tempargs ~ (^|.*)&videoQuality=(\d+)(.*)-TEMP) { set $tempargs $1$3-TEMP; }
if ($tempargs ~ (^|.*)&maxVideoBitrate=(\d+)(.*)-TEMP) { set $tempargs $1$3-TEMP; }
if ($tempargs ~ (^|.*)&videoBitrate=(\d+)(.*)-TEMP) { set $tempargs $1$3-TEMP; }
if ($tempargs ~ (^|.*)&videoResolution=(\d+)x(\d+)(.*)-TEMP) { set $tempargs $1$4-TEMP; }
if ($tempargs ~ (^|.*)-TEMP) { set $args $1; }
2 Likes

Where exactly do you insert this code? Where is the file located that needs this change? Or, are we creating a new file?

You need to set up nginx as a reverse proxy for Plex first and then in your configuration file you put those rules at the top of the location / { } directive using an include statement pointing to the file. Insert my bitrate code in the file shown with the directive “include /etc/nginx/conf.d/plex_force_bitrate.include;”.

Here is my config file:

upstream plexserver {
        server IP-OF-YOUR-PLEX-SERVER:32400;
        keepalive 32;
}

server {
        server_name DOMAIN-OF-YOUR-PLEX-SERVER.COM;

        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

        location / {
                include /etc/nginx/conf.d/plex_force_bitrate.include;

                send_timeout 100m;

                gzip on;
                gzip_vary on;
                gzip_min_length 1000;
                gzip_proxied any;
                gzip_types text/plain text/css text/xml application/xml text/javascript application/x-javascript image/svg+xml;
                gzip_disable "MSIE [1-6]\.";

                client_max_body_size 500M;

                proxy_set_header Host $host;
                proxy_set_header Referer $server_addr;
                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_set_header X-Plex-Client-Identifier $http_x_plex_client_identifier;
                proxy_set_header X-Plex-Device $http_x_plex_device;
                proxy_set_header X-Plex-Device-Name $http_x_plex_device_name;
                proxy_set_header X-Plex-Platform $http_x_plex_platform;
                proxy_set_header X-Plex-Platform-Version $http_x_plex_platform_version;
                proxy_set_header X-Plex-Product $http_x_plex_product;
                proxy_set_header X-Plex-Token $http_x_plex_token;
                proxy_set_header X-Plex-Version $http_x_plex_version;
                proxy_set_header X-Plex-Nocache $http_x_plex_nocache;
                proxy_set_header X-Plex-Provides $http_x_plex_provides;
                proxy_set_header X-Plex-Device-Vendor $http_x_plex_device_vendor;
                proxy_set_header X-Plex-Model $http_x_plex_model;
                proxy_set_header Sec-WebSocket-Extensions $http_sec_websocket_extensions;
                proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key;
                proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";

                proxy_http_version 1.1;
                proxy_redirect off;
                proxy_buffering off;

                proxy_pass https://plexserver;
        }

	location /tautulli/ {
                proxy_pass https://IP-OF-TAUTULLI:8080;

                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_set_header X-Forwarded-Ssl on;

                proxy_read_timeout 90;
        }

	ssl_stapling on;
        ssl_stapling_verify on;

        listen 443 http2;
#        listen [::]:443;
        ssl_certificate /etc/letsencrypt/live/LETSENCRYPTDOMAIN/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/LETSENCRYPTDOMAIN/privkey.pem;
        include /etc/letsencrypt/options-ssl-nginx.conf;
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
3 Likes

And doing so, it will set all client to Max Quality ?

It will not change the setting inside the app but it will force it anyways.

1 Like

And is it possible to make exceptions, like i just one 1 client to be able to transcodage ?

Sorry for the questions, but what you propose is really interesting :slight_smile:

Yes. What you could do is replace the first line to this:

if ($http_x_plex_device_name ~ (^|.*)Living room Roku(.*)) { set $tempargs ${args}-TEMP; }

Just replace Living room Roku with the name you give your device. There’s many headers you could check against. Make it specific to certain users etc…

3 Likes

Hmm @sixxnet i know it wasnt your solution but any idea how i’d do this with the cloudflare works script? (stop transcoding to highest quality)

Yes, set the bitrate manually in the script to like 60000000. That’s 60 million. (might not work for all clients)

Or edit the script to drop the parameters from the URL. (little more involved) Works for all clients I have tested except Android mobile. (this is what I suggest)

I have some stuff to get done today so I will reply later tonight with the edits on the cloudflare script if someone else doesn’t do it before me.

2 Likes

I think this is the best i’m gonna get, no matter what i set the bitrates to it still direct streams, but i’m ok with that, cpu isnt my issue here, it’s making sure users are viewing stuff in a decent quality!

image

(Not sure where plex is getting that required bandwidth from but its not using that much!)

This doesn’t take into account the fact that some users will need to still use a lower quality due to poor internet. Your straight up forcing everyone to max quality which is great, but not realistcally the best solution. That’s why in my cf-workers script I did a simple quality boost based on the current quality setting. If they were using the default I would bump them up by much more, but there will always be people who need to lower quality at times.

Also, doesn’t your solution completely disable the ability to transcode/run at any quality lower than the highest? That could definitely be a bad time for people trying to watch a 4k movie on a 1080p setup, and even worse if said user has internet that definitely couldn’t handle more than 20mbps.

1 Like

The way I have it working now doesn’t stop users from changing it mid stream, not had any complaints yet about buffering

That’s not the point. The title of the thread is default all clients to max internet streaming. That’s what it does. Your script forces a transcode 100% of the time with the bitrate set so low which is exactly what this thread doesn’t want. If somebody needs to tweak the paramaters they are able to. Or ask. It can be set up for specific users and or specific devices very easily.

@mark_07 Direct stream is fine. It doesn’t use the CPU for transcoding when direct streaming in this case. It would still convert audio if needed. You could try setting directPlay=1 in that script but it will break Android clients forcing that option.

Will almost be time for me to post the Christmas countdown.

Will this feature be released before Christmas 2022??? 2022-12-24T13:00:00Z

:thinking:

Released before Christmas?
  • Yes, I am living in a fantasy.
  • No, I am living in reality.

0 voters

3 Likes

This iterally drives me insane and I cannot process why they would set this to 720p 2 or 4mps! I’m finding now as well many clients update and the setting changes after the upgrade, WHY??? Very frustrating for us people maintaining our servers to run smoothly, and for my family to view things they way they should. We’re not running on dial-up anymore, and the concern for using bandwidth should be at the discretion of the user, NOT the app. I hope people upvote the hell out of this so this finally gets changed, I can’t stand it anymore.

2 Likes