Skip to content

A ytdl-core wrapper focused on efficiency for use in Discord music bots

License

Notifications You must be signed in to change notification settings

pozhiloy-enotik/ytdl-core-discord

This branch is 1 commit ahead of amishshah/ytdl-core-discord:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7a020ea · Jan 22, 2022

History

83 Commits
May 27, 2019
Aug 26, 2019
Mar 20, 2019
Mar 20, 2019
Jun 22, 2020
Feb 17, 2019
May 30, 2019
Jan 22, 2022
Jun 12, 2021
Jun 12, 2021

Repository files navigation

ytdl-core-discord

Build Status dependencies npm Patreon

A ytdl-core wrapper focused on efficiency for use in Discord music bots.

You can pass the exact same arguments as you would with the ytdl-core module, with the exception that you must await the function call.

What does it do?

For compatible videos, this module uses prism-media to extract Opus audio from a stream without having to pipe it through FFmpeg first. This greatly reduces the processing power required, making playback smoother and allowing you to play over more connections simultaneously.

For videos where the required codec (webm + opus) isn't available, the module will fallback to using FFmpeg to encode the stream in Opus. Many new videos on YouTube are available in this codec so hopefully this isn't frequent.

Put simply, this module finds the most efficient way to extract a stream of Opus audio from a YouTube video. Even in the worst case, it should still give better performance than ytdl-core.

Usage in Discord.js 12.x

const ytdl = require('ytdl-core-discord');

async function play(connection, url) {
  connection.play(await ytdl(url), { type: 'opus' });
}

Usage in Discord.js 11.4.x

const ytdl = require('ytdl-core-discord');

async function play(connection, url) {
  connection.playOpusStream(await ytdl(url));
}

Patreon

About

A ytdl-core wrapper focused on efficiency for use in Discord music bots

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%