Skip to content

视频接口

Video 方法

方法参数响应 data说明
video.startdevice_id: string 必填,width?: numberheight?: numberfps?: numberpixel_format?: string=mjpegprofile?: CaptureProfiledevice_idstream_idsession_tokenpixel_formatwidthheightfps创建视频流。
video.stopdevice_id: string 必填device_idstream_idstopped: true停止当前连接下指定设备的视频流。
video.set_formatdevice_id: string 必填,pixel_format?: string=mjpegwidth?: number=1280height?: number=720fps?: number=15device_idstream_idpixel_formatwidthheightfps更新当前 stream 格式。
video.set_profiledevice_id: string 必填,profile: CaptureProfile 必填;profile.output 可包含 qualitytarget_sizedevice_idpage_processingsingle_pageapplied更新视频实时处理 profile,并缓存后续采集使用的输出参数。

pixel_format 支持 mjpegjpegbgr24;其中 jpeg 会归一为 mjpegvideo.start 未传 widthheightfps 时,会按 1280*72015fps 注册 stream,最终返回值以 provider 实际选中的格式和分辨率为准。

CaptureProfile 对视频的影响

video.start 可以在创建视频流时应用 profilevideo.set_profile 可以在视频流已启动后更新实时处理 profile。CaptureProfile 的完整结构请参考 采集接口 / CaptureProfile

当前视频流实际使用的 CaptureProfile 字段:

字段说明
capture.page_processing仅当值为 single_page 时,会启用单页实时识别相关逻辑。
capture.single_page.realtime_detect_rects是否开启实时识别框。开启后,stream.frame_meta 可能返回 detected_rectsdetected_rects_source
capture.single_page.multi_target_paging仅在实时识别框开启时生效,用于返回多个目标识别框。
output.quality缓存为后续 capture.take 或设备硬拍任务的 JPG/JPEG 输出质量,不影响当前 Video WS 帧质量。
output.target_size缓存为后续 capture.take 或设备硬拍任务的目标输出尺寸,不影响当前 Video WS 帧分辨率。

video.set_profile 要求指定设备的视频流已经启动;未启动时会返回 stream not ready 类错误。视频流分辨率仍通过 video.set_format 控制。需要设置 output.target_size 时,客户端应先读取 device.open.data.capture_output.target_sizes,再把选中的档位写入 profile.output.target_size。翻页自动检测目前没有公开 CaptureProfile 参数,暂不作为已支持的视频能力描述。

Video WS 帧事件

如需了解客户端如何配对 stream.frame_meta 与二进制帧并渲染到页面,请参考 设备与视频 / 渲染视频帧

对外 SDK 默认使用 Video WSS:

text
wss://sdk-runtime.localhost:18091?session_token=<session_token>&stream_id=<stream_id>

自定义 TLS 部署时,使用证书匹配的 wss://<tls-host>:18091session_tokenstream_id 查询参数不可省略。

每帧先推送 stream.frame_meta 文本事件,再推送二进制帧。二进制帧格式由当前 pixel_format 决定:mjpeg/jpeg 输出 JPEG 编码帧,bgr24 输出 BGR24 原始帧。

payload 字段:device_idstream_idframe_seqtimestamp_mswidthheightpixel_format,可选 detected_rectsdetected_rects_source

CZUR Open Platform Documentation