mediamtx icon indicating copy to clipboard operation
mediamtx copied to clipboard

Add support for webRTC streaming

Open GauravChoube opened this issue 3 years ago • 11 comments

The only things missing in current project is webRTC which will provide less than 0.5s latency for live streaming. As you may be aware of hls or ll-hls has at least 1-2s delay for live streaming.

Regards Gaurav Choubey

GauravChoube avatar Sep 08 '21 13:09 GauravChoube

Hello, the problem of WebRTC is that it requires video re-encoding from H264 to VP8 (or alternatively, the video track must already be in VP8). This can't be done without integrating a H264 decoder into the server, and this can cause legal problems, since the MPEG group requires a fee to distribute software that decodes H264.

It also requires audio re-encoding from AAC to Opus.

WebRTC theoretically also supports H264 (only the baseline profile), i did a lot of research into it during my job, but i never got it working.

Anyway, i'm leaving this feature request here, waiting for future developments.

aler9 avatar Sep 08 '21 18:09 aler9

okay thanks for explanation.

GauravChoube avatar Sep 09 '21 06:09 GauravChoube

Hi,

I think, It can work with some strict settings, like disable B-frame on h264 encoder

I try rtsp-simple-server with https://github.com/deepch/RTSPtoWebRTC And it work fine.

I did some test with OBS and FFmpeg as publisher. Of course with OBS we need to had a audio transcoder to switch to Opus codec.

So I supposed it can work like this:

paths:
  all:
  original:
    runOnPublish: ffmpeg -i rtsp://localhost:$RTSP_PORT/$RTSP_PATH  -c:a opus -strict -2 -c:v copy -f rtsp rtsp://localhost:$RTSP_PORT/webrtc_$RTSP_PATH
    runOnPublishRestart: yes

An example with OBS: Screenshot from 2021-09-10 16-08-39

For exemple Wowza can convert RTMP to WebRTC: https://www.wowza.com/blog/converting-rtmp-to-webrtc-with-wowza-streaming-engine

Of course some browser can have limitations, I tried on Chrome/Chromium and Firefox, and Chrome Android and it work well.

aarnaud avatar Sep 10 '21 20:09 aarnaud

Would it be possible to also get webRTC as a source, or does anyone have a workaround to convert webRTC into RTSP?

gluedots avatar Dec 02 '21 14:12 gluedots

We use OpenVidu/Kurento to publish IP Cameras via RTSP to WebRTC https://openvidu.io/ At least that way is working. Simple RTSP Server acts as proxy for RTMP streams

Siedlerchr avatar Dec 08 '21 17:12 Siedlerchr

For the record, I'm not sure why you say WebRTC does not support h264. It definitely does, we have been running a custom CCTV system for a couple of years, all using h264 cameras and Janus webRTC gateway

eLvErDe avatar Dec 09 '21 22:12 eLvErDe

For the record, I'm not sure why you say WebRTC does not support h264.

It supports only the baseline profile, that is not used by most streams.

aler9 avatar Dec 14 '21 22:12 aler9

For regular camera it is, we have nearly 1000 cams from 10 different brands, all working through Janus and Firefox/Chrome

eLvErDe avatar Dec 14 '21 22:12 eLvErDe

Hi @aler9 , do you have any development or new ideas for this feature request ? Based on your feedback above, i am thinking maybe only baseline profile support should be added for now!

ilterpehlivan avatar Sep 27 '22 14:09 ilterpehlivan

Hey @aler9, any updates on this? When do you foresee some work on this topic?

vicmassy avatar Oct 18 '22 14:10 vicmassy

WebRTC support is in beta here #1242

aler9 avatar Nov 11 '22 21:11 aler9

WebRTC support has been added in v0.21.0.

aler9 avatar Dec 21 '22 22:12 aler9

This issue is being locked automatically because it has been closed for more than 6 months. Please open a new issue in case you encounter a similar problem.

github-actions[bot] avatar Jun 26 '23 15:06 github-actions[bot]