-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
Advice on solid 60fps streaming #3518
Comments
60fps is achievable with NVENC, but not at 4K, only at 1080p.
How much bandwidth do you have? 100Mbps, 1Gbps, more?
It is not in pure python at all: packet encoding and decoding is in C (Cython) via rencode and python-lz4.
Yes: #3376
This naive approach has been tried initially and it was an unmitigated disaster.
The batch delay is how long the server normally waits between each screen update it sends (when it needs to).
Correct.
In some cases it does work, which is why we have video region detection. |
I'm running on an AWS machine with 1Gbps+ so I don't think bandwidth is an issue.
The encode function in
Well, I just wonder how effective this would be at reducing jitter. I also looked at SRT, which is another UDP-based protocol meant for video streaming. It's unreliable (like UDP), but perhaps we could possibly split the packets into separate streams of video/input updates so that input is reliable over TCP and the video comes via SRT or something.
How long ago? Just as a test, I used |
Sure, but I don't think your client also runs there, does it?
Yes, that one really doesn't matter. It just dispatches to
Yes, that sounds good but it dramatically increases the logic needed for managing those network flows.
You can still test this by using strict encoding mode and forcing
The acquisition is one thing, but it's not a huge cost at 1080p, not enough to drop below 60fps. (run your server with |
I have a fiber connection and get about 170Mbps down on Google's speed test, so I don't think bandwidth is an issue.
My only concern is that it seems to be an event-based API rather than a stream-based one, which will be sort of annoying to integrate. (you mention this in the issue as well)
True, although I ran this test: Xpra
The FFPlay window appears on my client, and works "okay," but is pushing about 30fps if I had to guess. There are little stutters and in general it's workable, but not ideal. I also tried running FFmpeg directly
The FFPlay window appears and the video plays back at 60fps, 100% smoothly-- zero stutter or framerate decrease. So, both approaches use TCP and NVENC. Something must be going on in Xpra that's introducing stutter/delay. Any idea on what it could be/ways to debug? |
Raw 1080p60 consumes roughly 3Gbps (120 MPixels/s x 24-bit). Based on this, I would not be saying that bandwidth is not an issue at this point.
This is apples to oranges, but let's continue.
You can see exactly how many frames per second you're getting and which encoding is actually being used to update your screen with: xpra/xpra/client/paint_colors.py Lines 8 to 26 in f67fbd8
I don't think it is.
As per above, they're completely different.
See above, and the comment before that. ( But the starting point is always |
Ok, fair enough.
Using
I also used that configuration file which recognizes FFPlay as video, but it didn't seem to improve things. |
When I force NVENC, I get this error message in the logs:
When running both Xpra and ffplay however, I checked
Looks like only Xpra is attempting to use the GPU, so I wonder what's going wrong such that it can't use CUDA. Do you think it's misconfigured drivers or something? The entire server log is here, with more CUDA related errors: https://gist.github.com/SuperDisk/d9a575245020ebb3304038a9309b7453 |
While messing around with XPRA_PAINT_BOX, I found that sometimes the video detection will (technically correctly) find only the video region, and send that as h264 while sending the rest as (I think) webp. This actually results in really choppy/low framerate video in the video region, and the video scrubber also is quite choppy (due to being sent as webm I suppose). If I grab one of the nodes in the bottom part and jiggle it around, the entire region is detected as video and the framerate magically increases dramatically in both regions. The right and bottom edges flicker a different color which I think might be causing a small additional bit of stutter. I've noticed that when the full region is h264, and I'm moving the node around in a circle just to keep the thing detected as video, the FPS will start at around 30 and slowly "walk" up to about 50ish and then fall back down again once the bottom edge flickers pink. It continues in this cycle--is there some sort of overhead from switching between video/image, does it spin down/spin up the h264 encoder or something? You mentioned something similar about creating an NVENC context in your second comment but I didn't know if that's what you meant. Amazingly, just running with I found that when setting Notice that the chosen encoding seems to be flickering between h264 and rgb32. I would completely disable rgb32 if I could and just do only h264, but I can't due to the (I think) bug I mentioned in the previous issue comment. |
Don't do that.
Your server has no video encodings available, for whatever reason.
What do you mean? There is no way to force
This is a tricky case for the video region detection heuristics, my guess is that the top part updates more than the bottom one.
That's probably just the border of the video area which is an odd number and is therefore sent as something else (usually just
Yes.
You have
45 - you can't be idle surely? what is updating the screen? But that's still not 100% ideal, unless the other areas are also updating regularly, what you want is just the middle section as video and the rest as lossless. Just beware that these settings may be a good fit for this specific application, on this specific hardware, running over this specific connection... but that's not everyone's use case. Your logs have some serious NVENC errors which is not going to help.
This can cause choppiness, crashes, etc. |
Sure, will do tomorrow.
I'm using the package that you get from following the steps on the ubuntu installation section. I'll check out the beta version though or maybe build from source.
I specified As for speed, quality, and batch-delay, to be perfectly honest I haven't noticed much of a change when adjusting these parameters via the context menu on the tray icon. I noticed that the server is reporting an error about failing to decode the quality-change request packet, so I think maybe my requests to modify those parameters just aren't going through. I'll look more into it and create a proper bug report tomorrow as well.
Oh, well there is a 24fps video playing in the panel which is updating the screen. The FPS goes up to 60 when I start dragging the UI in a circle, which is causing more repainting I'm sure.
Do you think it would be viable to use NVIDIA's Video Processing Framework instead of the homegrown bindings to NVENC? Not sure if that would solve any problems, but their API certainly looks extremely simple. |
It does, but you should:
Perhaps. Xpra's Cython bindings were the first open-source implementation of NVENC, that was over 8 years ago. |
The ticket with changes that would help with NVENC is #3286. |
Hi, @SuperDisk |
@totaam I've been trying to build Xpra from source off the fork in #3286 using NVENC but I'm running into issues. The Ubuntu build instructions mention installing the following packages: apt-get install libnvidia-encode1 python3-numpy I'm getting this error:
Unfortunately I can't really find much information online about how to get this damn thing. It seems like at one point it was in the Ubuntu repo but now isn't? Searching for the filename yields this:
But that's just some stub I think, not the real thing. I've successfully built Xpra using those stubs but when I run Xpra, I see this error in the logs:
So, I'm missing |
Ah, I found Seems you have to manually pick one of the packages that provide it. What I'm running into now is this:
Here's the output of my
|
@SuperDisk all these questions have nothing to do with the OP's issue, please use a separate ticket for that in the future.
Looks like they've moved it:
Correct.
It uses the stubs for building and we get them from the CUDA SDK to avoid this madness with package names on all the different distros supported.
It is. You place your source in
Perhaps the structs have changed and there is a mistmatch between the version of the stubs or headers and the version of |
I originally emailed this to @totaam but he pointed me here.
I've been working on a virtualization platform for VFX software and I've been using Xpra as the front end. Ultimately the goal is to be able to maintain a solid 60fps video stream with no stutter and minimal latency. I'm currently getting the best performance using the NVEnc video encoder, but over a connection with about 30ms ping or so, the performance comes and goes-- at its best, it's decently smooth, but will often begin to stutter for seconds at a time before recovering.
First: are there any settings I can tweak which can help accomplish the goal of constant 60fps?
Second: I'm interested in doing some hacking on Xpra to improve latency/performance, but I wanted to reach out and find where the true bottlenecks are.
Some questions
Generally speaking I'm just wondering what the bottlenecks are that are causing jitter/lag currently so I can focus effort on them. Parsec, for example, works mindblowingly well in terms of latency, it really feels like you are physically in front of the remote computer. They use a custom proprietary protocol on top of UDP just for that though, but it would be awesome if Xpra could reach the same level (or at least close to it).
The text was updated successfully, but these errors were encountered: