I am having a nightmare of a time trying figure this out. I asked a question about this yesterday but only got so far, long story short, I cannot for the life of me figure this out.
All i want to do, is transcode a .avi file to a .flv file using FFmpeg in a node.js app, this works just using the command line for FFmpeg but not in the app, here's the code:
var ffmpeg = require('fluent-ffmpeg');
//make sure you set the correct path to your video file
var proc = new ffmpeg({ source: 'C:/Users/Jay/Documents/movie/drop.avi', nolog: true });
//Set the path to where FFmpeg is installed
proc.setFfmpegPath("C:\\Users\\Jay\\Documents\\FFMPEG\\bin");
proc
//set the size
//.withSize('50%') <-- error appears after this line
// set fps
//.withFps(24)
// set output format to force
//.toFormat('flv')
// setup event handlers
.on('end', function() {
console.log('file has been converted successfully');
})
.on('error', function(err) {
console.log('an error happened: ' + err.message);
})
// save to file <-- the new file I want -->
.saveToFile('C:/Users/Jay/Documents/movie/drop.flv');
The error appears on the line specified above, it's not an error with red writing, but it simply says:
an error happened: spawn ENOENT
Has anyone come across this?
By - nodejs tutorial - team The absence of PATH (i.e., it's undefined) will cause spawn to emit the ENOENT error, as it will not be possible to locate any command unless it's an absolute path to the executable file.
The reason the spawn was broken in the first place was because we were overriding the child process' environment variables in options.env which it normally would have inherited from its parent process. So without the PATH environment variable, the operating system doesn't know where to look for the node executable.
The absence of PATH (i.e., it's undefined) will cause spawn to emit the ENOENT error, as it will not be possible to locate any command unless it's an absolute path to the executable file. Spawn may emit the ENOENT error if the filename command (i.e, 'some-command') does not exist in at least one of the directories defined on PATH.
The key idea is to wrap the original spawn call with a wrapper which prints the arguments send to the spawn call. Here is the wrapper function, put it at the top of the index.js or whatever your server's starting script. click below button to copy the code. By - nodejs tutorial - team
Ben Fortune fixed the error for me, turns out I forgot to specify the ffmpeg.exe in the path to where FFmpeg was installed. Here is the updated version of the code:
var ffmpeg = require('fluent-ffmpeg');
//make sure you set the correct path to your video file
var proc = new ffmpeg({ source: 'C:/Users/Jay/Documents/movie/drop.avi', nolog: true });
//Set the path to where FFmpeg is installed
proc.setFfmpegPath("C:\\Users\\Jay\\Documents\\FFMPEG\\bin\\ffmpeg.exe"); //I forgot to include "ffmpeg.exe"
proc
//set the size
.withSize('50%')
// set fps
.withFps(24)
// set output format to force
.toFormat('flv')
// setup event handlers
.on('end', function() {
console.log('file has been converted successfully');
})
.on('error', function(err) {
console.log('an error happened: ' + err.message);
})
// save to file <-- the new file I want -->
.saveToFile('C:/Users/Jay/Documents/movie/drop.flv');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With