webrtc icon indicating copy to clipboard operation
webrtc copied to clipboard

Slows down the stream with 30+ clients

Open MariaGolubev opened this issue 3 years ago • 2 comments

Hello. My stream slows down on different devices with 30+ clients. I'm creating a test video from an gstreamer, sending it to TrackLocalStaticRTP. What could be the problem?

Send video to TrackLocalStaticRTP:

let video_track_clone = video_track.clone();
let join_handle = tokio::spawn(async move {
        let mut quit = false;
        while let Some(sample) = appsink_stream.next().await {
            if let Some(buffer) = sample.buffer() {
                if let Ok(map) = buffer.map_readable() {
                    let slice = map.as_slice();

                    // println!("{}", slice.len());
                    if let Err(err) = video_track_clone.write(slice).await {
                        if webrtc::Error::ErrConnectionClosed == err {
                            continue;
                        }

                        if webrtc::Error::ErrClosedPipe == err {
                            // The peerConnection has been closed.
                            break;
                        } else {
                            tracing::error!("video_track write err: {err}");
                            break;
                        }
                    }
                } else {
                    break;
                }
            } else {
                break;
            }
        }
    });

RTCP messages from the client do not process.

➜  videotestsrc_to_webrtc_broadcast_stream git:(main) ✗ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/***/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.59.0 (9d1b2106e 2022-02-23)

MariaGolubev avatar Mar 10 '22 09:03 MariaGolubev

gstreamer pipeline:

"videotestsrc \
                ! timeoverlay ! video/x-raw,width=320,height=240 \
                ! videoconvert ! videoscale ! videorate drop-only=true skip-to-first=true \
                ! video/x-raw,pixel-aspect-ratio=(fraction)1/1 \
                ! vaapipostproc \
                ! vaapih264enc \
                ! h264parse
                ! video/x-h264,stream-format=avc,profile=constrained-baseline \
                ! rtph264pay pt=96 \
                ! appsink name=sink"

MariaGolubev avatar Mar 10 '22 09:03 MariaGolubev

@RustPanda do you mean the stream server slows down when 30+ clients connect? I'm just curious - what kind of computer was the stream service running on? :o

lf94 avatar Nov 07 '23 13:11 lf94