WhipInto
RTP/RTSP to WHIP tool
要在树莓派 / ARM 开发板上推摄像头?
不要在这些开发板上把 whipinto 和软编码的 ffmpeg 搭配使用——CPU 撑不住。native-rpi / native-rkmpp 的 live777 构建在进程内用硬件完成采集和编码,见树莓派部署指南。whipinto 适用于已经编码好的源(网络摄像头、RTP/RTSP 流、文件、合成测试源)。
这个工具有两种模式:
rtprtsp as client
反向的 WHEP → RTP/RTSP 请使用 whepfrom;完整本机闭环见 三终端验流步骤。
获取工具与前置条件
请按安装指南下载软件包或预编译二进制,或在仓库中 运行 cargo build --release --bin whipinto 从源码构建。运行前需要可访问的 Live777 WHIP 端点,以及已编码的 RTP/RTSP 源。只有下面的示例需要 FFmpeg; synth:// 输入需要以 --features=rsmpeg 构建。
Bearer token
如果 live777.toml 的 [auth] 下配置了 tokens = ["live777"],请用 -t 传入相同 token:
whipinto -i input.sdp -t live777 -w http://127.0.0.1:7777/whip/777不要把 token 放进 URL,也不要把真实 token 写入公开的 shell 历史或配置文件。
选项
| 选项 | 默认值 | 说明 |
|---|---|---|
-i, --input | input.sdp | 输入源:SDP 文件路径(RTP)、rtsp://(RTSP client 模式)、synth://(生成测试帧) |
-w, --whip | 必填 | WHIP 端点 URL |
-t, --token | 无 | WHIP 认证使用的 Bearer token |
--command | 无 | 以子进程方式运行命令 |
--cable-url | 无 | Cable UDP 桥接 URL,用于 DataChannel <-> UDP 转发,例如 udp://0.0.0.0:9001?host=127.0.0.1&port=9000 |
--cable-label | - | DataChannel label,加入服务器上对应的 cable |
--ice-server | 无 | ICE 收集使用的服务器,可重复指定;格式 <url>[,<username>[,<credential>]]。默认为空——仅使用 host candidate(WHIP/WHEP 端点会通过 Link 头通告自己的 ICE 服务器) |
-v | warn | 提高日志级别(-v info,-vv debug,-vvv trace) |
RTP
whipinto -i input.sdp -w http://localhost:7777/whip/777TIP
你需要先创建一个 SDP 文件
可以用 ffmpeg -sdp_file flag 来创建 SDP 文件
RTP Only video
ffmpeg -re -f lavfi -i testsrc=size=1280x720:rate=30 \
-vcodec libx264 -pix_fmt yuv420p \
-g 60 -keyint_min 60 -crf 23 \
-preset ultrafast -tune zerolatency \
-profile:v main -level 4.1 \
-f rtp 'rtp://127.0.0.1:5002' -sdp_file input.sdpRTP Only audio
ffmpeg -re -f lavfi -i sine=frequency=1000 \
-acodec libopus \
-ar 48000 -ac 2 \
-b:a 48k -application voip \
-frame_duration 10 -vbr constrained \
-f rtp 'rtp://127.0.0.1:5004' -sdp_file input.sdpRTP Audio and Video
ffmpeg -re \
-f lavfi -i sine=frequency=1000 \
-f lavfi -i testsrc=size=1280x720:rate=30 \
-acodec libopus -vn -f rtp rtp://127.0.0.1:11111 \
-vcodec libvpx -an -f rtp rtp://127.0.0.1:11113 -sdp_file input.sdpRTSP Client
whipinto 作为一个客户端,从其他的 RTSP Server 来拉流
whipinto -i rtsp://127.0.0.1:8554 -w http://localhost:7777/whip/777Use transport tcp
whipinto -i rtsp://localhost:8554/test-rtsp?transport=tcp -w http://localhost:7777/whip/test-rtsp合成输入(Synthetic input)
启用 rsmpeg feature 后,-i 也接受 synth:// URL,在进程内生成测试帧(无需外部编码器):
whipinto -i 'synth://h264?audio=opus&width=1280&height=720&fps=30' \
-w http://localhost:7777/whip/777格式:synth://<vcodec>?<parameters>;<vcodec> 为 vp8、vp9、h264、h265、av1 之一,所有参数均可选:
| 参数 | 默认值 | 说明 |
|---|---|---|
audio | 无 | 音频编码:opus、g722(省略表示无音频) |
width | 640 | 视频宽度(像素) |
height | 480 | 视频高度(像素) |
fps | 30 | 视频帧率 |
duration | 无 | 发布指定秒数后停止 |
ice | --ice-server 的值 | ICE 服务器规格 <url>[,<username>[,<credential>]],可重复指定;对该输入替换命令行列表(空值表示禁用 ICE 服务器) |
About pkt_size=1200
WARNING
WebRTC必须满足 pkt_size<=1200
当 pkt_size > 1200 时(多数工具默认值 > 1200,例如: ffmpeg 默认 1472),需要进行解封装后重新封装处理
不过现在,我们已经在 AV1、VP8 和 VP9 编解码器中支持重新调整 pkt_size,您可以在 AV1、VP8 和 VP9 中使用任意大小的 pkt_size 值
| Codec | AV1 | VP9 | VP8 | H264 | H265 | OPUS | G722 |
|---|---|---|---|---|---|---|---|
pkt_size > 1200 | ⭐ | ⭐ | ⭐ | ⭐ | ⭐ | ⭐ | 💩 |
- ⭐ 正常运行
- 💩 不支持
排障
使用 -vv 输出 WebRTC 和桥接诊断日志。认证、HTTP 状态码和 ICE 失败的通用检查 见 排障;下表只列本工具特有的问题。
| 现象 | 检查项 |
|---|---|
404 Not Found | 检查 /whip/<stream> URL、流名、端口和反向代理路径,确认目标是 WHIP 而不是 WHEP 端点。 |
| 已连接但没有媒体 | 确认发送端正在向 SDP 端口发包、SDP 编码与实际输入一致,且 RTSP/SDP 输入可访问;同时检查上面的包大小和编码支持。 |