Permalink
Browse files

implemented loop([duration]) and takeFrames(frameCount) methods (closes

  • Loading branch information...
1 parent 82fd9e2 commit 28a37e7500a7275b9b31e85c9ce13d10f1f24da8 @schaermu schaermu committed Oct 30, 2012
Showing with 64 additions and 2 deletions.
  1. +11 −0 lib/fluent-ffmpeg.js
  2. +9 −1 lib/processor.js
  3. +43 −0 test/args.test.js
  4. +1 −1 test/coverage.html
View
@@ -137,6 +137,17 @@ function FfmpegCommand(args) {
this.options.video.codec = codec;
return this;
};
+ FfmpegCommand.prototype.loop = function(duration) {
+ this.options.video.loop = true;
+ if (duration) {
+ this.options.duration = duration;
+ }
+ return this;
+ };
+ FfmpegCommand.prototype.takeFrames = function(frameCount) {
+ this.options.video.framecount = frameCount;
+ return this;
+ };
FfmpegCommand.prototype.withAudioBitrate = function(abitrate) {
if (typeof abitrate === 'string' && abitrate.indexOf('k') > 0) {
abitrate = abitrate.replace('k', '');
View
@@ -447,6 +447,10 @@ exports = module.exports = function Processor(command) {
// add startoffset and duration
if (this.options.starttime) {
args.push('-ss', this.options.starttime);
+ }
+
+ if (this.options.video.loop) {
+ args.push('-loop', 1);
}
// add input file (if using fs mode)
@@ -489,6 +493,10 @@ exports = module.exports = function Processor(command) {
args.push('-t', this.options.duration);
}
+ if (this.options.video.framecount) {
+ args.push('-vframes', this.options.video.framecount);
+ }
+
// add format
if (this.options.format) {
args.push('-f', this.options.format);
@@ -585,7 +593,7 @@ exports = module.exports = function Processor(command) {
this.options.logger.error('no outputfile specified');
}
}
-//console.log(args);
+
return args;
};
};
View
@@ -281,6 +281,49 @@ describe('Command', function() {
args.indexOf('-ab').should.above(-1);
args.indexOf('256k').should.above(-1);
done();
+ });
+ });
+ });
+
+ describe('loop', function() {
+ it('should add the -loop 1 argument', function(done) {
+ new Ffmpeg({ source: this.testfile, nolog: true })
+ .loop()
+ .getArgs(function(args) {
+ args.indexOf('-loop').should.above(-1);
+ done();
+ });
+ });
+ it('should add the -loop 1 and a time argument (seconds)', function(done) {
+ new Ffmpeg({ source: this.testfile, nolog: true })
+ .loop(120)
+ .getArgs(function(args) {
+ args.indexOf('-loop').should.above(-1);
+ args.indexOf('-t').should.above(-1);
+ args.indexOf(120).should.above(-1);
+ done();
+ });
+ });
+ it('should add the -loop 1 and a time argument (timemark)', function(done) {
+ new Ffmpeg({ source: this.testfile, nolog: true })
+ .loop('00:06:46.81')
+ .getArgs(function(args) {
+ args.indexOf('-loop').should.above(-1);
+ args.indexOf('-t').should.above(-1);
+ args.indexOf('00:06:46.81').should.above(-1);
+ done();
+ });
+ });
+ });
+
+ describe('takeFrames', function() {
+ it('should add the -vframes argument', function(done) {
+ new Ffmpeg({ source: this.testfile, nolog: true })
+ .takeFrames(250)
+ .getArgs(function(args) {
+ args.indexOf('-vframes').should.above(-1);
+ args.indexOf(250).should.above(-1);
+ done();
});
});
});
View
Oops, something went wrong.

0 comments on commit 28a37e7

Please sign in to comment.