1
0
mirror of synced 2024-09-28 17:16:08 +00:00
SecurityCam.js/output-ffmpeg.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

45 lines
890 B
JavaScript

var util = require('util');
var stream = require('stream');
var FfmpegCommand = require('fluent-ffmpeg');
var helpers = require('./helpers');
function OutputFFMPEG(camId, options, now)
{
this.output = new stream.PassThrough();
var command = new FfmpegCommand();
command
.input(this.output)
.inputFormat(options.inputFormat);
if (options.inputFormat === 'mjpeg')
command.inputOption('-use_wallclock_as_timestamps 1');
command
.output(helpers.createVariableFilename(options.filename, now,
{
camId: camId
}))
.videoCodec(options.videoCodec)
.outputFormat(options.outputFormat)
.run();
}
OutputFFMPEG.prototype.getStream = function()
{
return this.output;
};
OutputFFMPEG.prototype.cleanup = function()
{
if (this.output !== null)
{
this.output.end();
this.output = null;
}
}
module.exports = OutputFFMPEG;