NorskTransform.streamKeyOverride() method

Provide a new stream key for a single stream. Cannot be subscribed to multiple streams at once.

The stream key is used for identifying streams within multiplexed sources and also is translated into URIs for HLS playlists and other resources.

This can be useful if changing sources and wanting to maintain a consistent streamkey going into an output

Signature:

streamKeyOverride(settings: StreamKeyOverrideSettings): Promise<StreamKeyOverrideNode>;

Parameters

Parameter Type Description

settings

StreamKeyOverrideSettings

New stream key plus general node settings.

Returns:

Example [08_pid_normalization.ts]

Receive an RTMP stream and package it in a transport stream with explicit PID mappings

export async function main() {
    const norsk = await Norsk.connect();

    let input = await norsk.input.rtmpServer({ id: "rtmpInput", port: 5001 });
    let videoPidNormalizer = await norsk.processor.transform.streamKeyOverride(videoStreamKeyConfig);
    let audioPidNormalizer = await norsk.processor.transform.streamKeyOverride(audioStreamKeyConfig);
    let output1 = await norsk.duplex.webRtcBrowser({ id: "webrtc" });
    let output2 = await norsk.output.fileTs(tsFileOutputSettings);

    videoPidNormalizer.subscribe([{ source: input, sourceSelector: selectVideo }]);
    audioPidNormalizer.subscribe([{ source: input, sourceSelector: selectAudio }]);

    let normalizedSources = [{ source: videoPidNormalizer, sourceSelector: selectVideo }, { source: audioPidNormalizer, sourceSelector: selectAudio }];
    output1.subscribe(normalizedSources);
    output2.subscribe(normalizedSources);

    console.log(`Local player: ${output1.playerUrl}`);
}

const videoStreamKeyConfig: StreamKeyOverrideSettings = {
    id: "video_stream_key",
    streamKey: {
        programNumber: 1,
        renditionName: "video",
        streamId: 256,
        sourceName: "input",
    },
};
const audioStreamKeyConfig: StreamKeyOverrideSettings = {
    id: "audio_stream_key",
    streamKey: {
        programNumber: 1,
        renditionName: "audio",
        streamId: 258,
        sourceName: "input",
    },
};
const tsFileOutputSettings: FileTsOutputSettings = {
    id: "localTsOutput",
    fileName: "/tmp/normalized.ts",
};

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

ffmpeg -v error -re -f lavfi -i "sine=frequency=220:sample_rate=48000" -loop 1 -i data/test-src-still.png -vf drawtext=fontfile=Arial.ttf:text="%{frame_num}":start_number=1:x=980:y=330:fontcolor=black:fontsize=40:box=1:boxcolor=white:boxborderw=5,scale=1280:720 -vcodec h264 -b:v 150000 -b:a 20000 -aspect 1280:720 -x264opts "keyint=25:min-keyint=25:no-scenecut:bframes=0" -bluray-compat true -tune stillimage -preset fast -pix_fmt yuv420p -acodec aac -metadata language=en -f flv 'rtmp://127.0.0.1:5001/norsk/high'

Find Examples