Fork: Discord-video-experiment
- 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
What I implemented and what I did not.
- VP8
- VP9
- H.264
- RTP (sending of realtime data)
- RTX (retransmission)
- Regular Voice Connection
- Go live
- Figure out rtp header extensions (discord specific) (discord seems to use one-byte RTP header extension https://www.rfc-editor.org/rfc/rfc8285.html#section-4.2)
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
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);
}
example/src/config.json
:
"token": "SELF TOKEN HERE",
"acceptedAuthors": ["USER_ID_HERE"],
- Configure your
config.json
with your accepted authors ids, and your self token - Generate js files with
npm run build
- Start program with:
npm run start
- 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://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
- 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.