phaux/node-ffmpeg-stream

Create a single audio / video stream using MediaStreamRecorder and Node.js

SalvatoreAD opened this issue · 6 comments

My webapp records the participants of video conference every 60 seconds and do the upload to the server using this function (I'm using another plugin (socket.io-stream) .

Server-side

ss(socket).on("file:add:stream", function(stream, data, roomId) {
    console.log(stream);
    var dataStream = fs.createWriteStream('./public/uploads/' + roomId + "/" + data + ".webm", {
        'flags': 'a',
        'encoding': 'base64'
    });

    stream.pipe(dataStream, {
        end: false
    });

    stream.on('end', function() {
        ss(socket).emit('file:add:stream:success');
    });
});

Client side

var stream = ss.createStream({
            highWaterMark: 384000,
            allowHalfOpen: true
        });
        stream.forceBase64 = true;
        ss(socket).emit('file:add:stream', stream, blob.streamid, roomId, blob.size);
        var blobReadStream = ss.createBlobReadStream(blob, {highWaterMark: 384000});
        blobReadStream.pipe(stream, {end: false});
        ss(socket).on('file:add:stream:success', function(data) {
            console.info('file uploaded to server');
        });

Whenever I concatenate the buffers arriving, the video saved (webm format) is played badly and out of sync.

How can I fix the problem with this plugin?

phaux commented
  1. Is the client code running in browser or node.js?
  2. Where does the client get the video stream from?
phaux commented

With this lib you can mix the streams as they are sent instead of using temporary file as you do now, but it won't help with the out-of-sync problem.

If you recorded the time when every client joined and then delay their stream in the final mixed stream appropiately there shouldn't be any problem.

The best solution would be to use WebRTC and make the server act as a peer in the meeting, but that's non-trivial.

Can you help me to create the server-side code and client-side code for browser? if I can create a better video files in my lib, it would be of great help. If you want I'll give you an email

phaux commented

No

I have difficulty to use your lib. Thanks anyway