index.js
function getLiveStream(options) {
    return raspivid(Object.assign({
        width: 960,
        height: 540,
        framerate: 20,
        profile: 'baseline',
        timeout: 0
    }, options))
    .pipe(new Splitter(NALseparator))
    .pipe(new stream.Transform({ transform: function (chunk, encoding, callback) {
        const chunkWithSeparator = Buffer.concat([NALseparator, chunk]);

        const chunkType = chunk[0] & 0b11111;

        // Capture the first SPS & PPS frames, so we can send stream parameters on connect.
        if (chunkType === 7 || chunkType === 8) {
            headerData.addParameterFrame(chunkWithSeparator);
        } else {
            // The live stream only includes the non-parameter chunks
            this.push(chunkWithSeparator);

            // Keep track of the latest IDR chunk, so we can start clients off with a near-current image
            if (chunkType === 5) {
                headerData.idrFrame = chunkWithSeparator;
            }
        }

        callback();
    }}));
}
function getLiveStream(options) {
    return raspivid(Object.assign({
        width: 960,
        height: 540,
        framerate: 20,
        profile: 'baseline',
        timeout: 0
    }, options))
    .pipe(new Splitter(NALseparator))
    .pipe(new stream.Transform({ transform: function (chunk, encoding, callback) {
        const chunkWithSeparator = Buffer.concat([NALseparator, chunk]);

        const chunkType = chunk[0] & 0b11111;

        // Capture the first SPS & PPS frames, so we can send stream parameters on connect.
        if (chunkType === 7 || chunkType === 8) {
            headerData.addParameterFrame(chunkWithSeparator);
        } else {
            // The live stream only includes the non-parameter chunks
            this.push(chunkWithSeparator);

            // Keep track of the latest IDR chunk, so we can start clients off with a near-current image
            if (chunkType === 5) {
                headerData.idrFrame = chunkWithSeparator;
            }
        }

        callback();
    }}));
}
function getLiveStream ( options ) { return raspivid ( Object . assign ( { width : 960 , height : 540 , framerate : 20 , profile : 'baseline' , timeout : 0 } , options ) ) . pipe ( new Splitter ( NALseparator ) ) . pipe ( new stream . Transform ( { transform : function ( chunk , encoding , callback ) { const chunkWithSeparator = Buffer . concat ( [ NALseparator , chunk ] ) ; const chunkType = chunk [ 0 ] & 0b11111 ; // Capture the first SPS & PPS frames, so we can send stream parameters on connect. if ( chunkType === 7 || chunkType === 8 ) { headerData . addParameterFrame ( chunkWithSeparator ) ; } else { // The live stream only includes the non-parameter chunks this . push ( chunkWithSeparator ) ; // Keep track of the latest IDR chunk, so we can start clients off with a near-current image if ( chunkType === 5 ) { headerData . idrFrame = chunkWithSeparator ; } } callback ( ) ; } } ) ) ; }
This returns the live stream only, without the parameter chunks
This returns the live stream only without the parameter chunks