Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot won't play any songs/Song ending early #1639

Closed
febkosq8 opened this issue Mar 4, 2023 · 42 comments
Closed

Bot won't play any songs/Song ending early #1639

febkosq8 opened this issue Mar 4, 2023 · 42 comments
Labels
discussion t:ffmpeg-stream FFMPEG streaming related

Comments

@febkosq8
Copy link
Contributor

febkosq8 commented Mar 4, 2023

Describe the bug
When I run the bot on my local Windows 11 machine, everything works fine.

But when the bot runs on Ubuntu 22, the bot will skip playing and directly go to the finish state.
I host my bot in Heroku (running on Ubuntu 22.04 stack).
This issue doesn't exist in Ubuntu 20 (As a workaround downgrading heroku stack to 20 fixes this issue).

Current list of affected Linux distro :

  1. Ubuntu 22.04
  2. Arch 5.15.79.1-microsoft-standard-WSL2
  3. CentOS Stream release 8
  4. 6.1.1-arch1-1

index.js

....
const { Player } = require("discord-player");
const player = new Player(client);
....

play.js

....
const query = interaction.options.getString("query");
const searchResult = await player.search(query);

if (!searchResult.hasTracks()) {
	        await interaction.editReply(`We found no tracks for ${query}!`);
	        return;
			} else {
				await player.play(interaction.member.voice.channel, searchResult, {
					nodeOptions: {
						metadata: interaction.channel,
						bufferingTimeout: 15000,
						leaveOnStop: true,
						leaveOnStopCooldown: 5000,
						leaveOnEnd: true,
						leaveOnEndCooldown: 15000,
						leaveOnEmpty: true,
						leaveOnEmptyCooldown: 300000,
						skipOnNoStream: true,
					},
				});
			}

await interaction.followUp({content: `⏱ | Loading your ${searchResult.playlist ? "playlist" : "track"}`,});
....

Attaching debug event to the player below :

Ubuntu 22.04

[DEBUG] Discord Player Debug Event
Preparing final stream config: {
"disableBiquad": false,
"disableEqualizer": false,
"disableVolume": false,
"disableFilters": false,
"disableResampler": false,
"sampleRate": 48000,
"eq": [],
"defaultFilters": [],
"volume": 100,
"transitionMode": false,
"ffmpegFilters": "",
"seek": 0
}
[DEBUG] Discord Player Debug Event
Initiating DSP filters pipeline...
[DEBUG] Discord Player Debug Event
Executing onAfterCreateStream hook...
[DEBUG] Discord Player Debug Event
Preparing AudioResource...
[DEBUG] Discord Player Debug Event
Initializing audio player...
[DEBUG] Discord Player Debug Event
state change:
from {"status":"idle","resource":false,"stepTimeout":false}
to {"status":"buffering","resource":true,"stepTimeout":false}
[DEBUG] Discord Player Debug Event
Dispatching audio...
[DEBUG] Discord Player Debug Event
Player triggered for Track {"title":"The Weeknd & Ariana Grande - Die For You (Remix)","reason":"normal"}
[DEBUG] Discord Player Debug Event
state change:
from {"status":"buffering","resource":true,"stepTimeout":false}
to {"status":"playing","missedFrames":0,"playbackDuration":0,"resource":true,"stepTimeout":false}
[DEBUG] Discord Player Debug Event
[NW] [WS] >> {"op":5,"d":{"speaking":1,"delay":0,"ssrc":140130}}
[DEBUG] Discord Player Debug Event
[NW] [WS] >> {"op":5,"d":{"speaking":0,"delay":0,"ssrc":140130}}
[DEBUG] Discord Player Debug Event
Track {"title":"The Weeknd & Ariana Grande - Die For You (Remix)","isTransitionMode":false} was marked as finished
[DEBUG] Discord Player Debug Event
Adding track to history and emitting finish event since transition mode is disabled...
[DEBUG] Discord Player Debug Event
No more tracks left in the queue to play and repeat mode is off, initiating #emitEnd()
[DEBUG] Discord Player Debug Event
state change:
from {"status":"playing","missedFrames":0,"playbackDuration":120,"resource":true,"stepTimeout":false}
to {"status":"idle","resource":false,"stepTimeout":false}
[DEBUG] Discord Player Debug Event
[NW] [WS] >> {"op":0,"d":{"server_id":"473160079739322368","user_id":"732230135671029831","session_id":"cc5bf168a85bab4fc3146fa8ed1f3825","token":"8b9a382096aef2eb"}}
[DEBUG] Discord Player Debug Event
Detected @discordjs/voice version 0.14.0 which needs keepAlive patch, applying patch...
[DEBUG] Discord Player Debug Event
[NW] state change:
from {"code":0,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"8b9a382096aef2eb","sessionId":"cc5bf168a85bab4fc3146fa8ed1f3825","userId":"732230135671029831"},"udp":false}
to {"code":1,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"8b9a382096aef2eb","sessionId":"cc5bf168a85bab4fc3146fa8ed1f3825","userId":"732230135671029831"},"udp":false}
[DEBUG] Discord Player Debug Event
[NW] [WS] << {"op":8,"d":{"v":4,"heartbeat_interval":13750.0}}
[DEBUG] Discord Player Debug Event
[NW] [WS] << {"op":2,"d":{"streams":[{"type":"video","ssrc":140131,"rtx_ssrc":140132,"rid":"","quality":0,"active":false}],"ssrc":140130,"port":50007,"modes":["aead_aes256_gcm_rtpsize","aead_aes256_gcm","aead_xchacha20_poly1305_rtpsize","xsalsa20_poly1305_lite_rtpsize","xsalsa20_poly1305_lite","xsalsa20_poly1305_suffix","xsalsa20_poly1305"],"ip":"66.22.197.156","experiments":["fixed_keyframe_interval"]}}
[DEBUG] Discord Player Debug Event
Detected @discordjs/voice version 0.14.0 which needs keepAlive patch, applying patch...
[DEBUG] Discord Player Debug Event
[NW] state change:
from {"code":1,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"8b9a382096aef2eb","sessionId":"cc5bf168a85bab4fc3146fa8ed1f3825","userId":"732230135671029831"},"udp":false}
to {"code":2,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"8b9a382096aef2eb","sessionId":"cc5bf168a85bab4fc3146fa8ed1f3825","userId":"732230135671029831"},"udp":true,"connectionData":{"ssrc":140130}}
[DEBUG] Discord Player Debug Event
[NW] [WS] << {"op":5,"d":{"user_id":"176002676696416257","ssrc":140032,"speaking":1}}
[DEBUG] Discord Player Debug Event
[NW] [WS] >> {"op":1,"d":{"protocol":"udp","data":{"address":"3.250.223.20","port":50105,"mode":"xsalsa20_poly1305_lite"}}}
[DEBUG] Discord Player Debug Event
Detected @discordjs/voice version 0.14.0 which needs keepAlive patch, applying patch...
[DEBUG] Discord Player Debug Event
[NW] state change:
from {"code":2,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"8b9a382096aef2eb","sessionId":"cc5bf168a85bab4fc3146fa8ed1f3825","userId":"732230135671029831"},"udp":true,"connectionData":{"ssrc":140130}}
to {"code":3,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"8b9a382096aef2eb","sessionId":"cc5bf168a85bab4fc3146fa8ed1f3825","userId":"732230135671029831"},"udp":true,"connectionData":{"ssrc":140130}}
[DEBUG] Discord Player Debug Event
[NW] [WS] << {"op":4,"d":{"video_codec":"H264","secret_key":[205,179,64,220,193,224,230,46,78,79,30,67,140,16,214,93,28,155,4,167,243,3,7,228,20,48,122,124,247,197,163,56],"mode":"xsalsa20_poly1305_lite","media_session_id":"e98e5b83cc02829367fafbdb7570e5ef","audio_codec":"opus"}}
[DEBUG] Discord Player Debug Event
Detected @discordjs/voice version 0.14.0 which needs keepAlive patch, applying patch...
[DEBUG] Discord Player Debug Event
[NW] state change:
from {"code":3,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"8b9a382096aef2eb","sessionId":"cc5bf168a85bab4fc3146fa8ed1f3825","userId":"732230135671029831"},"udp":true,"connectionData":{"ssrc":140130}}
to {"code":4,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"8b9a382096aef2eb","sessionId":"cc5bf168a85bab4fc3146fa8ed1f3825","userId":"732230135671029831"},"udp":true,"connectionData":{"ssrc":140130,"encryptionMode":"xsalsa20_poly1305_lite","secretKey":{"0":205,"1":179,"2":64,"3":220,"4":193,"5":224,"6":230,"7":46,"8":78,"9":79,"10":30,"11":67,"12":140,"13":16,"14":214,"15":93,"16":28,"17":155,"18":4,"19":167,"20":243,"21":3,"22":7,"23":228,"24":20,"25":48,"26":122,"27":124,"28":247,"29":197,"30":163,"31":56},"sequence":21114,"timestamp":841733103,"nonce":0,"nonceBuffer":{"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"speaking":false,"packetsPlayed":0}}
[DEBUG] Discord Player Debug Event
Stream extraction was successful for Track { title: The Weeknd & Ariana Grande - Die For You (Remix), url: https://www.youtube.com/watch?v=_MQjVzZSLNw } (Extractor: com.discord-player.youtubeextractor)
[DEBUG] Discord Player Debug Event
GuildQueue initialized for guild Makeshift Gaming (ID: 473160079739322368)
[DEBUG] Discord Player Debug Event
Connecting to voice channel VOICE 1 (ID: 750292121826754560)
[DEBUG] Discord Player Debug Event
Detected @discordjs/voice version 0.14.0 which needs keepAlive patch, applying patch...
[DEBUG] Discord Player Debug Event
Received play request from guild Makeshift Gaming (ID: 473160079739322368)
[DEBUG] Discord Player Debug Event
Requested option requires to play the track, initializing...
[DEBUG] Discord Player Debug Event
Initiating stream extraction process...
[DEBUG] Discord Player Debug Event
Executing onBeforeCreateStream hook (QueryType: youtubeSearch)...
[DEBUG] Discord Player Debug Event
Failed to get stream from onBeforeCreateStream!
[DEBUG] Discord Player Debug Event
Attempting to extract stream for Track { title: The Weeknd & Ariana Grande - Die For You (Remix), url: https://www.youtube.com/watch?v=_MQjVzZSLNw } using registered extractors
[DEBUG] Discord Player Debug Event
Detected @discordjs/voice version 0.14.0 which needs keepAlive patch, applying patch...
[DEBUG] Discord Player Debug Event
[NW] [WS] << {"op":5,"d":{"user_id":"176002676696416257","ssrc":140032,"speaking":1}}
[INFO] A interaction for : play was triggered in Guild : xxxx / xxxxx by User : Febkosq8#8685 / 407819516513484801
[DEBUG] Discord Player Debug Event
[NW] [WS] << {"op":5,"d":{"user_id":"407819516513484801","ssrc":139803,"speaking":1}}

Result when play command is used:
The bot joins the VC and leaves in a second. It also triggers the following events in order : audioTrackAdd > playerStart > emptyQueue > disconnect.


Windows 11 22H2

[DEBUG] Discord Player Debug Event
GuildQueue initialized for guild Makeshift Gaming (ID: 473160079739322368)
[DEBUG] Discord Player Debug Event
Connecting to voice channel VOICE 1 (ID: 750292121826754560)
[DEBUG] Discord Player Debug Event
Detected @discordjs/voice version 0.14.0 which needs keepAlive patch, applying patch...
[DEBUG] Discord Player Debug Event
Received play request from guild Makeshift Gaming (ID: 473160079739322368)
[DEBUG] Discord Player Debug Event
Requested option requires to play the track, initializing...
[DEBUG] Discord Player Debug Event
Initiating stream extraction process...
[DEBUG] Discord Player Debug Event
Executing onBeforeCreateStream hook (QueryType: youtubeSearch)...
[DEBUG] Discord Player Debug Event
Failed to get stream from onBeforeCreateStream!
[DEBUG] Discord Player Debug Event
Attempting to extract stream for Track { title: The Weeknd & Ariana Grande - Die For You (Remix), url: https://www.youtube.com/watch?v=_MQjVzZSLNw } using registered extractors
[DEBUG] Discord Player Debug Event
Detected @discordjs/voice version 0.14.0 which needs keepAlive patch, applying patch...
[DEBUG] Discord Player Debug Event
[NW] [WS] >> {"op":0,"d":{"server_id":"473160079739322368","user_id":"1030967755274473522","session_id":"e7adfc00d547375d387174b6a6bec45c","token":"64bbb0eed02f5ccd"}}
[DEBUG] Discord Player Debug Event
Detected @discordjs/voice version 0.14.0 which needs keepAlive patch, applying patch...
[DEBUG] Discord Player Debug Event
[NW] state change:
from {"code":0,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"64bbb0eed02f5ccd","sessionId":"e7adfc00d547375d387174b6a6bec45c","userId":"1030967755274473522"},"udp":false}
to {"code":1,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"64bbb0eed02f5ccd","sessionId":"e7adfc00d547375d387174b6a6bec45c","userId":"1030967755274473522"},"udp":false}
[DEBUG] Discord Player Debug Event
[NW] [WS] << {"op":8,"d":{"v":4,"heartbeat_interval":13750.0}}
[DEBUG] Discord Player Debug Event
[NW] [WS] << {"op":2,"d":{"streams":[{"type":"video","ssrc":140351,"rtx_ssrc":140352,"rid":"","quality":0,"active":false}],"ssrc":140350,"port":50007,"modes":["aead_aes256_gcm_rtpsize","aead_aes256_gcm","aead_xchacha20_poly1305_rtpsize","xsalsa20_poly1305_lite_rtpsize","xsalsa20_poly1305_lite","xsalsa20_poly1305_suffix","xsalsa20_poly1305"],"ip":"66.22.197.156","experiments":["fixed_keyframe_interval"]}}
[DEBUG] Discord Player Debug Event
Detected @discordjs/voice version 0.14.0 which needs keepAlive patch, applying patch...
[DEBUG] Discord Player Debug Event
[NW] state change:
from {"code":1,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"64bbb0eed02f5ccd","sessionId":"e7adfc00d547375d387174b6a6bec45c","userId":"1030967755274473522"},"udp":false}
to {"code":2,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"64bbb0eed02f5ccd","sessionId":"e7adfc00d547375d387174b6a6bec45c","userId":"1030967755274473522"},"udp":true,"connectionData":{"ssrc":140350}}
[DEBUG] Discord Player Debug Event
[NW] [WS] >> {"op":1,"d":{"protocol":"udp","data":{"address":"86.9.62.109","port":55093,"mode":"xsalsa20_poly1305_lite"}}}
[DEBUG] Discord Player Debug Event
Detected @discordjs/voice version 0.14.0 which needs keepAlive patch, applying patch...
[DEBUG] Discord Player Debug Event
[NW] state change:
from {"code":2,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"64bbb0eed02f5ccd","sessionId":"e7adfc00d547375d387174b6a6bec45c","userId":"1030967755274473522"},"udp":true,"connectionData":{"ssrc":140350}}
to {"code":3,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"64bbb0eed02f5ccd","sessionId":"e7adfc00d547375d387174b6a6bec45c","userId":"1030967755274473522"},"udp":true,"connectionData":{"ssrc":140350}}
[DEBUG] Discord Player Debug Event
[NW] [WS] << {"op":4,"d":{"video_codec":"H264","secret_key":[120,206,36,108,200,34,250,229,194,165,180,69,121,33,140,25,114,92,88,36,235,121,160,187,255,9,185,210,10,85,17,165],"mode":"xsalsa20_poly1305_lite","media_session_id":"e98e5b83cc02829367fafbdb7570e5ef","audio_codec":"opus"}}
[DEBUG] Discord Player Debug Event
Detected @discordjs/voice version 0.14.0 which needs keepAlive patch, applying patch...
[DEBUG] Discord Player Debug Event
[NW] state change:
from {"code":3,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"64bbb0eed02f5ccd","sessionId":"e7adfc00d547375d387174b6a6bec45c","userId":"1030967755274473522"},"udp":true,"connectionData":{"ssrc":140350}}
to {"code":4,"ws":true,"connectionOptions":{"endpoint":"rotterdam5312.discord.media:443","serverId":"473160079739322368","token":"64bbb0eed02f5ccd","sessionId":"e7adfc00d547375d387174b6a6bec45c","userId":"1030967755274473522"},"udp":true,"connectionData":{"ssrc":140350,"encryptionMode":"xsalsa20_poly1305_lite","secretKey":{"0":120,"1":206,"2":36,"3":108,"4":200,"5":34,"6":250,"7":229,"8":194,"9":165,"10":180,"11":69,"12":121,"13":33,"14":140,"15":25,"16":114,"17":92,"18":88,"19":36,"20":235,"21":121,"22":160,"23":187,"24":255,"25":9,"26":185,"27":210,"28":10,"29":85,"30":17,"31":165},"sequence":26724,"timestamp":3761747370,"nonce":0,"nonceBuffer":{"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"speaking":false,"packetsPlayed":0}}
[DEBUG] Discord Player Debug Event
Stream extraction was successful for Track { title: The Weeknd & Ariana Grande - Die For You (Remix), url: https://www.youtube.com/watch?v=_MQjVzZSLNw } (Extractor: com.discord-player.youtubeextractor)
[DEBUG] Discord Player Debug Event
Preparing final stream config: {
  "disableBiquad": false,
  "disableEqualizer": false,
  "disableVolume": false,
  "disableFilters": false,
  "disableResampler": false,
  "sampleRate": 48000,
  "eq": [],
  "defaultFilters": [],
  "volume": 100,
  "transitionMode": false,
  "ffmpegFilters": "",
  "seek": 0
}
[DEBUG] Discord Player Debug Event
Initiating DSP filters pipeline...
[DEBUG] Discord Player Debug Event
Executing onAfterCreateStream hook...
[DEBUG] Discord Player Debug Event
Preparing AudioResource...
[DEBUG] Discord Player Debug Event
Initializing audio player...
[DEBUG] Discord Player Debug Event
state change:
from {"status":"idle","resource":false,"stepTimeout":false}
to {"status":"buffering","resource":true,"stepTimeout":false}
[DEBUG] Discord Player Debug Event
Dispatching audio...
[INFO] A interaction for : play was triggered in Guild : xxxx / xxxx by User : Febkosq8#8685 / 407819516513484801
[DEBUG] Discord Player Debug Event
Player triggered for Track {"title":"The Weeknd & Ariana Grande - Die For You (Remix)","reason":"normal"}
[DEBUG] Discord Player Debug Event
state change:
from {"status":"buffering","resource":true,"stepTimeout":false}
to {"status":"playing","missedFrames":0,"playbackDuration":0,"resource":true,"stepTimeout":false}
[DEBUG] Discord Player Debug Event
[NW] [WS] >> {"op":5,"d":{"speaking":1,"delay":0,"ssrc":140350}}

Result when play command is used:
The bot joins the VC and starts to play the requested music. It also triggers the following events in order : audioTrackAdd > playerStart.

To Reproduce

Steps to reproduce the behavior:

  1. Run the bot on Ubuntu 22
  2. Use the play command to queue a song
  3. Bot will join the VC and leave immediately.

Expected behavior

  1. Run the bot on Ubuntu 22
  2. Use the play command to queue a song
  3. Bot will join the VC and start playing the requested song.

Screenshots

Please complete the following information:

  • Node Version: 18.14.2
  • Discord Player Version: 6.0.0
  • Discord.js Version: 14.7.1
  • @discord-player/equalizer Version: 0.2.0
  • @discord-player/extractor Version: 4.1.0
  • @discord-player/utils Version: 0.2.0
  • @discordjs/opus Version: 0.9.0
  • @discordjs/voice Version: 0.14.0

Additional context

The only changing factor I know is the ffmpeg build being used but Heroku same buildpack on stack 20 works fine.

@febkosq8 febkosq8 added the bug Something isn't working label Mar 4, 2023
@Greensky-gs
Copy link

Greensky-gs commented Mar 4, 2023

I have this issue too, on Ubuntu 22 like febkosq8, the bot just connects and skip to the song end, emitting the event

@febkosq8
Copy link
Contributor Author

febkosq8 commented Mar 4, 2023

Update :
Tried playing a local file as shown in LINK and that seems to work fine both on Heroku/Windows.

@Sir-Ayd
Copy link

Sir-Ayd commented Mar 4, 2023

I have the same issue in which bot can't play music on Heroku when using discord-player v6

@Mylloon
Copy link
Contributor

Mylloon commented Mar 5, 2023

I can confirm this issue, tried on :

  • Arch 5.15.79.1-microsoft-standard-WSL2
  • Docker image node:19.4.0-alpine3.16
  • v5 and v6

Local file was also working
Docker image node:19.7.0-bullseye-slim is working

@twlite
Copy link
Collaborator

twlite commented Mar 7, 2023

Are you guys by chance using es modules? 🤔

@febkosq8
Copy link
Contributor Author

febkosq8 commented Mar 7, 2023

Are you guys by chance using es modules? 🤔

Personally no.

@Mylloon
Copy link
Contributor

Mylloon commented Mar 7, 2023

I do

1 similar comment
@ddemile
Copy link

ddemile commented Mar 8, 2023

I do

@samusaran
Copy link

Same issue on CentOS Stream release 8.

It worked before on discord-player v5 (i used Androz2091 discord-music-bot directly, now I'm upgrading it to v6)

@pankofufu
Copy link

running linux on kernel 6.1.1-arch1-1, discord-player 6.1.0
bot won't play any music for me either

@samusaran
Copy link

So it seems it's more of a linux problem than an Ubuntu specific issue.

@febkosq8
Copy link
Contributor Author

But not all Linux distros. debian on wsl worked fine. So does Ubuntu 20.04.

@pankofufu
Copy link

i can't reproduce this on macOS 12.6.3 (UNIX based OS) so this is a Linux problem

@febkosq8 febkosq8 changed the title Bot won't play any songs if running on Ubuntu 22 Bot won't play any songs if running on some Linux distros Mar 12, 2023
@samusaran
Copy link

samusaran commented Mar 12, 2023

Could it be node-related? I'm still on node 16.

Im happy to help troubleshooting on my system.

@Mylloon
Copy link
Contributor

Mylloon commented Mar 12, 2023

Could it be node-related? I'm still on node 16.

Im happy to help troubleshooting on my system.

Nop, working on docker image node:19.7.0-bullseye-slim
Imo its more of a problem with recent versions of Linux, as older versions seem to work fine so far

@samusaran
Copy link

samusaran commented Mar 12, 2023 via email

@Mylloon
Copy link
Contributor

Mylloon commented Mar 12, 2023

For me it wasn't working for the alpine version of node 19 (node:19.4.0-alpine3.16) so I don't think it's node related, but maybe, Idk

@Sparoney
Copy link

I also had this problem on Ubuntu 22, I got it to work by running the bot in a Docker image, specifically ghcr.io/parkervcp/yolks:nodejs_18 for the Pterodactyl Panel, which appears to be based on the node:18-bullseye-slim image

@twlite twlite pinned this issue Mar 16, 2023
@Eaterminer
Copy link

Eaterminer commented Mar 17, 2023

Have any tempory fixes been found?

Edit: Trying above Fix, Didn't Notice it 0_0

@ghxst0x1
Copy link

It didn't work for me in the node:18-alpine image. So I used node:19.7.0-bullseye-slim as @Mylloon suggested above. It works for me now without the issue. I use railway.app to host the project. Since the node version is different from the image I used, I think it is because of the node version installed in the distro that causing the problem. I don't know if that is the case just a hunch.

@samusaran
Copy link

samusaran commented Mar 18, 2023 via email

@MsVoxxie
Copy link

Same issue here on ubuntu 22.04. Any news on this?

@tuomonen
Copy link

tuomonen commented Mar 19, 2023

I did not realize that this was an issue until I saw messages in Zerio's Discord channel.
The problem relates to audioTrackAdd and audioTracksAdd listeners. I have solved this by adding if condition to listeners:

player.events.on('audioTrackAdd', (queue, track) => { if (queue.node.isPlaying()){ queue.metadata.channel.send(``Added to the queue ${track.title}``) } else { queue.metadata.channel.send(``Track **${track.title}** queued``); } });

player.events.on('audioTracksAdd', (queue, track) => { if (queue.node.isPlaying()){ queue.metadata.channel.send(``Playlist added ${track.title}``) } else { queue.metadata.channel.send(``Playlist starts from title: ${track.title}``); } });

@samusaran
Copy link

I did not realize that this was an issue until I saw messages in Zerio's Discord channel. The problem relates to audioTrackAdd and audioTracksAdd listeners. I have solved this by adding if condition to listeners:

player.events.on('audioTrackAdd', (queue, track) => { if (queue.node.isPlaying()){ queue.metadata.channel.send(Added to the queue ${track.title}) } else { queue.metadata.channel.send(Track ${track.title} queued); } });

player.events.on('audioTracksAdd', (queue, track) => { if (queue.node.isPlaying()){ queue.metadata.channel.send(Playlist added ${track.title}) } else { queue.metadata.channel.send(Playlist starts from title: ${track.title}); } });

I didn't tried this fix, but how that would help?

@tuomonen
Copy link

tuomonen commented Mar 19, 2023

I did not realize that this was an issue until I saw messages in Zerio's Discord channel. The problem relates to audioTrackAdd and audioTracksAdd listeners. I have solved this by adding if condition to listeners:
player.events.on('audioTrackAdd', (queue, track) => { if (queue.node.isPlaying()){ queue.metadata.channel.send(Added to the queue ${track.title}) } else { queue.metadata.channel.send(Track ${track.title} queued); } });
player.events.on('audioTracksAdd', (queue, track) => { if (queue.node.isPlaying()){ queue.metadata.channel.send(Playlist added ${track.title}) } else { queue.metadata.channel.send(Playlist starts from title: ${track.title}); } });

I didn't tried this fix, but how that would help?

When a player starts to play, it checks the queue and notifies that it is empty, and skips to emptyQueue event. If you remove those audioTrack(s)Add events, the code works fine. So, the solution actually uses the event path: connection -> playerStart -> audioTrackAdd/audioTracksAdd -> emptyQueue.
My solution forces the event path to if condition. That it doesn't reach emptyQueue while it is playing.

@twlite
Copy link
Collaborator

twlite commented Mar 21, 2023

if it was youtube-sr problem, it would not return search result in first place. The issue occurs at audio player, where stream just ends after 120ms playback. This could possibly be ffmpeg issue? I don't have time to look into it at the moment as im busy these days.

@HankBoone
Copy link

HankBoone commented Mar 21, 2023

I'm also going to do some testing this week. I agree with skdhg on this one. It's very possible it's a ffmpeg issue due to it having issues with the stream data. I'll update this thread if I discover anything valuable for sharing.

@tuomonen
Copy link

tuomonen commented Mar 21, 2023

Sorry, I been also buzy. I have a student group as trainers and we have developed a discord bot for taking a break and it based on a music bot. One of students uses Linux and last week a fix I mentioned earlier did worked but not on this week.
Another thing what I noticed yesterday (Windows user) was that one of the students had removed queue from play.js and they is still able to add /play music1, /play music2, /play music3, etc. (as there would be a queue) and player plays music2 after it has finished music1. Earlier at list in @discord/voice and distube adding a new /play music command caused (without queue handling) that player switches to a new song which just added.

We have used singleton and useMasterPlayer() in our project and code based on strictly discord-player 6.0, discord v.14, and node.js 18.15.

@twlite
Copy link
Collaborator

twlite commented Mar 21, 2023

I will try to investigate this issue today and let you guys know 👍

@twlite
Copy link
Collaborator

twlite commented Mar 21, 2023

Conclusion

The problem seems to be static binaries of ffmpeg, pulled from johnvansickle.com/ffmpeg. Please install ffmpeg via apt or other package managers and avoid static binaries.


Update 1:

The bot seems to be working fine on WSL - Ubuntu 22.04 under following circumstances:

Update 2 (follow-up to update 1):

This issue occurs upon using ffmpeg-static instead of the version used in update 1:

FFmpeg Static

ffmpeg version 5.0.1-static https://johnvansickle.com/ffmpeg/

Debug Log

[DEBUG] Player triggered for Track {"title":"2 Phút Hơn - KAIZ Remix","reason":"normal"}

[DEBUG] state change:
from {"status":"buffering","resource":true,"stepTimeout":false}
to {"status":"playing","missedFrames":0,"playbackDuration":0,"resource":true,"stepTimeout":false}

[DEBUG] [NW] [WS] >> {"op":5,"d":{"speaking":1,"delay":0,"ssrc":746032}}

[DEBUG] [NW] [WS] >> {"op":5,"d":{"speaking":0,"delay":0,"ssrc":746032}}

[DEBUG] Track {"title":"2 Phút Hơn - KAIZ Remix","isTransitionMode":false} was marked as finished

[DEBUG] Adding track to history and emitting finish event since transition mode is disabled...

[DEBUG] No more tracks left in the queue to play and repeat mode is off, initiating #emitEnd()

[DEBUG] state change:
from {"status":"playing","missedFrames":0,"playbackDuration":120,"resource":true,"stepTimeout":false}
to {"status":"idle","resource":false,"stepTimeout":false}

Update 3 (heroku buildpack ffmpeg latest)

This buildpack seems to be using johnvansickle.com/ffmpeg (the same one is used by ffmpeg-static package) based on this line https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest/blob/25e435c249349b5d201f346449fcdf26bce1a065/bin/compile#L34

The problem seems to be static binaries of ffmpeg, pulled from johnvansickle.com/ffmpeg. Please install ffmpeg via apt or other package managers and avoid static binaries.

@twlite twlite added t:ffmpeg-stream FFMPEG streaming related and removed bug Something isn't working labels Mar 21, 2023
@tscheick
Copy link

This fixes my issue. Thanks for taking the time to look!

I removed 'ffmpeg-static' from my project yesterday but didn't realize it was still in my node_modules folder (I don't do much js dev). Once I cleared it out, it started to work. I can also confirm it works with ffmpeg 6.0 but I can't recommend anyone install it since it may break something else for you.

@twlite
Copy link
Collaborator

twlite commented Mar 23, 2023

Removed ffmpeg and ffmpeg-static and installed ffmpeg through sudo apt install ffmpeg and cleared npm cache as well and then tried still track ending immediately.

Ubuntu 22.10 btw

What is the ffmpeg version as per player.scanDeps()?

@CaptSpider4
Copy link

Nvm i completely removed bot files, hosted again and it worked
I guess even after npm cache clean --force cache was not cleared for some reason

@samusaran
Copy link

Solved on centos by removing ffmpeg-static, removing package-lock.json and reinstalled all packages. Ffmpeg installed on system is version 5.x

@twlite
Copy link
Collaborator

twlite commented May 1, 2023

from discord-player v6.3x, the package ships with its own ffmpeg implementation which gives less priority to static binaries so it should work better than how it used to. You can also set FFMPEG_PATH environment variable to load ffmpeg from custom path if needed.

@Loadren
Copy link

Loadren commented Jul 25, 2023

I'm sorry, I've done everything here without it working.

My buildbacks are as follow :

  1. https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git
  2. https://github.com/xrisk/heroku-opus.git
  3. heroku/nodejs

Here is the interesting part of my package.json

{
    "engines": {
        "node": "18.14.2",
        "npm": "9.6.7"
    },
    "dependencies": {
        "@discord-player/extractor": "^4.4.0",
        "@discordjs/opus": "^0.8.0",
        "discord-player": "^6.6.1",
        "discord.js": "^14.11.0",
        "ms": "^3.0.0-canary.1",
        "play-dl": "^1.9.6"
    }
}

I tried npm install then I tried yarn, both before and after removing lock files and node_modules folder.
I tried reseting the Heroku repo by cleaning everything inside and reinstalling from scratch.

I don't think I can sudo snap install ffmpeg inside of Heroku since first, it's bash, and I don't think I have the rights to do so. Any advice?

@twlite
Copy link
Collaborator

twlite commented Jul 25, 2023

@Loadren can you try running your bot inside docker container? Pretty sure heroku supports docker

@Loadren
Copy link

Loadren commented Jul 25, 2023

@skdhg I've never used Docker, but I'll try it and give you feedback.

@Loadren
Copy link

Loadren commented Jul 25, 2023

@skdhg Docker worked! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion t:ffmpeg-stream FFMPEG streaming related
Projects
None yet
Development

No branches or pull requests