feat(stream): add adaptive NVENC bitrate control - #5460
Open
Dragon-kanji wants to merge 8 commits into
Open
Conversation
Signed-off-by: leandredesmaretz <leandre@eshot.io>
Signed-off-by: leandredesmaretz <leandre@eshot.io>
Signed-off-by: leandredesmaretz <leandre@eshot.io>
Signed-off-by: leandredesmaretz <leandre@eshot.io>
Signed-off-by: leandredesmaretz <leandre@eshot.io>
Signed-off-by: burnrazor <128198300+Dragon-kanji@users.noreply.github.com>
Dragon-kanji
force-pushed
the
feat/adaptive-bitrate
branch
from
July 29, 2026 17:06
3c61e0f to
97937f2
Compare
Signed-off-by: burnrazor <128198300+Dragon-kanji@users.noreply.github.com>
Signed-off-by: burnrazor <128198300+Dragon-kanji@users.noreply.github.com>
|
Dragon-kanji
marked this pull request as ready for review
July 29, 2026 23:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
This PR adds an opt-in adaptive bitrate path for Sunshine's native NVENC encoder on Windows. It is disabled by default.
The reason I built it is pretty practical. I stream from a Windows desktop to a Steam Deck docked to my TV, and the Wi-Fi there is sometimes unstable. Fixed bitrate works well most of the time, but when the connection suddenly degrades, latency can climb very quickly and the stream can become almost unusable.
The new controller reduces the bitrate when packet loss persists, then recovers gradually once the connection looks healthy again. I tried to reuse the existing protocol and signals as much as possible. It uses Moonlight's existing
SS_FRAME_FEC_STATUSreports, the frame-loss recovery signals Sunshine already handles, and ENet RTT samples. It does not add a new feedback protocol.The implementation adds bounded per-session telemetry aggregation, the adaptive controller, and native NVENC runtime bitrate reconfiguration without restarting the encoder. The controller never exceeds the bitrate requested by Moonlight or Sunshine's configured
max_bitrateceiling. If the encoder is unsupported, or if the telemetry is missing or invalid, Sunshine keeps the normal fixed-bitrate behavior.The PR also adds the Windows Audio/Video setting, documentation, and test coverage. I kept the telemetry, controller, and NVENC reconfiguration together because the individual pieces do not provide much value on their own, but I am fine splitting the work if that would make review easier.
Testing performed:
BUILD_WERROR=ON, and the native NVENC SDK 11, 12, and 13 implementationsThe hardware encoder probe was excluded from the SSH-only test session because it requires an interactive Windows desktop.
Screenshot
The new setting is shown below in its default, disabled state.
Issues Fixed or Closed
Roadmap Issues
Type of Change
Checklist
AI Usage
See our AI usage policy.