Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed uuid dependency

  • Loading branch information...
commit baf569bf8e8e19c72067a390dce265a75fb6ff58 1 parent 2b1b484
@eralpkaraduman eralpkaraduman authored
Showing with 22 additions and 21 deletions.
  1. +11 −7 examples/mergeVideos.js
  2. +10 −13 lib/processor.js
  3. +1 −1  package.json
View
18 examples/mergeVideos.js
@@ -7,17 +7,21 @@ var ffmpeg = require('../index');
ffmpeg -i source.mp4 -qscale:v 1 intermediate2.mpg
ffmpeg -i concat:"intermediate1.mpg|intermediate2.mpg" -c copy intermediate_all.mpg
ffmpeg -i intermediate_all.mpg -qscale:v 2 output.mp4
+
+ Create temporary .mpg files for each video and deletes them after merge is completed.
+ These files are created by filename pattern like [videoFilename.ext].temp.mpg [outputFilename.ext].temp.merged.mp4
*/
var firstFile = "title.mp4";
-var secondFile = "source.mp4"
-var outPath = "out.mp4"
-var tempFolderPath = "myTempFolder/"; // requires a temp folder to store intermediate videos, deletes them after merge is completed.
+var secondFile = "source.mp4";
+var thirdFile = "third.mov";
+var outPath = "out.mp4";
var proc = new ffmpeg({source:firstFile,nolog:true})
.mergeAdd(secondFile)
- //.mergeAdd(thirdFile)
+ .mergeAdd(thirdFile)
//.mergeAdd(fourthFile)
- .mergeToFile(outPath,tempFolderPath,function(){
- console.log('files has been merged succesfully');
- });
+ //.mergeAdd(...)
+ .mergeToFile(outPath,function(){
+ console.log('files have been merged successfully');
+ });
View
23 lib/processor.js
@@ -4,8 +4,7 @@ var fs = require('fs'),
os = require('os').platform(),
exec = require('child_process').exec,
spawn = require('child_process').spawn,
- Registry = require('./registry'),
- uuid = require('node-uuid'),
+ Registry = require('./registry');
exports = module.exports = function Processor(command) {
// constant for timeout checks
@@ -106,7 +105,7 @@ exports = module.exports = function Processor(command) {
});
};
- this.mergeToFile = function(targetfile,tempFolderPath,callback){
+ this.mergeToFile = function(targetfile,callback){
this.options.outputfile = targetfile;
var self = this;
var options = this.options;
@@ -118,26 +117,24 @@ exports = module.exports = function Processor(command) {
// creates intermediate copies of each video.
var makeIntermediateFile = function(_mergeSource,_callback){
- var fname = uuid.v1()+".mpg";
- var fullP = self.escapedPath(path.join(tempFolderPath, fname), true);
+ var fname = _mergeSource+".temp.mpg";
var command = [
self.ffmpegPath,
[
'-i', _mergeSource,
'-qscale:v',1,
- fullP
+ fname
].join(' ')
];
exec(command.join(' '),function(err, stdout, stderr) {
if(err)throw err;
- _callback(fullP);
+ _callback(fname);
});
};
// concat all created intermediate copies
- var concatIntermediates = function(intermediatesList,_callback){
- var fname = uuid.v1()+".mpg";
- var fullP = self.escapedPath(path.join(tempFolderPath, fname), true);
+ var concatIntermediates = function(target,intermediatesList,_callback){
+ var fname = target+".temp.merged.mpg";
// unescape paths
for(var i=0; i<intermediatesList.length; i++){
@@ -150,12 +147,12 @@ exports = module.exports = function Processor(command) {
'-loglevel','panic', //Generetes too much muxing warnings and fills default buffer of exec. This is to ignore them.
'-i', 'concat:"'+intermediatesList.join("|")+'"',
'-c',"copy",
- fullP
+ fname
].join(' ')
];
exec(command.join(' '), function(err, stdout, stderr) {
if(err)throw err;
- _callback(fullP);
+ _callback(fname);
});
};
@@ -203,7 +200,7 @@ exports = module.exports = function Processor(command) {
})
},function(err){
if(err)throw err;
- concatIntermediates(intermediateFiles,function(concatResult){
+ concatIntermediates(targetfile,intermediateFiles,function(concatResult){
if(!concatResult)throw new Error("Invalid concat result file");
quantizeConcat(concatResult,intermediateFiles.length,function(){
intermediateFiles.push(concatResult); // add concatResult to intermediates list so it can be deleted too.
View
2  package.json
@@ -10,7 +10,7 @@
},
"repository": "git://github.com/schaermu/node-fluent-ffmpeg.git",
"devDependencies": { "mocha": "latest", "should": "latest" },
- "dependencies": { "winston": ">=0.5.10","node-uuid":"1.4.0" },
+ "dependencies": { "winston": ">=0.5.10" },
"engines" : { "node" : ">=0.5.0" },
"main": "index",
"scripts": {
Please sign in to comment.
Something went wrong with that request. Please try again.