将传统 Deepstream 应用迁移到 Python 中的 Service Maker 应用#
将传统 Deepstream 应用程序迁移到 Python 应用程序,有两种选择。一种选择是使用带有配置文件的 Pipeline API,另一种选择是使用 Flow API。每种方法都有其自身的优势,可以根据应用程序开发人员的具体要求和偏好进行选择。
使用 pipeline API 将 Deepstream 应用程序迁移到 Python 应用程序的指南与 Service Maker C++ API 的指南保持一致。因此,本节将重点介绍如何使用 Flow API 将 Deepstream 应用程序迁移到 Python 应用程序。
定义视频源
Service Maker 使用源列表 YAML 文件来定义输入,包括源信息和输入配置。源列表文件的规范可以在SourceConfig中找到。一旦我们有了源列表文件,我们就可以用它创建一个批量捕获流
from pyservicemaker import Pipeline, Flow Flow(Pipeline("my-pipeline")).batch_capture("my_source_list.yaml")
Pipeline 自定义
在 Flow API 中,传统 Deepstream 应用程序的配置文件中用于 pipeline 自定义的每个预定义部分都对应于其各自的功能
DS 配置
Flow API 名称
primary-gie
infer
secondary-gie
infer
tracker
track
Sink 管理
Flow API 具有与传统 Deepstream 应用程序中支持的每种 sink 类型对应的功能
DS Sink 类型
Flow API 名称
Fakesink
render(mode=RenderMode.DISCARD)
Display
render(mode=RenderMode.DISPLAY)
File
encode(“/tmp/sample.mp4”)
UDP
encode(“udp://127.0.0.1:5400”)
RTSP
encode(”rtsp://127.0.0.1:5400”)
MsgConvBroker
publish
要启用多 sink,我们可以调用 fork() 来 fork 当前流,并在其后附加各种 sink 功能(查看前面章节中的“fork”功能)。