Skip to content

WhepProbe

whepprobe 是一个类似 ffprobe 的 WHEP 端点诊断工具。它订阅 WHEP 流并验证流是否可达、视频是否能通过 rsmpeg crate 调用 FFmpeg 正常解码。

如果需要基于真实浏览器的播放验证,请查看 WhepWright

构建

bash
# 需要 FFmpeg 开发库
cargo build --bin whepprobe --features rsmpeg

用法

探测一个 WHEP 端点:

bash
whepprobe -w http://localhost:7777/whep/live

指定预期编码和超时时间:

bash
whepprobe -w http://localhost:7777/whep/live --codec h264 --timeout 60

输出 JSON 格式,方便脚本或 CI 使用:

bash
whepprobe -w http://localhost:7777/whep/live --output json

选项

选项默认值说明
-w, --whep必填WHEP 端点 URL
-t, --tokenWHIP/WHEP 认证使用的 Bearer token
-vwarn提高日志级别(-v info,-vv debug,-vvv trace)
--codec自动检测预期视频编码:vp8vp9h264h265av1rsmpeg 后端会从 WHEP 会话自动检测编码,因此该选项仅影响报告结果。
--sprop-paramsH.265 sprop 参数(sprop-vps=...;sprop-sps=...;sprop-pps=...
--decode-duration5WHEP 连接成功后持续解码的秒数。超过 10 的值会被静默截断。
--outputhuman输出格式:humanjson
--timeout30整体超时时间(秒)

退出码

  • 0:探测成功(WHEP 已连接且视频已解码)。
  • 1:探测失败或发生错误。

核心库

探测逻辑位于 livetwo::probe,可以被集成测试或其他 Rust 工具复用:

rust
use cli::Codec;
use livetwo::probe::{ProbeBackend, ProbeConfig};
use livetwo::probe::rsmpeg::RsmpegProbe;
use std::time::Duration;

// RsmpegProbe 需要 `livetwo` 启用 `rsmpeg` feature 才能使用。
let config = ProbeConfig {
    whep_url: "http://localhost:7777/whep/live".to_string(),
    timeout: Duration::from_secs(30),
    codec: Some(Codec::Vp8),
    sprop_params: None,
    token: None,
};

let result = RsmpegProbe::default().probe(&config).await?;
assert!(result.success);

Released under the MPL-2.0 License.