bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
11.67k stars 1.47k forks source link

Add support for webRTC streaming #566

Closed GauravChoube closed 1 year ago

GauravChoube commented 3 years ago

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

aler9 commented 3 years ago

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.

GauravChoube commented 3 years ago

okay thanks for explanation.

aarnaud commented 3 years ago

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.

gluedots commented 2 years ago

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

Siedlerchr commented 2 years ago

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

eLvErDe commented 2 years ago

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

aler9 commented 2 years ago

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.

eLvErDe commented 2 years ago

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

ilterpehlivan commented 1 year ago

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!

vicmassy commented 1 year ago

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

aler9 commented 1 year ago

WebRTC support is in beta here #1242

aler9 commented 1 year ago

WebRTC support has been added in v0.21.0.

github-actions[bot] commented 1 year ago

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.