跳到主要内容

多流推理

gst-ai-multistream-inference 同时处理多路视频流,每路独立执行目标检测,适合安防监控、多路分析等场景。

前提条件

步骤

1. 安装 ffmpeg 并转码视频

默认视频格式与 Q900 的 GStreamer 渲染管线存在兼容性问题,需转码为 baseline H.264:

radxa@airbox$
sudo apt install -y ffmpeg
sudo ffmpeg -y -i /etc/media/video.mp4 \
-c:v libx264 \
-profile:v baseline \
-level 3.1 \
-pix_fmt yuv420p \
-vf scale=640:480 \
-r 30 \
-g 30 \
-keyint_min 30 \
-bf 0 \
-an \
-movflags +faststart \
/etc/media/video_safe.mp4

关键参数说明:

参数作用
-profile:v baseline禁用 B 帧,避免 qtdemux dmabuf 协商冲突
-bf 0关闭 B 帧
-keyint_min 30 -g 30关键帧间隔 1 秒,便于 seek
-movflags +faststartmoov 原子前置,加快解码器初始化
-an去除音频,减小文件体积

2. 创建配置文件

配置中所有流指向同一个转码后的视频:

radxa@airbox$
python3 -c "
import json
with open('/etc/configs/config-multistream-inference.json') as f:
c = json.load(f)
c['input-file-path'] = ['/etc/media/video_safe.mp4'] * 16
json.dump(c, open('/tmp/cfg_multistream.json', 'w'), indent=2)
print('config written')
"

3. 运行

radxa@airbox$
gst-ai-multistream-inference --config-file=/tmp/cfg_multistream.json

Ctrl + C 停止。

预期输出

终端输出:

HTP Core Count = 2
Run app with model: /etc/models/yolox_quantized.tflite and labels: /etc/labels/yolox.json and use case: Detection
VERBOSE: Replacing 329 out of 329 node(s) with delegate (TfLiteQnnDelegate) node
...
Pipeline state changed from PAUSED to PLAYING

显示器上同时显示多路检测画面。

验证

  • 每路视频 329 个算子全部委派到 DSP
  • Pipeline 进入 PLAYING 状态

    您需要登录 GitHub 才能发表评论。如果您已登录,请忽略此消息。

    Radxa-docs © 2026 by Radxa Computer (Shenzhen) Co.,Ltd. is licensed under CC BY 4.0