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

Streaming to multiple users results in high CPU usage #160

Open
christian-rieger opened this issue Jul 26, 2023 · 6 comments
Open

Streaming to multiple users results in high CPU usage #160

christian-rieger opened this issue Jul 26, 2023 · 6 comments

Comments

@christian-rieger
Copy link

Hello,

I noticed when I am streaming to multiple users that my CPU usage grows proportionally, when I stream to 6 People my CPU is at 100%.

Is it possible that the stream needs to be encoded and encrypted for every viewer?
Is there anything I can do to optimize this?

Kind Regards,
Chris

@jmattheis
Copy link
Member

Yes, the user that shares their screen will encode, encrypt and upload the video stream for each connected user.

The CPU usage can be optimized by reducing the frame rate or resolution (#84).

Screego could also take responsibility for distributing the videostream, meaning the user that shares will upload the stream to screego, and screego forwards it to all connected users.
You could check out Jitsi that already has this functionality.

@JulianGro
Copy link

Yes, the user that shares their screen will encode, encrypt and upload the video stream for each connected user.

Am I understanding this right that screengo encodes the video for every viewer instead of just once?

@jmattheis
Copy link
Member

jmattheis commented Jul 29, 2023

I cannot say for sure, because this is done in the browser implementation of WebRTC, but I'd expect it is encoded for every viewer. Basically, screego obtains a MediaStream via MediaDevices#getDisplayMedia and then forwards this stream via RTCPeerConnection#addTrack.

When both peers do the WebRTC handshake, they choose a codec they both support. This means if the video is streamed to multiple peers which support different codecs, the browser has to encode it multiple times with different codecs. If the browser is smart is enough to cache the encoded stream, when another peer uses the same codec I don't know, but given the high cpu usage I'd expect it's encoded again.

@xiaguoxin
Copy link

It is true. We test it in our lab, when multiple user connected, the share screen pc almost freezed. If there are any way to fix it?

@jmattheis
Copy link
Member

Currenty not, you can use Jitsi or another sharing tool, they proxy the traffic through the server, so the one that shares the screen doesn't have to encode the video multiple times.

@wangdemon
Copy link

Currenty not, you can use Jitsi or another sharing tool, they proxy the traffic through the server, so the one that shares the screen doesn't have to encode the video multiple times.

Using other sharing tools,Can you provide an example or link

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

No branches or pull requests

5 participants