m1k1o / neko

A self hosted virtual browser that runs in docker and uses WebRTC.
https://neko.m1k1o.net/
Apache License 2.0
5.98k stars 449 forks source link

Stream is lagging #198

Open DerKartdomi opened 1 year ago

DerKartdomi commented 1 year ago

Hello, If I Stream Something and there are 10 people the Stream Starts to lagg. Can I configure Something or Something that its better?

yesBad commented 1 year ago

What specs does your server have and what resolution are you streaming with?

DerKartdomi commented 1 year ago

The Server has 10gb ram and 9 CPU I Stream with 1920x1080@30

yesBad commented 1 year ago

CPU would be what?

DerKartdomi commented 1 year ago

![Uploading IMG_20220830_182650.jpg…]()

yesBad commented 1 year ago

This isn't an image.

DerKartdomi commented 1 year ago

processor : 1 vendor_id : GenuineIntel cpu family : 15 model : 6 model name : Common KVM processor stepping : 1 microcode : 0x1 cpu MHz : 2693.508 cache size : 16384 KB physical id : 0 siblings : 8 core id : 1 cpu cores : 8 apicid : 1 initial apicid : 1 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic hypervisor lahf_lm cpuid_fault pti bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit bogomips : 5387.01 clflush size : 64 cache_alignment : 128 address sizes : 40 bits physical, 48 bits virtual power management: processor : 2 vendor_id : GenuineIntel

yesBad commented 1 year ago

What host are you using?

And that doesn't tell the CPU-

DerKartdomi commented 1 year ago

Ahh I Host on Debian 10

yesBad commented 1 year ago

I didn't ask for the OS, I asked what host do you use and what CPU do you have.

m1k1o commented 1 year ago

Looks like VM Common KVM processor. Maybe your provider is giving you 9 CPUs but they are shared and therefore less performant if there is high demand. Where do you host it?

yesBad commented 1 year ago

Looks like VM Common KVM processor. Maybe your provider is giving you 9 CPUs but they are shared and therefore less performant if there is high demand. Where do you host it?

Yeah it's a VPS most probably from Contabo which is overallocated to the shit.

DerKartdomi commented 1 year ago

Its hosted ob a vm. CPU idk

yesBad commented 1 year ago

Its hosted ob a vm. CPU idk

Where did you buy the machine/VPS/VM?

DerKartdomi commented 1 year ago

From a friend. It hosted on a virtual dedicated on a dedicated

yesBad commented 1 year ago

Ask your friend?

yesBad commented 1 year ago

You not giving information isn't helping your case. I suggest trying 1280x720@30fps

DerKartdomi commented 1 year ago

Intel Xeon E5-2697v2

DerKartdomi commented 1 year ago

You not giving information isn't helping your case. I suggest trying 1280x720@30fps

if there are 8 people it starts lagging ._.

m1k1o commented 1 year ago

Virtual dedicated but dedicated only for you or your friend uses that? Depending on what else runs on the server, what is typical load an networking. Every participant needs own stream over UDP.

DerKartdomi commented 1 year ago

the server is not busy but it's kind of a vm on my proxmox running on a dedi proxmox

m1k1o commented 1 year ago

Whats the network there?

DerKartdomi commented 1 year ago

How do U mean? My Traffic oder how much my Download/Upload is?

m1k1o commented 1 year ago

Dedi proxmox upstream. Is it in datacentre connected to backbone or at home?

DerKartdomi commented 1 year ago

in total we have 10gbit/s. the VM currently has a download speed of 800mbit/s Upload: 486mbit/s

m1k1o commented 1 year ago

That sounds sufficient. Do you use default image without any modifications? Could you try to set up multiple (two) rooms each with multiple (7) participants and see if that works better?

DerKartdomi commented 1 year ago

it doesn't get any better... you can check it out if you want, I took a screenshot

https://screen.magic-pics.tk/FOku9/qIzuBoXI34.mp4

m1k1o commented 1 year ago

Then it might not problem in neko, if there are two separate instances of it with people connected. Looks like cpu is not keeping up. Can you show load of the server? And cpu usage. With e.G. htop.

DerKartdomi commented 1 year ago

the 9th core is not loaded yet. after a restart it is there

https://screen.magic-pics.tk/FOku9/laVItOZu56.png

mbattista commented 1 year ago
  1. Can you share, which settings are you using for neko? e.g. Are you using H264 or VP8? Is it still lagging if you use the other one, that you do not currently use?

  2. Is it lagging for ALL people or just for one?

  3. At last try, you could try to increase the CPU Threads for the video stream with an custom pipeline. An (untested) example would be:

      NEKO_VIDEO: |
        ximagesrc display-name=%s use-damage=0 show-pointer=true use-damage=false
          ! video/x-raw,framerate=30/1
          ! videoconvert
          ! queue
          ! video/x-raw,framerate=30/1,format=NV12
          ! video/x-raw,format=NV12
          ! x264enc threads=6 bitrate=6000 key-int-max=60 vbv-buf-capacity=6000 byte-stream=true tune=zerolatency speed-preset=veryfast ! video/x-h264,stream-format=byte-stream
  4. Another interesting log would be the webrtc package you receive. On chrome://webrtc-internals/ you can see if you have dropped webrtc frames, even through in the video it looks like CPU issues, since the sound is also problematic.

  5. I just do not understand why the amount of viewers is any problem besides networking. Neko is an one videostream, N subscriber solution. There should not be any lags in the stream because more viewer watch the stream. Can you also check, if there are lags over time if just one person watches?

  6. Are you sure you do not have any bandwidth issue? 8 Users with the standard settings would be around 25-30MB/s upload. Can you messure the upload of the server, if it can hit the 480MB/s?

DerKartdomi commented 1 year ago

I have now activated H264. It's a bit better but even with 8 people it starts to hang again. How to properly set the pipeline? I pasted the code and it was unhealthy then.

Video ohne Pipeline: https://screen.magic-pics.tk/FOku9/godAqIGE57.mp4

mbattista commented 1 year ago

Sorry, I could not test the pipeline, you could try the following:

NEKO_VIDEO: ximagesrc display-name=%s show-pointer=true use-damage=false ! video/x-raw,framerate=30/1 ! videoconvert ! queue ! video/x-raw,format=NV12 ! x264enc threads=6 bitrate=3500 key-int-max=60 vbv-buf-capacity=4000 byte-stream=true tune=zerolatency speed-preset=veryfast ! video/x-h264,stream-format=byte-stream

But again, I do not believe that the pipeline is at fault. If it is the pipeline, the video would lag, no matter how many watchers. Also 8 people in the SFU should not increase the load significant enough that the CPU would have any problems with the pipeline, especially since only 5 of the 8 cores should have load because of encoding video and sound.

Can you provide information about the internet speed of the server, e.g. with https://github.com/sivel/speedtest-cli

Alternativ can you try to decrease the bitrate and try again? e.g. NEKO_VIDEO_BITRATE: 1200

DerKartdomi commented 1 year ago

If I add a Pipeline its running unhealthy but with the lower bitrate it works better

ehfd commented 4 months ago

GPUs (vaapih264enc / nvh264enc) for encoding and color conversion would help in this situation.