gpt4 book ai didi

node.js - 发生错误 : spawn ENOENT, node.js 和 FFmpeg

转载 作者:搜寻专家 更新时间:2023-10-31 23:42:55 26 4
gpt4 key购买 nike

我一直在做一场噩梦,试图解决这个问题。昨天我问了一个关于这个的问题,但到此为止,长话短说,我这辈子都弄不明白。

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

有没有人遇到过这个?

最佳答案

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

关于node.js - 发生错误 : spawn ENOENT, node.js 和 FFmpeg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24324231/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com