> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 长时间游戏捕获 (wdcapturesession.exe)

> 长时间游戏捕获 (wdcapturesession.exe)

使用此工具启动和停止游戏的捕获,并将文件保存到主机暂存驱动器(例如 `xd:\clips\file.mp4`)。

<Note>
  您也可以使用 [XBOX Manager](/tools/tools-console/xbom/xbom) 工具捕获视频并保存到本地 PC。
</Note>

| 命令                               | 说明                                      |
| -------------------------------- | --------------------------------------- |
| [start](#wdcapturesession_start) | 启动捕获会话。                                 |
| [stop]()                         | 停止捕获会话并完成将文件写入磁盘。如果检测到磁盘空间不足,则会自动调用该命令。 |

<a id="wdcapturesession_start" />

## wdcapturesession start

启动捕获会话并以 MP4 文件格式保存到暂存驱动器。

`FilePath` 是可选参数,路径默认为 `d:\clips\sessionvideo_[timestamp].mp4`。`FilePath` 名称中需要有 MP4 扩展名。如果未指定路径,则将文件写入 `d:\clips` 路径。

`Max duration in seconds` 为可选参数,默认为 3600 秒。

在正捕获活动会话时调用 `start` 会返回错误 “Error: Cannot start session capture, Recording in Progress”(0x8C111120)。

`wdcapturesession start /f:<filepath> /d:<maxduration in seconds> /autostop`

| 选项         | 说明                                                      |
| ---------- | ------------------------------------------------------- |
| `f`        | 输出文件的路径和名称                                              |
| `d`        | 指定会话捕获的最大持续时间(秒)。默认为 3600。                              |
| `autostop` | 当游戏标题退出时自动停止捕获会话。此标志为可选,并且仅适用于主机版本的 `wdcapturesession`。 |

<a id="wdcapturesession_stop" />

## wdcapturesession stop

停止捕获会话并完成将文件写入磁盘。如果检测到磁盘空间不足,将自动调用。

`wdcapturesession stop `

## 结合 wdcapturesession 使用实时消息传递协议 (RTMP)

RTMP 是一种音频/视频流式传输协议,适用于存档目的(例如运行测试)和实时流式传输。

<Note>
  RTMP 不支持加密。请勿通过公共互联网使用它传输机密信息。
</Note>

例如,一个合适的命令可能是 `wdcapturesession start /f:rtmp://servername/live/streamname`。

与现有场景类似,`wdcapturesession stop` 会停止流式传输会话、发布流,然后关闭与服务器的连接。此功能仅限于开发套件。

RTMP 具有以下限制:

* 默认最长时间限制为 1 小时(3600 秒)。如果需要更长的录制时间,请使用 `/d:` 选项。
* 视频以 H264 格式发送,分辨率为 HD、30 fps,约 5 Mbps。
* 音频以 AAC 立体声格式发送。

支持仅限于未加密的连接,因此请仅在内部网络上分享机密内容。此功能可与 Google Cloud Service、nginx-rtmp 和 YouTube RTMP 服务器配合使用。

例如,`YouTube` 要求在接收 `wdcapturesession` 的输出时使用此选项以从默认模式切换到 `"live"` 发布模式。

一个合适的 URL 可能是 `rtmp://servername/live/streamkey?publishmode=live`。

## 另请参阅

[基于主机的命令行工具](/tools/tools-console/console_commandlinetools/consolecommandlinetools)

[XTF 传输错误](/tools/tools-console/commandlinetools/xtf-transport-errors)


## Related topics

- [基于主机的命令行工具](/zh-CN/tools/tools-console/console_commandlinetools/consolecommandlinetools.md)
- [视频捕获 (wdcapturesession.exe)](/zh-CN/tools/tools-pc/commandlinetools/gr-wdcapturesession.md)
- [PC 开发的命令行工具](/zh-CN/tools/tools-pc/commandlinetools/gr-commandlinetools-toc.md)
- [面向 XBOX 的主机端命令行工具](/zh-CN/tools/tools-console/console_commandlinetools/index.md)
- [命令行工具](/zh-CN/tools/tools-pc/commandlinetools/index.md)
