Code Monkey home page Code Monkey logo

ytdl-core-discord's Introduction

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

ytdl-core-discord's People

Contributors

amishshah avatar dependabot-preview[bot] avatar dependabot[bot] avatar favna avatar jonathanzhao02 avatar s1nnohlakes avatar skiptirengu avatar teeseal avatar yannhodiesne avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.