NorskOutput.whep() method

Hosts media for clients connecting via WebRTC using the WHEP standard.

To send media to a remote Media Server via WebRTC see NorskOutput.whip(). See also NorskInput.whip(), NorskDuplex.webRtcBrowser().

Signature:

whep(settings: WhepOutputSettings): Promise<WhepOutputNode>;

Parameters

Parameter Type Description

settings

WhepOutputSettings

Configuration for the WebRTC Stream

Returns:

Promise<WhepOutputNode>

Example [01_rtmp_to_webrtc.ts]

Subscribe to an RTMP source and generate local WebRTC output from it

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

output.subscribe([{ source: input, sourceSelector: selectAV }]); 
console.log(`WebRTC Player URL: ${output.playerUrl}`);

Run the following command to generate example input at url rtmp://127.0.0.1:1935/norsk/high:

ffmpeg -v error -re -stream_loop -1 -i data/InkDrop.ts  -vcodec copy -codec copy -f flv 'rtmp://127.0.0.1:1935/norsk/high'

Example [02_srt_to_webrtc.ts]

Subscribe to an SRT source and generate local WebRTC output from it

export async function main() {
  // Note how, other than the input line, this example and rtmp_to_webrtc
  // are identical.
  const norsk = await Norsk.connect();

  const input = await norsk.input.srt(srtInputSettings);
  const output = await norsk.output.whep({ id: "webrtc", ...webRtcServerConfig });

  output.subscribe([{ source: input, sourceSelector: selectAV }]);
  console.log(`WebRTC Player URL: ${output.playerUrl}`);
}

const srtInputSettings: SrtInputSettings = {
  id: "srtInput",
  ip: "0.0.0.0",
  port: 5001,
  mode: "listener",
  sourceName: "camera1",
};

Run the following command to generate example input at url srt://127.0.0.1:5001?pkt_size=1316:

ffmpeg -v error -re -stream_loop -1 -i data/Weaving.ts  -vcodec copy -codec copy -f mpegts -flush_packets 0 'srt://127.0.0.1:5001?pkt_size=1316'

Find Examples

Search for examples using whep in our examples repo.