基于事件的视频录制Event-based video recording

建议的读前准备Suggested pre-reading

概述Overview

基于事件的视频录制 (EVR) 是指由事件触发的视频录制过程。Event-based video recording (EVR) refers to the process of recording video triggered by an event. 相关事件可能源于视频信号本身的处理(例如动作检测),也可能来自独立源(例如开门)。The event in question, could originate due to processing of the video signal itself (for example, detection on motion) or could be from an independent source (for example, opening of a door).

可以使用由 RTSP 源节点、资产接收器节点和其他节点组成的媒体图,将 CCTV 相机中的视频(由事件触发)录制到媒体服务资产中,如以下用例所述。You can record video (triggered by an event) from a CCTV camera to a Media Services asset using a media graph consisting of an RTSP source node, an asset sink node, and other nodes as outlined in the use cases below. 可以将资产接收器节点配置为在每次发生事件时生成新资产,使与每个事件相对应的视频位于其自己的资产中。You can configure the asset sink node to generate new assets each time an event occurs, so that the video that corresponds to each event will be in its own asset. 也可以选择使用一种资产来保存所有事件的视频。You can also choose to use one asset to hold the video for all events.

作为资产接收器节点的替代方法,你可以使用文件接收器节点将视频的短片段(与感兴趣的事件相关)捕获到边缘设备的本地文件系统上的指定位置。As an alternative to the asset sink node, you can use a file sink node to capture short snippets of video (related to an event of interest), to a specified location on the local file system on the Edge device.

本文介绍了一些与基于事件的视频录制有关的用例。A few use cases related to event-based video recording are described in this article.

基于动作检测的视频录制Video recording based on motion detection

在此用例中,只能在视频中检测到动作时录制视频片段,并在生成此类视频片段时收到警报。In this use case, you can record video clips only when there is motion detected in the video and be alerted when such a video clip is generated. 这可能与涉及关键基础结构保护的商业安全场景相关。This could be relevant in commercial security scenarios involving protection of critical infrastructure. 通过在检测到意外动作时生成警报并录制视频,可以提高人类操作员的效率,因为只有在生成警报时才需要执行操作。By generating alerts and recording video when unexpected motion is detected, you can improve the efficiency of the human operator, since action is only needed when the alert is generated.

下图显示了用于处理此用例的媒体图的图形表示形式。The diagram below shows a graphical representation of a media graph that addresses this use case. 可在此处找到此类媒体图的图形拓扑的 JSON 表示形式。The JSON representation of the graph topology of such a media graph can be found here.

基于动作检测的视频录制

在该图中,RTSP 源节点捕获了来自相机的实时视频源,并将其传递到动作检测处理器节点。In the diagram, the RTSP source node captures the live video feed from the camera and delivers it to a motion detection processor node. 在检测到实时视频中的动作后,动作检测处理器节点将生成事件,该事件将到达信号入口处理器节点以及 IoT 中心消息接收器节点。Upon detecting motion in the live video, the motion detection processor node generates event which go to the signal gate processor node, as well as to the IoT Hub message sink node. 后一个节点将事件发送到 IoT Edge 中心,从那里可以将事件路由到其他目标以触发警报。The latter node sends the events to the IoT Edge Hub, from where they can be routed to other destinations to trigger alerts.

来自动作检测器节点的事件将触发信号入口处理器节点,并将使来自 RTSP 源节点的实时视频源流到资产接收器节点。An event from the motion detector node will trigger the signal gate processor node, and it will let the live video feed from the RTSP source node flow through to the asset sink node. 如果没有后续此类动作检测事件,入口将在配置的时间范围之后关闭。In the absence of subsequent such motion detection events the gate will close after a configured amount of time. 这决定了录制视频的持续时间。This determines the duration of the recorded video.

基于来自其他源的事件的视频录制Video recording based on events from other sources

在此用例中,可以使用来自另一个 IoT 传感器的信号触发视频录制。In this use case, signals from another IoT sensor can be used to trigger recording of video. 下图显示了用于处理此用例的媒体图的图形表示形式。The diagram below shows a graphical representation of a media graph that addresses this use case. 可在此处找到此类媒体图的图形拓扑的 JSON 表示形式。The JSON representation of the graph topology of such a media graph can be found here.

基于来自其他源的事件的视频录制

在该图中,外部传感器将事件发送到 IoT Edge 中心。In the diagram, the external sensor sends events to the IoT Edge Hub. 然后,事件通过 IoT 中心消息源节点路由到信号入口处理器节点。The events are then routed to the signal gate processor node via the IoT Hub message source node. 信号入口处理器节点的行为与之前的用例相同 - 当外部事件触发它时,它将打开并让实时视频源从 RTSP 源节点流到文件接收器节点(或资产接收器节点)。The behavior of the signal gate processor node is the same as with the previous use case - it will open and let the live video feed flow through from the RTSP source node to the file sink node (or asset sink node) when it is triggered by the external event.

如果你使用文件接收器节点,则视频将录制到边缘设备上的本地文件系统中。If you use a file sink node the video will be recorded to the local file system on the edge device. 否则,如果你使用资产接收器节点,则视频将录制到资产中。Else if you use an asset sink node, the video will be recorded to an asset.

基于外部推理模块的视频录制Video recording based on an external inferencing module

在此用例中,你可以根据来自外部逻辑系统的信号来录制视频片段。In this use case, you can record video clips based on a signal from an external logic system. 此类用例的一个示例是,只有在公路上的交通视频源中检测到卡车时才录制视频片段。An example of such a use case could be recording a video clip only when a truck is detected in the video feed of traffic on a highway. 下图显示了用于处理此用例的媒体图的图形表示形式。The diagram below shows a graphical representation of a media graph that addresses this use case. 可在此处找到此类媒体图的图形拓扑的 JSON 表示形式。The JSON representation of the graph topology of such a media graph can be found here.

基于外部推理模块的视频录制

在该图中,RTSP 源节点捕获了来自相机的实时视频源,并将其传递到两个分支:一个具有信号入口处理器节点,另一个使用 HTTP 扩展节点将数据发送到外部逻辑模块。In the diagram, the RTSP source node captures the live video feed from the camera and delivers it to two branches: one has a signal gate processor node, and the other uses an HTTP extension node to send data to an external logic module. HTTP 扩展节点允许媒体图通过 REST 将图像帧(以 JPEG、BMP 或 PNG 格式)发送到外部推理服务。The HTTP extension node allows the media graph to send image frames (in JPEG, BMP, or PNG formats) to an external inference service over REST. 此信号路径通常仅支持低帧速率(小于 5fps)。This signal path can typically only support low frame rates (<5fps). 可以使用 HTTP 扩展处理器节点来降低发送到外部推理模块的视频的帧速率。You can use the HTTP extension processor node to lower the frame rate of the video going to the external inferencing module.

来自外部推理服务的结果由 HTTP 扩展节点检索,并通过 IoT 中心消息接收器节点中继到 IoT Edge 中心,外部逻辑模块可以在此处对这些结果进行进一步处理。The results from the external inference service are retrieved by the HTTP extension node, and relayed to the IoT Edge hub via IoT Hub message sink node, where they can be further processed by the external logic module. 例如,如果推理服务能够检测车辆,则逻辑模块可以查找特定的车辆(例如公共汽车或卡车)。If the inference service is capable of detecting vehicles, for example, the logic module could look for a specific vehicle such as a bus or a truck. 当逻辑模块检测到相关对象时,它可以通过将事件通过 IoT Edge 中心发送到图形中的 IoT 中心消息源节点来触发信号入口处理器节点。When the logic module detects the object of interest, it can trigger the signal gate processor node by sending an event via the IoT Edge Hub to the IoT Hub message source node in the graph. 来自信号入口的输出显示为到达文件接收器节点或资产接收器节点。The output from the signal gate is shown to go to either a file sink node or an asset sink node. 如果是到达文件接收器节点,视频将录制到边缘设备的本地文件系统中。In the former case, the video will be recorded to the local file system on the edge device. 如果是到达资产接收器节点,视频将录制到资产中。In the latter case, the video will be recorded to an asset.

增强此示例的一种方法是,在抵达 HTTP 扩展处理器节点之前使用动作检测器处理器。An enhancement to this example is to use a motion detector processor ahead of the HTTP extension processor node. 这将减少推理服务的负担,例如夜间公路上可能会有很长一段时间没有车辆经过。This will reduce the load on the inference service, such as nighttime when there may be long periods of time when there are no vehicles on the highway.

后续步骤Next steps

教程:基于事件的视频录制Tutorial: event-based video recording