feat: Add Max Bitrate option (#3628)
Some checks failed
CI / GitHub Env Debug (push) Waiting to run
CI / Setup Release (push) Waiting to run
CI / Setup Flatpak Matrix (push) Waiting to run
CI / Linux Flatpak (push) Blocked by required conditions
CI / Linux AppImage (push) Blocked by required conditions
CI / Homebrew (macos-13) (push) Blocked by required conditions
CI / Homebrew (macos-14) (push) Blocked by required conditions
CI / Homebrew (ubuntu-latest) (push) Blocked by required conditions
CI / Homebrew (ubuntu-latest (Release)) (push) Blocked by required conditions
CI / Windows (push) Blocked by required conditions
CI Docker / Check Dockerfiles (push) Waiting to run
CI Docker / Setup Release (push) Blocked by required conditions
CI Docker / Docker${{ matrix.tag }} (push) Blocked by required conditions
CodeQL / Get language matrix (push) Waiting to run
CodeQL / Analyze (${{ matrix.name }}) (push) Blocked by required conditions
Build GH-Pages / prep (push) Waiting to run
Build GH-Pages / call-jekyll-build (push) Blocked by required conditions
localize / Update Localization (push) Has been cancelled

This commit is contained in:
Utkarsh Dalal 2025-02-10 01:30:29 +05:30 committed by GitHub
parent ff0ed25e47
commit 3a88ddc639
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 37 additions and 2 deletions

View File

@ -1316,6 +1316,29 @@ editing the `conf` file in a text editor. Use the examples as reference.
</tr>
</table>
### max_bitrate
<table>
<tr>
<td>Description</td>
<td colspan="2">
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.
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}
0
@endcode</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
max_bitrate = 5000
@endcode</td>
</tr>
</table>
### min_fps_factor
<table>

View File

@ -509,7 +509,8 @@ namespace config {
{} // wa
}, // display_device
1 // min_fps_factor
1, // min_fps_factor
0 // max_bitrate
};
audio_t audio {
@ -1138,6 +1139,7 @@ namespace config {
bool_f(vars, "dd_wa_hdr_toggle", video.dd.wa.hdr_toggle);
int_between_f(vars, "min_fps_factor", video.min_fps_factor, {1, 3});
int_f(vars, "max_bitrate", video.max_bitrate);
path_f(vars, "pkey", nvhttp.pkey);
path_f(vars, "cert", nvhttp.cert);

View File

@ -138,6 +138,7 @@ namespace config {
} dd;
int min_fps_factor; // Minimum fps target, determines minimum frame time
int max_bitrate; // Maximum bitrate, sets ceiling in kbps for bitrate requested from client
};
struct audio_t {

View File

@ -1687,7 +1687,8 @@ namespace video {
}
}
auto bitrate = config.bitrate * 1000;
auto bitrate = ((config::video.max_bitrate > 0) ? std::min(config.bitrate, config::video.max_bitrate) : config.bitrate) * 1000;
BOOST_LOG(info) << "Max bitrate is " << config::video.max_bitrate;
ctx->rc_max_rate = bitrate;
ctx->bit_rate = bitrate;

View File

@ -179,6 +179,7 @@
"dd_mode_remapping": {"mixed": [], "resolution_only": [], "refresh_rate_only": []},
"dd_wa_hdr_toggle": "disabled",
"min_fps_factor": 1,
"max_bitrate": 0,
},
},
{

View File

@ -17,6 +17,13 @@ const config = ref(props.config)
<input type="number" min="1" max="3" class="form-control" id="min_fps_factor" placeholder="1" v-model="config.min_fps_factor" />
<div class="form-text">{{ $t('config.min_fps_factor_desc') }}</div>
</div>
<!--max_bitrate-->
<div class="mb-3">
<label for="max_bitrate" class="form-label">{{ $t("config.max_bitrate") }}</label>
<input type="number" class="form-control" id="max_bitrate" placeholder="0" v-model="config.max_bitrate" />
<div class="form-text">{{ $t("config.max_bitrate_desc") }}</div>
</div>
</template>
<style scoped>