RTMP to WebRTC

While Hello Norsk is about the shortest Norsk media application you can write, it does not take much more to start building meaningful media flows. How about receiving an RTMP stream and republishing it as WebRTC?

Below is the entire program - it runs, and does useful things! Let’s walk through this line by line as well:

const norsk = await Norsk.connect();  (1)

const input = await norsk.input.rtmpServer({ id: "rtmpInput" }); (2)
const output = await norsk.output.whep({ id: "webrtc", ...webRtcServerConfig }); (3)

output.subscribe([{ source: input, sourceSelector: selectAV }]); (4)
console.log(`WebRTC Player URL: ${output.playerUrl}`);
1 Connect to the Norsk Media instance
2 Tell Norsk to create an RTMP server for input
3 Tell Norsk to create a WebRTC server for output
4 Subscribe the WebRTC output to the audio and video coming from the RTMP input

That’s it!

Again - the above code is one of the examples. All you should need to do to launch it is to run

./run-example --license-file [path-to-your-license-file-here] start rtmp_to_webrtc

The examples repo will provide sample sources, so you should be able to dive right in looking at the output and marveling at the visualiser…​

Anything that gets streamed to the RTMP server will be republished as WebRTC. Not bad for a few lines of code!