2014-06-20 254 views
2

我有一个时间的噩梦想弄明白这一点。我昨天问了一个关于这个问题的问题,但只是到目前为止,长话短说,我不能为我的生活弄清楚这一点。发生了一个错误:spawn 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 

有没有人碰到这个?

+3

通常表示它找不到您正在尝试产卵的文件,在这种情况下为ffmpeg.exe。将路径指向二进制文件,而不是文件夹。 –

+0

本财富,你是一个救生员,非常感谢:) – user2757842

+1

我怎么会去做这个在Mac上 –

回答

3

Ben Fortune修复了我的错误,结果我忘了在FFmpeg的安装路径中指定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');