discordbot:修复“未找到的ffmpeg”

问题描述 投票:0回答:2

错误的错误:


这是代码:Error: 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!'); } } });

这是我的软件包。JSON文件:

{
  "name": "x",
  "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"
  }
}

向语音介绍
Discord.js中的语音可用于许多事物,例如音乐机器人,录制或中继音频。

在discord.js,您可以通过连接到VoiceChannel来获得语音来获取VoiceConnection,您可以在其中开始流式传输和接收音频。
javascript ffmpeg discord discord.js
2个回答
4
投票

ffmpeg -npm install ffmpeg-binaries

一个作品编码器,从下面选择一个:

npm install node-opus
(表现更好)

  • npm install opusscript
    (良好的网络连接)
  • 首选的Opus Engine是节点 - Opus,因为它的性能明显优于Opusscript。两者都可用时,Discord.js将自动选择node-opus。仅建议使用opusscript用于很难进行节点 - opus的开发环境。对于生产机器人,应该将使用节点opus视为必需品,尤其是在多个服务器上运行的情况下。
  • ffmpeg
是使用音频/视频/image/subtitle东西配合使用的便捷工具,在这种情况下,从任意容器中提取音频的bitstream(例如MP4,MKV,FLV,OGG,OGG)是必需的,需要与脱节的coctectipcoctec

opus。

尽管这是独立的平台,但对于每个平台都需要不同的过程,请注意:我仅列出了我拥有专业知识的那些平台。

4
投票

您主要使用软件包管理器及其依赖项安装它,或者您可以使用手动编译代码的方式,并在HEREhere.中描述的步骤进行编译。 # Ubuntu / Debian / Linux Mint sudo apt install ffmpeg # ArchLinux / Manjaro / Anarchy sudo pacman -S ffmpeg # Gentoo / Funtoo USE=opus sudo emerge ffmpeg windows windows并不容易,因为GNU/Linux,您要么手动满足所有依赖项,然后用MSVC独自编译所有内容,或者使用Cygwin或Msys2编译。

替代方法是从

Zeranoe

的网站下载预编译的Windows二进制文件。

this将下载您要提取和复制

bin/
文件夹的所有内容的邮政编码,这些档案是ffmpeg二进制文件。可选地,将它们存储在
Path环境变量中列出的文件路径中,以简单地将其运行在shell中。

我在discord.js播放流的问题甚至以为我安装了ffmpeg,所以如果不能在cmd中单独运行cmd,这是一个可能的修复程序,至少是在Windows中进行的解决方案,然后我去了Node_modules \ Prism-Media \ SR

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.