6

我正在做噩梦,试图弄清楚这一点。我昨天问了一个关于这个的问题,但到目前为止,长话短说,我无法为我的生活解决这个问题。

我想要做的就是在 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

有没有人遇到过这个?

4

1 回答 1

9

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');
于 2014-06-20T09:47:20.827 回答