2014-06-20 326 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');