Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose more nvenc and nvprefs options #1798

Closed
wants to merge 6 commits into from

Conversation

ns6089
Copy link
Contributor

@ns6089 ns6089 commented Oct 29, 2023

Description

Screenshot

2023-10-29 13_42_26-Sunshine — Mozilla Firefox

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Branch Updates

LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.

  • I want maintainers to keep my branch updated

1. Spatial AQ, for some reason NVENC have problems recovering details on
   flat regions of static images over multiple frames, official docs
   recommend to enable it for "game-streaming"
2. Override default DPB size in situations when moonlight doesn't request
   one explicitly, can improve the window of instant recovery from dropped
   or corrupted frames with Reference Frame Invalidation
3. Percentage increase of default single-frame VBV/HRD, can act as
   low latency variable bitrate substitute
"nvenc_preset": "1",
"nvenc_realtime_hags": "enabled",
"nvenc_spatial_aq": "disabled",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"nvenc_spatial_aq": "disabled",
"nvenc_spatial_aq": "disabled",
"nvenc_vbv_increase": 0,

.. Caution:: Applies to Windows only.

**Default**
Variable is unset and sunshine will pick whatever it thinks is the best.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the default is not 5?

Generally, placeholders in the config ui match the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current default is constant 5, but I can't guarantee it will stay as single constant value in the future and not change dynamically depending on let's say video resolution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, if it changes in the future to an auto mode this can be adjusted accordingly.

For now, I think this should be 5. Also, as long as the config UI uses the correct defaults, then it allows us to modify the default when a user updates. As long as they are using our old default, they will also start using our new default.

Comment on lines +1238 to +1239
"nvenc_latency_over_power": "enabled",
"nvenc_opengl_vulkan_on_dxgi": "enabled",
Copy link
Member

@ReenigneArcher ReenigneArcher Oct 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"nvenc_latency_over_power": "enabled",
"nvenc_opengl_vulkan_on_dxgi": "enabled",
"nvenc_h264_hevc_ref_frames": "5",
"nvenc_latency_over_power": "enabled",
"nvenc_opengl_vulkan_on_dxgi": "enabled",

.. Caution:: Applies to Windows only.

**Default**
Variable is unset and sunshine will pick whatever it thinks is the best.
Copy link
Member

@ReenigneArcher ReenigneArcher Oct 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Variable is unset and sunshine will pick whatever it thinks is the best.
``5``

@@ -1077,6 +1130,96 @@ nvenc_realtime_hags

nvenc_realtime_hags = enabled

nvenc_h264_hevc_ref_frames
Copy link
Collaborator

@cgutman cgutman Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should expose this option to users (at least in this fully-configurable form). The number of reference frames is limited by the codec specification and is resolution-dependent (as you mentioned below).

It would be easy for a user to end up in a situation where they specify a value here that works for 720p then later switch to 4K and wonder why things are totally broken, or they specify a value that works for HEVC but not H.264. The issues caused by getting it wrong are going to be really hard to diagnose both for us and for users, especially since it may only manifest with packet loss.

I think if we want to expose this option, we should do so in a way that only exposes a few known good options. For now, maybe we expose "Auto" (our current behavior) and "1". If we later decide to increase reference frames up to the codec maximum for each resolution, we can either change the behavior of "Auto" and explicitly add "5" as an option or add an option for "Maximum", depending on how the decoder compatibility looks in our testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm back from the dead, somewhat. Sorry for leaving it to you to deal with.

Now to remember my reasoning behind this option, I think it went like this

  1. While "5" is a safe default value, it comes with the cost of needless memory overhead (on both server and client) when packet loss never happens. And can be considered a regression for such scenarios since we used "1" before RFI support was implemented.
  2. But "5" is only barely enough for RFI, because of the latencies involved and that the wireless network instabilities usually last longer than a couple of milliseconds. So on unstable networks you would generally want the highest number your decoder can handle (for given resolution).

As for packet loss, I don't think it can happen because of this option since it doesn't increase the amount of data sent over the network. Decoder artifacts on the other hand are fully expected, if it goes above the maximum supported codec profile level for given decoder hardware.


For now, maybe we expose "Auto" (our current behavior) and "1"

Maybe just use "RFI support on/off" server-side option, with the description of what it is and the memory overhead.
But ideally, this selection should be moved to the client side, since only that side has the information about the decoder and expected network stability. It's just easier to patch one server than 10 clients, even though it's not the "proper" solution. @cgutman I'm unable allocate time to patch every moonlight client, but can make quick sunshine PR if you're ok with it? This option can be useful right now for vm-to-vm looking glass and similar scenarios.

@ReenigneArcher Sorry for disappearing (this project was consistently eating up more time I was allocating to it, so I had to pull a hard stop), but can I have the discord access back so I'm aware of the recent developments? Pretty please with a cherry on top.

@cgutman cgutman mentioned this pull request Jan 2, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants