发生错误:产生ENOENT,node.js&FFmpeg

我有一个噩梦的时间试图解决这个问题。 我昨天问了一个关于这个问题的问题,但是到目前为止,长话短说,我不能为我的生活弄清楚这一点。

我想要做的就是在一个node.js应用程序中使用FFmpeg将一个.avi文件转码为一个.flv文件,这个工作只是使用FFmpeg的命令行而不是在应用程序中,代码如下:

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

错误出现在上面指定的行上,这不是红色写入错误,但它只是说:

 an error happened: spawn ENOENT 

有没有人遇到过这个?

Ben Fortune为我修复了这个错误,结果我忘记了在FFmpeg的安装path中指定了ffmpeg.exe。 以下是代码的更新版本:

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