distubejs / ytdl-core

YouTube video downloader in javascript.
MIT License
293 stars 50 forks source link

Audio plays for a few seconds, then stops #11

Closed eugabrielsilva closed 1 year ago

eugabrielsilva commented 1 year ago

Describe the bug

After the last update, the audio plays for a few seconds, then stops. Using with Discord and the new CookieManager.

Environment

skick1234 commented 1 year ago

How do you play audio? Using ytdl's built-in stream?

eugabrielsilva commented 1 year ago

How do you play audio? Using ytdl's built-in stream?

Here's my code snippet:

 serverQueue.resource = voice.createAudioResource(ytdl(song.url, {
            filter: 'audioonly',
            fmt: 'mp3',
            highWaterMark: 1 << 30,
            liveBuffer: 20000,
            dlChunkSize: 4096,
            quality: 'lowestaudio',
            bitrate: 128,
            agent: agent
        }));
        return serverQueue.player.play(serverQueue.resource);
skick1234 commented 1 year ago

Try increasing dlChunkSize to at least 1MB (1024 * 1024) or removing it to use the default value (10MB).

I have just migrated to undici (https://github.com/distubejs/ytdl-core/commit/5cf3d28540856ef0f2ece629b98971a282d92d40) and it is much faster than miniget. YouTube rate limit will make the download chunks return empty data and your stream will be silent.