John Kim
John Kim

Reputation: 1158

Ffmpeg : Bitstream not supported by this decoder

I'm trying to create a livestream web app using NodeJS. The code I currently have emits a raw (webm format) binary stream from the webcam on the client using socket IO and the node server receives this raw data. Using fluent-ffmpeg, I want to encode this binary stream into mpegts and send it to an RTMP server in real time, without creating any intermediary files. However when trying to convert the blobs in ffmpeg I get the following error :

Error while decoding stream #0:1: Invalid data found when processing input
[NULL @ 000001b15e67bd80] Invalid sync code 61f192.
[libvpx @ 000001b15e6c5000] Failed to decode frame: Bitstream not supported by this decoder

My relevant frontend client code :

navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
    video_show(stream);//only show locally, not remotely

    socket.emit('config_rtmpDestination',url);
    socket.emit('start','start');
    var options = {mimeType: 'video/webm;codecs=h264'};

    mediaRecorder = new MediaRecorder(stream, options);
    mediaRecorder.start(2000);

    mediaRecorder.onstop = function(e) {
        stream.stop();
    }

    mediaRecorder.ondataavailable = function(e) {
        //var arraybuffer = Uint8Array.from(e.data).buffer;
        socket.emit("binarystream", blob);
        //chunks.push(e.data);
    }
}).catch(function(err) {
    console.log('The following error occured: ' + err);
    show_output('Local getUserMedia ERROR:'+err);
});

Relevant NodeJS server code :

socket.on('binarystream',function(m){
    feedStream(m);
});

socket.on('start',function(m){
    ...
    var ops=[
        '-vcodec', socket._vcodec,'-i','-',
        '-c:v', 'libx264', '-preset', 'veryfast', '-tune', 'zerolatency',
        '-an', '-bufsize', '1000',
        '-f', 'mpegts', socket._rtmpDestination
    ];
    ffmpeg_process=spawn('ffmpeg', ops);
    feedStream=function(data){
        ffmpeg_process.stdin.write(data);
    }
    ...
}

Upvotes: 0

Views: 2947

Answers (1)

tarun jain
tarun jain

Reputation: 91

For anyone who is bumping to this issue.. try replacing libvpx with libvpx-vp9 or to the more advanced version of libvpx

Upvotes: 2

Related Questions