javascript - Discord 机器人:修复“未找到 FFMPEG”
问题描述
我想让我的 Discord 机器人加入语音聊天,但每次我做到这一点时,我都会在 log(cmd) 中出现错误,说FFMPEG not found
,请帮助我。
错误图片:
这是代码:
client.on('message', message => {
// Voice only works in guilds, if the message does not come from a guild,
// we ignore it
if (!message.guild) return;
if (message.content === '/join') {
// Only try to join the sender's voice channel if they are in one themselves
if (message.member.voiceChannel) {
message.member.voiceChannel.join()
.then(connection => { // Connection is an instance of VoiceConnection
message.reply('I have successfully connected to the channel!');
})
.catch(console.log);
} else {
message.reply('You need to join a voice channel first!');
}
}
});
这是我的 package.json 文件:
{
"name": "xxxtentacion",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
},
"dependencies": {
"discord.js": "^11.4.2",
"dotenv": "^6.2.0",
"ffmpeg": "0.0.4",
"opusscript": "0.0.6"
},
"devDependencies": {
"nodemon": "^1.18.9"
}
}
解决方案
FFmpeg是处理音频/视频/图像/字幕内容的便捷工具,在这种情况下,此工具用于从比特流(例如 mp4、mkv、flv、ogg)的任意容器中提取音频到不和谐兼容的 VoIP 编解码器作品。
尽管它旨在独立于平台,但对于每个平台都需要不同的程序,请注意:我只列出了我擅长的那些平台。
GNU/Linux
您主要使用包管理器来安装它及其依赖项,或者您可以使用手动编译代码的方式使用此处描述的步骤。
# Ubuntu / Debian / Linux Mint
sudo apt install ffmpeg
# ArchLinux / Manjaro / Anarchy
sudo pacman -S ffmpeg
# Gentoo / Funtoo
USE=opus sudo emerge ffmpeg
视窗
Windows 不像 GNU/Linux 那样容易,你要么手动满足所有依赖项,然后用 MSVC 自己编译所有东西,要么使用 Cygwin 或 Msys2 编译。另一种方法是从Zeranoe的网站下载预编译的 Windows 二进制文件。由于Zeranoe的网站已关闭,请从Gyan的网站或其他任何地方下载。
这将为您下载一个 Zip 存档,您必须提取并复制该bin/
文件夹的所有内容,即 FFmpeg 二进制文件。或者,将它们存储在PATH环境变量中列出的文件路径中,以便像ffmpeg
在 shell 中一样简单地运行它。
推荐阅读
- python - 在 SQLAlchemy 中加入两个 text() 语句
- angular - tslint 吐出圈复杂度错误
- android - 打开谷歌地图并返回用户选择的位置
- database - Cassandra cql 相当于 sql 中的 over()
- c# - 带有 On 前缀的订阅者方法
- r - 如何使用 R 中的范围(开始-结束)值将单列拆分为多列?
- c# - 如何让 UWP GridView 用鼠标滚轮水平滚动
- python - 如何使用“pymqi”Python 库在队列管理器中配置 CCSID 值?
- r - 如何使用 if 和函数在 R 中的传单中添加弹出窗口?
- xml - 如何使用 xslt 从输入 xml 中获取重复属性的值到单个值