Androz2091 / discord-player

🎧 Complete framework to simplify the implementation of music commands using discord.js v14
https://discord-player.js.org/
MIT License
604 stars 192 forks source link

Custom Stream Engine Issues #1008

Closed iim-ayush closed 2 years ago

iim-ayush commented 2 years ago

Describe the bug

Mentioned steps to create a resource for play-dl is wrong. It creates issues when play-dl changes its in-built structure. Either remove the steps or add a way to provide stream type of created resource.

To Reproduce Steps to reproduce the behavior:

  1. Download latest play-dl version.
  2. Use code as mentioned in url.
  3. Music will never play

Expected behavior Music should be able to play

Suggestions Modification of custom stream Engine.

import play from 'play-dl'

const queue = player.createQueue(..., {
    ...,
    async onBeforeCreateStream(track, source, _queue) {
        // only trap youtube source
        if (source === "youtube") {
            const playdl_stream = await playdl.stream(track.url)
            return { stream : playdl_stream.stream, type: playdl_stream.type }; // Now just use this object to get type and stream.
        }
    }
});

Please complete the following information:

Additional context

iim-ayush commented 2 years ago

Play-dl latest version converts Webm to Opus by itself.

FFmpeg never converts raw Opus packets to raw PCM. So your custom engine method will no longer work.

twlite commented 2 years ago

It would not be a perfect solution for us, we need pcm for volumes, and audio filters. Either let users pick what format to retrieve from play-dl or users will need to pipe the stream to opus decoder and then send it back to discord-player. Custom stream engine is not only built for play-dl but anything in general.

iim-ayush commented 2 years ago

Ok Thanks for the info.

I will see what I can do.