nginxwebrtcrtmpobs

send nginx rtmp fragments to WebRTC


I'd like to use OBS to stream via RTMP to a nginx server, and then locally send the RTMP fragments to WebRTC, so that they can be transmitted to the client via a MediaStream. I think this possible as it is essentially described here. I'm doing this because the multi-second latency of HLS is not appropriate for what I'm trying to do.

I'm having trouble extracting the RTMP fragments from nginx, the only plausible command I could find for doing this in the documentation was pull rtmp://.... When I tried this I did not see any files appearing in my root folder, where I would normally find the HLS files if I were using hls on. Does anyone know how to accomplish what I'm trying achieve above?

Thanks!


Solution

  • This is easily possible! You could base it off Pion’s rtp-to-webrtc example. This allows you to easily get media from ffmpeg into the browser.

    The ffmpeg command you run instead would be like this one ffmpeg -re -i rtmp://localhost:1935/$app/$name -vn -acodec libopus -f rtp rtp://localhost:6000 -vcodec copy -an -f rtp rtp:localhost:5000 -sdp_file video.sdp

    I would consider transcoding to VP8 since not all browsers support H264.

    —-

    If you want sub-second playback in the browser I would check out Project Lightspeed that’s your best option today IMO.