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

Screen sharing is very laggy #21

Open
Allenille opened this issue Jan 15, 2025 · 2 comments
Open

Screen sharing is very laggy #21

Allenille opened this issue Jan 15, 2025 · 2 comments

Comments

@Allenille
Copy link

When I use screen sharing from the demo page https://demo.ovenplayer.com/demo_input.html to stream to my local OvenMediaEngine server, the stream is very laggy and the bitrate is moving from 200kbps to 1500kbps even if I set the maximum bitrate to 10000kbps.
With OBS and rtmp everything is working fine but using the OvenLiveKit demo to stream webrtc to my server is very laggy.

Is it normal when I see the stream that I have like 5 fps ? If I play a video on the screen I am sharing the result is pixelated and it seems I have 5 fps ...

Any leads to solve that ?

Everything is local so I should not have any network problems.

My settings on the OvenLiveKit demo:
Browser: chrome and vivaldi
Display Media: Screen sharing
Resolution: Full HD 1920*1080
Framerate: 30
Max bitrate: 10000
Video codec: H264

The settings of my OvenmediaEngine:

<?xml version="1.0" encoding="UTF-8"?>

<Server version="8">
    <Name>OvenMediaEngine</Name>
    <!-- Host type (origin/edge) -->
    <Type>origin</Type>
    <!-- Specify IP address to bind (* means all IPs) -->
    <IP>*</IP>
    <PrivacyProtection>false</PrivacyProtection>
    <Modules>
        <HTTP2>
            <Enable>true</Enable>
        </HTTP2>
    </Modules>

    <!-- Settings for the ports to bind -->
    <Bind>
        <Providers>
            <RTMP>
                <Port>1935</Port>
                <WorkerCount>1</WorkerCount>
            </RTMP>
            <WebRTC>
                <Signalling>
                    <Port>4333</Port>
                    <TLSPort>4334</TLSPort>
                    <WorkerCount>1</WorkerCount>
                </Signalling>
                <IceCandidates>
                    <IceCandidate>*:20000-20004/udp</IceCandidate>
                    <!-- 
                        If you want to stream WebRTC over TCP, specify IP:Port for TURN server.
                        This uses the TURN protocol, which delivers the stream from the built-in TURN server to the
                    player's TURN client over TCP. 
                        For detailed information, refer
                    https://airensoft.gitbook.io/ovenmediaengine/streaming/webrtc-publishing#webrtc-over-tcp
                    -->
                    <TcpRelay>*:4478</TcpRelay>
                    <!-- TcpForce is an option to force the use of TCP rather than UDP in WebRTC
                    streaming. (You can omit ?transport=tcp accordingly.) If <TcpRelay> is not set,
                    playback may fail. -->
                    <TcpForce>true</TcpForce>
                    <TcpRelayWorkerCount>1</TcpRelayWorkerCount>
                </IceCandidates>
            </WebRTC>
        </Providers>

        <Publishers>
            <WebRTC>
                <Signalling>
                    <Port>3333</Port>
                    <TLSPort>3334</TLSPort>
                    <WorkerCount>1</WorkerCount>
                </Signalling>
                <IceCandidates>
                    <IceCandidate>*:10000-10004/udp</IceCandidate>
                    <!-- 
                        If you want to stream WebRTC over TCP, specify IP:Port for TURN server.
                        This uses the TURN protocol, which delivers the stream from the built-in TURN server to the
                    player's TURN client over TCP. 
                        For detailed information, refer
                    https://airensoft.gitbook.io/ovenmediaengine/streaming/webrtc-publishing#webrtc-over-tcp
                    -->
                    <TcpRelay>*:3478</TcpRelay>
                    <!-- TcpForce is an option to force the use of TCP rather than UDP in WebRTC
                    streaming. (You can omit ?transport=tcp accordingly.) If <TcpRelay> is not set,
                    playback may fail. -->
                    <TcpForce>true</TcpForce>
                    <TcpRelayWorkerCount>1</TcpRelayWorkerCount>
                </IceCandidates>
            </WebRTC>
        </Publishers>

        <Managers>
            <API>
                <Port>8081</Port>
                <!--<TLSPort>8082</TLSPort>-->
                <WorkerCount>1</WorkerCount>
            </API>
        </Managers>
    </Bind>


    <Managers>
        <Host>
            <Names>
                <Name>*</Name>
            </Names>
            <TLS>
                <!--<CertPath>airensoft_com.crt</CertPath>
				<KeyPath>airensoft_com.key</KeyPath>
				<ChainCertPath>airensoft_com_chain.crt</ChainCertPath>-->
            </TLS>
        </Host>
        <API>
            <!--
            <AccessToken> is a token for authentication, and when you invoke the API, you must put "Basic
            base64encode(<AccessToken>)" in the "Authorization" header of HTTP request.
            For example, if you set <AccessToken> to "ome-access-token", you must set "Basic
            b21lLWFjY2Vzcy10b2tlbg==" in the "Authorization" header. And put the secret in the OME_API_TOKEN env variable on backend.
            -->
            <AccessToken>ome-access-token</AccessToken>
            <CrossDomains>
                <Url>*</Url>
            </CrossDomains>
        </API>
    </Managers>

    <VirtualHosts>
        <VirtualHost>
            <Name>origin</Name>
            <!--Distribution
            is a value that can be used when grouping the same vhost distributed across multiple
            servers. This value is output to the events log, so you can use it to aggregate
            statistics. -->
            <Distribution>origin</Distribution>

            <!-- Settings for multi ip/domain and TLS -->
            <Host>
                <Names>
                    <Name>*</Name>
                </Names>
            </Host>
            <!-- Settings for applications -->
            <Applications>
                <Application>
                    <Name>app</Name>
                    <!-- Application type (live/vod) -->
                    <Type>live</Type>
                    <OutputProfiles>
                        <!-- Enable this configuration if you want to hardware acceleration using
                        GPU -->
                        <HardwareAcceleration>false</HardwareAcceleration>
                        <OutputProfile>
                            <Name>bypass_stream</Name>
                            <OutputStreamName>${OriginStreamName}</OutputStreamName>
                            <Encodes>
                                <Audio>
                                    <Bypass>true</Bypass>
                                </Audio>
                                <Video>
                                    <Bypass>true</Bypass>
                                </Video>
                                <Audio>
                                    <Codec>opus</Codec>
                                    <Bitrate>128000</Bitrate>
                                    <Samplerate>48000</Samplerate>
                                    <Channel>2</Channel>
                                </Audio>
                            </Encodes>
                        </OutputProfile>
                    </OutputProfiles>
                    <Providers>
                        <RTMP/>
                        <WebRTC>
                            <Timeout>30000</Timeout>
                            <CrossDomains>
                                <Url>*</Url>
                            </CrossDomains>
                        </WebRTC>
                    </Providers>
                    <Publishers>
                        <AppWorkerCount>1</AppWorkerCount>
                        <StreamWorkerCount>8</StreamWorkerCount>
                        <WebRTC>
                            <Timeout>30000</Timeout>
                            <Rtx>false</Rtx>
                            <Ulpfec>false</Ulpfec>
                            <JitterBuffer>false</JitterBuffer>
                        </WebRTC>
                    </Publishers>
                </Application>
            </Applications>
        </VirtualHost>
    </VirtualHosts>
</Server>
@SangwonOh
Copy link
Member

@Allenille Hi. Screen sharing via browser can cause FPS drops as it uses huge computing resources for stream encoding.

I use Intel i9-10900, Nvidia GTX 1660 Ti and also use hardware acceleration in Chrome. In my test environment, sharing the screen with OvenMediaEngine and playing it with OvenPlayer is very smooth.

What are the computing specs of your test environment? If you can test it in a better computing environment, please share the results.

@Allenille
Copy link
Author

@SangwonOh Hello! Thank you for your response!

My test environment should not pose any issues, as I am using an Intel(R) Xeon(R) W-2135 CPU @ 3.70GHz, an NVidia RTX 2070, and hardware acceleration in Chrome.
My machine has plenty of resources available when I start sharing my screen, with CPU usage peaking at around 15%. Additionally, I have no problems using OBS with the x264 encoder.

Is my config OK ? Do I need to tweak the demo page to make it work ? Any suggestion ?
Very strange that it does not work on my side and work on yours.

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

2 participants