Thursday, 13 April 2017

Streaming binary data and using stream.pipe to write it to a file?

I want to stream binary data from my client (the client's canvas.toDataURL), in order to create a movie file.

My question is: What should I use to pipe the binary data and write it to a file? Take a look at the comment in my following node.js code:

server.on('connection', function (client) {
    client.on('stream', function (stream, meta) {

        var path = '../video/' + meta.id + '.webm';

        // Right here - What should I use to pipe the binary stream?
        stream.pipe(????????);
    });
});


Note: I'm currently doing the same for creating a .wav file, with no problem, using:

var wav = require('wav');

And then piping the data:

var fileWriter = new wav.FileWriter(path, { channels: 1, sampleRate: 44100, bitDepth: 16 });
stream.pipe(fileWriter);

But again, how can I implement the same for piping the images?



via Koby Douek

No comments:

Post a Comment