discordjs / voice

Implementation of the Discord Voice API for discord.js and other JS/TS libraries
Apache License 2.0
327 stars 111 forks source link

DiscordJS/Voice AudioPlayer goes on Idle while playing livestreams on ytdl after a few seconds #219

Closed framilano closed 2 years ago

framilano commented 2 years ago

Hi everyone, trying to create a Discord Music Bot from the ground using ytdl, everything's fine, except for for livestreams I'm using this configuration for normal videos, and it works (this setting doesn't work with livestreams though)

resource = createAudioResource(ytdl(song_data['video_url'], {quality:'highestaudio', filter: 'audioonly'}))

And using for livestreams:

if (song_data['isLive']) resource = createAudioResource(ytdl(song_data['video_url'], {itag:95}))

The audio plays for a few seconds (maybe one minute sometimes) and then just stops, AudioPlayer goes in Idle, no error thrown, nothing. Any idea?

Here's my package.json

{
  "engines": {
    "npm": "^8.0.0",
    "node": "^16.11.1"
  },
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "@discordjs/builders": "^0.6.0",
    "@discordjs/opus": "^0.5.3",
    "@discordjs/rest": "^0.1.0-canary.0",
    "@discordjs/voice": "^0.6.0",
    "ansi-regex": "^6.0.1",
    "bufferutil": "^4.0.4",
    "cross-fetch": "^3.1.4",
    "discord-api-types": "^0.23.1",
    "discord.js": "^13.2.0",
    "ffmpeg-static": "^4.4.0",
    "libsodium-wrappers": "^0.7.9",
    "utf-8-validate": "^5.0.6",
    "ytdl-core": "^4.9.1",
    "zlib-sync": "^0.1.7"
  }
}
iim-ayush commented 2 years ago

@framilano

Switch to play-dl for livestream support.

framilano commented 2 years ago

@killer069

Sure it works, the audio quality is not that great though, and I hear some hiccups during livestreams. Any way to change the quality or itag?

iim-ayush commented 2 years ago

@framilano

Hiccups occurs when you don't have a good internet. Just host your bot temporarily on free google Cloud shell and see the difference.

framilano commented 2 years ago

@killer069 Okay, actually on Heroku it works fine. Kinda weird that it doesn't work that well with a 1Gbit connection on a Raspberry Pi though.

But yeah, it does what you said so, closed.