How to use WebRTC to stream video to RTMP?

限于喜欢 提交于 2019-12-11 18:22:15

问题


I am trying to build a service that streams your screen from a browser to clients (something like twitch).

What I have accomplished is I have built a working nginx server with rtmp, I tested it using OBS. That works pretty well.

And my question is how to stream a screen from a browser (not from OBS or other broadcasters) using WebRTC to nginx server with RTMP?


回答1:


For RTSP<->WebRTC / RTMP<->WebRTC conversions, you need to run some kind of WebRTC gateway / media server software that works with all these formats/protocols and can transmux between all of them. Try Wowza / Unreal Media Server / Flashphoner. https://en.wikipedia.org/wiki/Comparison_of_streaming_media_systems

So in your case you want to publish the screen from browser to media server via WebRTC (H264 codec is a must) and then pull RTMP stream from the media server to nginx server with nginx-rtmp module.

Note that the opposite is possible too: You could push a stream to media server via RTMP, (for example, OBS screen capture) and then send this stream from media server to web browser(s) via WebRTC.

The main issue in these conversions is codec compatibility: H264 must be used for video, but if you need audio then you will have to do Opus to AAC transcoding.



来源:https://stackoverflow.com/questions/56238148/how-to-use-webrtc-to-stream-video-to-rtmp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!