相关疑难解决方法(0)

How to concat chunks of incoming binary into video (webm) file node js?

I am trying to upload chunks of base64 to node js server and save those chunks into one file

let chunks = [];

app.post('/api', (req, res) => {
    let {blob} = req.body;
    //converting chunks of base64 to buffer
    chunks.push(Buffer.from(blob, 'base64'));
    res.json({gotit:true})

});

app.post('/finish', (req, res) => {
    let buf = Buffer.concat(chunks);
    fs.writeFile('finalvideo.webm', buf, (err) => {
        console.log('Ahh....', err)
    });
    console.log('SAVED')
    res.json({save:true})
});
Run Code Online (Sandbox Code Playgroud)

Problem with the above code is video is not playable I don't why Am I really doing something …

buffer fs node.js arraybuffer getusermedia

5
推荐指数
1
解决办法
6414
查看次数

标签 统计

arraybuffer ×1

buffer ×1

fs ×1

getusermedia ×1

node.js ×1