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

时间:2014-06-20 09:36:57

标签: node.js ffmpeg transcode

我正在做一个噩梦,试图解决这个问题。我昨天问了一个关于这个的问题,但到目前为止只有很长一段时间,我不能为我的生活做出这样的决定。

我想做的就是使用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

有没有人遇到过这个?

1 个答案:

答案 0 :(得分:4)

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