All Projects → discord-player → discord-ytdl-core

discord-player / discord-ytdl-core

Licence: Apache-2.0 License
Simple ytdl wrapper for discord bots with custom ffmpeg args support.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to discord-ytdl-core

live-stream-media-source-extensions
Live stream h264 encoded mp4 video on media source extensions using ffmpeg, node.js, socket.io, and express. Works in chrome, firefox, safari, and android. Not iOS compatible. Work has moved to mse-live-player repo =>
Stars: ✭ 24 (-53.85%)
Mutual labels:  stream, ffmpeg
Homebridge Camera Ffmpeg
Homebridge Plugin Providing FFmpeg-based Camera Support
Stars: ✭ 726 (+1296.15%)
Mutual labels:  stream, ffmpeg
Huong-dan-cai-dat-stream-server-va-chuyen-doi-video-sang-streaming
Hướng dẫn cài đặt stream server và chuyển đổi video thường sang dạng TS Streaming
Stars: ✭ 29 (-44.23%)
Mutual labels:  stream, ffmpeg
youtube-play
🎵 A command-line utility which streams music from YouTube
Stars: ✭ 47 (-9.62%)
Mutual labels:  stream, ffmpeg
firebase
Firebase Go REST SDK
Stars: ✭ 22 (-57.69%)
Mutual labels:  stream
JJMumbleBot
A plugin-based All-In-One mumble bot solution in python 3.7+ with extensive features and support for custom plugins.
Stars: ✭ 40 (-23.08%)
Mutual labels:  ffmpeg
yt-interval
Flask app to download YT videos in intervals. Eg. from start to 30 seconds: start-30
Stars: ✭ 47 (-9.62%)
Mutual labels:  ffmpeg
30-days-of-shade
30 days of shaders in GLSL using GLSLCanvas
Stars: ✭ 134 (+157.69%)
Mutual labels:  ffmpeg
camstudio
CamStudio fork
Stars: ✭ 83 (+59.62%)
Mutual labels:  ffmpeg
video-summarizer
Summarizes videos into much shorter videos. Ideal for long lecture videos.
Stars: ✭ 92 (+76.92%)
Mutual labels:  ffmpeg
deejay-stereo
Discord music bot built using djs v13, discord-player. Slash Commands only bot
Stars: ✭ 42 (-19.23%)
Mutual labels:  discord-player
cpsfy
🚀 Tiny goodies for Continuation-Passing-Style functions, fully tested
Stars: ✭ 58 (+11.54%)
Mutual labels:  stream
FFmpeg-3.4-Android
This repository helps to compile FFmpeg 3.4 Version for Android using Android NDK Standalone Toolchain.
Stars: ✭ 23 (-55.77%)
Mutual labels:  ffmpeg
laav
Asynchronous Audio / Video Library for H264 / MJPEG / OPUS / AAC / MP2 encoding, transcoding, recording and streaming from live sources
Stars: ✭ 50 (-3.85%)
Mutual labels:  stream
staxrip
StaxRip is a video encoding app for Windows with a unrivaled feature set and usability.
Stars: ✭ 132 (+153.85%)
Mutual labels:  ffmpeg
evry
Split STDIN stream and execute specified command every N lines/seconds.
Stars: ✭ 61 (+17.31%)
Mutual labels:  stream
parallel stream
A parallelized stream implementation for Elixir
Stars: ✭ 86 (+65.38%)
Mutual labels:  stream
twitchpipe
Pipe your favorite Twitch streams to the media player of your choice, or a file to save them for later. Supports low-latency playback.
Stars: ✭ 28 (-46.15%)
Mutual labels:  stream
pv
Unix Pipe Viewer (pv) utility in Node.js
Stars: ✭ 20 (-61.54%)
Mutual labels:  stream
MQPlayer
Android video player based on FFmpeg and Exoplayer
Stars: ✭ 20 (-61.54%)
Mutual labels:  ffmpeg

discord-ytdl-core

Simple ytdl wrapper for discord bots with custom ffmpeg args support.

Installing

First of all, you need to install ytdl-core with npm install --save ytdl-core.

Install ytdl core

$ npm i ytdl-core

Install discord ytdl core

$ npm i discord-ytdl-core

https://www.npmjs.com/package/discord-ytdl-core

Opus [optional]

Please install opus engine if you want to encode the stream to opus format.

Supported Opus Engines

API

YTDL(youtubeURL, options)

Similar to ytdl-core but this method allows you to pass custom FFmpeg args in options.

ytdl("https://www.youtube.com/watch?v=QnL5P0tFkwM", {
    filter: "audioonly",
    fmt: "mp3",
    encoderArgs: ['-af', 'bass=g=10']
}).pipe(fs.createWritestream("bass_boosted.mp3"));

YTDL.arbitraryStream(source, options)

This method allows you to play the stream from other sources rather than just youtube. Stream source must be a string or stream object (internal.Readable | internal.Duplex). Through URL: https://listen.moe/kpop/opus

Using fs:

let stream = fs.createReadStream("./music.mp4");
ytdl.arbitraryStream(stream, {
    fmt: "mp3",
    encoderArgs: ["bass=g=5"]
}).pipe(fs.createWriteStream("./music.mp3"))

Options

This package provides 4 extra options excluding ytdl-core options.

  • seek: This option takes the time in seconds. If this option is provided, it will return the stream from that frame. Seek option is provided here because discord.js seek doesn't work for ogg/opus & webm/opus stream. This option is ignored when the supplied parameter type isn't a number.

  • encoderArgs: This option takes the Array of FFmpeg arguments. Invalid args will throw error and crash the process. This option is ignored when the supplied parameter type isn't array. Invalid FFmpeg args might crash the process.

  • opusEncoded: This option takes a Boolean value. If true, it returns opus encoded stream. If fmt option isn't provided, it returns converted stream type of discord.js. Other values returns unknown stream if opusEncoded is false.

  • fmt: Forcefully changes the stream format. Don't use this option for default value. Even though this option changes the format, it returns opus stream if opusEncoded is set to true.

  • Other options are the options for ytdl-core.

Example

Playing Opus Encoded Stream

const { ytdl } = require("discord-ytdl-core");
const Discord = require("discord.js");
const client = new Discord.Client();

client.on("ready", () => {
    console.log("ready")
});

client.on("message", msg => {
    if (msg.author.bot || !msg.guild) return;
    if (msg.content === "!play") {
        if (!msg.member.voice.channel) return msg.channel.send("You're not in a voice channel?");
        let stream = ytdl("https://www.youtube.com/watch?v=QnL5P0tFkwM", {
            filter: "audioonly",
            opusEncoded: true,
            encoderArgs: ['-af', 'bass=g=10,dynaudnorm=f=200']
        });
        
        msg.member.voice.channel.join()
        .then(connection => {
            let dispatcher = connection.play(stream, {
                type: "opus"
            })
            .on("finish", () => {
                msg.guild.me.voice.channel.leave();
            })
        });
    }
});

client.login("TOKEN");

Unknown Stream

const { ytdl } = require("discord-ytdl-core");
const Discord = require("discord.js");
const client = new Discord.Client();

client.on("ready", () => {
    console.log("ready")
});

client.on("message", msg => {
    if (msg.author.bot || !msg.guild) return;
    if (msg.content === "!play") {
        if (!msg.member.voice.channel) return msg.channel.send("You're not in a voice channel?");
        let stream = ytdl("https://www.youtube.com/watch?v=QnL5P0tFkwM", {
            filter: "audioonly",
            opusEncoded: false,
            fmt: "mp3",
            encoderArgs: ['-af', 'bass=g=10,dynaudnorm=f=200']
        });
        
        msg.member.voice.channel.join()
        .then(connection => {
            let dispatcher = connection.play(stream, {
                type: "unknown"
            })
            .on("finish", () => {
                msg.guild.me.voice.channel.leave();
            })
        });
    }
});

client.login("TOKEN");

Converted Stream

const { ytdl } = require("discord-ytdl-core");
const Discord = require("discord.js");
const client = new Discord.Client();

client.on("ready", () => {
    console.log("ready")
});

client.on("message", msg => {
    if (msg.author.bot || !msg.guild) return;
    if (msg.content === "!play") {
        if (!msg.member.voice.channel) return msg.channel.send("You're not in a voice channel?");
        let stream = ytdl("https://www.youtube.com/watch?v=QnL5P0tFkwM", {
            filter: "audioonly",
            opusEncoded: false,
            encoderArgs: ['-af', 'bass=g=10,dynaudnorm=f=200']
        });
        
        msg.member.voice.channel.join()
        .then(connection => {
            let dispatcher = connection.play(stream, {
                type: "converted"
            })
            .on("finish", () => {
                msg.guild.me.voice.channel.leave();
            })
        });
    }
});

client.login("TOKEN");

Downloading the video

const { ytdl } = require("discord-ytdl-core");
const { createWriteStream } = require ("fs");

const url = "https://www.youtube.com/watch?v=QnL5P0tFkwM";

let stream = ytdl(url, {
    encoderArgs: ["-af", "asetrate=44100*1.25,bass=g=20,dynaudnorm=f=150"],
    fmt: "mp3",
    opusEncoded: false
});

stream.pipe(createWriteStream(__dirname+"/test.mp3"));

Arbitrary Stream

const { ytdl } = require("discord-ytdl-core");
const Discord = require("discord.js");
const client = new Discord.Client();

client.on("ready", () => {
    console.log("ready")
});

client.on("message", msg => {
    if (msg.author.bot || !msg.guild) return;
    if (msg.content === "!play") {
        if (!msg.member.voice.channel) return msg.channel.send("You're not in a voice channel?");
        let stream = ytdl.arbitraryStream("https://listen.moe/kpop/opus", {
            opusEncoded: true,
            encoderArgs: ['-af', 'bass=g=10,dynaudnorm=f=200']
        });
        
        msg.member.voice.channel.join()
        .then(connection => {
            let dispatcher = connection.play(stream, {
                type: "opus"
            })
            .on("finish", () => {
                msg.guild.me.voice.channel.leave();
            })
        });
    }
});

client.login("TOKEN");

Other functions

Check out ytdl-core for other functions.

Sponsor this project

Related

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].