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

PR33 with changed vbv-bufsize causes stuttering on rpi3 #478

Closed
2 tasks done
Forusim opened this issue Nov 6, 2022 · 11 comments
Closed
2 tasks done

PR33 with changed vbv-bufsize causes stuttering on rpi3 #478

Forusim opened this issue Nov 6, 2022 · 11 comments
Labels
fixed This issue has been fixed and will be available in the next release. os:Windows OS is Windows

Comments

@Forusim
Copy link

Forusim commented Nov 6, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Is your issue described in the documentation?

  • I have read the documentation

Describe the Bug

Moonlight embedded 2.5.3 works fluent on my raspberry pi3 with Sunshine 0.11.1 with following settings:

width = 1920
height = 1080
fps = 60
bitrate = 12500
packetsize = 1392
codec = auto
platform = default

The default bitrate for 1080p@60fps is 20000 kbits, which is causing delays my rpi3 client. Whereas 12500 kbit gives a good picture and minimal delay in sound and controls.

With Sunshine 0.12.0 - 0.15.0 I observe stuttering every few seconds, usually when the scene changes or a button is pressed.
I suspect the issue is caused by #33.
I do not see this stuttering on other clients like Windows 7 with Moonlight QT @ 1080p 60fps 20000 kbits.

Looking at the changes in that PR there might be some starvation on bitrate or overshot in the rc_buffer_size:
Before:

auto bitrate = config.bitrate * 1000
ctx->rc_buffer_size = bitrate / config.framerate

Result:

auto bitrate = 12500 * 1000
rc_buffer_size = 12500 / 60

After:

auto bitrate = config.bitrate * (hardware ? 1000 : 800)
ctx->rc_buffer_size = bitrate / 10

Result:

auto bitrate = 12500 * 800
rc_buffer_size = 12500 / 10

Can above changes to the formula cause the observed stuttering in my case?
Would it be possible to have options to tune above parameters on such constrained scenarios?

Expected Behavior

No negative impact after PR

Additional Context

Client:
Recalbox 7.2.2
Raspberry Pi 3
Moonlight Embedded 2.5.3

Host Operating System

Windows

Operating System Version

Windows 10 21H2 (Patched 10/2022)

Architecture

64 bit

Sunshine commit or version

0.15.0

Package

Windows - portable

GPU Type

none (software encoding)

GPU Model

UHD 750

GPU Driver/Mesa Version

31.0.101.3790

Capture Method (Linux Only)

No response

Relevant log output

Not sure if there is something relevant
[fps] -- [[30,60]]
[vt_coder] -- [auto]
[amd_rc] -- [auto]
[vt_realtime] -- [enabled]
[key_rightalt_to_key_win] -- [disabled]
[resolutions] -- [[
    1280x720,
    1920x1080,
    1920x1200
]]
[origin_pin_allowed] -- [pc]
[gamepad] -- [x360]
[nv_coder] -- [auto]
[dwmflush] -- [disabled]
[min_log_level] -- [debug]
[vt_software] -- [auto]
[amd_quality] -- [default]
[origin_web_ui_allowed] -- [pc]
[nv_rc] -- [auto]
[hevc_mode] -- [0]
[encoder] -- [software]
[nv_preset] -- [default]
[upnp] -- [disabled]
[amd_coder] -- [auto]
[2022:11:06:14:41:45]: Info: Compiling shaders...
[2022:11:06:14:41:45]: Info: Compiled shaders
[2022:11:06:14:41:45]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2022:11:06:14:41:45]: Info: Trying encoder [software]
[2022:11:06:14:41:46]: Error: Failed to sync desktop to thread [0x000000AA]
[2022:11:06:14:41:46]: Info:
Device Description : Intel(R) UHD Graphics 750
Device Vendor ID   : 0x00008086
Device Device ID   : 0x00004C8A
Device Video Mem   : 128 MiB
Device Sys Mem     : 0 MiB
Share Sys Mem      : 65401 MiB
Feature Level      : 0x0000B100
Capture size       : 1920x1200
Offset             : 0x0
Virtual Desktop    : 1920x1200
[2022:11:06:14:41:46]: Debug: Source format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2022:11:06:14:41:46]: Info: Color coding [Rec. 601]
[2022:11:06:14:41:46]: Info: Color range: [JPEG]
[2022:11:06:14:41:46]: Error: Failed to sync desktop to thread [0x000000AA]
[2022:11:06:14:41:46]: Info:
Device Description : Intel(R) UHD Graphics 750
Device Vendor ID   : 0x00008086
Device Device ID   : 0x00004C8A
Device Video Mem   : 128 MiB
Device Sys Mem     : 0 MiB
Share Sys Mem      : 65401 MiB
Feature Level      : 0x0000B100
Capture size       : 1920x1200
Offset             : 0x0
Virtual Desktop    : 1920x1200
[2022:11:06:14:41:46]: Debug: Source format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2022:11:06:14:41:46]: Info: Color coding [Rec. 601]
[2022:11:06:14:41:46]: Info: Color range: [JPEG]
[2022:11:06:14:41:46]: Error: Failed to sync desktop to thread [0x000000AA]
[2022:11:06:14:41:46]: Info:
Device Description : Intel(R) UHD Graphics 750
Device Vendor ID   : 0x00008086
Device Device ID   : 0x00004C8A
Device Video Mem   : 128 MiB
Device Sys Mem     : 0 MiB
Share Sys Mem      : 65401 MiB
Feature Level      : 0x0000B100
Capture size       : 1920x1200
Offset             : 0x0
Virtual Desktop    : 1920x1200
[2022:11:06:14:41:46]: Debug: Source format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2022:11:06:14:41:46]: Info: Color coding [Rec. 601]
[2022:11:06:14:41:46]: Info: Color range: [JPEG]
[2022:11:06:14:41:46]: Error: Failed to sync desktop to thread [0x000000AA]
[2022:11:06:14:41:46]: Info:
Device Description : Intel(R) UHD Graphics 750
Device Vendor ID   : 0x00008086
Device Device ID   : 0x00004C8A
Device Video Mem   : 128 MiB
Device Sys Mem     : 0 MiB
Share Sys Mem      : 65401 MiB
Feature Level      : 0x0000B100
Capture size       : 1920x1200
Offset             : 0x0
Virtual Desktop    : 1920x1200
[2022:11:06:14:41:46]: Debug: Source format [DXGI_FORMAT_B8G8R8A8_UNORM]
[x2022:11:06:14:41:46]: Info: Color coding [Rec. 709]2
6[42022:11:06:14:41:46]: Info: Color range: [JPEG]
[error]: high profile doesn't support a bit depth of 10
[2022:11:06:14:41:46]: Error: Could not open codec [libx264]: Invalid argument
[2022:11:06:14:41:46]: Error: Failed to sync desktop to thread [0x000000AA]
[2022:11:06:14:41:46]: Info:
Device Description : Intel(R) UHD Graphics 750
Device Vendor ID   : 0x00008086
Device Device ID   : 0x00004C8A
Device Video Mem   : 128 MiB
Device Sys Mem     : 0 MiB
Share Sys Mem      : 65401 MiB
Feature Level      : 0x0000B100
Capture size       : 1920x1200
Offset             : 0x0
Virtual Desktop    : 1920x1200
[2022:11:06:14:41:46]: Debug: Source format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2022:11:06:14:41:46]: Info: Color coding [Rec. 601]
[2022:11:06:14:41:46]: Info: Color range: [JPEG]
[2022:11:06:14:41:46]: Warning: software: h264: replacing nalu prefix data
[2022:11:06:14:41:46]: Info:
[2022:11:06:14:41:46]: Info: // Ignore any errors mentioned above, they are not relevant. //
[2022:11:06:14:41:46]: Info:
[2022:11:06:14:41:46]: Debug: ------  h264 ------
[2022:11:06:14:41:46]: Debug: PASSED: supported
[2022:11:06:14:41:46]: Debug: REF_FRAMES_RESTRICT: supported
[2022:11:06:14:41:46]: Debug: REF_FRAMES_AUTOSELECT: supported
[2022:11:06:14:41:46]: Debug: SLICE: supported
[2022:11:06:14:41:46]: Debug: CBR: supported
[2022:11:06:14:41:46]: Debug: DYNAMIC_RANGE: unsupported
[2022:11:06:14:41:46]: Debug: VUI_PARAMETERS: supported
[2022:11:06:14:41:46]: Debug: NALU_PREFIX_5b: unsupported
[2022:11:06:14:41:46]: Debug: -------------------
[2022:11:06:14:41:46]: Info: Found encoder software: [libx264]
[2022:11:06:14:41:46]: Info: Configuration UI available at [https://localhost:47990]
[2022:11:06:14:41:47]: Info: Registered Sunshine Gamestream service
[2022:11:06:14:41:48]: Debug: Found device: http://192.168.188.101:49000/igddesc.xml
[2022:11:06:14:41:48]: Debug: Found device: http://192.168.188.1:49000/igddesc.xml
[2022:11:06:14:41:48]: Debug: Found valid IGD device: http://192.168.188.1:49000/igddesc.xml
[2022:11:06:14:41:48]: Debug: Found external ip: 45.84.27.44
[2022:11:06:14:42:51]: Debug: TUNNEL :: NONE
[2022:11:06:14:42:51]: Debug: METHOD :: GET
[2022:11:06:14:42:51]: Debug: DESTINATION :: /serverinfo
[2022:11:06:14:42:51]: Debug: Accept -- */*
[2022:11:06:14:42:51]: Debug: Host -- 192.168.188.15:47989
[2022:11:06:14:42:51]: Debug:  [--]
[2022:11:06:14:42:51]: Debug: uuid -- 7f399361-1e87-4380-80c7-5550d61d6c0a
[2022:11:06:14:42:51]: Debug: uniqueid -- 0123456789ABCDEF
[2022:11:06:14:42:51]: Debug:  [--]
[2022:11:06:14:42:51]: Info: /CN=NVIDIA GameStream Client -- verified
[2022:11:06:14:42:51]: Debug: TUNNEL :: HTTPS
[2022:11:06:14:42:51]: Debug: METHOD :: GET
[2022:11:06:14:42:51]: Debug: DESTINATION :: /serverinfo
[2022:11:06:14:42:51]: Debug: Accept -- */*
[2022:11:06:14:42:51]: Debug: Host -- 192.168.188.15:47984
[2022:11:06:14:42:51]: Debug:  [--]
[2022:11:06:14:42:51]: Debug: uuid -- 6775d029-396b-4c8e-a9c9-25a6e9ef596e
[2022:11:06:14:42:51]: Debug: uniqueid -- 0123456789ABCDEF
[2022:11:06:14:42:51]: Debug:  [--]
[2022:11:06:14:42:51]: Info: /CN=NVIDIA GameStream Client -- verified
[2022:11:06:14:42:51]: Debug: TUNNEL :: HTTPS
[2022:11:06:14:42:51]: Debug: METHOD :: GET
[2022:11:06:14:42:51]: Debug: DESTINATION :: /applist
[2022:11:06:14:42:51]: Debug: Accept -- */*
[2022:11:06:14:42:51]: Debug: Host -- 192.168.188.15:47984
[2022:11:06:14:42:51]: Debug:  [--]
[2022:11:06:14:42:51]: Debug: uuid -- 33977145-c50f-47c1-b5ee-e761c4376d81
[2022:11:06:14:42:51]: Debug: uniqueid -- 0123456789ABCDEF
[2022:11:06:14:42:51]: Debug:  [--]
[2022:11:06:14:42:51]: Info: /CN=NVIDIA GameStream Client -- verified
[2022:11:06:14:42:51]: Debug: TUNNEL :: HTTPS
[2022:11:06:14:42:51]: Debug: METHOD :: GET
[2022:11:06:14:42:51]: Debug: DESTINATION :: /launch
[2022:11:06:14:42:51]: Debug: Accept -- */*
[2022:11:06:14:42:51]: Debug: Host -- 192.168.188.15:47984
[2022:11:06:14:42:51]: Debug:  [--]
[2022:11:06:14:42:51]: Debug: localAudioPlayMode -- 0
[2022:11:06:14:42:51]: Debug: gcmap -- 1
[2022:11:06:14:42:51]: Debug: remoteControllersBitmap -- 1
[2022:11:06:14:42:51]: Debug: rikeyid -- 209517920
[2022:11:06:14:42:51]: Debug: surroundAudioInfo -- 196610
[2022:11:06:14:42:51]: Debug: rikey -- a8b256b41a29c9d9450fe38d0e8d95ef
[2022:11:06:14:42:51]: Debug: sops -- 0
[2022:11:06:14:42:51]: Debug: mode -- 1920x1080x60
[2022:11:06:14:42:51]: Debug: appid -- 5
[2022:11:06:14:42:51]: Debug: uuid -- 730f2ccc-5235-4734-a27d-e22362b1837b
[2022:11:06:14:42:51]: Debug: additionalStates -- 1
[2022:11:06:14:42:51]: Debug: uniqueid -- 0123456789ABCDEF
[2022:11:06:14:42:51]: Debug:  [--]
[2022:11:06:14:42:51]: Info: Executing: [D:\Spiele\Emulation\DuckStation\duckstation-nogui-x64-ReleaseLTCG.exe]
[2022:11:06:14:42:51]: Debug: handle_read(): Handle read of size: 89 bytes
[2022:11:06:14:42:51]: Debug: handle_payload(): Handle read of size: 0 bytes
[2022:11:06:14:42:51]: Debug: type [REQUEST]
[2022:11:06:14:42:51]: Debug: sequence number [1]
[2022:11:06:14:42:51]: Debug: protocol :: RTSP/1.0
[2022:11:06:14:42:51]: Debug: payload ::
[2022:11:06:14:42:51]: Debug: command :: OPTIONS
[2022:11:06:14:42:51]: Debug: target :: rtsp://0.0.0.0:48010
[2022:11:06:14:42:51]: Debug: CSeq ::  1
[2022:11:06:14:42:51]: Debug: X-GS-ClientVersion ::  14
[2022:11:06:14:42:51]: Debug: Host ::  0.0.0.0
[2022:11:06:14:42:51]: Debug: ---Begin MessageBuffer---
OPTIONS
---End MessageBuffer---
[2022:11:06:14:42:51]: Debug: ---Begin Response---
RTSP/1.0 200 OK
CSeq: 1



---End Response---
[2022:11:06:14:42:51]: Debug: handle_read(): Handle read of size: 165 bytes
[2022:11:06:14:42:51]: Debug: handle_payload(): Handle read of size: 0 bytes
[2022:11:06:14:42:51]: Debug: type [REQUEST]
[2022:11:06:14:42:51]: Debug: sequence number [2]
[2022:11:06:14:42:51]: Debug: protocol :: RTSP/1.0
[2022:11:06:14:42:51]: Debug: payload ::
[2022:11:06:14:42:51]: Debug: command :: DESCRIBE
[2022:11:06:14:42:51]: Debug: target :: rtsp://0.0.0.0:48010
[2022:11:06:14:42:51]: Debug: CSeq ::  2
[2022:11:06:14:42:51]: Debug: X-GS-ClientVersion ::  14
[2022:11:06:14:42:51]: Debug: Host ::  0.0.0.0
[2022:11:06:14:42:51]: Debug: Accept ::  application/sdp
[2022:11:06:14:42:51]: Debug: If-Modified-Since ::  Thu, 01 Jan 1970 00:00:00 GMT
[2022:11:06:14:42:51]: Debug: ---Begin MessageBuffer---
DESCRIBE
---End MessageBuffer---
[2022:11:06:14:42:51]: Debug: ---Begin Response---
RTSP/1.0 200 OK
CSeq: 2


a=fmtp:97 surround-params=21101
a=fmtp:97 surround-params=642012435
a=fmtp:97 surround-params=660012345
a=fmtp:97 surround-params=85301233456
a=fmtp:97 surround-params=88001233456

---End Response---
[2022:11:06:14:42:51]: Debug: handle_read(): Handle read of size: 183 bytes
[2022:11:06:14:42:51]: Debug: handle_payload(): Handle read of size: 0 bytes
[2022:11:06:14:42:51]: Debug: type [REQUEST]
[2022:11:06:14:42:51]: Debug: sequence number [3]
[2022:11:06:14:42:51]: Debug: protocol :: RTSP/1.0
[2022:11:06:14:42:51]: Debug: payload ::
[2022:11:06:14:42:51]: Debug: command :: SETUP
[2022:11:06:14:42:51]: Debug: target :: streamid=audio/0/0
[2022:11:06:14:42:51]: Debug: CSeq ::  3
[2022:11:06:14:42:51]: Debug: X-GS-ClientVersion ::  14
[2022:11:06:14:42:51]: Debug: Host ::  0.0.0.0
[2022:11:06:14:42:51]: Debug: Transport ::  unicast;X-GS-ClientPort=50000-50001
[2022:11:06:14:42:51]: Debug: If-Modified-Since ::  Thu, 01 Jan 1970 00:00:00 GMT
[2022:11:06:14:42:51]: Debug: ---Begin MessageBuffer---
SETUP
---End MessageBuffer---
[2022:11:06:14:42:51]: Debug: ---Begin Response---
RTSP/1.0 200 OK
CSeq: 3
Session: DEADBEEFCAFE;timeout = 90
Transport: server_port=48000



---End Response---
[2022:11:06:14:42:51]: Debug: handle_read(): Handle read of size: 207 bytes
[2022:11:06:14:42:51]: Debug: handle_payload(): Handle read of size: 0 bytes
[2022:11:06:14:42:51]: Debug: type [REQUEST]
[2022:11:06:14:42:51]: Debug: sequence number [4]
[2022:11:06:14:42:51]: Debug: protocol :: RTSP/1.0
[2022:11:06:14:42:51]: Debug: payload ::
[2022:11:06:14:42:51]: Debug: command :: SETUP
[2022:11:06:14:42:51]: Debug: target :: streamid=video/0/0
[2022:11:06:14:42:51]: Debug: CSeq ::  4
[2022:11:06:14:42:51]: Debug: X-GS-ClientVersion ::  14
[2022:11:06:14:42:51]: Debug: Host ::  0.0.0.0
[2022:11:06:14:42:51]: Debug: Session ::   DEADBEEFCAFE
[2022:11:06:14:42:51]: Debug: Transport ::  unicast;X-GS-ClientPort=50000-50001
[2022:11:06:14:42:51]: Debug: If-Modified-Since ::  Thu, 01 Jan 1970 00:00:00 GMT
[2022:11:06:14:42:51]: Debug: ---Begin MessageBuffer---
SETUP
---End MessageBuffer---
[2022:11:06:14:42:51]: Debug: ---Begin Response---
RTSP/1.0 200 OK
CSeq: 4
Session: DEADBEEFCAFE;timeout = 90
Transport: server_port=47998



---End Response---
[2022:11:06:14:42:51]: Debug: handle_read(): Handle read of size: 210 bytes
[2022:11:06:14:42:51]: Debug: handle_payload(): Handle read of size: 0 bytes
[2022:11:06:14:42:51]: Debug: type [REQUEST]
[2022:11:06:14:42:51]: Debug: sequence number [5]
[2022:11:06:14:42:51]: Debug: protocol :: RTSP/1.0
[2022:11:06:14:42:51]: Debug: payload ::
[2022:11:06:14:42:51]: Debug: command :: SETUP
[2022:11:06:14:42:51]: Debug: target :: streamid=control/13/0
[2022:11:06:14:42:51]: Debug: CSeq ::  5
[2022:11:06:14:42:51]: Debug: X-GS-ClientVersion ::  14
[2022:11:06:14:42:51]: Debug: Host ::  0.0.0.0
[2022:11:06:14:42:51]: Debug: Session ::   DEADBEEFCAFE
[2022:11:06:14:42:51]: Debug: Transport ::  unicast;X-GS-ClientPort=50000-50001
[2022:11:06:14:42:51]: Debug: If-Modified-Since ::  Thu, 01 Jan 1970 00:00:00 GMT
[2022:11:06:14:42:51]: Debug: ---Begin MessageBuffer---
SETUP
---End MessageBuffer---
[2022:11:06:14:42:51]: Debug: ---Begin Response---
RTSP/1.0 200 OK
CSeq: 5
Session: DEADBEEFCAFE;timeout = 90
Transport: server_port=47999



---End Response---
[2022:11:06:14:42:51]: Debug: handle_read(): Handle read of size: 1483 bytes
[2022:11:06:14:42:51]: Debug: handle_payload(): Handle read of size: 1315 bytes
[2022:11:06:14:42:51]: Debug: Found Content-Length:  1315 bytes
[2022:11:06:14:42:51]: Debug: type [REQUEST]
[2022:11:06:14:42:51]: Debug: sequence number [6]
[2022:11:06:14:42:51]: Debug: protocol :: RTSP/1.0
[2022:11:06:14:42:51]: Debug: payload :: v=0
o=android 0 14 IN IPv4 192.168.188.15
s=NVIDIA Streaming Client
a=x-nv-video[0].clientViewportWd:1920
a=x-nv-video[0].clientViewportHt:1080
a=x-nv-video[0].maxFPS:60
a=x-nv-video[0].packetSize:1392
a=x-nv-video[0].rateControlMode:4
a=x-nv-video[0].timeoutLengthMs:7000
a=x-nv-video[0].framesWithInvalidRefThreshold:0
a=x-nv-video[0].initialBitrateKbps:12500
a=x-nv-video[0].initialPeakBitrateKbps:12500
a=x-nv-vqos[0].bw.minimumBitrateKbps:12500
a=x-nv-vqos[0].bw.maximumBitrateKbps:12500
a=x-nv-vqos[0].fec.enable:1
a=x-nv-vqos[0].videoQualityScoreUpdateTime:5000
a=x-nv-vqos[0].qosTrafficType:5
a=x-nv-aqos.qosTrafficType:4
a=x-nv-general.featureFlags:167
a=x-nv-general.useReliableUdp:13
a=x-nv-vqos[0].fec.minRequiredFecPackets:2
a=x-nv-vqos[0].drc.enable:0
a=x-nv-general.enableRecoveryMode:0
a=x-nv-video[0].videoEncoderSlicesPerFrame:1
a=x-nv-clientSupportHevc:0
a=x-nv-vqos[0].bitStreamFormat:0
a=x-nv-video[0].dynamicRangeMode:0
a=x-nv-video[0].maxNumReferenceFrames:1
a=x-nv-video[0].clientRefreshRateX100:0
a=x-nv-audio.surround.numChannels:2
a=x-nv-audio.surround.channelMask:3
a=x-nv-audio.surround.enable:0
a=x-nv-audio.surround.AudioQuality:0
a=x-nv-aqos.packetDuration:5
a=x-nv-video[0].encoderCscMode:0
t=0 0
m=video 47998
[2022:11:06:14:42:51]: Debug: command :: ANNOUNCE
[2022:11:06:14:42:51]: Debug: target :: streamid=control/13/0
[2022:11:06:14:42:51]: Debug: CSeq ::  6
[2022:11:06:14:42:51]: Debug: X-GS-ClientVersion ::  14
[2022:11:06:14:42:51]: Debug: Host ::  0.0.0.0
[2022:11:06:14:42:51]: Debug: Session ::   DEADBEEFCAFE
[2022:11:06:14:42:51]: Debug: Content-type ::  application/sdp
[2022:11:06:14:42:51]: Debug: Content-length ::  1315
[2022:11:06:14:42:51]: Debug: ---Begin MessageBuffer---
ANNOUNCE
---End MessageBuffer---
[2022:11:06:14:42:51]: Debug: ---Begin Response---
RTSP/1.0 200 OK
CSeq: 6



---End Response---
[2022:11:06:14:42:51]: Debug: handle_read(): Handle read of size: 91 bytes
[2022:11:06:14:42:51]: Debug: handle_payload(): Handle read of size: 0 bytes
[2022:11:06:14:42:51]: Debug: type [REQUEST]
[2022:11:06:14:42:51]: Debug: sequence number [7]
[2022:11:06:14:42:51]: Debug: protocol :: RTSP/1.0
[2022:11:06:14:42:51]: Debug: payload ::
[2022:11:06:14:42:51]: Debug: command :: PLAY
[2022:11:06:14:42:51]: Debug: target :: /
[2022:11:06:14:42:51]: Debug: CSeq ::  7
[2022:11:06:14:42:51]: Debug: X-GS-ClientVersion ::  14
[2022:11:06:14:42:51]: Debug: Host ::  0.0.0.0
[2022:11:06:14:42:51]: Debug: Session ::   DEADBEEFCAFE
[2022:11:06:14:42:51]: Debug: ---Begin MessageBuffer---
PLAY
---End MessageBuffer---
[2022:11:06:14:42:51]: Debug: ---Begin Response---
RTSP/1.0 200 OK
CSeq: 7



---End Response---
[2022:11:06:14:42:51]: Info: CLIENT CONNECTED
[2022:11:06:14:42:51]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:42:51]: Debug: type [IDX_START_B]
[2022:11:06:14:42:51]: Debug: RAISE: 192.168.188.137:45934 :: VIDEO
[2022:11:06:14:42:51]: Debug: Received ping from 192.168.188.137:45934 [474E4950]
[2022:11:06:14:42:51]: Debug: Start capturing Video
[2022:11:06:14:42:51]: Debug: Detecting monitors...
[2022:11:06:14:42:51]: Debug:
====== ADAPTER =====
Device Name      : Intel(R) UHD Graphics 750
Device Vendor ID : 0x00008086
Device Device ID : 0x00004C8A
Device Video Mem : 128 MiB
Device Sys Mem   : 0 MiB
Share Sys Mem    : 65401 MiB

    ====== OUTPUT ======
[2022:11:06:14:42:51]: Debug:     Output Name       : \\.\DISPLAY1
    AttachedToDesktop : yes
    Resolution        : 1920x1200

[2022:11:06:14:42:51]: Debug:
====== ADAPTER =====
Device Name      : Microsoft Basic Render Driver
Device Vendor ID : 0x00001414
Device Device ID : 0x0000008C
Device Video Mem : 0 MiB
Device Sys Mem   : 0 MiB
Share Sys Mem    : 65401 MiB

    ====== OUTPUT ======
[2022:11:06:14:42:51]: Debug: --begin relative mouse move packet--
deltaX [1]
deltaY [1]
--end relative mouse move packet--
[2022:11:06:14:42:51]: Debug: --begin relative mouse move packet--
deltaX [-1]
deltaY [-1]
--end relative mouse move packet--
[2022:11:06:14:42:51]: Info:
Device Description : Intel(R) UHD Graphics 750
Device Vendor ID   : 0x00008086
Device Device ID   : 0x00004C8A
Device Video Mem   : 128 MiB
Device Sys Mem     : 0 MiB
Share Sys Mem      : 65401 MiB
Feature Level      : 0x0000B100
Capture size       : 1920x1200
Offset             : 0x0
Virtual Desktop    : 1920x1200
[2022:11:06:14:42:51]: Debug: Source format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2022:11:06:14:42:51]: Info: Color coding [Rec. 601]
[2022:11:06:14:42:51]: Info: Color range: [MPEG]
[2022:11:06:14:42:52]: Debug: RAISE: 192.168.188.137:43421 :: AUDIO
[2022:11:06:14:42:52]: Debug: Received ping from 192.168.188.137:43421 [474E4950]
[2022:11:06:14:42:52]: Debug: Start capturing Audio
[2022:11:06:14:42:52]: Debug: Couldn't initialize audio client for [Mono]: [0x88890008]
[2022:11:06:14:42:52]: Debug: Mono: unsupported
[2022:11:06:14:42:52]: Debug: Stereo: supported
[2022:11:06:14:42:52]: Debug: Couldn't initialize audio client for [Mono]: [0x88890008]
[2022:11:06:14:42:52]: Debug: Mono: unsupported
[2022:11:06:14:42:52]: Debug: Stereo: supported
[2022:11:06:14:42:52]: Debug: Couldn't initialize audio client for [Mono]: [0x88890008]
[2022:11:06:14:42:52]: Debug: Mono: unsupported
[2022:11:06:14:42:52]: Debug: Stereo: supported
[2022:11:06:14:42:52]: Debug: Trying audio format [Mono]
[2022:11:06:14:42:52]: Debug: Couldn't initialize audio client for [Mono]: [0x88890008]
[2022:11:06:14:42:52]: Debug: Trying audio format [Stereo]
[2022:11:06:14:42:52]: Debug: Found audio format [Stereo]
[2022:11:06:14:42:52]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:42:52]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:02]: Debug: largeMotor: 0
smallMotor: 0
[2022:11:06:14:43:02]: Debug: largeMotor: 0
smallMotor: 0
[2022:11:06:14:43:02]: Debug: largeMotor: 0
smallMotor: 0
[2022:11:06:14:43:02]: Debug: largeMotor: 0
smallMotor: 0
[2022:11:06:14:43:02]: Debug: Send gamepadnr [0] with lowfreq [0] and highfreq [0]
[2022:11:06:14:43:02]: Debug: Send gamepadnr [0] with lowfreq [0] and highfreq [0]
[2022:11:06:14:43:02]: Debug: Send gamepadnr [0] with lowfreq [0] and highfreq [0]
[2022:11:06:14:43:02]: Debug: Send gamepadnr [0] with lowfreq [0] and highfreq [0]
[2022:11:06:14:43:04]: Debug: largeMotor: 0
smallMotor: 0
[2022:11:06:14:43:04]: Debug: Send gamepadnr [0] with lowfreq [0] and highfreq [0]
[2022:11:06:14:43:06]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:07]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:07]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:07]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:08]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:08]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:08]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:25]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:26]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:31]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:31]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:36]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:36]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:37]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:37]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:38]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:40]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:41]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:47]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:47]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:47]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:48]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:52]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:53]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:54]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:54]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:56]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:57]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:57]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:43:58]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:02]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:02]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:07]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:10]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:10]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:10]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:10]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:11]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:12]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:12]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:13]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:13]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:13]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:14]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:15]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:15]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:15]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:15]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:15]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:18]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:18]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:18]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:18]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:18]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:18]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:19]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:19]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:20]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:22]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:25]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:25]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:25]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:26]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:26]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:29]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:29]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:31]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:31]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:31]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:35]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:36]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:36]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:36]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:36]: Debug: type [IDX_REQUEST_IDR_FRAME]
[2022:11:06:14:44:39]: Info: CLIENT DISCONNECTED
[2022:11:06:14:44:39]: Debug: Waiting for video to end...
[2022:11:06:14:44:39]: Debug: Waiting for audio to end...
[2022:11:06:14:44:39]: Debug: Waiting for control to end...
[2022:11:06:14:44:39]: Debug: Resetting Input...
[2022:11:06:14:44:39]: Debug: Removing references to any connections...
[2022:11:06:14:44:39]: Debug: Session ended
[2022:11:06:14:44:39]: Debug: Waiting for main listening thread to end...
[2022:11:06:14:44:39]: Debug: Waiting for main video thread to end...
[2022:11:06:14:44:39]: Debug: Waiting for main audio thread to end...
[2022:11:06:14:44:39]: Debug: Waiting for main control thread to end...
[2022:11:06:14:44:39]: Debug: All broadcasting threads ended
@ReenigneArcher ReenigneArcher added help wanted Extra attention is needed os:Windows:10 labels Nov 6, 2022
psyke83 added a commit to psyke83/SunshineStream that referenced this issue Nov 7, 2022
If the libx264 encoder is configured to use >4 slices, the existing
bufsize (bitrate / framerate) is set too low, causing a quality
degradation and failure for the encoder to attain the target bitrate.

A previous commit set this to a larger value (bitrate / 2), but this
seemed to cause issues with the RPI3 hardware decoder; see: LizardByte#478

Ref: https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate
"Specifying too small -bufsize would cause ffmpeg to degrade the output image quality, because it would have to (frequently) conform to the limitations and would not have enough of a free space to use some optimizations (for example, optimizations based on the frame repetitions and similar), because the buffer would not contain enough frames for the optimizations to be effective."
psyke83 added a commit to psyke83/SunshineStream that referenced this issue Nov 7, 2022
If the libx264 encoder is configured to use >4 slices, the existing
bufsize (bitrate / framerate) is set too low, causing a quality
degradation and failure for the encoder to attain the target bitrate.

A previous commit set this to a larger value (bitrate / 10), but this
seemed to cause issues with the RPI3 hardware decoder; see: LizardByte#478

Ref: https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate
"Specifying too small -bufsize would cause ffmpeg to degrade the output image quality, because it would have to (frequently) conform to the limitations and would not have enough of a free space to use some optimizations (for example, optimizations based on the frame repetitions and similar), because the buffer would not contain enough frames for the optimizations to be effective."
@psyke83
Copy link
Collaborator

psyke83 commented Nov 7, 2022

Hi,

Can you see if #482 will fix your issue? Keep in mind that the PR will also revert the change to the bitrate calculation, so you may need to decrease the bitrate in your client to compensate.

I've set the PR to draft status, so I'm not sure if it will produce build artifacts that you can use to test if you can't run a local build.

@ReenigneArcher
Copy link
Member

I'm running the PR now, it will generate artifacts that can be used to test.

@Forusim
Copy link
Author

Forusim commented Nov 8, 2022

Thanks for prompt solution proposal.
I tested with the build from https://github.com/LizardByte/Sunshine/actions/runs/3406969437 and have to say, that the shuttering is reduced significantly. We are definitive on the right track here, but it still happens every ~10 seconds for few frames.
It is noticeable on jumping in a game, where the camera is following up the character. So for platforming games I would still prefer 0.11.1 over the current version.

No sure, if there are bitrate and rc_buffer_size values, which fits all demands?
Would it be possible to make a parameter for it?

@psyke83
Copy link
Collaborator

psyke83 commented Nov 8, 2022

My understanding of bufsize is that the size represents the interval of bytes in which the encoder checks to see if the current bitrate is matching the expected maxrate, and thus makes the appropriate changes to make future bitrate conform to the limit. If it's set too low, it seems to cause major quality issues with the libx264 encoder, especially if using many slices/threads, and I don't believe there's an arbitrary static value that can/should set in the interface, as the optimal value depends on the bitrate of the stream.

I would suggest that you test 0.11.1 vs this PR on a Windows or Linux desktop client configured to use the same bitrate as your RPI3, while monitoring the average incoming bandwidth. It's possible that 0.11.1 works better simply because you are not attaining the client-requested bitrate that you're expecting (which is what the bufsize increase effectively fixes). If so, the solution may simply be to reduce the bitrate in your RPI3 client until it performs similarly to the older build.

I have a headless RPI3 that I can make available for testing, but it would help if you could let me know more details about your setup (e.g. Raspberry Pi OS version, if you're using the 64bit or legacy build, if you run Moonlight embedded from desktop or if it's a RetroPie packaged build, etc.).

If you can run a build, perhaps try ctx->rc_buffer_size = bitrate / ((config.framerate * 10) / 15);?

psyke83 added a commit to psyke83/SunshineStream that referenced this issue Nov 8, 2022
…4 slice count

If the libx264 encoder is configured to use >4 slices, the existing
bufsize (bitrate / framerate) is set too low, causing a quality
degradation and failure for the encoder to attain the target bitrate.

A previous commit set this to a larger value (bitrate / 10), but this
seemed to cause issues with the RPI3 hardware decoder; see: LizardByte#478

Ref: https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate
"Specifying too small -bufsize would cause ffmpeg to degrade the output image quality, because it would have to (frequently) conform to the limitations and would not have enough of a free space to use some optimizations (for example, optimizations based on the frame repetitions and similar), because the buffer would not contain enough frames for the optimizations to be effective."
@psyke83
Copy link
Collaborator

psyke83 commented Nov 8, 2022

I've done more testing. With 16 threads (worst case scenario), capturing 1080p @ 12.5Mbps / 60FPS:

  • bitrate / framerate: average of 6.5Mbps
  • bitrate / (framerate / 2): average bitrate of 15.5MBps
  • bitrate / (framerate / 1.5): average bitrate of 13.5MBps

I tested other intermediary values, and the throttling effect occurs to some degree from 1.1x to 1.4x, so I believe this is the best we can do. Since the 1.5x value seems to get us closer to the target bitrate than 2.0x without noticeable thottling in the worst case of 16 threads, I've updated the PR.

If you still have problems with the new version of the PR, keep in mind that your actual bitrate on 0.11.1 could have been peaking as low as ~7Mbps (depending on your thread count), so you may still have to reduce the bitrate in your client further.

@Forusim
Copy link
Author

Forusim commented Nov 8, 2022

I have also done some testing with https://github.com/LizardByte/Sunshine/actions/runs/3415758658 and was able to achieve the same fluent stream as with 0.11.1.
I needed to reduce the moonlight bitrate to 12500 / 1.5 ~ 8500 as per your above math.
What would be the impact on the picture quality by this bitrate reduction or is there none due to how the bitrate is calculated in sunshine?
Why would the rpi3 struggle to stream above 7 Mbps, whereas it plays 3D Bluray Remuxes (~ 30 Mbps) over the same network via Kodi without issues?

@psyke83
Copy link
Collaborator

psyke83 commented Nov 8, 2022

Have you tried monitoring bandwidth to confirm the real average incoming bitrate on 0.11.1? That would be a good first step. Regardless, I agree that the Pi 3 should be capable of much better performance. Perhaps your client is not using hardware decoding for some reason?

@Forusim
Copy link
Author

Forusim commented Nov 9, 2022

I was not able to directly monitor the bandwidth on the rpi3 due to lack of tools in the recalbox buildroot. However from my Windows 10 host I see ~ 5 Mbps upload to rpi3 on both 0.11.1 and the DEV versions. CPU utilization on rpi3 is in both cases ~2%.
Amazing how such low bandwidth is capable to stream very readable desktop at 1080p@60fps with AVC. From my perception the PQ on 0.11.1 with 12500 and DEV with 8500 kbit are equally good to very good.
If there are no other side effects, I would be happy with the latest adjustments.

@Forusim
Copy link
Author

Forusim commented Nov 9, 2022

Before closing the issue, I have one more question:
Reading through the PR33 I don´t fully understand the background, but read about dependency on threads/slices and negative impact if there is too much of those.
Wouldn´t it make sense to include slices/threads into the formula instead of fixed constant 1.5?

@ReenigneArcher
Copy link
Member

Before closing the issue

Please don't close the issue. We will close it automatically when it's resolved. For now this fix is not even part of the Sunshine code base.

psyke83 added a commit to psyke83/SunshineStream that referenced this issue Nov 17, 2022
…4 slice count

If the libx264 encoder is configured to use >4 slices, the existing
bufsize (bitrate / framerate) is set too low, causing a quality
degradation and failure for the encoder to attain the target bitrate.

A previous commit set this to a larger value (bitrate / 10), but this
seemed to cause issues with the RPI3 hardware decoder; see: LizardByte#478

Ref: https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate
"Specifying too small -bufsize would cause ffmpeg to degrade the output image quality, because it would have to (frequently) conform to the limitations and would not have enough of a free space to use some optimizations (for example, optimizations based on the frame repetitions and similar), because the buffer would not contain enough frames for the optimizations to be effective."
ReenigneArcher pushed a commit to psyke83/SunshineStream that referenced this issue Dec 15, 2022
…4 slice count

If the libx264 encoder is configured to use >4 slices, the existing
bufsize (bitrate / framerate) is set too low, causing a quality
degradation and failure for the encoder to attain the target bitrate.

A previous commit set this to a larger value (bitrate / 10), but this
seemed to cause issues with the RPI3 hardware decoder; see: LizardByte#478

Ref: https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate
"Specifying too small -bufsize would cause ffmpeg to degrade the output image quality, because it would have to (frequently) conform to the limitations and would not have enough of a free space to use some optimizations (for example, optimizations based on the frame repetitions and similar), because the buffer would not contain enough frames for the optimizations to be effective."
@ReenigneArcher ReenigneArcher added fixed This issue has been fixed and will be available in the next release. and removed help wanted Extra attention is needed labels Dec 15, 2022
@LizardByte-bot
Copy link
Member

This issue has been fixed and will be available in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed This issue has been fixed and will be available in the next release. os:Windows OS is Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants