@dank074/discord-video-stream

中文文档
7.0.0发布于 2026/09/14ISCTypeScriptES Module近 30 天下载 5661

Experiment for making video streaming work for discord selfbots

原始使用文档
文档目录14 节
  1. Features
  2. Implementation
  3. Video codecs
  4. Packet types
  5. Connection types
  6. Encryption
  7. Extras
  8. Requirements
  9. Usage
  10. Encoder options available
  11. playStream options available
  12. Performance tips
  13. Running example
  14. FAQs

Discord self-bot video

pkg.pr.new

Fork: Discord-video-experiment

[!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

Features

  • Playing video & audio in a voice channel (Go Live, or webcam video)

Implementation

What I implemented and what I did not.

Video codecs

  • VP8 (once supported, removed for maintainability)
  • VP9
  • H.264
  • H.265
  • AV1

Packet types

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

Connection types

  • Regular Voice Connection
  • Go Live

Encryption

Extras

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

"a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level"
"a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"
"a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"
"a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid"
"a=extmap:5 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"
"a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type"
"a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing"
"a=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space"
"a=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"
"a=extmap:11 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"
"a=extmap:13 urn:3gpp:video-orientation"
"a=extmap:14 urn:ietf:params:rtp-hdrext:toffset"

Requirements

For full functionality, this library requires an FFmpeg build with libzmq enabled. Here is our recommendation:

Usage

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

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

[!IMPORTANT] This library makes use of native dependencies (node-av and node-datachannel). If you use package managers that don't run install scripts by default (pnpm, bun, etc.), you'll need to allow running install scripts for node-av and node-datachannel for proper operation.

Create a new Streamer, and pass it a selfbot Client

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

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

Make client join a voice channel

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

Start sending media

import { prepareStream, playStream, Utils, Encoders } from "@dank074/discord-video-stream"
try {
    // NVENC is also available, change Encoders.software to Encoders.nvenc and
    // adapt the settings
    let encoder = Encoders.software({
        x264: {
            preset: "superfast"
        },
        x265: {
            preset: "superfast"
        }
    });
    const { command, output } = prepareStream("DIRECT VIDEO URL OR READABLE STREAM HERE", {
        encoder,

        // Specify either width or height for aspect ratio aware scaling
        // Specify both for stretched output
        height: 1080,

        // Force frame rate, or leave blank to use source frame rate
        frameRate: 30,
        bitrateVideo: 5000,
        bitrateVideoMax: 7500,
        videoCodec: Utils.normalizeVideoCodec("H264" /* or H265 */),
    });
    command.on("error", (err, stdout, stderr) => {
        // Handle ffmpeg errors here
    });

    await playStream(output, streamer, {
        type: "go-live" // use "camera" for camera stream
    });

    console.log("Finished playing video");
} catch (e) {
    console.log(e);
}

Encoder options available

/**
 * A function returning encoder settings for a specific avg and max bitrate
 * You can define your own, or use the pre-made functions in the library
 */
encoder: EncoderSettingsGetter;
/**
 * Disable transcoding of the video stream. If specified, all video related
 * options have no effects
 * 
 * Only use this if your video stream is Discord streaming friendly, otherwise
 * you'll get a glitchy output
 */
noTranscoding?: boolean;
/**
 * Video output width
 */
width?: number;
/**
 * Video output height
 */
height?: number;
/**
 * Video output frames per second
 */
fps?: number;
/**
 * Video average bitrate in kbps
 */
bitrateVideo?: number;
/**
 * Video max bitrate in kbps
 */
bitrateVideoMax?: number;
/**
 * Audio bitrate in kbps
 */
bitrateAudio?: number;
/**
 * Enable audio output
 */
includeAudio?: boolean;
/**
 * Enables hardware accelerated video decoding. Enabling this option might result in an exception
 * being thrown by Ffmpeg process if your system does not support hardware acceleration
 */
hardwareAcceleratedDecoding?: boolean;
/**
 * Output video codec. **Only** supports H264, H265, and VP8 currently
 */
videoCodec?: SupportedVideoCodec;
/**
 * Adds ffmpeg params to minimize latency and start outputting video as fast as possible.
 * Might create lag in video output in some rare cases
 */
minimizeLatency?: boolean;
/**
 * Custom headers for HTTP requests
 */
customHeaders?: Record<string, string>;
/**
   * Custom input options to pass directly to ffmpeg
   * These will be added to the command *before* other options
 */
customInputOptions?: string[];
/**
 * Custom ffmpeg flags/options to pass directly to ffmpeg
 * These will be added to the command *after* other options
 */
customFfmpegFlags?: string[];

playStream options available

/**
 * Set stream type as "Go Live" or camera stream
 */
type?: "go-live" | "camera",

/**
 * Override video width sent to Discord.
 * 
 * DO NOT SPECIFY UNLESS YOU KNOW WHAT YOU'RE DOING!
 */
width?: number,

/**
 * Override video height sent to Discord.
 * 
 * DO NOT SPECIFY UNLESS YOU KNOW WHAT YOU'RE DOING!
 */
height?: number,

/**
 * Override video frame rate sent to Discord.
 * 
 * DO NOT SPECIFY UNLESS YOU KNOW WHAT YOU'RE DOING!
 */
frameRate?: number,

/**
 * Same as ffmpeg's `readrate_initial_burst` command line flag
 * 
 * See https://ffmpeg.org/ffmpeg.html#:~:text=%2Dreadrate_initial_burst
 */
readrateInitialBurst?: number,

Performance tips

See this page for some tips on improving performance

Running example

examples/basic/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. Join a voice channel
  5. Start streaming with commands:

for go-live

$play-live <Direct video link>

or for cam

$play-cam <Direct video link>

for example:

$play-live http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4

FAQs

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

Yes, just send the media packets over both 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

版本与发布记录

@dank074/discord-video-stream 共发布 33 个版本,首次发布于 2023/03/15;过去 12 个月发布了 2 个版本。

版本发布日期距今
7.0.0latest2026/09/141 个月前
6.0.02026/03/068 个月前
5.0.22025/06/151.4 年前
5.0.12025/04/241.5 年前
5.0.02025/02/231.7 年前
4.2.02025/02/031.8 年前

关于 @dank074/discord-video-stream 的常见问题

@dank074/discord-video-stream 是什么?

Experiment for making video streaming work for discord selfbots

如何安装 @dank074/discord-video-stream?

在项目目录运行 npm install @dank074/discord-video-stream,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@lng2004/discord.js-selfbot-v13(^3.7.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dank074/discord-video-stream 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dank074/discord-video-stream 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dank074/discord-video-stream 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.4.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@dank074/discord-video-stream 可以商用吗?

@dank074/discord-video-stream 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dank074/discord-video-stream 的下载量有多少?

根据 npm 官方下载统计,@dank074/discord-video-stream 在 2026/10/12 – 2026/11/10 这 30 天内被下载 5,661 次,日均约 189 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dank074/discord-video-stream 还在维护吗?

最新版本 7.0.0 发布于 2026/09/14(1 个月前);至今共发布 33 个版本,其中过去 12 个月发布了 2 个;首次发布于 2023/03/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。