# @dank074/discord-video-stream 中文文档

规范地址：https://npmcn.com/package/%40dank074/discord-video-stream/

版本：7\.0\.0
npm 元数据更新时间：2026-09-13T23:01:14.818Z
中文译文更新时间：2026-11-11T10:50:22.044Z
软件包许可：ISC

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40dank074/discord-video-stream
原文对照：https://npmcn.com/package/%40dank074/discord-video-stream/?lang=original
项目主页：https://github.com/Discord-RE/Discord-video-stream#readme
源码仓库：https://github.com/dank074/Discord-video-stream

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：440 kB，127 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=22\.4\.0
- 运行依赖：8 个
- peer 依赖：@lng2004/discord\.js-selfbot-v13 ^3\.7\.2
- 首次发布：2023-03-15T01:44:07.160Z
- 最新版本发布：2026-09-13T23:01:14.658Z
- 近 30 天下载量：5661（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：33（近 12 个月 2 个）

## 中文简介

为不相通的自机器人制作视频流的实验

## 安装

```sh
npm install @dank074/discord-video-stream
```

也可以使用：`pnpm add @dank074/discord-video-stream`、`yarn add @dank074/discord-video-stream`、`bun add @dank074/discord-video-stream`

## README

# Discord 自机器人视频

[![pkg.pr.new](https://pkg.pr.new/badge/Discord-RE/Discord-video-stream)](https://pkg.pr.new/~/Discord-RE/Discord-video-stream)

叉: [Discord-video- 实验](https://github.com/mrjvs/Discord-video-experiment)

> \[叹息\] 使用您账户上的任何自动化程序都会导致您的账户被Discord永久禁用. 冒险使用

## 特征

-   在语音频道播放视频和音频( A)`Go Live`,或网络相机视频)

## 执行情况

我所执行的和所没有的.

### 视频解码器

-   [ ] VP8(支持一次,为可维护性而删除)
-   [ ] 自愿承诺9
-   [x] H.264 (英语)
-   [x] H.265 (英语)
-   [ ] 自动取款机1

### 包类型

-   [x] RTP( 发送实时数据)
-   [ ] RTX(再发送)

### 连接类型

-   [x] 正则语音连接
-   [x] 开始生活

### 加密

-   [x] 传输加密
-   [x] [端到端加密](https://github.com/dank074/Discord-video-stream/issues/102)

### 额外

-   [x] 查找 RTP 标题扩展名( discord special) (discord 似乎使用 [单字节 RTP 标题扩展名](https://www.rfc-editor.org/rfc/rfc8285.html#section-4.2)(中文(简体) )

由 Discord 支持的扩展( 取自 Webrtc sdp 交换器)

```
"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"
```

## 所需资源

对于全部功能,此库需要使用 FFmpeg 构建 `libzmq` 启用 。 我们的建议如下:

-   视窗 & Linux : [BtbN 的 FFmpeg 构建](https://github.com/BtbN/FFmpeg-Builds)
-   macOS (英特尔): [从未见过.cx](https://evermeet.cx/ffmpeg/)
-   macOS (Apple硅): 安装自家酿造机

## 使用量

安装此软件包, 并同时安装端点依赖性@ lng2004/ discord.js- selfbot- v13 :

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

> \[大 该图书馆使用本土附属物(`node-av` 财务报告和审定财务报表 `node-datachannel`) (中文(简体) ). 如果您使用默认不运行安装脚本的软件包管理器( Q)`pnpm`, (中文(简体) ), `bun`等),您需要允许运行安装脚本用于 `node-av` 财务报告和审定财务报表 `node-datachannel` 正常操作.

创建新 Streamer, 并传递给自控客户端

```typescript
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');
```

让客户端加入语音频道

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

开始发送媒体

```typescript
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);
}
```

## 可用的编码器选项

```typescript
/**
 * 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` 可用选项

```typescript
/**
 * 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,
```

## 绩效提示

见 [此页面](https://npmcn.com/package/%40dank074/discord-video-stream/PERFORMANCE.md) 关于改进业绩的一些建议

## 运行示例

`examples/basic/src/config.json`数字 :

```json
"token": "SELF TOKEN HERE",
"acceptedAuthors": ["USER_ID_HERE"],
```

1.  配置您的 `config.json` 和你的自我标志
2.  生成 js 文件 `npm run build`
3.  以 : `npm run start`
4.  加入语音频道
5.  以命令开始流出 :

用于启动

```
$play-live <Direct video link>
```

或用于相机

```
$play-cam <Direct video link>
```

例如:

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

## 问题

-   我能同时在现有的语音连接(CAM)和连接上流吗?

是的,只是发送媒体包 通过两个连接。 语音网关希望您在用户打开相机时发出信号,以确保您使用 `client.signalVideo(guildId, channelId, true)` 在开始发送相机媒体包之前.

-   这个图书馆有机器人标志吗?

不,Discord屏蔽了来自bots的视频 这就是为什么这个库 使用自机器人库作为对等依赖。 您必须使用用户代号

## 常见问题

### @dank074/discord-video-stream 是什么？

为不相通的自机器人制作视频流的实验

### 如何安装 @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 和提交记录判断。

