Skip to content

Commit

Permalink
Add stillImageSource option, for faster snapshot pulls in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
SphtKr committed Nov 12, 2016
1 parent 9d63067 commit 3381cf2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ffmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function FFMPEG(hap, ffmpegOpt) {
}

this.ffmpegSource = ffmpegOpt.source;
this.ffmpegImageSource = ffmpegOpt.stillImageSource;

this.services = [];
this.streamControllers = [];
Expand Down Expand Up @@ -122,7 +123,8 @@ FFMPEG.prototype.handleCloseConnection = function(connectionID) {

FFMPEG.prototype.handleSnapshotRequest = function(request, callback) {
let resolution = request.width + 'x' + request.height;
let ffmpeg = spawn('ffmpeg', (this.ffmpegSource + ' -t 1 -s '+ resolution + ' -f image2 -').split(' '), {env: process.env});
var imageSource = this.ffmpegImageSource !== undefined ? this.ffmpegImageSource : this.ffmpegSource;
let ffmpeg = spawn('ffmpeg', (imageSource + ' -t 1 -s '+ resolution + ' -f image2 -').split(' '), {env: process.env});
var imageBuffer = Buffer(0);

ffmpeg.stdout.on('data', function(data) {
Expand Down

0 comments on commit 3381cf2

Please sign in to comment.