Skip to content

Commit

Permalink
Merge pull request felixge#64 from phated/master
Browse files Browse the repository at this point in the history
add image size option to png encoder
  • Loading branch information
bkw committed Sep 4, 2013
2 parents 8f544a5 + 3056077 commit 879f644
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ server. Once you have done that, you should try feeding them into the
Returns a new `Client` object. `options` include:

* `ip`: The IP of the drone. Defaults to `'192.168.1.1'`.
* `frameRate`: The frame rate of the PngEncoder. Defaults to `5`.
* `imageSize`: The image size produced by PngEncoder. Defaults to `null`.

#### client.createREPL()

Expand Down
18 changes: 11 additions & 7 deletions lib/video/PngEncoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function PngEncoder(options) {
this.readable = true;

this._spawn = options.spawn || spawn;
this._imageSize = options.imageSize || null;
this._frameRate = options.frameRate || 5;
this._pngSplitter = options.pngSplitter || new PngSplitter();
this._log = options.log;
Expand Down Expand Up @@ -87,14 +88,17 @@ PngEncoder.prototype._initFfmpegAndPipes = function() {
};

PngEncoder.prototype._spawnFfmpeg = function() {
var ffmpegOptions = [];
ffmpegOptions.push('-i', '-'); // input flag
ffmpegOptions.push('-f', 'image2pipe'); // format flag
if(this._imageSize){
ffmpegOptions.push('-s', this._imageSize); // size flag
}
ffmpegOptions.push('-vcodec', 'png'); // codec flag
ffmpegOptions.push('-r', this._frameRate); // framerate flag
ffmpegOptions.push('-'); // output
// @TODO allow people to configure the ffmpeg path
return this._spawn('ffmpeg', [
'-i' ,'-',
'-f', 'image2pipe',
'-vcodec', 'png',
'-r', this._frameRate,
'-',
]);
return this._spawn('ffmpeg', ffmpegOptions);
};

PngEncoder.prototype.end = function() {
Expand Down

0 comments on commit 879f644

Please sign in to comment.