I'm trying to take screenshots from a movie file and my app crashes with the following error:
$ FFMPEG_PATH=C:\\Apps\\ffmpeg\\bin\\ node .
=====Convert Video Failed======
{ [Error: spawn c:\Apps\ffmpeg\bin\ffprobe.exe
c:\Program Files (x86)\ImageMagick-6.8.3-Q16\ffprobe.exe ENOENT]
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn c:\\Apps\\ffmpeg\\bin\\ffprobe.exe\r\nc:\\Program Files (x86)\\ImageMagick-6.8.3-Q16\\ffprobe.exe',
path: 'c:\\Apps\\ffmpeg\\bin\\ffprobe.exe\r\nc:\\Program Files (x86)\\ImageMagick-6.8.3-Q16\\ffprobe.exe',
spawnargs:
[ '-show_streams',
'-show_format',
'j:\\some.avi' ] }
stdout: undefined
stderr: undefined
As you can see I'm passing a the FFMPEG_PATH env variable because otherwise I'm getting a similar error:
$ node .
=====Convert Video Failed======
{ [Error: spawn c:\Apps\ffmpeg\bin\ffprobe.exe
c:\Program Files (x86)\ImageMagick-6.8.3-Q16\ffprobe.exe ENOENT]
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn c:\\Apps\\ffmpeg\\bin\\ffprobe.exe\r\nc:\\Program Files (x86)\\ImageMagick-6.8.3-Q16\\ffprobe.exe',
path: 'c:\\Apps\\ffmpeg\\bin\\ffprobe.exe\r\nc:\\Program Files (x86)\\ImageMagick-6.8.3-Q16\\ffprobe.exe',
spawnargs:
[ '-show_streams',
'-show_format',
'j:\\some.avi' ] }
stdout: undefined
stderr: undefined
In both cases you can see that the command that node/fluent-ffmpeg is using results in a double path like this: c:\\Apps\\ffmpeg\\bin\\ffprobe.exe\r\nc:\\Program Files (x86)\\ImageMagick-6.8.3-Q16\\ffprobe.exe which obviously fails.
What causes this and how do I fix it?
Win 7, Node v4.1.2, ffmpeg version N-76041-g0418541
The code I'm using:
var ffmpeg = require('fluent-ffmpeg');
// ffmpeg.setFfprobePath("c:\\Apps\\ffmpeg\\bin\\ffprobe.exe");
var filename = 'j:\\some.avi';
var command = ffmpeg(filename);
// Code from an example
command
.on('filenames', function(filenames) {
console.log('Will generate ' + filenames.join(', '))
})
.on('end', function() {
console.log('Screenshots taken');
})
.on('error', function(err, stdout, stderr) {
console.log(" =====Convert Video Failed======");
console.log(err);
console.log("stdout: " + stdout);
console.log("stderr: " + stderr);
})
.screenshots({
// Will take screens at 20%, 40%, 60% and 80% of the video
count: 4,
folder: 'd:\\projects\\pics'
})
It only happens in Git Bash - which I got used to working in window with. Running the script in normal cmd works properly.
Related
Having an issue with fs.writeFile in my nodejs app running locally where im getting an error of this below,
I am running on localhost xampp also on windows if that may be an issue?
[Error: ENOENT: no such file or directory, open 'C:\Users\exampleuser\Desktop\examplenodejspath\product\sku123.json'] {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\exampleuser\\Desktop\\examplenodejspath\\product\\sku123.json'
}
Below is a copy of the code.
var product = {"SKU": "sku123","name": "test"};
fs.writeFile(__dirname + "/product/" + product.SKU + ".json", product, 'utf8', function (err) {
if (err) {
return console.log(err);
}
console.log("product was saved!");
});
I can confirm the path is correct. but for some reason it still returns its not correct.
Any help would be appericated
I have an exe and I want to run it from node.js, and pass an argument, except that it doesn't work..
var exec = require('child_process').execFile;
const fs = require('fs');
try {
if (fs.existsSync("./program/bin/Release/program.exe")) {
console.log("Exists")
} else {
console.log("Not Exists")
}
} catch(err) {
console.log(err)
}
setTimeout(function() {
exec('./program/bin/Release/program.exe manual', function(err, data) {
console.log(err)
console.log(data.toString());
});
}, 0);
It definitely exists as it prints exists, and I can run it from a cmd prompt giving manual as an argument. But through node.js it is not working. It comes back with
Error: spawn ./program/bin/Release/program.exe manual ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn ./program/bin/Release/program.exe manual',
path: './program/bin/Release/program.exe manual',
spawnargs: [],
cmd: './program/bin/Release/program.exe manual'
}
Does anyone know?
Thanks
Arguments should be passed as an array of strings as the second argument, like so:
exec('./program/bin/Release/program.exe', ['manual'], function(err, data) {
console.log(err)
console.log(data.toString());
});
https://nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback
I am able to run 'ipconfig.exe' or 'netstat.exe' using exec but I am unable to run .bat command "chef" or "chef-apply".
OS: Windows 7
exports.testscript=function(req,res){
var exec = require('child_process').exec;
console.log("inside function");
var child = exec('chef-apply azurepro.rb' , {cwd :'C:\Users\xyz\chef-repo'},
function(error, stdout, stderr){
console.log(stdout);
console.log(stderr);
if (error !== null) {
console.log(error);
return;
}
});
//child.stdin.end();
};
I am getting this error,
{ [Error: spawn cmd.exe ENOENT]
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn cmd.exe',
path: 'cmd.exe',
cmd: 'cmd.exe /s /c "chef-apply azurepro.rb"' }
From my understanding the bin path for command is not resolved. How can I fix this?
I am using the gith to build a webhook server on the amazon server to automate the deployment. When I updated my repository, the gith server can receive the update, then I want to execute the bash.
The bash file is on the path of /home/ubuntu/node/githook/hook.sh, console.log(__dirname+'/hook.sh'); output the right path, but when using the execFile to execute the path, it gave a error
error { [Error: spawn EACCES] code: 'EACCES', errno: 'EACCES', syscall: 'spawn' }
The code is above, but don't know why executing the code gave me such error.
var gith = require('gith').create( 8080 );
var execFile = require('child_process').execFile;
gith({
repo: 'heroku/node-js-sample'
}).on( 'all', function( payload ) {
if( payload.branch === 'master' )
{
//console.log('all',payload );
console.log(__dirname+'/hook.sh');
execFile(__dirname+'/hook.sh', function(error, stdout, stderr) {
// Log success in some manner
if(error) console.log("error",error);
else console.log( 'exec complete',stdout );
});
}
});
You have to make your bash script executable. Use this :
chmod +x hook.sh
I've searched a lot but got no correct answer.
Firstly I'm sure the command is usable under command line, here is the output:
> lessc
lessc: no input files
usage: lessc [option option=parameter ...] <source> [destination]
However when use child_process.spawn, I got:
> node test.js
Encountered error: { [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }
I'm sure the process.env is given to spawn, here is the nodejs code:
var build = require('child_process').spawn(
'lessc',
[],
{
stdio: 'inherit',
env: process.env
}
);
build.on(
'error',
function (err) {
console.log('Encountered error:', err);
process.exit();
}
);
build.on(
'close',
function (err) {
console.log('close');
}
);
And weiredly, it only encounter ENOENT when the command is installed via npm install -g, it works well on for example dir or del system command
As is turns out, the following works:
var spawn = require('child_process').spawn;
var b = spawn(
process.env.comspec,
['/c', 'lessc'],
{ stdio: 'inherit' }
);
Note that you don't need to explicitly pass env as you do, the default is to inherit.