发生了一个错误:spawn ENOENT,node.js和FFmpeg。

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

有人遇到过这个问题吗?


3
通常意味着它无法找到您要生成的文件,这种情况下是ffmpeg.exe。将路径指向二进制文件,而不是文件夹。 - Ben Fortune
Ben Fortune,你真是救星,非常感谢 :) - user2757842
1
我该如何在Mac上完成这个任务? - Nick Garver
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');

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接