Repository navigation
Conversation
Contributor
Author
porkloin
marked this pull request as ready for review
November 20, 2026 00:10
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.
Currently, Moonshine encodes video at the full bitrate the user picked in Moonlight and sends FEC, audio and packet headers on top, so a 20 Mb/s setting sends 24–25 Mb/s. On a link without that headroom, the excess is dropped and the stream freezes.
This means that the "real" bitrate being sent to moonlight clients is regularly ~110% of the declared bitrate the user has chosen in moonlight.
This PR fits the whole stream inside the user's declared bitrate, the way Moonlight expects (it sends the setting as
x-ml-video.configuredBitrateKbpsfor this) and Sunshine does incmd_announce()(src/rtsp.cpp):stream.video.bitrate_includes_overhead, on by default.Testing
Moonshine's tests
All 199 pass, including a new one for the calculation: 20 Mb/s with 20% FEC and 512 kb/s audio gives 14.99 Mb/s of video, the overhead caps apply at 1 Mb/s, and an FEC percentage above 80 is ignored, as in Sunshine.
Integration testing
Tested with moonshine-test-headless, which streams a test app from Moonshine to a headless Moonlight client and records what the client receives. The app was framestamp, a full-motion test pattern whose frames the client checks against the expected image. 1920x1080 at 60 fps, 20 Mb/s, 20 s per codec. This branch (150dd98) against main (934c5c5).
Link with little headroom. Client on the same machine (RX 7900 XTX), its network limited to 22 Mb/s with a 50 ms router queue and 10 ms of delay. The harness summary below is from this run.
Peak bitrate fell from 114% to 89% of the setting. On an RX 9070 XT, main got 56, 34 and 32 fps; this branch 60 fps with nothing lost.
No bandwidth limit. The builds match on both GPUs, at 1080p60 and at 3840x2160 120 fps 113 Mb/s: the same missing frames, keyframes and freeze time. Host latency p99 2.59 ms against 2.68 ms.
Over Wi-Fi 7, to an RX 9070 XT client: peak bitrate fell from 114–115% to 91–97%, and neither build lost a frame. Both had freezes, the longest (5–6 s) on this branch's HEVC stream in both runs. Moonshine never went more than 40 ms between frames sent, so these are most likely Wi-Fi interference.
Picture quality. The client's error against the expected image (worst stream, 99th percentile) rose from 0.9–1.8 to 1.1–2.8 at 1080p60, and by 0.1–0.8 at 4K120. No picture was corrupt.
The harness's timing comparison gives no verdict, because it only compares streams encoded at the same bitrate.
Moonshine 150dd98 vs main 934c5c5 · 1920x1080 at 60 fps, link capped at 22 Mb/s
Hardware
Stream
Report card
Client
The client machine's decoding and display. Moonshine doesn't control these, so they aren't scored, but a slow client can cause freezes and keyframes in the report card.
Checks
Results produced by moonshine-test-headless. Results file attached.
To run the same test on your hardware:
podman container runlabel run ghcr.io/porkloin/moonshine-test-headless -- \ --moonshine porkloin@bitrate-overhead --baseline --iterations 3 \ --app framestamp-full --chaos --rate 22000:50 --delay 10To view the attached results:
podman container runlabel run ghcr.io/porkloin/moonshine-test-headless:view \ path/to/results.tar.gz