diff --git a/lib/video.js b/lib/video.js index 903efdb..d282381 100644 --- a/lib/video.js +++ b/lib/video.js @@ -45,7 +45,7 @@ module.exports = function (filePath, settings, infoConfiguration, infoFile) { * Add an input stream */ this.addInput = function (argument) { - inputs.push(argument); + inputs.push(`"${argument.replace('"', '\\"')}"`); } /** @@ -59,7 +59,7 @@ module.exports = function (filePath, settings, infoConfiguration, infoFile) { * Set the output path */ var setOutput = function (path) { - output = path; + output = `"${path.replace('"', '\\"')}"`; } /*********************/ @@ -455,7 +455,7 @@ module.exports = function (filePath, settings, infoConfiguration, infoFile) { */ var resetCommands = function (self) { commands = new Array() - inputs = [self.file_path]; + inputs = [`"${self.file_path.replace('"', '\\"')}"`]; filtersComlpex = new Array(); output = null; options = new Object(); @@ -541,7 +541,9 @@ module.exports = function (filePath, settings, infoConfiguration, infoFile) { return { width : width, height : height, aspect : aspect }; } - + var encodeArguments = function(argu) { + return argu.replace(/"/g, '\"').replace(/ /g, '\ ').replace(/\(/g, '\(').replace(/\)/g, '\)'); + } /** * Executing the commands list */ @@ -551,16 +553,12 @@ module.exports = function (filePath, settings, infoConfiguration, infoFile) { var onlyDestinationFile = folder != undefined ? false : true; // Building the value for return value. Check if the callback is not a function. In this case will created a new instance of the deferred class var deferred = typeof callback != 'function' ? when.defer() : { promise : null }; - // Deal with input paths that have spaces in them, by quoting them - for (i=0; i 0 ? ['-filter_complex "'].concat(filtersComlpex.join(', ')).join('') + '"' : []) - .concat([output]); + .concat([encodeArguments(output)]); // Reset commands resetCommands(this); // Execute the commands from the list @@ -623,7 +621,7 @@ module.exports = function (filePath, settings, infoConfiguration, infoFile) { this.addCommand('-vn'); this.addCommand('-ar', 44100); this.addCommand('-ac', 2); - this.addCommand('-ab', 192); + this.addCommand('-ab', '192k'); this.addCommand('-f', 'mp3'); // Add destination file path to the command list