Permalink
Browse files

updated fork

  • Loading branch information...
1 parent 268da84 commit 38062b04898dadd61454a069aca3a5891bcd7b64 @smremde smremde committed Jun 28, 2013
Showing with 202 additions and 100 deletions.
  1. +1 −1 .travis.yml
  2. +37 −0 Gruntfile.js
  3. +7 −4 Makefile
  4. +18 −0 README.md
  5. +24 −0 examples/livertmp2hls.js
  6. +0 −35 grunt.js
  7. +2 −2 lib/extensions.js
  8. +5 −3 lib/fluent-ffmpeg.js
  9. +9 −8 lib/metadata.js
  10. +34 −14 lib/processor.js
  11. +25 −8 package.json
  12. +2 −1 test/args.test.js
  13. +10 −3 test/coverage.html
  14. +2 −1 test/debug.test.js
  15. +26 −20 test/processor.test.js
View
@@ -3,4 +3,4 @@ before_script:
- sudo apt-get install -y ffmpeg libavcodec-extra-53
language: node_js
node_js:
- - 0.6
+ - 0.8
View
@@ -0,0 +1,37 @@
+module.exports = function(grunt) {
+
+ grunt.initConfig({
+ pkg: grunt.file.readJSON('package.json'),
+ shell: {
+ makeTest: {
+ command: 'make test-colors',
+ options: {
+ stdout: true,
+ stderr: true
+ }
+ }
+ },
+ lint: {
+ files: ['grunt.js', 'lib/**/*.js']
+ },
+ watch: {
+ scripts: {
+ files: ['test/**/*.js','lib/**/*.js'],
+ tasks: ['shell'],
+ options: {
+ nospawn: true,
+ },
+ },
+ }
+ });
+
+ grunt.loadNpmTasks('grunt-contrib-watch');
+
+ grunt.loadNpmTasks('grunt-shell');
+
+ grunt.registerTask('test', ['shell']);
+
+ grunt.registerTask('commit', ['shell']);
+
+ grunt.registerTask('default', ['watch']);
+};
View
@@ -1,13 +1,16 @@
-REPORTER = list
+REPORTER = spec
test:
- @NODE_ENV=test ./node_modules/.bin/mocha -u bdd --require should --reporter $(REPORTER)
+ @NODE_ENV=test mocha --require should --reporter $(REPORTER)
+
+test-colors:
+ @NODE_ENV=test mocha --require should --reporter $(REPORTER) --colors
test-cov: lib-cov
@FLUENTFFMPEG_COV=1 $(MAKE) test REPORTER=html-cov > test/coverage.html
lib-cov:
@rm -fr ./$@
- @jscoverage --no-highlight lib $@
+ @jscoverage lib $@
-.PHONY: test test-cov lib-cov
+.PHONY: test test-cov lib-cov test-colors
View
@@ -2,6 +2,9 @@
This library abstracts the complex command-line usage of ffmpeg into a fluent, easy to use node.js module. In order to be able to use this module, make sure you have [ffmpeg](http://www.ffmpeg.org) installed on your system (including all necessary encoding libraries like libmp3lame or libx264).
Now including input streaming support (means you can convert **on-the-fly** using an input- and an outputstream)!
+
+### Sorry for the long period of inactivity, i had to settle some private stuff! Now back in full effect :)
+
## Installation
Via npm:
`$ npm install fluent-ffmpeg`
@@ -13,6 +16,8 @@ To run unit tests, make sure have mocha installed on your system (registered as
`$ make test`
+For constant checking your test install grunt globally (`npm uninstall -g grunt && npm install -g grunt-cli && npm install grunt`)
+
If you want to re-generate the test coverage report (filed under test/coverage.html), run
`$ make test-cov`
@@ -96,6 +101,9 @@ One pretty neat feature is the ability of fluent-ffmpeg to generate any amount o
var proc = new ffmpeg({ source: '/path/to/your_movie.avi' })
.withSize('150x100')
.takeScreenshots(5, '/path/to/thumbnail/folder', function(err, filenames) {
+ if(err){
+ throw err;
+ }
console.log(filenames);
console.log('screenshots were saved');
});
@@ -198,6 +206,16 @@ In case you need to add, for instance, and audio track
console.log('file has been created with soundtrack succesfully');
});
+### Concatenating Inputs
+To append a video to the end of another
+
+ var ffmpeg = require('fluent-ffmpeg');
+ var proc = new ffmpeg({source: "title.mp4"})
+ .mergeAdd("source.mp4")
+ .mergeToFile("out.mp4", "myTempFolder/", function(){
+ console.log('files has been merged succesfully');
+ });
+
### Creating a custom preset
To create a custom preset, you have to create a new file inside the `lib/presets` folder. The filename is used as the preset's name ([presetname].js). In order to make the preset work, you have to export a `load` function using the CommonJS module specifications:
View
@@ -0,0 +1,24 @@
+var ffmpeg = require('../index');
+
+// make sure you set the correct path to your video file
+var proc = new ffmpeg({ source: 'rtmp://path/to/live/stream', nolog: true, timeout: 432000, inputlive:true })
+ // set video bitrate
+ .withVideoBitrate(1024)
+ // set h264 preset
+ .addOption('preset','superfast')
+ // set target codec
+ .withVideoCodec('libx264')
+ // set audio bitrate
+ .withAudioBitrate('128k')
+ // set audio codec
+ .withAudioCodec('libfaac')
+ // set number of audio channels
+ .withAudioChannels(2)
+ // set hls segments time
+ .addOption('-hls_time', 10)
+ // include all the segments in the list
+ .addOption('-hls_list_size',0)
+ // save to file
+ .saveToFile('/path/to/your_target.m3u8', function(retcode, error){
+ console.log('file has been converted succesfully');
+ });
View
@@ -1,35 +0,0 @@
-module.exports = function(grunt) {
- // Project configuration.
- grunt.initConfig({
- pkg: '<json:package.json>',
- lint: {
- files: ['grunt.js', 'lib/**/*.js']
- },
- watch: {
- files: '<config:lint.files>',
- tasks: 'default'
- },
- jshint: {
- options: {
- curly: true,
- eqeqeq: true,
- immed: true,
- latedef: true,
- newcap: true,
- noarg: true,
- sub: true,
- undef: true,
- boss: true,
- eqnull: true,
- node: true,
- laxcomma: true
- },
- globals: {
- exports: true
- }
- }
- });
-
- // Default task.
- grunt.registerTask('default', 'lint');
-};
View
@@ -8,8 +8,8 @@ exports = module.exports = function Extensions() {
};
this.determineFfmpegPath = function() {
- if (process.env.FFMPEG_PATH) {
- return process.env.FFMPEG_PATH;
+ if (this.ffmpegPath) {
+ return this.ffmpegPath;
}
return 'ffmpeg';
};
View
@@ -12,10 +12,11 @@ var path = require('path'),
*/
function FfmpegCommand(args) {
var source = args.source,
- timeout = args.timeout || 30,
+ timeout = args.timeout != null ? args.timeout : 30,
priority = args.priority || 0,
logger = args.logger || null,
- nologging = args.nolog || false;
+ nologging = args.nolog || false,
+ inputlive = args.inputlive || false;
if (!logger && !nologging) {
// create new winston instance
@@ -58,6 +59,7 @@ function FfmpegCommand(args) {
keepPixelAspect: false,
inputfile: srcfile,
inputstream: srcstream,
+ inputlive: inputlive,
timeout: timeout,
mergeList:[],
video: {},
@@ -323,4 +325,4 @@ exports.Metadata = require('./metadata');
exports.Calculate = require('./calculate');
exports.CONSTANT_BITRATE = 1;
-exports.VARIABLE_BITRATE = 2;
+exports.VARIABLE_BITRATE = 2;
View
@@ -1,5 +1,6 @@
-var exec = require('child_process').exec
- , os = require('os').platform();
+var exec = require('child_process').exec,
+ path = require('path'),
+ os = require('os').platform();
exports = module.exports = function Metadata(inputfile) {
this.escapedPath = function(path, enclose) {
@@ -12,25 +13,25 @@ exports = module.exports = function Metadata(inputfile) {
var fName = parts[parts.length - 1];
parts[parts.length - 1] = fName.replace(/[\s\\:"'*?<>|\/]+/mig, '-');
path = parts.join('\\');
- if (enclose)
+ if (enclose && path[0] != '"' && path[path.length-1] != '"')
path = '"' + path + '"'
} else {
- if (enclose)
+ if (enclose && path[0] != '"' && path[path.length-1] != '"')
path = '"' + path + '"';
}
}
return path;
};
-
- this.inputfile = inputfile;
+
+ this.inputfile = inputfile?path.normalize(inputfile):'';
this.setFfmpegPath = function(path) {
this.ffmpegPath = path;
};
// for internal use
this.getMetadata = function(inputfile, callback) {
- this.inputfile = inputfile;
+ this.inputfile = path.normalize(inputfile);
this._loadDataInternal(callback);
};
@@ -42,7 +43,7 @@ exports = module.exports = function Metadata(inputfile) {
};
this._loadDataInternal = function(callback) {
- var inputfile = this.escapedPath(this.inputfile);
+ var inputfile = this.escapedPath(this.inputfile, true);
var self = this;
exec(this.ffmpegPath + ' -i ' + inputfile, function(err, stdout, stderr) {
// parse data from stderr
Oops, something went wrong.

0 comments on commit 38062b0

Please sign in to comment.