deepch / RTSPtoWeb

RTSP Stream to WebBrowser
MIT License
1.16k stars 283 forks source link

WebRTC - Very bad video performance #110

Open Kiwa21 opened 2 years ago

Kiwa21 commented 2 years ago

Hello, My goal is to transform a IP camera live stream to a WebRTC stream in a web browser. My RTSP stream is a 1080p h264 stream with a bitrate of 3Mbps/

For testing purpose, I am streaming a video file to a RTSP stream with the wonderful rtsp-simple-server software. I'm using this command for reference:
ffmpeg -re -stream_loop -1 -i ~/Workspace/rtsp/video.mp4 -c copy -f rtsp rtsp://localhost:8554/video

I'm launching RTSPtoWeb with the right config.json :

"streams": {
    "demo": {
      "channels": {
        "0": {
          "url": "rtsp://localhost:8554/video"
        }
      },
      "name": "demo"
    }
  }

I can see the WebRTC stream but performances are really bad. The video stutters a lot and freeze randomly for a few seconds. (HLS and HLS LL are not giving good results as well).

Chrome and Firefox are not giving the same results. Chrome has less "freeze" but a lot more stuttering and sometime "old" frames come after "new frames" i can have the 12.8s frame then 13.0sec then 12.9sec for example. Firefox is smoother but a lot more hard freeze.

Do you have any ideas ? I thought that maybe it was slow because of a CPU encoding/decoding but the video is already h264 encoded so the RTSPtoWeb should have to decode/encode again.

Thanks !!

Kiwa21 commented 2 years ago

I posted a video of my screen here : https://vimeo.com/680452241

deepch commented 2 years ago

share you stream please im test it

maxi1134 commented 2 years ago

I have a very similar issue!

The video loads, then plays a bit, then freezes, then plays, and so on.

Did you found a solution?

brujoand commented 2 years ago

I've got the same issue. The video freezes for seconds at the time, and generally just doesn't work. It seems like this happens whenever I add a stream which has audio, regardless of wether "audio": true has been set in the config or not. All my sources are 4k RTSP streams encoded as h264/acc. I tried enabling debug for one of the comeras which has sound, but the only thing I'm seeing logged is [Unsupported NAL Type 6], which I understand is benign?

Kiwa21 commented 2 years ago

I solved the issue by re-encoding and compressing the stream with a lower bitrate. I'm not sure what is the real source of this issue though.

My stream was a 1080p @ 3Mbps, I used rtsp-simple-server for compressing like this: ffmpeg -i rtsp://INPUTSTREAM -pix_fmt yuv420p -c:v libx264 -preset ultrafast -b:v 600k -max_muxing_queue_size 1024 -f rtsp rtsp://localhost:8554/compressed

With the compressed stream, I don't have the stuttering issue etc.

brujoand commented 2 years ago

aha, I'm running 4k @ 6Mbps, so I guess that's my problem then. In that case I'd rather have some lag using rtsp when launching the stream I think. But thanks for the tip 👍

mt-krainski commented 1 year ago

Same issue here. I'm testing now with streaming a local file to rtsp and trying to receive it in a browser. E.g. take Sintel, transcode it to mpegts (for some reason rtsp was not happy with the webm format)

ffmpeg -i Sintel.2010.1080p.webm -vcodec libx264 sintel.ts

Stream to an rtsp server

ffmpeg -re -i ~/Downloads/sintel.ts -c copy -f rtsp rtsp://localhost:8554/sintel

I'm also seeing [Unsupported NAL Type 6] in the debug log. None of the streams are working for me. They're not just jittery - they're not working. Lowering the bitrate helped a bit but it's still quite bad. The stream works fine when displayed e.g. in VLC.

Any hint would be appreciated, I'm happy to carry out some tests or help with debugging.

pLavrenov commented 1 year ago

same problem with rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4