【发布时间】:2021-09-20 17:28:39
【问题描述】:
我试图使用名为youtube-mp3-downloader 的 npm 包制作 youtube 视频到 mp3 转换器,npm 文档说我必须下载 FFmpeg 才能运行程序,所以我下载了 FFmpeg Windows 版本。然后我将 FFmpeg 二进制路径添加到代码中,以便运行程序并获得预期的输出,即保存到指定位置的 mp3 文件和输出数据,但每次运行程序时,我都会收到错误 spawn ../client/ffmpeg-4.4-full_build/bin ENOENT .当我研究错误时,我发现我必须将ffmpeg 和fluent-ffmpeg 依赖项安装到我的节点模块中,所以我这样做了,但错误仍然存在。我做错了什么?
var YoutubeMp3Downloader = require("youtube-mp3-downloader");
//Configure YoutubeMp3Downloader with your settings
var YD = new YoutubeMp3Downloader({
// FFmpeg binary location *Where the error is arising
"ffmpegPath": "../client/ffmpeg-4.4-full_build/bin",
// Output file location (default: the home directory)
"outputPath": "../client/audio",
// Desired video quality (default: highestaudio)
"youtubeVideoQuality": "highestaudio",
"queueParallelism": 2, // Download parallelism (default: 1)
// Interval in ms for the progress reports (default: 1000)
"progressTimeout": 2000,
"allowWebm": false // Enable download from WebM sources (default: false)
});
//Download video and save as MP3 file
YD.download("Vhd6Kc4TZls");
YD.on("finished", function(err, data) {
console.log(JSON.stringify(data));
});
YD.on("error", function(error) {
console.log(error);
});
YD.on("progress", function(progress) {
console.log(JSON.stringify(progress));
});
【问题讨论】:
标签: javascript node.js ffmpeg