Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions lib/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('"', '\\"')}"`);
}

/**
Expand All @@ -59,7 +59,7 @@ module.exports = function (filePath, settings, infoConfiguration, infoFile) {
* Set the output path
*/
var setOutput = function (path) {
output = path;
output = `"${path.replace('"', '\\"')}"`;
}

/*********************/
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
*/
Expand All @@ -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<inputs.length; i++) {
inputs[i] = '\'' + inputs[i] + '\'';
}
// Create a copy of the commands list
var finalCommands = ['ffmpeg -i']
.concat(inputs.map(utils.addQuotes).join(' -i '))
.concat(inputs.map(encodeArguments).join(' -i '))
.concat(commands.join(' '))
.concat(filtersComlpex.length > 0 ? ['-filter_complex "'].concat(filtersComlpex.join(', ')).join('') + '"' : [])
.concat([output]);
.concat([encodeArguments(output)]);
// Reset commands
resetCommands(this);
// Execute the commands from the list
Expand Down Expand Up @@ -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
Expand Down