Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 28a37e7500a7275b9b31e85c9ce13d10f1f24da8 1 parent 82fd9e2
@schaermu schaermu authored
View
11 lib/fluent-ffmpeg.js
@@ -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
10 lib/processor.js
@@ -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
43 test/args.test.js
@@ -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
2  test/coverage.html
1 addition, 1 deletion not shown
Please sign in to comment.
Something went wrong with that request. Please try again.