Error: write EPIPE

Code:

function createStream(url, type, mode, options) {
    let FFmpegArgs;

    switch(mode) {
        case '1': {
            const inputStream = ytdl(url, options);
            FFmpegArgs = [ '-reconnect', '1', '-reconnect_streamed', '1', '-reconnect_delay_max', '5', '-i', url, '-analyzeduration', '0', '-loglevel', '0', '-f', options && options.format && typeof options.format === 'string' ? options.format : 's16le', '-ar', '48000', '-ac', '2' ];

            FFmpegArgs.concat(options.filters);

            let transcoder = new prism.FFmpeg({ shell: false, args: FFmpegArgs });
            const output = inputStream.pipe(transcoder);

            if(options && !options.opusEncoded) {
                for(const event of events) {
                    inputStream.on(event, (...args) => output.emit(event, ...args));
                }

                inputStream.on('error', error => transcoder.destroy(error));
                output.on('close', () => transcoder.destroy());
                console.log(output)
                return output;
            }

            const opus = new prism.opus.Encoder({ rate: 48000, channels: 2, frameSize: 960 });
            const outputStream = output.pipe(opus);

            for (const event of events) {
                inputStream.on(event, (...args) => outputStream.emit(event, ...args));
            }

            const _destroy = error => {
                if (!transcoder.destroyed)
                    transcoder.destroy();
                if (!opus.destroyed)
                    opus.destroy();
            }

            outputStream.on('close', _destroy).on('error', _destroy);
            console.log(outputStream)
            return outputStream;
        }

        case '2': {
            //to be continued
        }
    }
}

Help me please. I have been suffering for 2 days (
P.S. Discord.js v13

is the ffmpeg process crashing before it reads all of the input you’re trying to give it?

Perhaps it is happening, I’m just getting to know him.

As you may have noticed there are lots and lots of changes in Discord.js v13. I have sound files and YouTube videos playing but I’m sure my code isn’t doing what yours is doing. If you haven’t already I would make sure you can play a simple mp3 file (from your server) as step 1.

I don’t know what all that code is doing so I’m afraid that I can’t be of more help.

This code sets FFMPEG parameters for adding filters like bassboost and 3D.

But everything works if you don’t do those particular things? You want to know all the basic parts work. Then I would suggest you visit the Discord.JS discord they have a bunch of channels devoted to v13 and I’ve never failed to get a response to problems I have posted there.