【问题标题】:an error happened: spawn ENOENT, node.js & FFmpeg发生错误:spawn ENOENT、node.js & FFmpeg
【发布时间】:2014-06-20 17:47:20
【问题描述】:

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

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

有人遇到过这个吗?

【问题讨论】:

  • 通常意味着它找不到您要生成的文件,在本例中为 ffmpeg.exe。指向二进制文件的路径,而不是文件夹。
  • Ben Fortune,你是救生员,非常感谢 :)
  • 我将如何在 mac 上执行此操作

标签: node.js ffmpeg transcode


【解决方案1】:

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-11-13
    • 2016-10-07
    • 1970-01-01
    • 2015-12-15
    • 2014-09-25
    • 2022-11-04
    • 2019-11-25
    • 2015-10-02
    • 2019-11-01
    相关资源
    最近更新 更多