Skip to content

Experiment for making video streaming work for discord selfbots.

Notifications You must be signed in to change notification settings

Listlessness/Discord-video-stream

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discord bot video

Fork: Discord-video-experiment

Features

  • Playing vp8 video in a voice channel (go live, or webcam video)
  • Transcoding video to vp8 and audio to opus (using ffmpeg)
  • Screensharing using Puppeteer

Implementation

What I implemented and what I did not.

Video codecs

  • VP8
  • VP9
  • H.264

Packet types

  • RTP (sending of realtime data)
  • RTX (retransmission)

Connection types

  • Regular Voice Connection
  • Go live

Extras

Requirements

Ffmpeg is required for the usage of this package. If you are on linux you can easily install ffmpeg from your distribution's package manager.

If you are on Windows, you can download it from the official ffmpeg website: https://ffmpeg.org/download.html

Usage

Install the package, alongside its peer-dependency discord.js-selfbot-v13:

npm install @dank074/discord-video-stream@latest
npm install discord.js-selfbot-v13@latest

Create a new client, and patch its events to listen for voice gateway events:

import { Client } from "discord.js-selfbot-v13";
import "@dank074/discord-video-stream";

const client = new Client();
client.login('TOKEN HERE');

client.patchVoiceEvents();

Make client join a voice channel and create a stream:

await client.joinVoice("GUILD ID HERE", "CHANNEL ID HERE");

const streamUdpConn = await client.createStream();

Start sending media over the udp connection:

streamUdpConn.voiceConnection.setSpeaking(true);
streamUdpConn.voiceConnection.setVideoStatus(true);
try {
    const res = await streamLivestreamVideo("DIRECT VIDEO URL OR READABLE STREAM HERE", streamUdpConn);

    console.log("Finished playing video " + res);
} catch (e) {
    console.log(e);
} finally {
    streamUdpConn.voiceConnection.setSpeaking(false);
    streamUdpConn.voiceConnection.setVideoStatus(false);
}

Running example

example/src/config.json:

"token": "SELF TOKEN HERE",
"acceptedAuthors": ["USER_ID_HERE"],
  1. Configure your config.json with your accepted authors ids, and your self token
  2. Generate js files with npm run build
  3. Start program with: npm run start
  4. Start streaming with commands:

for go-live

$play-live <Direct video link> <Voice channel Url>

or for cam

$play-cam <Direct video link> <Voice channel Url>

or for screensharing using puppeteer

$play-screen <website url> <Voice channel url>

for example:

$play-live http:https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 https://discord.com/channels/<guild_id>/<channel_id>

You can get the channel url by right clicking the voice channel and selecting Copy Link

image

FAQS

  • Can I stream on existing voice connection (CAM) and in a go-live connection simultaneously?

Yes, just send the media packets over both udp connections. The voice gateway expects you to signal when a user turns on their camera, so make sure you signal using client.signalVideo(guildId, channelId, true) before you start sending cam media packets.

About

Experiment for making video streaming work for discord selfbots.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%