an error happened: spawn ENOENT, node.js & FFmpeg

北城余情 提交于 2019-12-22 10:54:43

问题


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?


回答1:


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');


来源:https://stackoverflow.com/questions/24324231/an-error-happened-spawn-enoent-node-js-ffmpeg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!