I'm just trying to save an mp4 to a different mp4 (before I even start playing around with the different compression settings). What exactly is going wrong here?
const ffmpeg = require('ffmpeg');
try {
var process = new ffmpeg('./original.mp4');
process.then(function (video) {
video
.save('./new.mp4', function (error, file) {
if (!error) {
console.log('Video file: ' + file);
} else {
console.log(error)
}
});
}, function (err) {
console.log('Error: ' + err);
});
} catch (e) {
console.log(e.code);
console.log(e.msg);
}
I get the following error:
Error: Command failed: ffmpeg -i ./original.mp4 ./new.mp4
/bin/sh: ffmpeg: command not found
at ChildProcess.exithandler (child_process.js:390:12)
at ChildProcess.emit (events.js:400:28)
at maybeClose (internal/child_process.js:1055:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) {
killed: false,
code: 127,
signal: null,
cmd: 'ffmpeg -i ./original.mp4 ./new.mp4'
}
It seems that the library you're using tries to call an ffmpeg executable but cannot find it.
Related
I am trying to use https://www.npmjs.com/package/passbook to generate iOS passbook using lambda. The package has the following snippet to sign the manifest:
var sign = execFile("openssl", args, { stdio: "pipe" }, function(error, stdout, stderr) {
var trimmedStderr = stderr.trim();
// Windows outputs some unhelpful error messages, but still produces a valid signature
if (error || (trimmedStderr && trimmedStderr.indexOf('- done') < 0)) {
callback(new Error(error || stderr));
} else {
var signature = stdout.split(/\n\n/)[3];
callback(null, new Buffer(signature, "base64"));
}
});
But when I executed it on AWS Lambda (NodeJs 10), I got the following error:
Error: spawn openssl ENOENT
at /var/task/node_modules/passbook/lib/pass.js:361:16
at exithandler (child_process.js:301:5)
at ChildProcess.errorhandler (child_process.js:313:5)
at ChildProcess.emit (events.js:189:13)
at ChildProcess.EventEmitter.emit (domain.js:441:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
I am thinking the AMI image used does not have openssl installed. Does anyone know if openssl installed and where it is located?
I'm using node.js to run a python script through the web browser. below is the ScriptRunner.js code.
var PythonShell = require('python-shell');
var path = require('path');
exports.runScript = function() {
var options = {
scriptPath: 'D:\L4Project\working code\finalproject\routes'
};
PythonShell.run('sensitive2.py',options, function (err, results) {
if (err) throw err;
console.log('results: %j', results);
});
}
when I run the script in browser it returns error message like below.
D:\L4Project\working code\finalproject\routes\scriptRunner.js:10
if (err) throw err;
^
outes\sensitive2.py': [Errno 22] Invalid argumentg codeinalproject at PythonShell.parseError (D:\L4Project\working code\finalproject\node_modules\python-shell\index.js:191:17)
at terminateIfNeeded (D:\L4Project\working code\finalproject\node_modules\python-shell\index.js:98:28)
at ChildProcess.<anonymous> (D:\L4Project\working code\finalproject\node_modules\python-shell\index.js:89:9)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
I have googles lot and nothing worked. Can Somebody help me to solve the problem?
Want to concatenate two audio files. i used an npm known as audioconcate but when i installed and configured the below code i am confronted with the following error
Error: Error: Cannot find ffmpeg
at E:\VoiceMan\registercheck\node_modules\fluent-ffmpeg\lib\processor.js:136:22
at E:\VoiceMan\registercheck\node_modules\fluent-ffmpeg\lib\capabilities.js:123:9
at E:\VoiceMan\registercheck\node_modules\async\dist\async.js:356:16
at nextTask (E:\VoiceMan\registercheck\node_modules\async\dist\async.js:5057:29)
at E:\VoiceMan\registercheck\node_modules\async\dist\async.js:5064:13
at apply (E:\VoiceMan\registercheck\node_modules\async\dist\async.js:21:25)
at E:\VoiceMan\registercheck\node_modules\async\dist\async.js:56:12
at E:\VoiceMan\registercheck\node_modules\async\dist\async.js:840:16
at E:\VoiceMan\registercheck\node_modules\fluent-ffmpeg\lib\capabilities.js:116:11
at E:\VoiceMan\registercheck\node_modules\fluent-ffmpeg\lib\utils.js:223:16
ffmpeg stderr: undefined
here is the code i am using: (all audio files are in the same folder also)
var audioconcat = require('audioconcat')
var songs = [
'a(1).mp3',
'a(2).mp3',
'a(3).mp3'
]
audioconcat(songs)
.concat('all.mp3')
.on('start', function (command) {
console.log('ffmpeg process started:', command)
})
.on('error', function (err, stdout, stderr) {
console.error('Error:', err)
console.error('ffmpeg stderr:', stderr)
})
.on('end', function (output) {
console.error('Audio created in:', output)
})
Does not look like you have ffmpeg installed, it is a requirement for that package.
Requirements
ffmpeg with additional compilation flags --enable-libass --enable-libmp3lame
https://www.npmjs.com/package/audioconcat
I'm using Node v6.7.0 trying to use 'fs' module but there is error as you see below. i Have tried to install it in addition but is not working(even if i add whole path). If i check in the site https://www.npmjs.com/package/fs you can see the message. Any ideas how can use the module?
var filename = process.argv[2];
var version = process.argv[3];
var fs = require('fs');
var prompt = require('C:/Program Files/nodejs/node_modules/prompt');
var p4 = require('C:/Program Files/nodejs/node_modules/p4');
p4.edit(filename, function(err, data) {
if (err) {
console.error(err.message);
}
fs.readFile(filename, 'utf8', function (err, data) {
if (err) {
return console.log(err);
}
var result = data.replace(/string to be replaced/g, version);
fs.writeFile(filename, result, 'utf8', function (err) {
if (err) return console.log(err);
});
});
console.log(data);
prompt.start();
prompt.get('p4 submit -c changelist', function (err, result) {
if(err) {
console.log(err.message);
}
console.log(result);
});
});
fs.js:303
binding.open(pathModule._makeLong(path),
^
TypeError: path must be a string or Buffer
at TypeError (native)
at Object.fs.readFile (fs.js:303:11)
at C:\WorkSpace\http.js:22:9
at C:\Program Files\nodejs\node_modules\p4\p4.js:13:24
at ChildProcess.exithandler (child_process.js:213:5)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Socket.<anonymous> (internal/child_process.js:334:11)
at emitOne (events.js:96:13)
Process finished with exit code 1
fs is a nodejs core module : here is the fs documentation
I found the answer it should be executed in node command line and var filename = process.argv[2]; must be filled up.
I use node youtube-dl modul with Meteor.js to get information about youtube videos, bc I'm learning to work with Meteor server side, but I get this error I can't solve for half a day. Since youtube-dl is npm modul, can Meteor work with those without further customization?
Client code:
if (Meteor.isClient) {
Template.front.events({
'click #buttondl': function () {
// if submited link to input
if (inputdl.value != '') {
var link = inputdl.value;
Meteor.call('information', link);
}
}
});
}
Server code:
if (Meteor.isServer) {
Meteor.methods({
information: function (link) {
var youtubedl = Meteor.require('youtube-dl');
var url = youtubedl(link);
youtubedl.getInfo(url, function(err, info) {
if (err) throw err;
console.log('id:', info.id);
console.log('title:', info.title);
console.log('url:', info.url);
console.log('thumbnail:', info.thumbnail);
console.log('description:', info.description);
console.log('filename:', info._filename);
console.log('duration:', info.duration);
console.log('format_id:', info.format_id);
});
}
});
}
And the error I'm getting:
W20150709-14:35:19.472(-4)? (STDERR) events.js:72
W20150709-14:35:19.472(-4)? (STDERR) throw er; // Unhandled 'error' event
W20150709-14:35:19.472(-4)? (STDERR) ^
W20150709-14:35:19.477(-4)? (STDERR) Error: Command failed: File "/Users/matejhlavacka/node_modules/youtube-dl/bin/youtube-dl", line 2
W20150709-14:35:19.478(-4)? (STDERR) SyntaxError: Non-ASCII character '\xc4' in file /Users/matejhlavacka/node_modules/youtube-dl/bin/youtube-dl on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
W20150709-14:35:19.478(-4)? (STDERR)
W20150709-14:35:19.478(-4)? (STDERR) at ChildProcess.exithandler (child_process.js:658:15)
W20150709-14:35:19.478(-4)? (STDERR) at ChildProcess.emit (events.js:98:17)
W20150709-14:35:19.478(-4)? (STDERR) at maybeClose (child_process.js:766:16)
W20150709-14:35:19.478(-4)? (STDERR) at Socket.<anonymous> (child_process.js:979:11)
W20150709-14:35:19.478(-4)? (STDERR) at Socket.emit (events.js:95:17)
W20150709-14:35:19.479(-4)? (STDERR) at Pipe.close (net.js:466:12)
EDIT:
I finally solved it. Instead of node-youtube-dl I used basic python youtube-dl and this tutorial on how to execute unix command with Meteor.
Sample code for getting video description on server is the following:
Meteor.methods({
information: function (link) {
exec = Npm.require('child_process').exec;
runCommand = function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if(error !== null) {
console.log('exec error: ' + error);
}
}
exec("youtube-dl --get-description " + link, runCommand);
}
});
It fails probably because you have a python version that is too old, as documented in the youtube-dl FAQ you need python 2.6 or higher. Upgrading python should solve the issue.