1
0
mirror of synced 2024-09-28 17:16:08 +00:00
SecurityCam.js/output-mjpeg-split.js
Mark van Renswoude dd75bef94f Separated the output into separate pluggable modules
Added raw and mjpeg-split output modules
Added before/after/during commands
Updated sample config and added readme
2016-07-16 11:35:15 +02:00

44 lines
783 B
JavaScript

var MjpegConsumer = require('mjpeg-consumer');
var FileOnWrite = require('file-on-write');
var helpers = require('./helpers');
function OutputMJPEGSplit(camId, options, now)
{
var frameCounter = 0;
this.output = new FileOnWrite({
filename: function(data)
{
frameCounter++;
return helpers.createVariableFilename(options.filename, now,
{
camId: camId,
frame: frameCounter
});
}
});
this.consumer = new MjpegConsumer();
this.consumer.pipe(this.output);
}
OutputMJPEGSplit.prototype.getStream = function()
{
return this.consumer;
};
OutputMJPEGSplit.prototype.cleanup = function()
{
if (this.consumer !== null)
{
this.consumer.end();
this.consumer = null;
}
}
module.exports = OutputMJPEGSplit;