diff --git a/docs/source/about/advanced_usage.rst b/docs/source/about/advanced_usage.rst index c9d9ebae3b4..231be65545e 100644 --- a/docs/source/about/advanced_usage.rst +++ b/docs/source/about/advanced_usage.rst @@ -430,6 +430,20 @@ resolutions 3840x1600, ] +max_bitrate +^^^^^^^^^^^ + +**Description** + The maximum bitrate (in Kbps) that Sunshine will encode the stream at. If set to 0, it will always use the bitrate requested by Moonlight. + +**Default** + ``0`` + +**Example** + .. code-block:: text + + max_bitrate = 5000 + Audio ----- diff --git a/src/config.cpp b/src/config.cpp index c08f5a9c4eb..ffe80c3be3c 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -403,6 +403,7 @@ namespace config { }, // supported resolutions { 10, 30, 60, 90, 120 }, // supported fps + 0, // max bitrate }; input_t input { @@ -993,6 +994,7 @@ namespace config { list_string_f(vars, "resolutions"s, nvhttp.resolutions); list_int_f(vars, "fps"s, nvhttp.fps); list_prep_cmd_f(vars, "global_prep_cmd", config::sunshine.prep_cmds); + int_f(vars, "max_bitrate", nvhttp.max_bitrate); string_f(vars, "audio_sink", audio.sink); string_f(vars, "virtual_sink", audio.virtual_sink); diff --git a/src/config.h b/src/config.h index 749a8556d11..4abf05704a8 100644 --- a/src/config.h +++ b/src/config.h @@ -102,6 +102,7 @@ namespace config { std::string external_ip; std::vector resolutions; std::vector fps; + int max_bitrate; }; struct input_t { diff --git a/src/video.cpp b/src/video.cpp index 1191a8684bf..1d68cf33ac5 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -1552,7 +1552,7 @@ namespace video { } if (video_format[encoder_t::CBR]) { - auto bitrate = config.bitrate * 1000; + auto bitrate = ((config::nvhttp.max_bitrate != 0) ? std::min(config.bitrate, config::nvhttp.max_bitrate) : config.bitrate) * 1000; ctx->rc_max_rate = bitrate; ctx->bit_rate = bitrate; diff --git a/src_assets/common/assets/web/config.html b/src_assets/common/assets/web/config.html index 6e2b61b760c..625bd22e1b8 100644 --- a/src_assets/common/assets/web/config.html +++ b/src_assets/common/assets/web/config.html @@ -228,6 +228,19 @@

resolutions and fps are supported.
This setting does not change how the screen stream is sent to Moonlight +
+ + +
+ Maximum bitrate for streaming in Kbps. If not specified, the default bitrate is used +
+
@@ -1164,10 +1177,12 @@

"encoder": "", "fps": "[10,30,60,90,120]", "gamepad": "auto", + "global_prep_cmd": "[]", "hevc_mode": 0, "av1_mode": 0, "key_rightalt_to_key_win": "disabled", "keyboard": "enabled", + "max_bitrate": 0, "min_log_level": 2, "mouse": "enabled", "nvenc_h264_cavlc": "disabled", @@ -1184,7 +1199,6 @@

"vt_coder": "auto", "vt_realtime": "enabled", "vt_software": "auto", - "global_prep_cmd": "[]", } new Vue({