You are absolutely right.
The Readable
stream emits end
event only when it is totally consumed.
Have a look here: http://nodejs.org/api/stream.html#stream_event_end
Node.js & avconv — real-time video conversion
Pergunta
I'm working on real-time video conversion demo app. Video file is parsed with node-multiparty
, file's part is piped
to avconv.stdin
and when processed, the chunk pipes
to write stream
.
Here's a part of the source code:
var form = new multiparty.Form(),
args = ['-i', 'pipe:0', '-f', 'webm', 'pipe:1'],
avconv = spawn('avconv', args),
output = fs.createWriteStream(filePath);
form.on('part', function (part) {
if (part.filename) {
part.pipe(avconv.stdin);
part.on('end', function() {
console.log('===== Video has been uploaded! =====');
avconv.stdin.end();
});
}
});
avconv.stdout.pipe(output);
I'm interested in end
event attached to file's part
. Normally the event should be fired when a part is parsed, which means it has been uploaded.
I have a test video file (~800KB) and a low-level laptop for testing. While running a test on localhost, end
event is firing at the very end of avconv
conversion process, which lasts for ~15s.
800KB video file has been uploaded way faster, but it looks like the part
stream is still not empty waiting for data to be processed by avconv
.
Am I right or there's another thing?
Solução