OneLiberty / moonlight-chrome-tizen

A WASM port of Moonlight for Samsung Smart TV's running Tizen OS (5.5 and up)
GNU General Public License v3.0
185 stars 15 forks source link

Some TV's skip frames and have high input lag when set to higher Mbps network speed #20

Open Neverwinterx opened 6 months ago

Neverwinterx commented 6 months ago

This is not really an issue with your code/docker itself. I just want to put this out here, so people can find it if they encounter the same problem.

If you encounter high input lag, or see the TV skip frames (for example in a 2D platformer it will look like your character teleports a bit), then try lowering the Mbps network speed in the Moonlight client.

I had this issue occurring for me when I had it set to 100Mbps, in combination with the Sunshine server. I didn't have the problem when I was using Geforce experience to stream, my guess is that Geforce experience server doesn't really fully listen to the Mbps network setting on the client side.

Setting it to 60Mbps solved it for me. And it's definitely not an issue with the server pc setup or local network. My pc is highend (14900K + RTX 4090) and it has a wired network connection, and the network works fine for everything else.

If I look it up, you can find that most TV's support at most 100Mbps network speed (some seem to confuse this with the video bitrate they can handle, that is not the same). But that's probably the theoretical upper limit of their network adapter. What they can really handle is probably a bit lower. My guess is that the TV can't handle (either the network adapter itself, or perhaps the internal processor) the higher network speed and gets overwhelmed by the amount of network packets and starts dropping packets or gets network buffer problems And my tv is a recent S95C, QD-OLED. An internet speedtest in the samsung browser app on my TV shows a measured internet download speed that starts at 50Mbps and then ends at around 90Mbps, while the exact same internet speedtest on my pc goes to 290Mbps (the limit of my internet connection).

@OneLiberty You may want to put a warning for this in the readme, or perhaps even in the GUI when you select the network speed. I wouldn't fully block higher Mbps network speed, TV's in the future may support it.

Karabacak021 commented 6 months ago

There you can check the video bitrate specification for your TV: First find the model group there https://developer.samsung.com/smarttv/develop/specifications/tv-model-groups.html

I'm not sure, but maybe it is the 23TV_PREMIUM3

Then you can check the bitrate there: https://developer.samsung.com/smarttv/develop/specifications/media-specifications/2023-tv-video-specifications.html

Neverwinterx commented 6 months ago

There you can check the video bitrate specification for your TV: First find the model group there https://developer.samsung.com/smarttv/develop/specifications/tv-model-groups.html

I'm not sure, but maybe it is the 23TV_PREMIUM3

Then you can check the bitrate there: https://developer.samsung.com/smarttv/develop/specifications/media-specifications/2023-tv-video-specifications.html

In that link is not clear though whether they are talking about video bitrate and network bitrate. Those are not necessarily the same thing. They may overlap, but not necessarily. The way it's worded with "This topic describes the media formats supported by Samsung Smart TV, and the limitations on their support." and "Media with higher bit or frame rate than specifications can cause video or audio playback to stall." makes me think they are talking specifically about video bitrate. And then it doesn't have to mean you can pull that video bitrate over wired network to the TV. But looking at that table, my point is moot, because all max video bitrates they can handle stay below the 100Mbps network hardware limit of most TV's and the One Connect box. So you will hit the video bitrate limit currently before you can hit their network limit.

It's interesting that I can see by monitoring the send rate in Windows of the network on the host pc, that the actual network Mbps send rate of the host is quite a bit higher than the Mbps set in the Moonlight client (up to 72 Mbps send rate on host when set to 60 on the client side).

OneLiberty commented 6 months ago

@Neverwinterx On the client, Mbps refers to the video bitrate, not the internet speed. Also, while it is true that the ethernet controller is limited to 100mbps, some tvs can go a bit higher than that using wifi (probably 150mbps).

I might update it to say it's the video bitrate and not the internet speed. Also, setting it to 100mpbs is in most cases a bad idea for current TVs.

Neverwinterx commented 6 months ago

@Neverwinterx On the client, Mbps refers to the video bitrate, not the internet speed. Also, while it is true that the ethernet controller is limited to 100mbps, some tvs can go a bit higher than that using wifi (probably 150mbps).

I might update it to say it's the video bitrate and not the internet speed. Also, setting it to 100mpbs is in most cases a bad idea for current TVs.

Thanks that clarifies. By the way is there any way to enable an onscreen performance stats with things like client frame rate, network drops etc? Some other moonlight clients have that, and I think it would help in troubleshooting many problems.

hot22shot commented 6 months ago

I just bought a S90C and I wondered if it was best to use wired ethernet plug maxed at 100MB instead of the Wifi5 that should be able to go much higher.

OneLiberty commented 6 months ago

@Neverwinterx Nope, not yet. Probably in the future, don't know when tho. For now debug logs does the trick

@hot22shot i'll say ethernet, as latency can be lower

Neverwinterx commented 6 months ago

@Neverwinterx Nope, not yet. Probably in the future, don't know when tho. For now debug logs does the trick

There seems to be some fluctuation/variation depending on the content of the actual bitrate the tv can handle, or the actual bitrate that is being transmitted by the sunshine server. Have you experienced that? My PC has an nvidia card, and sunshine server set to nvenc P1. I had moonlight on tv set to HEVC Main 10, 4K and 60fps and no HDR. According to spec, TV should be able to handle 80Mbps at those settings. I had it set to 77Mbps to on the safe side, and that seemed to be working fine in most games at same settings. And yet now I'm playing A Plague Tale: Requiem and there I noticed some stutter and slight input delay. I've lowered to 70Mbps and then still had slight stutter, and lowered even further to 60Mbps and now it seems fine.

I could try to lower the video bitrate on moonlight on the TV, and raise the nvenc instead of P1 to higher values. Although to be honest I'm not sure if it really matters for me, I didn't really notice anything to image quality when I lowered to 60Mbps. Most video downloads on the internet have lower bitrates than that. Only raw bluray in exceptional movies goes beyong that as far as I read.

OneLiberty commented 6 months ago

I don't exactly know why, but it might be because even though TVs can handle 80mbps video streaming (and i assume some audio at the same time) it should be close to a full usage of the CPU. Add Networking and input, and somethings must be dropped for the tv to follow. This is the reason why i'm looking for a way to show rendered fps on the app before adding 120fps options.

That's just a wild guess.

But yeah, i think 60mbps is plenty enough to get a nice stream going.

Neverwinterx commented 4 months ago

Update: I still notice some stutter / choppyness when playing Plague Tale Requiem on 4K 60 fps 60Mbps on HEVC Main 10 and sunshine nvenc set to P1 and HDR off. I don't really notice any input lag. The fps on my hosting pc itself is fine and I don't see the same stutter when playing locally on that pc, so it has to do with the streaming. I've tried various things like lowering the bitrate, changing to H264 and enabling/disabling frame pacing. None of those help, except lowering the resolution to 1440p, that definitely resolves it. And I'm not sure what the actual cause of that is or where the problem really lies. Like mentioned above the hosting pc can handle it. Is the tv not able to handle 4K? But the TV should be able to handle that just fine, it can handle 4K HEVC HDR movies through Jellyfin streaming. If the bitrate is the problem, then why doesn't lowering the bitrate to 15Mbps on 4K not help? I tried starting the moonlight with the debug tools, but the console output doesn't give me any indication where the issue might lie. Any ideas?