如何为您的 Discord 机器人安装 FFMPEG?

How to install FFMPEG for your discord bot?

我想让我的 discord 机器人播放音乐,但我一直收到 "FFMPEG not found" 错误。

我的机器人主要由 ping 组成,所以我不会上传那部分。音乐代码应该是这首

const Discord = require('discord.js');
const bot = new Discord.Client();
var bm = message.content.toLowerCase()

bot.on('message',(message) => {

     if (bm == "pray") {
    var VC = message.member.voiceChannel;
    if (!VC)
        return message.reply("You are not in the church my son.")
VC.join()
    .then(connection => {
        const dispatcher = connection.playFile('d:/mp3.MP3');
        dispatcher.on("end", end => {VC.leave()});
    })
    .catch(console.error); )

P.S。 : 我知道我应该以某种方式导入 FFMPEG,因为我已经下载了它。但是我不知道怎么办。

我在 http://blog.gregzaal.com/how-to-install-ffmpeg-on-windows/ 上找到了答案。在这里你可以看到如何添加FFMPEG下载、解压、路径和使用。

你应该从 NPM 安装所有与 ffmpeg 相关的模块,然后定义它(比如,const ffmpeg = require("ffmpeg-extra")。 这对我有用。

Watch: How to set Environment variables in Windows.
This is required to understand the HowTo below.

安装 FFmpeg

  • 从 zeranoe 下载二进制文件。
  • 解压缩并复制 bin 文件夹内容。
  • C: 驱动器中创建一个名为 ffmpeg_bins 的目录。
  • 通过单击浏览文件夹将其添加到路径。

恭喜,您刚刚学会了在 Windows OS.

中安装 FFmpeg