Open BradyBrenot opened 3 months ago
The recent modifications to the FFmpeg decoder enhance video frame processing by implementing a mechanism to request IDR frames when a specified threshold of frames is exceeded. By introducing a new constant and a counter for frames since the last IDR, the decoder improves its ability to handle frame corruption, ensuring more stable and higher-quality video playback.
Files | Change Summary |
---|---|
Streaming/FFmpegDecoder.cpp , Streaming/FFmpegDecoder.h |
Added MAX_DELAY_BETWEEN_IDR_FRAMES constant and framesSinceLastIDR variable to improve IDR frame management and overall decoding stability. |
🐇
In the land of frames so bright,
We count each one with delight.
If too many pass by my way,
An IDR frame I shall say!
Hopping through scenes, clear and fast,
Stability's here, at long last!
🎥
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
I would have liked to have only sent this when the decoder starts to get weird, but I couldn't find any way to detect that. Tried logging anything I could find and nothing really stands out.
I haven't checked:
Looks like missed frames can't be used, at least not for the issue as it happens to me. 0 missed frames and still the corruption starts.
Issues
1 New issue
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Hi @BradyBrenot,
Just to confirm, have you checked the Sunshine build here https://github.com/TheElixZammuto/moonlight-xbox/issues/117#issuecomment-2234149165 ?
In practice the commit https://github.com/LizardByte/Sunshine/commit/4840aaa00386674108ea93987ba5bc69aa6291e6 of the test build of Sunshine should already do this but on NVEnc only (the issue only occurs there IIRC), on the server side.
To mitigate #117 (Compression artifacts forming when left on the same scene for a while), request an IDR frame from the host every 1000 packets. This seems to reset the decoder well enough to completely avoid slow corruption problem, but shouldn't add too much extra bandwidth.
Unless I'm missing something, Sunshine never sends I or IDR frames after initially establishing the stream unless it's specifically asked to by the client.
(This is a hacky mitigation, not a proper fix. It works but it's not the ideal fix. Since this only seems to happen on this platform, I'm guessing either we're touching memory we shouldn't / in a way we shouldn't, or ffmpeg has a hardware acceleration bug on this platform. Tracking down the root cause is a pain though, especially with UWP's limitations)
Summary by CodeRabbit
New Features
Bug Fixes