Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gabrielmaialva33/discord-video-stream

Experiment for making video streaming work for discord self bots
https://github.com/gabrielmaialva33/discord-video-stream

discord discord-selfbot ffmpeg stream streaming

Last synced: 28 days ago
JSON representation

Experiment for making video streaming work for discord self bots

Awesome Lists containing this project

README

        




Live


VideoStream lib for Discord



An open-source Discord lib to stream videos on voice channels.


waka
License
GitHub top language
GitHub language count
Repository size

GitHub last commit
Maia



About   |   
Features   |   
Implementation   |   
Requirements   |   
Usage   |   
FAQS   


> [!CAUTION]
> Using any kind of automation programs on your account can result in your account getting permanently banned by
> Discord. Use at your own risk

## :bookmark: About

This project implements the custom Discord UDP protocol for sending media. Since Discord is likely change their custom
protocol, this library is subject to break at any point. An effort will be made to keep this library up to date with the
latest Discord protocol, but it is not guranteed.

For better stability it is recommended to use WebRTC protocol instead since Discord is forced to adhere to spec, which
means that the non-signaling code is guaranteed to work.


## :rocket: **Features**

- Playing vp8 or h264 video in a voice channel (`go live`, or webcam video)
- Playing opus audio in a voice channel


## :construction: **Implementation**

What I implemented and what I did not.

#### Video codecs

- [x] VP8
- [ ] VP9
- [x] H.264
- [x] H.265

#### Packet types

- [x] RTP (sending of realtime data)
- [ ] RTX (retransmission)

#### Connection types

- [x] Regular Voice Connection
- [x] Go live

#### Extras

- [x] 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)

Extensions supported by Discord (taken from the webrtc sdp exchange)


## :computer: Requirements

- **[FFmpeg](https://ffmpeg.org/download.html)** is required for the usage of this package. If you are on linux you can
easily install ffmpeg from your
distribution's package manager.

```sh
# For Ubuntu
$ sudo apt-get install ffmpeg
# For MacOS
$ brew install ffmpeg
```

- **[discord.js-selfbot-v13](https://www.npmjs.com/package/discord.js-selfbot-v13)** is required for the usage of this
package. If you are on linux you can easily install discord.js-selfbot-v13 from your

```sh
$ pnpm add discord.js-selfbot-v13
```


## :package: Usage

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

```typescript
import { Client } from 'discord.js-selfbot-v13'
import { Streamer } from '@gabrielmaialva33/discord-video-stream'

const streamer = new Streamer(new Client())
await streamer.client.login('TOKEN HERE')
```

Make client join a voice channel and create a stream:

```typescript
await streamer.joinVoice('GUILD ID HERE', 'CHANNEL ID HERE')
const udp = await streamer.createStream()
```

Start sending media over the udp connection:

```typescript
udp.mediaConnection.setSpeaking(true)
udp.mediaConnection.setVideoStatus(true)
try {
const res = await streamLivestreamVideo('DIRECT VIDEO URL OR READABLE STREAM HERE', udp)

console.log('Finished playing video ' + res)
} catch (e) {
console.log(e)
} finally {
udp.mediaConnection.setSpeaking(false)
udp.mediaConnection.setVideoStatus(false)
}
```


### :arrow_down: 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.

- Does this library work with bot tokens?

No, Discord blocks video from bots which is why this library uses a selfbot library as peer dependency. You must use a
user token


## :memo: License

This project is under the **MIT** license. [MIT](./LICENSE) ❤️


## :rocket: **Contributors**

| [![Maia](https://avatars.githubusercontent.com/u/26732067?size=100)](https://github.com/gabrielmaialva33) |
| --------------------------------------------------------------------------------------------------------- |
| [Maia](https://github.com/gabrielmaialva33) |

### Special Thanks

A huge thank you to [mrjvs](https://github.com/mrjvs) for their inspiring work
on [Discord-video-experiment](https://github.com/mrjvs/Discord-video-experiment). Their contributions have been
invaluable!

## :star:

Liked? Leave a little star to help the project ⭐





© 2017-present Maia