# discord-stream-client

> Experiment for making video streaming work for discord selfbots

Latest version **1.4.8** (published 2024-01-15) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install discord-stream-client
pnpm add discord-stream-client
yarn add discord-stream-client
bun add discord-stream-client
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.4.8 |
| Published | 2024-01-15 |
| First published | 2023-04-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 1.1 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 37 |
| Author | aiko-chan-ai |
| Maintainers | aikochan2k6 |
| Keywords | discord, video, voice, stream, go-live |

## Links

- npm: https://www.npmjs.com/package/discord-stream-client
- Repository: https://github.com/aiko-chan-ai/Discord-video-selfbot
- Issues: https://github.com/aiko-chan-ai/Discord-video-selfbot/issues
- npm.io page: https://npm.io/package/discord-stream-client

## Dependencies (6)

- [ws](https://npm.io/package/ws.md) ^8.14.2
- [prism-media](https://npm.io/package/prism-media.md) ^1.3.4
- [fluent-ffmpeg](https://npm.io/package/fluent-ffmpeg.md) ^2.1.2
- [@discordjs/opus](https://npm.io/package/@discordjs/opus.md) ^0.9.0
- [fluent-ffmpeg-util](https://npm.io/package/fluent-ffmpeg-util.md) ^0.2.0-alpha.1
- [@aikochan2k6/fluent-ffmpeg-multistream-ts](https://npm.io/package/@aikochan2k6/fluent-ffmpeg-multistream-ts.md) ^1.0.1

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.4.8 (latest) — 2024-01-15
- 1.4.7 — 2024-01-15
- 1.4.6 — 2023-12-17
- 1.4.5 — 2023-10-20
- 1.4.4 — 2023-09-28
- 1.4.3 — 2023-09-10
- 1.4.2 — 2023-08-25
- 1.4.1 — 2023-08-24
- 1.4.0 — 2023-08-23
- 1.3.1 — 2023-08-11
- 1.3.0 — 2023-08-10
- 1.2.8 — 2023-08-07
- 1.2.7 — 2023-08-07
- 1.2.6 — 2023-08-07
- 1.2.5 — 2023-08-07
- … 15 more at https://npm.io/package/discord-stream-client/versions

## README

## Discord selfbot video

Fork: [Discord-video-stream](https://github.com/dank074/Discord-video-stream) <3

## Features

-   Playing VP8 / H264 video in a voice channel (`go live`, or webcam video)
-   Transcoding video to VP8 / H264 and audio to opus (using ffmpeg)

## Implementation

What I implemented and what I did not.

#### Video codecs

-   [x] VP8
-   [ ] VP9
-   [x] H.264

#### 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)

## 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

> # Example: [Repo](https://github.com/aiko-chan-ai/Discord-SB-Stream)

Install the package, alongside its peer-dependency discord.js-selfbot-v13:

```
npm install discord-stream-client@latest
npm install discord.js-selfbot-v13@latest
```

Create a new client, new StreamClient and login:

```js
import { Client } from 'discord.js-selfbot-v13';
import { DiscordStreamClient } from 'discord-stream-client';

const client = new Client();
const StreamClient = new DiscordStreamClient(client);

StreamClient.setResolution('720p');
// StreamClient.setVideoCodec('VP8'); // H264 is default

const token = 'token';

await client.login(token);
```

Make client join a voice channel and create a stream (Screen Share):

```js
// Connect to a voice channel
const voiceConnection = await StreamClient.joinVoiceChannel(
	client.channels.cache.get('voice channel id'),
	{
		selfDeaf: false,
		selfMute: true,
		selfVideo: false,
	},
);
// Create a stream
const streamConnection = await voiceConnection.createStream();
// Create a player
const player = StreamClient.createPlayer(
	'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4', // DIRECT VIDEO URL OR READABLE STREAM HERE
	streamConnection.udp, // UDP connection
);
// Events
player.on('start', () => {
	console.log('Started playing');
});
player.on('finish', () => {
	console.log('Finished playing');
});
// Play video !!!
player.play();
// Stop playing
player.stop();
```

---
_Source: https://npm.io/package/discord-stream-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
