WO2023000639A1 - Video generation method and apparatus, electronic device, storage medium, and program - Google Patents

Video generation method and apparatus, electronic device, storage medium, and program Download PDF

Info

Publication number
WO2023000639A1
WO2023000639A1 PCT/CN2022/074117 CN2022074117W WO2023000639A1 WO 2023000639 A1 WO2023000639 A1 WO 2023000639A1 CN 2022074117 W CN2022074117 W CN 2022074117W WO 2023000639 A1 WO2023000639 A1 WO 2023000639A1
Authority
WO
WIPO (PCT)
Prior art keywords
video
event
predetermined event
time interval
data
Prior art date
Application number
PCT/CN2022/074117
Other languages
French (fr)
Chinese (zh)
Inventor
徐尤龙
樊俊良
陈万里
张广程
温祖钦
陈宇恒
Original Assignee
上海商汤智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 上海商汤智能科技有限公司 filed Critical 上海商汤智能科技有限公司
Publication of WO2023000639A1 publication Critical patent/WO2023000639A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/222Studio circuitry; Studio devices; Studio equipment
    • H04N5/262Studio circuits, e.g. for mixing, switching-over, change of character of image, other special effects ; Cameras specially adapted for the electronic generation of special effects
    • H04N5/265Mixing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/44016Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving splicing one content stream with another content stream, e.g. for substituting a video clip
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display

Definitions

  • the present disclosure relates to the technical field of computer vision, including but not limited to a video generation method, device, electronic equipment, storage medium and program.
  • the present disclosure proposes a video generation technical solution, including but not limited to a video generation method, device, electronic equipment, storage medium and program, which can improve the efficiency of event backtracking during video analysis.
  • the present disclosure provides a video generation method, including:
  • the video data of the video stream into the preset cache queue, the video data including the data packets of the video stream and the time information of the data packets; when receiving the event message for the video stream Next, according to the triggering moment of the predetermined event in the event message, determine the time interval corresponding to the predetermined event, the duration of the time interval is less than or equal to the duration of the video data in the buffer queue; from the buffer queue In the video data, the video file of the video segment corresponding to the time interval is obtained; the video file of the video segment is stored in a preset storage space, so as to obtain the video segment associated with the predetermined event.
  • the trigger moment is within the time interval
  • the time interval includes a start moment and an end moment
  • the video data acquired from the buffer queue is related to the
  • the video file of the video segment corresponding to the time interval includes: when the current moment reaches the end moment, from the video data in the cache queue, copy the data packet of the video segment corresponding to the time interval; Encapsulate the data packets of the video clips to obtain the video files of the video clips.
  • the storing the video file of the video segment in a preset storage space to obtain the video segment associated with the predetermined event includes: storing the video file of the video segment The file is stored in the storage space; an association relationship between the predetermined event and the storage address of the video file in the storage space is established, so as to obtain a video segment associated with the predetermined event.
  • the method further includes: performing event detection on video frames of the video stream, and determining whether a predetermined event occurs in the video frame; if a predetermined event occurs in the video frame , determining the triggering moment of the predetermined event according to the time information of the video frame; sending an event message for the video stream, where the event message includes the predetermined event and the triggering moment.
  • the method is applied to an electronic device, and a visual analysis service and a video editing service are run in the electronic device, and the visual analysis service is configured to: perform Event detection, determining whether a predetermined event occurs in the video frame; in the case of a predetermined event occurring in the video frame, determining the triggering moment of the predetermined event according to the time information of the video frame; The service sends the event message.
  • the video editing service is configured to: write the video data of the video stream into a preset cache queue; when receiving the event message sent by the visual analysis service Next, according to the triggering moment of the predetermined event, determine the time interval corresponding to the predetermined event; from the video data in the cache queue, obtain the video file of the video segment corresponding to the time interval; The video files of the segment are stored in a preset storage space, so as to obtain the video segment associated with the predetermined event.
  • the method further includes: reading a video file of a video segment associated with the predetermined event from the storage space in response to a viewing operation on the predetermined event; playing the video file.
  • the video stream includes one or more video streams
  • the buffer queue includes a circular queue
  • the predetermined event includes a pedestrian fall event, a pedestrian retrograde event, a pedestrian squatting event, and a smoking event. at least one of .
  • the present disclosure provides a video generation device, including:
  • the data cache module is configured to write the video data of the video stream into a preset cache queue, the video data including the data packets of the video stream and the time information of the data packets;
  • the time interval determination module is configured to determine the time interval corresponding to the predetermined event according to the triggering moment of the predetermined event in the event message when the event message for the video stream is received, and the time interval of the time interval The duration is less than or equal to the duration of the video data in the cache queue;
  • a video file obtaining module configured to obtain a video file of a video segment corresponding to the time interval from the video data in the cache queue
  • the storing and associating module is configured to store the video file of the video segment in a preset storage space, so as to obtain the video segment associated with the predetermined event.
  • the trigger moment is within the time interval, and the time interval includes a start moment and an end moment
  • the video file acquisition module is configured to: reach the end moment at the current moment In the case of time, from the video data in the cache queue, copy the data packet of the video segment corresponding to the time interval; encapsulate the data packet of the video segment to obtain the video file of the video segment.
  • the storing and associating module is configured to: store the video file of the video clip in the storage space; establish the relationship between the scheduled event and the video file in the storage space The association relationship between the storage addresses of , so as to obtain the video clips associated with the predetermined event.
  • the device further includes: an event detection module configured to perform event detection on a video frame of the video stream, and determine whether a predetermined event occurs in the video frame; a time determination module configured to When a predetermined event occurs in the video frame, according to the time information of the video frame, determine the triggering moment of the predetermined event; the message sending module is configured to send an event message for the video stream, the event The message includes the predetermined event and the triggering moment.
  • an event detection module configured to perform event detection on a video frame of the video stream, and determine whether a predetermined event occurs in the video frame
  • a time determination module configured to When a predetermined event occurs in the video frame, according to the time information of the video frame, determine the triggering moment of the predetermined event
  • the message sending module is configured to send an event message for the video stream, the event The message includes the predetermined event and the triggering moment.
  • the apparatus is applied to an electronic device, and a visual analysis service and a video editing service are run in the electronic device, and the visual analysis service is configured to: perform Event detection, determining whether a predetermined event occurs in the video frame; in the case of a predetermined event occurring in the video frame, determining the triggering moment of the predetermined event according to the time information of the video frame; The service sends the event message.
  • the video editing service is configured to: write the video data of the video stream into a preset cache queue; when receiving the event message sent by the visual analysis service Next, according to the triggering moment of the predetermined event, determine the time interval corresponding to the predetermined event; from the video data in the cache queue, obtain the video file of the video segment corresponding to the time interval; The video files of the segment are stored in a preset storage space, so as to obtain the video segment associated with the predetermined event.
  • the device further includes: a video file reading module configured to read a video file associated with the predetermined event from the storage space in response to a viewing operation on the predetermined event A video file of the segment; a video playing module configured to play the video file.
  • the video stream includes one or more video streams
  • the buffer queue includes a circular queue
  • the predetermined event includes a pedestrian fall event, a pedestrian retrograde event, a pedestrian squatting event, and a smoking event. at least one of .
  • the present disclosure provides an electronic device, including: a memory configured to store executable instructions; a processor configured to call the instructions stored in the memory to execute the above video generation method.
  • the present disclosure provides a computer-readable storage medium, on which computer program instructions are stored, and the above-mentioned method is implemented when the computer program instructions are executed by a processor.
  • the present disclosure provides a computer program, including computer-readable codes.
  • a processor in the electronic device executes to realize any one of the above-mentioned video generation methods.
  • the video data of the video stream can be cached in the cache queue; when a predetermined event occurs, the time interval corresponding to the predetermined event is determined; the video file of the corresponding video segment is obtained from the cache queue and stored, and the stored
  • the video files are associated with the corresponding scheduled events, thereby improving the efficiency of event backtracking and saving a lot of storage resources.
  • Fig. 1 shows a flowchart of a video generation method in an embodiment of the present disclosure.
  • Fig. 2 shows a schematic diagram of the processing procedure of the video generation method of the embodiment of the present disclosure.
  • FIG. 3 shows a block diagram of a video generating device of an embodiment of the present disclosure.
  • Fig. 4 shows a block diagram of an electronic device according to an embodiment of the present disclosure.
  • Fig. 5 shows a block diagram of an electronic device according to an embodiment of the present disclosure.
  • the video generation method provided by the embodiments of the present disclosure can be executed by electronic devices such as terminal devices or servers, and the terminal devices can be user equipment (User Equipment, UE), mobile devices, user terminals, terminals, cellular phones, cordless phones, personal digital Assistant (Personal Digital Assistant, PDA), handheld device, computing device, vehicle-mounted device, wearable device, etc., the method can be implemented by calling the computer-readable instructions stored in the memory by the processor. Alternatively, the method may be performed by a server.
  • UE User Equipment
  • PDA Personal Digital Assistant
  • the video generation method provided by the embodiments of the present disclosure can be applied to smart city systems and smart community systems to realize the intelligent video analysis function in the security monitoring process, and present video clips associated with the alarm event when the video stream triggers the alarm event.
  • FIG. 1 shows a flow chart of a video generation method in an embodiment of the present disclosure.
  • the video generation method provided in an embodiment of the present disclosure may include the following steps:
  • Step S11 Write video data of the video stream into a preset buffer queue, the video data including data packets of the video stream and time information of the data packets.
  • Step S12 When the event message for the video stream is received, determine the time interval corresponding to the predetermined event according to the triggering moment of the predetermined event in the event message, and the duration of the time interval is less than or equal to The duration of the video data in the cache queue.
  • Step S13 Obtain the video file of the video segment corresponding to the time interval from the video data in the cache queue.
  • Step S14 storing the video file of the video segment in a preset storage space, so as to obtain the video segment associated with the predetermined event.
  • the video generation method of the embodiment of the present disclosure can cache the video data of the video stream in the cache queue, and detect the predetermined event of interest in the video stream through computer vision; determine the time interval corresponding to the predetermined event when the predetermined event occurs; Edit and store the corresponding video clips from the cache queue, and associate the stored video clips with the corresponding scheduled events, so that users can efficiently look back at the video screen when the event occurred, store really useful videos, and save a lot of storage resources.
  • the video stream to be analyzed may be an online video stream or an offline video stream collected by various video capture devices, and a predetermined event may occur in a picture of the video stream.
  • the embodiment of the present disclosure does not limit the source and type of the video stream.
  • pedestrians may have abnormal behaviors, such as falling, walking backwards, squatting, etc.
  • the predetermined events in the video stream may include pedestrian falling events, pedestrian retrograde events, pedestrian squatting events, and the like.
  • the predetermined events in the video stream may include smoking events, illegal entry into non-visiting areas, and the like.
  • abnormal behaviors of people or vehicles may occur, for example, the driver does not wear a seat belt, fatigue driving, running a red light, etc.
  • predetermined events in the video stream may include corresponding various violation events.
  • the embodiment of the present disclosure does not limit the specific type of the predetermined event.
  • a visual analysis service may run in the electronic device, and analyze predetermined events of interest in the video stream by way of computer vision. For example, image recognition and event detection are performed on one or more video frames of the video stream, and corresponding event detection results are output.
  • the event detection result may include any one of the following information: whether a scheduled event occurs, the type of the scheduled event that occurred.
  • Predetermined events can be detected through a trained event detection network, and the event detection network can use a convolutional neural network.
  • Embodiments of the present disclosure do not limit the network type and network structure of the event detection network.
  • a video clipping service may run in the electronic device for clipping a video stream.
  • Both the visual analysis service and the video editing service can be processes running on an electronic device, and can run on the same electronic device or different electronic devices, which is not limited in the embodiments of the present disclosure.
  • the video clip service can continuously pull the video data of the video stream, combine the received video data packet and the time information of the video data packet into a new data packet, and write it into the preset cache queue middle.
  • the time information of the video data packet may be the receiving time of the video data packet, or the collection time of the video data packet, which is not limited in the embodiments of the present disclosure.
  • the cache queue can be a ring queue, or a queue of other structures; the capacity of the cache queue can be set according to the actual situation. None are restricted.
  • new video data can be used to overwrite the earliest cached video data, thereby enabling circular buffering of video data.
  • the new video data in the case of using a circular queue, if the queue is full, the new video data can automatically overwrite the earliest cached video data, so that the circular buffering of video data can be automatically realized, saving processing resources .
  • the visual analysis service when detecting that a predetermined event occurs in the video stream, the visual analysis service will send an event message for the video stream to the video editing service, and the event message includes the predetermined event and the corresponding trigger time.
  • the trigger moment of the predetermined event is determined according to the time information of the video frame where the predetermined event occurs.
  • the time information of the video frame can be the receiving time of the video frame received by the electronic device, or the acquisition time of the video frame, as long as it is consistent with the cache
  • the time information of the video data can be synchronized. In this way, the occurrence of time misalignment can be avoided.
  • step S12 the video editing service determines that a predetermined event occurs in the video stream when receiving the event message. According to the triggering moment of the predetermined event in the event message, the time interval corresponding to the predetermined event can be determined, that is, the time interval corresponding to the video segment to be edited.
  • the triggering moment of the scheduled event is time t
  • n seconds can be traced backward
  • the time interval corresponding to the video segment to be edited is [t-m, t+n].
  • the duration (m+n) of the time interval is less than or equal to the duration of the video data in the cache queue.
  • the video data after the trigger time t may not be cached in the cache queue, and in this case, asynchronous processing may be performed.
  • the video file in step S14, can be stored in a preset storage space, and the association between the video file and the predetermined event can be established to obtain the video segment associated with the predetermined event , so that relevant personnel can trace back the event.
  • the preset storage space may be a storage space of the electronic device itself, or a storage space of a storage server in the cloud, which is not limited in this embodiment of the present disclosure.
  • the video data of the video stream is cached in the cache queue; when a predetermined event occurs, the time interval corresponding to the predetermined event is determined; the video file of the corresponding video segment is obtained from the cache queue and stored, and the stored video
  • the file is associated with the corresponding scheduled event, which is convenient for users to efficiently review the video screen when the event occurred, store the really useful video, and save a lot of storage resources.
  • the visual analysis service and the video editing service may be respectively run on the same or different electronic devices.
  • the visual analysis service and the video editing service can obtain video streams respectively.
  • the acquired video stream may include one or more video streams, for example, video streams of different areas of a shopping mall.
  • the visual analysis service and the video editing service can process each video stream separately.
  • the embodiment of the present disclosure does not limit the number of video streams.
  • the video stream can be detected.
  • the video generation method in the embodiment of the present disclosure may further include the following steps: performing event detection on the video frame of the video stream, and determining whether a predetermined event occurs in the video frame; When a predetermined event occurs in a video frame, determine the triggering moment of the predetermined event according to the time information of the video frame; send an event message for the video stream, the event message includes the predetermined event and the trigger moment.
  • the video stream may be decoded to obtain multiple video frames of the video stream, and event detection is performed on each video frame.
  • event detection is performed on continuous video frames; frame extraction is first performed on continuous video frames, and then event detection is performed on the extracted video frames; event detection is performed on key frames in video frames, which is not covered in the embodiments of the present disclosure. limit.
  • different event detection modes may be set according to types of various predetermined events to be detected. For example, when detecting the pedestrian retrograde event of the escalator, the pedestrian in the video frame can be identified, and the relative speed between the pedestrian and the escalator can be analyzed to determine whether the pedestrian retrograde event occurs; for example, when the pedestrian fall event of the escalator is detected , it can identify pedestrians in the video frame, analyze the body posture of pedestrians, and judge whether pedestrians fall.
  • the embodiment of the present disclosure does not limit the specific manner of event detection.
  • the detection of predetermined events can be realized through a trained event detection network, and the event detection network can use one or more convolutional neural networks.
  • the type and network structure are not limited.
  • the triggering moment of the predetermined event may be determined according to time information of the video frame.
  • the time information of the video frame can be directly determined as the trigger moment of the predetermined event; In some cases, the time information of the last frame or the middle frame of multiple video frames may be determined as the triggering moment of the predetermined event. Embodiments of the present disclosure do not limit this.
  • an event message for the video stream may be sent, where the event message includes the scheduled event and the triggering moment of the scheduled event, so as to clip the video data in the buffer queue.
  • the detection of predetermined events can be realized, and the accuracy of event detection can be improved.
  • the visual analysis service when the video stream is detected by the visual analysis service, the visual analysis service is configured to: perform event detection on video frames of the video stream, and determine Whether a predetermined event occurs; if the predetermined event occurs in the video frame, determine the triggering moment of the predetermined event according to the time information of the video frame; and send the event message to the video editing service.
  • the visual analysis service may perform event detection on video frames of the acquired video stream, and determine whether a predetermined event occurs in the video frame; if a predetermined event occurs in the video frame, according to the video frame time information to determine the trigger moment of the predetermined event.
  • the visual analysis service may send an event message to the video clipping service, where the event message includes the scheduled event and the triggering time of the scheduled event, so that the video clipping service clips the video data in the cache queue .
  • the visual analysis process is separated from the video editing process, so that the visual analysis process can be set according to the requirements of the business system without affecting the video editing process.
  • the visual analysis service and the video editing service can obtain video streams separately, and do not rely on the function of obtaining video clips by time from the original video stream. Even if the original video stream does not support video clips by time, the video editing process can also be implemented normally.
  • the processing procedures of steps S11-S14 may be realized through a video editing service.
  • the video clip service can be configured to: write the video data of the video stream into a preset cache queue; upon receiving the event message sent by the visual analysis service, according to the triggering moment of the predetermined event, determine The time interval corresponding to the predetermined event; from the video data in the cache queue, obtain the video file of the video segment corresponding to the time interval; store the video file of the video segment into a preset storage space , to get the video clip associated with the predetermined event.
  • the video editing service may set up a video processing instance for each video stream, and a memory-based cache queue is set in each video processing instance.
  • the video reading module of the video processing instance continuously reads the video data of the corresponding video stream, combines the received video data packet and the time information of the video data packet into a new data packet, and writes it into the preset cache queue .
  • the time information of the video data packet may be the receiving time of the video data packet, or may be the collection time of the video data packet, which is not limited in the embodiments of the present disclosure.
  • the buffer queue may be a ring queue.
  • a circular queue By adopting a circular queue, when the queue is full, new video data can automatically overwrite the earliest cached video data, thereby automatically realizing circular buffering of video data and saving processing resources.
  • the ring queue can buffer 60s of video data, and the embodiment of the present disclosure does not limit the length of the ring queue.
  • the video editing service will continuously monitor event messages from the visual analysis service.
  • the video editing service may verify the event message to confirm whether it is a scheduled event of interest.
  • the predetermined events concerned by the visual analysis service and the video clip service may be different, for example, the predetermined events concerned by the visual analysis service include A, B, and C, while the predetermined events concerned by the video clip service include A and B. Embodiments of the present disclosure do not limit this.
  • the video editing service can determine the time interval corresponding to the predetermined event, that is, the time interval corresponding to the video segment to be edited, according to the trigger time in the event message.
  • the time interval corresponding to the video segment to be edited is [t-m, t+n].
  • the duration (m+n) of the time interval is less than or equal to the duration of the video data in the cache queue.
  • m may take a value of 3s
  • n may take a value of 6s. Embodiments of the present disclosure do not limit specific values of m and n.
  • the trigger moment t is within the time interval [t-m, t+n], and the time interval [t-m, t+n] includes a start moment (t-m) and an end moment (t+n) .
  • step S13 may include:
  • the video data after the trigger time t may not be cached in the cache queue, and asynchronous processing may be performed.
  • the video clip service receives the event message and passes the verification, it can start an asynchronous video clip processing process.
  • the processing can copy the data packets of the video segment corresponding to the time interval from the video data in the cache queue; Encapsulate the data packet of the video segment to generate a video file of the video segment.
  • the video file may be temporarily cached in the memory of the electronic device for subsequent storage in the storage space.
  • asynchronous video clip processing can be realized, thereby effectively intercepting video segments corresponding to predetermined events, and improving processing efficiency and accuracy.
  • step S14 may include the following steps: storing the video file of the video segment in the storage space; establishing an association between the predetermined event and the storage address of the video file in the storage space, to obtain video clips associated with the predetermined event.
  • the generated video file can be uploaded to the storage space, and the video file temporarily cached in the memory is deleted after the upload is successful.
  • the storage space can return the storage address of the video file in the storage space to the electronic device.
  • the storage space may be a storage space of a cloud storage server.
  • the video clip service can establish an association between the scheduled event and the storage address of the video file, and end the asynchronous video clip processing of this event process. In this way, video clips associated with the scheduled event can be obtained, so that relevant personnel can look back at the video screen of the scheduled event.
  • video clips can be stored and the association between predetermined events and video clips can be realized. Therefore, only video clips associated with predetermined events can be persistently stored, thereby saving a lot of storage resources.
  • Fig. 2 shows a schematic diagram of the processing procedure of the video generation method of the embodiment of the present disclosure.
  • n video streams video stream 1, video stream 2, . . . , video stream n.
  • the video editing service can set up a video processing instance for each video stream, and there are n video processing instances: instance 1, instance 2, ..., instance n, and each video processing instance is provided with a memory-based ring queue.
  • the visual analysis service and the video editing service can respectively read and process each video stream.
  • the video stream 1 is taken as an example for description below.
  • step 1 the video clip service reads the video data of video stream 1 through the video reading module of instance 1; in step 2, the received video data packet and the time information of the video data packet Combine into a new data packet and write it into the ring queue.
  • the visual analysis service may read video data of video stream 1, decode multiple video frames of the video stream, and perform event detection on each video frame. If a predetermined event is detected, the predetermined event is triggered in step 3, and an event message is sent to the video editing service, and the message includes the predetermined event and its triggering time.
  • the video editing service when the video editing service receives the event message and passes the verification, it determines the time interval corresponding to the predetermined event, and starts an asynchronous video editing process. When the end moment of the time interval is reached, in step 4, the corresponding video segment is obtained from the circular queue, and a file of the video segment is generated.
  • the video editing service can store video clips and associate scheduled events, upload the files of the video clips to the storage space, establish the association between the scheduled events and the storage addresses of the video files, and end the asynchronous video editing process. In this way, video clips associated with the scheduled event can be obtained, so that relevant personnel can look back at the video picture of the scheduled event.
  • the video generation method of the embodiment of the present disclosure may further include the following step: in response to a viewing operation on the predetermined event, reading the information associated with the predetermined event from the storage space The video file of the video clip; play said video file.
  • relevant personnel need to look back at a scheduled event, they can trigger a viewing operation for the scheduled event, such as clicking the icon of the scheduled event, or clicking a control corresponding to viewing the scheduled event, etc.
  • a viewing operation for the scheduled event such as clicking the icon of the scheduled event, or clicking a control corresponding to viewing the scheduled event, etc.
  • the electronic device in response to the viewing operation on the predetermined event, can read the associated video file of the video segment from the storage space according to the association between the predetermined event and the storage address of the video file.
  • document For example, a file read request is sent to a storage server in the cloud, so that the storage server returns a corresponding video file.
  • the electronic device may play the video file, so that relevant personnel can watch the video picture corresponding to the predetermined event. In this way, the convenience of going back to the scheduled event can be improved, and relevant personnel can quickly observe more details of the event.
  • the video generation method of the embodiment of the present disclosure can set visual perception rules to set interested scheduled events, and output the corresponding events when the rules are triggered; the video clip service can cache the video data of the video stream in the cache queue, When an event occurs, determine the time interval corresponding to the scheduled event; clip and store the corresponding video clips from the cache queue, and associate the stored video clips with the corresponding scheduled event, so that users can efficiently look back at the video screen when the event occurs, and store Really useful video, save a lot of storage resources.
  • the video generation method of the embodiment of the present disclosure can automatically trigger the interception of video clips based on computer vision, and does not need to manually screen the video clips of interest; the video data of the video stream will be cached in a memory-based circular queue, without NVR (Network Video Recorder, network video recording equipment) and other types of devices are required to store all videos, and only persistently store video clips associated with scheduled events, which greatly saves storage space; usually events are only associated with snapshots, this solution Predetermined events are associated with video clips, so that events can be indexed to related videos, and more event details can be quickly observed.
  • NVR Network Video Recorder, network video recording equipment
  • the video generation method of the embodiment of the present disclosure can be applied to application scenarios such as intelligent video analysis, security monitoring, smart city, and smart community, and can filter out interesting video clips from massive video data. Only the videos you are interested in can be stored, and you can quickly view the video images at that time when the online video stream triggers an alarm event.
  • the present disclosure also provides a video generating device, electronic equipment, computer-readable storage medium, and program, all of which can be used to realize any video generating method provided in the present disclosure, corresponding technical solutions and descriptions, and corresponding records in the method section.
  • FIG. 3 shows a block diagram of a video generation device in an embodiment of the present disclosure.
  • the video generation device provided in an embodiment of the present disclosure includes:
  • the data cache module 31 is configured to write the video data of the video stream into a preset cache queue, the video data including the data packets of the video stream and the time information of the data packets;
  • the time interval determination module 32 is configured to determine the time interval corresponding to the predetermined event according to the triggering moment of the predetermined event in the event message when receiving the event message for the video stream, the time interval The duration is less than or equal to the duration of the video data in the cache queue;
  • the video file obtaining module 33 is configured to obtain the video file of the video segment corresponding to the time interval from the video data in the cache queue;
  • the storing and associating module 34 is configured to store the video file of the video segment in a preset storage space, so as to obtain the video segment associated with the predetermined event.
  • the trigger moment is within the time interval, and the time interval includes a start moment and an end moment
  • the video file acquisition module 33 is configured to: reach the In the case of the end moment, from the video data in the cache queue, copy the data packets of the video segments corresponding to the time interval; encapsulate the data packets of the video segments to obtain the video files of the video segments.
  • the storage and association module 34 is configured to: store the video file of the video segment in the storage space; In order to obtain the video clips associated with the predetermined event.
  • the device further includes: an event detection module configured to perform event detection on a video frame of the video stream, and determine whether a predetermined event occurs in the video frame; a time determination module configured to When a predetermined event occurs in the video frame, according to the time information of the video frame, determine the triggering moment of the predetermined event; the message sending module is configured to send an event message for the video stream, the event The message includes the predetermined event and the triggering moment.
  • an event detection module configured to perform event detection on a video frame of the video stream, and determine whether a predetermined event occurs in the video frame
  • a time determination module configured to When a predetermined event occurs in the video frame, according to the time information of the video frame, determine the triggering moment of the predetermined event
  • the message sending module is configured to send an event message for the video stream, the event The message includes the predetermined event and the triggering moment.
  • the apparatus is applied to an electronic device, and a visual analysis service and a video editing service are run in the electronic device, and the visual analysis service is configured to: analyze the video frame of the video stream Perform event detection to determine whether a predetermined event occurs in the video frame; if a predetermined event occurs in the video frame, determine the triggering moment of the predetermined event according to the time information of the video frame; The clipping service sends the event message.
  • the video editing service is configured to: write the video data of the video stream into a preset cache queue; when receiving the event message sent by the visual analysis service Next, according to the triggering moment of the predetermined event, determine the time interval corresponding to the predetermined event; from the video data in the cache queue, obtain the video file of the video segment corresponding to the time interval; The video files of the segment are stored in a preset storage space, so as to obtain the video segment associated with the predetermined event.
  • the device further includes: a video file reading module configured to read a video file associated with the predetermined event from the storage space in response to a viewing operation on the predetermined event A video file of the segment; a video playing module configured to play the video file.
  • the video stream includes one or more video streams
  • the buffer queue includes a circular queue
  • the predetermined event includes a pedestrian fall event, a pedestrian retrograde event, a pedestrian squatting event, and a smoking event. at least one of .
  • the functions or modules included in the apparatus provided by the embodiments of the present disclosure can be configured to execute the methods described in the above method embodiments, and its specific implementation can refer to the descriptions of the above method embodiments. It is concise and will not be repeated here.
  • Embodiments of the present disclosure also provide a computer-readable storage medium, on which computer program instructions are stored, and the above-mentioned method is implemented when the computer program instructions are executed by a processor.
  • Computer readable storage media may be volatile or nonvolatile computer readable storage media.
  • An embodiment of the present disclosure also proposes an electronic device, including: a memory configured to store executable instructions; a processor configured to call the instructions stored in the memory to execute the above video generation method.
  • the type of the electronic device may be a terminal device, a server or other types of devices.
  • An embodiment of the present disclosure also provides a computer program product, including computer-readable codes, or a non-volatile computer-readable storage medium carrying computer-readable codes, when the computer-readable codes are stored in a processor of an electronic device When running in the electronic device, the processor in the electronic device executes the above method.
  • FIG. 4 shows a block diagram of an electronic device 400 according to an embodiment of the present disclosure.
  • the device type of the electronic device 400 may include any of the following: mobile phone, computer, digital broadcast terminal, messaging device, game console, tablet device, medical device, fitness device, personal digital assistant.
  • electronic device 400 may include one or more of the following components: processing component 402, memory 404, power supply component 406, multimedia component 408, audio component 410, input/output (I/O) interface 412, sensor component 414 , and the communication component 416 .
  • the processing component 402 generally controls the overall operations of the electronic device 400, such as operations associated with display, phone calls, data communications, camera operations, and recording operations.
  • the processing component 402 may include one or more processors 420 to execute instructions to complete all or part of the steps of the above method.
  • processing component 402 may include one or more modules that facilitate interaction between processing component 402 and other components.
  • processing component 402 may include a multimedia module to facilitate interaction between multimedia component 408 and processing component 402 .
  • the memory 404 is configured to store various types of data to support operations at the electronic device 400 . Examples of such data include instructions for any application or method operating on the electronic device 400, contact data, phonebook data, messages, pictures, videos, and the like.
  • the memory 404 can be implemented by any type of volatile or non-volatile storage device or their combination, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable Programmable Read Only Memory (EPROM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), Magnetic Memory, Flash Memory, Magnetic or Optical Disk.
  • SRAM static random access memory
  • EEPROM electrically erasable programmable read-only memory
  • EPROM erasable Programmable Read Only Memory
  • PROM Programmable Read Only Memory
  • ROM Read Only Memory
  • Magnetic Memory Flash Memory
  • Magnetic or Optical Disk Magnetic Disk
  • the power supply component 406 provides power to various components of the electronic device 400 .
  • Power components 406 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for electronic device 400 .
  • the multimedia component 408 includes a screen providing an output interface between the electronic device 400 and the user.
  • the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user.
  • the touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may not only sense a boundary of a touch or swipe action, but also detect duration and pressure associated with the touch or swipe action.
  • the multimedia component 408 includes a front camera and/or a rear camera.
  • the front camera and/or the rear camera can receive external multimedia data.
  • Each front camera and rear camera can be a fixed optical lens system or have focal length and optical zoom capability.
  • the audio component 410 is configured to output and/or input audio signals.
  • the audio component 410 includes a microphone (MIC), which is configured to receive external audio signals when the electronic device 400 is in operation modes, such as call mode, recording mode and voice recognition mode. Received audio signals may be further stored in memory 404 or sent via communication component 416 .
  • the audio component 410 may also include a speaker for outputting audio signals.
  • the I/O interface 412 provides an interface between the processing component 402 and a peripheral interface module.
  • the peripheral interface module may be a keyboard, a click wheel, a button, and the like. These buttons may include, but are not limited to: a home button, volume buttons, start button, and lock button.
  • Sensor assembly 414 includes one or more sensors for providing various aspects of status assessment for electronic device 400 .
  • the sensor assembly 414 can detect the open/close state of the electronic device 400, the relative positioning of the components, such as the display and the keypad of the electronic device 400, the sensor assembly 414 can also detect the electronic device 400 or one of the electronic device 400 Changes in position of components, presence or absence of user contact with electronic device 400 , electronic device 400 orientation or acceleration/deceleration and temperature changes in electronic device 400 .
  • the sensor assembly 414 may include a proximity sensor configured to detect the presence of nearby objects in the absence of any physical contact.
  • Sensor assembly 414 may also include an optical sensor, such as a complementary metal-oxide-semiconductor (CMOS) or charge-coupled device (CCD) image sensor, for use in imaging applications.
  • CMOS complementary metal-oxide-semiconductor
  • CCD charge-coupled device
  • the sensor assembly 414 may also include an acceleration sensor, a gyro sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
  • the communication component 416 is configured to facilitate wired or wireless communication between the electronic device 400 and other devices.
  • the electronic device 400 can access a wireless network based on a communication standard, such as a wireless network (WiFi), a second generation mobile communication technology (2G) or a third generation mobile communication technology (3G), or a combination thereof.
  • the communication component 416 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel.
  • the communication component 416 also includes a near field communication (NFC) module to facilitate short-range communication.
  • the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wide Band (UWB) technology, Bluetooth (BT) technology and other technologies.
  • RFID Radio Frequency Identification
  • IrDA Infrared Data Association
  • UWB Ultra Wide Band
  • Bluetooth Bluetooth
  • the electronic device 400 may be programmed by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable A gate array (FPGA), controller, microcontroller, microprocessor or other electronic component implementation for performing the methods described above.
  • ASICs application-specific integrated circuits
  • DSPs digital signal processors
  • DSPDs digital signal processing devices
  • PLDs programmable logic devices
  • FPGA field programmable A gate array
  • controller microcontroller, microprocessor or other electronic component implementation for performing the methods described above.
  • An embodiment of the present disclosure provides a non-volatile computer-readable storage medium, such as a memory 404 including computer program instructions, which can be executed by the processor 420 of the electronic device 400 to complete the above video generation method.
  • FIG. 5 shows a block diagram of an electronic device 500 according to an embodiment of the present disclosure.
  • the electronic device 500 may be provided as a server.
  • electronic device 500 includes processing component 522 , which further includes one or more processors, and a memory resource represented by memory 532 for storing instructions executable by processing component 522 , such as application programs.
  • the application program stored in memory 532 may include one or more modules each corresponding to a set of instructions.
  • the processing component 522 is configured to execute instructions to perform the above method.
  • the electronic device 500 may further include a power supply component 526 configured to perform power management of the electronic device 500, a wired or wireless network interface 550 configured to connect the electronic device 500 to a network, and an input/output (I/O O) Interface 558.
  • the electronic device 500 can operate based on the operating system stored in the memory 532, such as the Microsoft server operating system (Windows ServerTM), the graphical user interface-based operating system (Mac OS XTM) introduced by Apple Inc., the multi-user and multi-process computer operating system (UnixTM). ), a free and open source Unix-like operating system (LinuxTM), an open source Unix-like operating system (FreeBSDTM), or similar.
  • An embodiment of the present disclosure provides a non-volatile computer-readable storage medium, such as a memory 532 including computer program instructions, which can be executed by the processing component 522 of the electronic device 500 to complete the above method.
  • a non-volatile computer-readable storage medium such as a memory 532 including computer program instructions, which can be executed by the processing component 522 of the electronic device 500 to complete the above method.
  • An embodiment of the present disclosure provides a computer program, including computer readable codes.
  • a processor in the electronic device executes any one of the video generation methods described above. .
  • the disclosed devices and methods may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of units is only a logical function division.
  • the mutual coupling, or direct coupling, or communication connection of the various components shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be electrical, mechanical or other forms .
  • the units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed to multiple grid units ; Some or all of the units can be selected according to the actual situation to realize the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application can be integrated into one processing module, or each unit can be used as a single unit, or two or more units can be integrated into one unit; the above-mentioned integration
  • the unit can be realized in the form of hardware or in the form of hardware plus software functional unit.
  • the present disclosure relates to a video generation method, device, electronic equipment, storage medium and program, the method comprising: writing the video data of the video stream into a preset cache queue, the video data including the A data packet and the time information of the data packet; in the case of receiving an event message for the video stream, according to the triggering moment of the predetermined event in the event message, determine the time interval corresponding to the predetermined event, so The duration of the time interval is less than or equal to the duration of the video data in the cache queue; from the video data in the cache queue, obtain the video file of the video segment corresponding to the time interval; The file is stored in a preset storage space, so as to obtain video clips associated with the predetermined event.
  • the embodiments of the present disclosure can improve the efficiency of event backtracking during video analysis.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
  • Television Signal Processing For Recording (AREA)

Abstract

The present disclosure relates to a video generation method and apparatus, an electronic device, a storage medium, and a program. The method comprises: writing video data of a video stream into a preset cache queue, the video data comprising a data packet of the video stream and time information of the data packet; when an event message for the video stream is received, according to a trigger moment of a predetermined event in the event message, determining a time interval corresponding to the predetermined event, wherein the duration of the time interval is less than or equal to the duration of the video data in the cache queue; from within the video data of the cache queue, acquiring a video file of a video clip corresponding to the time interval; and storing the video file of the video clip into a preset storage space so as to acquire a video clip associated with the predetermined event. Embodiments of the present disclosure can increase the efficiency of event backtracking.

Description

视频生成方法、装置、电子设备、存储介质和程序Video generating method, device, electronic device, storage medium and program
相关申请的交叉引用Cross References to Related Applications
本专利申请要求2021年07月23日提交的中国专利申请号为202110837802.8、申请人为上海商汤智能科技有限公司,申请名称为“视频生成方法及装置、电子设备和存储介质”的专利申请的优先权,该申请的全文以引用的方式并入本申请中。This patent application requires that the Chinese patent application number 202110837802.8 submitted on July 23, 2021, the applicant is Shanghai Shangtang Intelligent Technology Co., Ltd., and the patent application titled "video generation method and device, electronic equipment and storage medium" has priority rights, the entirety of which is incorporated into this application by reference.
技术领域technical field
本公开涉及计算机视觉技术领域,包括不限于一种视频生成方法、装置、电子设备、存储介质和程序。The present disclosure relates to the technical field of computer vision, including but not limited to a video generation method, device, electronic equipment, storage medium and program.
背景技术Background technique
随着各种视频采集设备的普及,视频资源的数据量也在飞速增长。在无计算机视觉的视频系统中,需要人工筛查用户感兴趣的视频片段,对海量的视频资源进行处理的人力成本很高。在单纯的计算机视觉系统中,可以进行图像识别并输出对应的检测结果,同样需要人工介入通过检测结果对事件关联的视频片段进行回溯。在视频系统没有视频存储功能的情况下无法进行事件回溯;在视频系统有视频存储功能的情况下,可能会存储大量的无效视频,浪费大量的存储资源,同时存在权限不足、视频数据量过大等问题,导致事件回溯的效率较低,事件回溯的成本较高。With the popularization of various video capture devices, the data volume of video resources is also increasing rapidly. In a video system without computer vision, it is necessary to manually screen the video clips that users are interested in, and the human cost of processing massive video resources is very high. In a pure computer vision system, image recognition can be performed and corresponding detection results can be output, but manual intervention is also required to trace back the event-related video clips through the detection results. When the video system does not have a video storage function, event retrospective cannot be performed; when the video system has a video storage function, a large number of invalid videos may be stored, wasting a large amount of storage resources, and there are insufficient permissions and excessive video data And other problems, resulting in low efficiency of event backtracking and high cost of event backtracking.
发明内容Contents of the invention
本公开提出了一种视频生成技术方案,包括不限于一种视频生成方法、装置、电子设备、存储介质和程序,可以在视频分析时提高事件回溯的效率。The present disclosure proposes a video generation technical solution, including but not limited to a video generation method, device, electronic equipment, storage medium and program, which can improve the efficiency of event backtracking during video analysis.
本公开提供了一种视频生成方法,包括:The present disclosure provides a video generation method, including:
将视频流的视频数据写入到预设的缓存队列中,所述视频数据包括所述视频流的数据包和所述数据包的时间信息;在接收到针对所述视频流的事件消息的情况下,根据所述事件消息中预定事件的触发时刻,确定与所述预定事件对应的时间区间,所述时间区间的时长小于或等于所述缓存队列中的视频数据的时长;从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件;将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段。Write the video data of the video stream into the preset cache queue, the video data including the data packets of the video stream and the time information of the data packets; when receiving the event message for the video stream Next, according to the triggering moment of the predetermined event in the event message, determine the time interval corresponding to the predetermined event, the duration of the time interval is less than or equal to the duration of the video data in the buffer queue; from the buffer queue In the video data, the video file of the video segment corresponding to the time interval is obtained; the video file of the video segment is stored in a preset storage space, so as to obtain the video segment associated with the predetermined event.
在一种可能的实现方式中,所述触发时刻处于所述时间区间内,所述时间区间包括起始时刻和结束时刻,其中,所述从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件,包括:在当前时刻到达所述结束时刻的情况下,从所述缓存队列的视频数据中,复制与所述时间区间对应的视频片段的数据包;对所述视频片段的数据包进行封装,得到所述视频片段的视频文件。In a possible implementation manner, the trigger moment is within the time interval, and the time interval includes a start moment and an end moment, wherein the video data acquired from the buffer queue is related to the The video file of the video segment corresponding to the time interval includes: when the current moment reaches the end moment, from the video data in the cache queue, copy the data packet of the video segment corresponding to the time interval; Encapsulate the data packets of the video clips to obtain the video files of the video clips.
在一种可能的实现方式中,所述将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段,包括:将所述视频片段的视频文件存储到所述存储空间中;建立所述预定事件与所述视频文件在所述存储空间中的存储地址之间的关联关系,以得到与所述预定事件相关联的视频片段。In a possible implementation manner, the storing the video file of the video segment in a preset storage space to obtain the video segment associated with the predetermined event includes: storing the video file of the video segment The file is stored in the storage space; an association relationship between the predetermined event and the storage address of the video file in the storage space is established, so as to obtain a video segment associated with the predetermined event.
在一种可能的实现方式中,所述方法还包括:对所述视频流的视频帧进行事件检测,确定所述视频帧中是否发生预定事件;在所述视频帧中发生预定事件的情况下,根据所述视频帧的时间信息,确定所述预定事件的触发时刻;发送针对所述视频流的事件消息,所述事件消息包括所述预定事件及所述触发时刻。In a possible implementation manner, the method further includes: performing event detection on video frames of the video stream, and determining whether a predetermined event occurs in the video frame; if a predetermined event occurs in the video frame , determining the triggering moment of the predetermined event according to the time information of the video frame; sending an event message for the video stream, where the event message includes the predetermined event and the triggering moment.
在一种可能的实现方式中,所述方法应用于电子设备,所述电子设备中运行有视觉分析服务和视频剪辑服务,所述视觉分析服务被配置为:对所述视频流的视频帧进行事件检测,确定所述视频帧中是否发生预定事件;在所述视频帧中发生预定事件的情况下,根据所述视频帧的时间信息,确定所述预定事件的触发时刻;向所述视频剪辑服务发送 所述事件消息。In a possible implementation manner, the method is applied to an electronic device, and a visual analysis service and a video editing service are run in the electronic device, and the visual analysis service is configured to: perform Event detection, determining whether a predetermined event occurs in the video frame; in the case of a predetermined event occurring in the video frame, determining the triggering moment of the predetermined event according to the time information of the video frame; The service sends the event message.
在一种可能的实现方式中,所述视频剪辑服务被配置为:将所述视频流的视频数据写入到预设的缓存队列中;在接收到所述视觉分析服务发送的事件消息的情况下,根据所述预定事件的触发时刻,确定与所述预定事件对应的时间区间;从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件;将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段。In a possible implementation manner, the video editing service is configured to: write the video data of the video stream into a preset cache queue; when receiving the event message sent by the visual analysis service Next, according to the triggering moment of the predetermined event, determine the time interval corresponding to the predetermined event; from the video data in the cache queue, obtain the video file of the video segment corresponding to the time interval; The video files of the segment are stored in a preset storage space, so as to obtain the video segment associated with the predetermined event.
在一种可能的实现方式中,所述方法还包括:响应于针对所述预定事件的查看操作,从所述存储空间读取与所述预定事件相关联的视频片段的视频文件;播放所述视频文件。In a possible implementation manner, the method further includes: reading a video file of a video segment associated with the predetermined event from the storage space in response to a viewing operation on the predetermined event; playing the video file.
在一种可能的实现方式中,所述视频流包括一路或多路视频流,所述缓存队列包括环形队列,所述预定事件包括行人跌倒事件、行人逆行事件、行人蹲坐事件、吸烟事件中的至少一种。In a possible implementation manner, the video stream includes one or more video streams, the buffer queue includes a circular queue, and the predetermined event includes a pedestrian fall event, a pedestrian retrograde event, a pedestrian squatting event, and a smoking event. at least one of .
本公开提供了一种视频生成装置,包括:The present disclosure provides a video generation device, including:
数据缓存模块,配置为将视频流的视频数据写入到预设的缓存队列中,所述视频数据包括所述视频流的数据包和所述数据包的时间信息;The data cache module is configured to write the video data of the video stream into a preset cache queue, the video data including the data packets of the video stream and the time information of the data packets;
时间区间确定模块,配置为在接收到针对所述视频流的事件消息的情况下,根据所述事件消息中预定事件的触发时刻,确定与所述预定事件对应的时间区间,所述时间区间的时长小于或等于所述缓存队列中的视频数据的时长;The time interval determination module is configured to determine the time interval corresponding to the predetermined event according to the triggering moment of the predetermined event in the event message when the event message for the video stream is received, and the time interval of the time interval The duration is less than or equal to the duration of the video data in the cache queue;
视频文件获取模块,配置为从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件;A video file obtaining module configured to obtain a video file of a video segment corresponding to the time interval from the video data in the cache queue;
存储及关联模块,配置为将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段。The storing and associating module is configured to store the video file of the video segment in a preset storage space, so as to obtain the video segment associated with the predetermined event.
在一种可能的实现方式中,所述触发时刻处于所述时间区间内,所述时间区间包括起始时刻和结束时刻,其中,所述视频文件获取模块配置为:在当前时刻到达所述结束时刻的情况下,从所述缓存队列的视频数据中,复制与所述时间区间对应的视频片段的数据包;对所述视频片段的数据包进行封装,得到所述视频片段的视频文件。In a possible implementation manner, the trigger moment is within the time interval, and the time interval includes a start moment and an end moment, wherein the video file acquisition module is configured to: reach the end moment at the current moment In the case of time, from the video data in the cache queue, copy the data packet of the video segment corresponding to the time interval; encapsulate the data packet of the video segment to obtain the video file of the video segment.
在一种可能的实现方式中,所述存储及关联模块配置为:将所述视频片段的视频文件存储到所述存储空间中;建立所述预定事件与所述视频文件在所述存储空间中的存储地址之间的关联关系,以得到与所述预定事件相关联的视频片段。In a possible implementation manner, the storing and associating module is configured to: store the video file of the video clip in the storage space; establish the relationship between the scheduled event and the video file in the storage space The association relationship between the storage addresses of , so as to obtain the video clips associated with the predetermined event.
在一种可能的实现方式中,所述装置还包括:事件检测模块,配置为对所述视频流的视频帧进行事件检测,确定所述视频帧中是否发生预定事件;时刻确定模块,配置为在所述视频帧中发生预定事件的情况下,根据所述视频帧的时间信息,确定所述预定事件的触发时刻;消息发送模块,配置为发送针对所述视频流的事件消息,所述事件消息包括所述预定事件及所述触发时刻。In a possible implementation manner, the device further includes: an event detection module configured to perform event detection on a video frame of the video stream, and determine whether a predetermined event occurs in the video frame; a time determination module configured to When a predetermined event occurs in the video frame, according to the time information of the video frame, determine the triggering moment of the predetermined event; the message sending module is configured to send an event message for the video stream, the event The message includes the predetermined event and the triggering moment.
在一种可能的实现方式中,所述装置应用于电子设备,所述电子设备中运行有视觉分析服务和视频剪辑服务,所述视觉分析服务被配置为:对所述视频流的视频帧进行事件检测,确定所述视频帧中是否发生预定事件;在所述视频帧中发生预定事件的情况下,根据所述视频帧的时间信息,确定所述预定事件的触发时刻;向所述视频剪辑服务发送所述事件消息。In a possible implementation manner, the apparatus is applied to an electronic device, and a visual analysis service and a video editing service are run in the electronic device, and the visual analysis service is configured to: perform Event detection, determining whether a predetermined event occurs in the video frame; in the case of a predetermined event occurring in the video frame, determining the triggering moment of the predetermined event according to the time information of the video frame; The service sends the event message.
在一种可能的实现方式中,所述视频剪辑服务被配置为:将所述视频流的视频数据写入到预设的缓存队列中;在接收到所述视觉分析服务发送的事件消息的情况下,根据所述预定事件的触发时刻,确定与所述预定事件对应的时间区间;从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件;将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段。In a possible implementation manner, the video editing service is configured to: write the video data of the video stream into a preset cache queue; when receiving the event message sent by the visual analysis service Next, according to the triggering moment of the predetermined event, determine the time interval corresponding to the predetermined event; from the video data in the cache queue, obtain the video file of the video segment corresponding to the time interval; The video files of the segment are stored in a preset storage space, so as to obtain the video segment associated with the predetermined event.
在一种可能的实现方式中,所述装置还包括:视频文件读取模块,配置为响应于针对所述预定事件的查看操作,从所述存储空间读取与所述预定事件相关联的视频片段的 视频文件;视频播放模块,配置为播放所述视频文件。In a possible implementation manner, the device further includes: a video file reading module configured to read a video file associated with the predetermined event from the storage space in response to a viewing operation on the predetermined event A video file of the segment; a video playing module configured to play the video file.
在一种可能的实现方式中,所述视频流包括一路或多路视频流,所述缓存队列包括环形队列,所述预定事件包括行人跌倒事件、行人逆行事件、行人蹲坐事件、吸烟事件中的至少一种。In a possible implementation manner, the video stream includes one or more video streams, the buffer queue includes a circular queue, and the predetermined event includes a pedestrian fall event, a pedestrian retrograde event, a pedestrian squatting event, and a smoking event. at least one of .
本公开提供了一种电子设备,包括:存储器,所述存储器配置为存储可执行指令;处理器,所述处理器被配置为调用所述存储器存储的指令,以执行上述视频生成方法。The present disclosure provides an electronic device, including: a memory configured to store executable instructions; a processor configured to call the instructions stored in the memory to execute the above video generation method.
本公开提供了一种计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现上述方法。The present disclosure provides a computer-readable storage medium, on which computer program instructions are stored, and the above-mentioned method is implemented when the computer program instructions are executed by a processor.
本公开提供了一种计算机程序,包括计算机可读代码,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器执行用于实现上述任意一种视频生成方法。The present disclosure provides a computer program, including computer-readable codes. When the computer-readable codes are run in an electronic device, a processor in the electronic device executes to realize any one of the above-mentioned video generation methods.
在本公开实施例中,能够在缓存队列中缓存视频流的视频数据;在发生预定事件时确定与预定事件对应的时间区间;从缓存队列中获取对应的视频片段的视频文件并存储,将存储的视频文件与对应的预定事件相关联,从而提高事件回溯的效率,节省大量存储资源。In the embodiment of the present disclosure, the video data of the video stream can be cached in the cache queue; when a predetermined event occurs, the time interval corresponding to the predetermined event is determined; the video file of the corresponding video segment is obtained from the cache queue and stored, and the stored The video files are associated with the corresponding scheduled events, thereby improving the efficiency of event backtracking and saving a lot of storage resources.
应理解,以上的一般描述和后文的细节描述仅是示例性和解释性的,而非限制本公开。It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
附图说明Description of drawings
此处的附图被并入说明书中并构成本说明书的一部分,这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。The accompanying drawings here are incorporated into the description and constitute a part of the present description. These drawings show embodiments consistent with the present disclosure, and are used together with the description to explain the technical solution of the present disclosure.
图1示出本公开实施例的视频生成方法的流程图。Fig. 1 shows a flowchart of a video generation method in an embodiment of the present disclosure.
图2示出本公开实施例的视频生成方法的处理过程的示意图。Fig. 2 shows a schematic diagram of the processing procedure of the video generation method of the embodiment of the present disclosure.
图3示出本公开实施例的视频生成装置的框图。FIG. 3 shows a block diagram of a video generating device of an embodiment of the present disclosure.
图4示出本公开实施例的一种电子设备的框图。Fig. 4 shows a block diagram of an electronic device according to an embodiment of the present disclosure.
图5示出本公开实施例的一种电子设备的框图。Fig. 5 shows a block diagram of an electronic device according to an embodiment of the present disclosure.
具体实施方式detailed description
以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所提供的实施例仅仅用以解释本申请,不用于限定本申请。另外,以下所提供的实施例是用于实施本申请的部分实施例,而非提供实施本申请的全部实施例,在不冲突的情况下,本申请实施例记载的技术方案可以任意组合的方式实施。The present application will be described in further detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the embodiments provided here are only used to explain the present application, not to limit the present application. In addition, the embodiments provided below are some embodiments for implementing the application, rather than providing all the embodiments for implementing the application. In the case of no conflict, the technical solutions described in the embodiments of the application can be combined in any manner implement.
本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中术语“至少一种”表示多种中的任意一种或多种中的至少两种的任意组合,例如,包括A、B、C中的至少一种,可以表示包括从A、B和C构成的集合中选择的任意一个或多个元素。The term "and/or" in this article is just an association relationship describing associated objects, which means that there can be three relationships, for example, A and/or B can mean: A exists alone, A and B exist simultaneously, and there exists alone B these three situations. In addition, the term "at least one" herein means any one of a variety or any combination of at least two of the more, for example, including at least one of A, B, and C, which may mean including from A, Any one or more elements selected from the set formed by B and C.
本公开实施例提供的视频生成方法,可以由终端设备或服务器等电子设备执行,终端设备可以为用户设备(User Equipment,UE)、移动设备、用户终端、终端、蜂窝电话、无绳电话、个人数字助理(Personal Digital Assistant,PDA)、手持设备、计算设备、车载设备、可穿戴设备等,所述方法可以通过处理器调用存储器中存储的计算机可读指令的方式来实现。或者,可通过服务器执行所述方法。The video generation method provided by the embodiments of the present disclosure can be executed by electronic devices such as terminal devices or servers, and the terminal devices can be user equipment (User Equipment, UE), mobile devices, user terminals, terminals, cellular phones, cordless phones, personal digital Assistant (Personal Digital Assistant, PDA), handheld device, computing device, vehicle-mounted device, wearable device, etc., the method can be implemented by calling the computer-readable instructions stored in the memory by the processor. Alternatively, the method may be performed by a server.
本公开实施例提供的视频生成方法,可以应用于智慧城市系统、智慧社区系统,实现安防监控过程中的智能视频分析功能,在视频流触发告警事件时呈现告警事件相关联的视频片段。The video generation method provided by the embodiments of the present disclosure can be applied to smart city systems and smart community systems to realize the intelligent video analysis function in the security monitoring process, and present video clips associated with the alarm event when the video stream triggers the alarm event.
以下,对本公开实施例提供的视频生成方法、装置、电子设备、存储介质和程序进行详细介绍。Hereinafter, the video generation method, device, electronic device, storage medium, and program provided by the embodiments of the present disclosure are introduced in detail.
图1示出本公开实施例的视频生成方法的流程图,如图1所示,本公开实施例提供的视频生成方法可以包括以下步骤:FIG. 1 shows a flow chart of a video generation method in an embodiment of the present disclosure. As shown in FIG. 1 , the video generation method provided in an embodiment of the present disclosure may include the following steps:
步骤S11:将视频流的视频数据写入到预设的缓存队列中,所述视频数据包括所述视频流的数据包和所述数据包的时间信息。Step S11: Write video data of the video stream into a preset buffer queue, the video data including data packets of the video stream and time information of the data packets.
步骤S12:在接收到针对所述视频流的事件消息的情况下,根据所述事件消息中预定事件的触发时刻,确定与所述预定事件对应的时间区间,所述时间区间的时长小于或等于所述缓存队列中的视频数据的时长。Step S12: When the event message for the video stream is received, determine the time interval corresponding to the predetermined event according to the triggering moment of the predetermined event in the event message, and the duration of the time interval is less than or equal to The duration of the video data in the cache queue.
步骤S13:从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件。Step S13: Obtain the video file of the video segment corresponding to the time interval from the video data in the cache queue.
步骤S14:将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段。Step S14: storing the video file of the video segment in a preset storage space, so as to obtain the video segment associated with the predetermined event.
本公开实施例的视频生成方法,能够在缓存队列中缓存视频流的视频数据,并通过计算机视觉方式检测视频流中感兴趣的预定事件;在发生预定事件时确定与预定事件对应的时间区间;从缓存队列中剪辑对应的视频片段并存储,将存储的视频片段和对应的预定事件相关联,从而方便用户高效回溯事件发生时的视频画面,存储真正有用的视频,节省大量存储资源。The video generation method of the embodiment of the present disclosure can cache the video data of the video stream in the cache queue, and detect the predetermined event of interest in the video stream through computer vision; determine the time interval corresponding to the predetermined event when the predetermined event occurs; Edit and store the corresponding video clips from the cache queue, and associate the stored video clips with the corresponding scheduled events, so that users can efficiently look back at the video screen when the event occurred, store really useful videos, and save a lot of storage resources.
在示例中,待分析的视频流可以为各种视频采集设备采集的、在线视频流或离线视频流,视频流的画面中可能发生预定事件。本公开实施例对视频流的来源及类型等均不作限制。In an example, the video stream to be analyzed may be an online video stream or an offline video stream collected by various video capture devices, and a predetermined event may occur in a picture of the video stream. The embodiment of the present disclosure does not limit the source and type of the video stream.
在示例中,在电动扶梯的视频流中,行人可能出现异常行为,例如,跌倒、逆行、蹲坐等。相应地,视频流中的预定事件可包括行人跌倒事件、行人逆行事件、行人蹲坐事件等。In an example, in the video stream of the escalator, pedestrians may have abnormal behaviors, such as falling, walking backwards, squatting, etc. Correspondingly, the predetermined events in the video stream may include pedestrian falling events, pedestrian retrograde events, pedestrian squatting events, and the like.
在示例中,在商场、展馆等场所的视频流中,人员可能出现异常行为,例如,吸烟、进入非参观区域等。相应地,视频流中的预定事件可包括吸烟事件、违规进入非参观区域的事件等。In an example, in video streams of shopping malls, exhibition halls and other places, people may have abnormal behaviors, such as smoking, entering non-visiting areas, and so on. Correspondingly, the predetermined events in the video stream may include smoking events, illegal entry into non-visiting areas, and the like.
在示例中,在道路的视频流中,可能发生人员或车辆的异常行为,例如,驾驶员未系安全带、疲劳驾驶、闯红灯等。相应地,视频流中的预定事件可包括对应的各种违章事件。本公开实施例对预定事件的具体类型不作限制。In an example, in the video stream of the road, abnormal behaviors of people or vehicles may occur, for example, the driver does not wear a seat belt, fatigue driving, running a red light, etc. Correspondingly, predetermined events in the video stream may include corresponding various violation events. The embodiment of the present disclosure does not limit the specific type of the predetermined event.
在一种可能的实现方式中,可在电子设备中运行有视觉分析服务,通过计算机视觉的方式,分析视频流中感兴趣的预定事件。例如,对视频流的一个或多个视频帧进行图像识别及事件检测,并输出相应的事件检测结果。In a possible implementation manner, a visual analysis service may run in the electronic device, and analyze predetermined events of interest in the video stream by way of computer vision. For example, image recognition and event detection are performed on one or more video frames of the video stream, and corresponding event detection results are output.
在示例中,事件检测结果可以包括以下信息中的任一项:是否发生预定事件、发生的预定事件的类型。可通过已训练的事件检测网络检测预定事件,事件检测网络可以采用卷积神经网络,本公开实施例对事件检测网络的网络类型及网络结构均不作限制。In an example, the event detection result may include any one of the following information: whether a scheduled event occurs, the type of the scheduled event that occurred. Predetermined events can be detected through a trained event detection network, and the event detection network can use a convolutional neural network. Embodiments of the present disclosure do not limit the network type and network structure of the event detection network.
在一种可能的实现方式中,可在电子设备中运行有视频剪辑服务,用于对视频流进行剪辑。视觉分析服务和视频剪辑服务均可为电子设备中运行的进程,可运行于同一电子设备,也可运行于不同的电子设备,本公开实施例对此不作限制。In a possible implementation manner, a video clipping service may run in the electronic device for clipping a video stream. Both the visual analysis service and the video editing service can be processes running on an electronic device, and can run on the same electronic device or different electronic devices, which is not limited in the embodiments of the present disclosure.
在示例中,可通过该视频剪辑服务持续拉取视频流的视频数据,将接收到的视频数据小包和该视频数据小包的时间信息组合成一个新的数据包,写入到预设的缓存队列中。该视频数据小包的时间信息可以为接收到该视频数据小包的接收时间,或者视频数据小包的采集时间,本公开实施例对此不作限制。In an example, the video clip service can continuously pull the video data of the video stream, combine the received video data packet and the time information of the video data packet into a new data packet, and write it into the preset cache queue middle. The time information of the video data packet may be the receiving time of the video data packet, or the collection time of the video data packet, which is not limited in the embodiments of the present disclosure.
在一种可能的实现方式中,该缓存队列可以采用环形队列,也可为其他结构的队列;该缓存队列的容量可根据实际情况设置,本公开实施例对缓存队列的类型及缓存队列的容量均不作限制。In a possible implementation, the cache queue can be a ring queue, or a queue of other structures; the capacity of the cache queue can be set according to the actual situation. None are restricted.
在一种可能的实现方式中,在该缓存队列已存满的情况下,可以用新的视频数据覆 盖最早缓存的视频数据,从而能够实现视频数据的循环缓存。In a possible implementation, when the cache queue is full, new video data can be used to overwrite the earliest cached video data, thereby enabling circular buffering of video data.
在一种可能的实现方式中,在采用环形队列的情况下,如果队列已存满,则新的视频数据能够自动覆盖最早缓存的视频数据,从而能够自动实现视频数据的循环缓存,节省处理资源。In a possible implementation, in the case of using a circular queue, if the queue is full, the new video data can automatically overwrite the earliest cached video data, so that the circular buffering of video data can be automatically realized, saving processing resources .
在一种可能的实现方式中,在检测到视频流中发生预定事件时,视觉分析服务会向视频剪辑服务发送针对视频流的事件消息,事件消息中包括该预定事件及对应的触发时刻。In a possible implementation manner, when detecting that a predetermined event occurs in the video stream, the visual analysis service will send an event message for the video stream to the video editing service, and the event message includes the predetermined event and the corresponding trigger time.
在示例中,根据发生预定事件的视频帧的时间信息确定预定事件的触发时刻,该视频帧的时间信息可为电子设备接收到该视频帧的接收时间,或者视频帧的采集时间,只要与缓存的视频数据的时间信息同步即可。这样,可避免发生时间错位的情况。In an example, the trigger moment of the predetermined event is determined according to the time information of the video frame where the predetermined event occurs. The time information of the video frame can be the receiving time of the video frame received by the electronic device, or the acquisition time of the video frame, as long as it is consistent with the cache The time information of the video data can be synchronized. In this way, the occurrence of time misalignment can be avoided.
在一种可能的实现方式中,在步骤S12中,视频剪辑服务在接收到事件消息时,确定视频流中发生预定事件。根据事件消息中预定事件的触发时刻,可确定与该预定事件对应的时间区间,即待剪辑的视频片段对应的时间区间。In a possible implementation manner, in step S12, the video editing service determines that a predetermined event occurs in the video stream when receiving the event message. According to the triggering moment of the predetermined event in the event message, the time interval corresponding to the predetermined event can be determined, that is, the time interval corresponding to the video segment to be edited.
在示例中,假设预定事件的触发时刻为时刻t,则可基于预定事件的触发时刻t,向前追溯m秒并向后追溯n秒,则待剪辑的视频片段对应的时间区间为[t-m,t+n]。该时间区间的时长(m+n)小于或等于缓存队列中的视频数据的时长。本公开实施例对m,n的具体取值不作限制。In the example, assuming that the triggering moment of the scheduled event is time t, based on the triggering moment t of the scheduled event, m seconds can be traced forward and n seconds can be traced backward, then the time interval corresponding to the video segment to be edited is [t-m, t+n]. The duration (m+n) of the time interval is less than or equal to the duration of the video data in the cache queue. The embodiments of the present disclosure do not limit specific values of m and n.
在一种可能的实现方式中,在预定事件被触发时,缓存队列中可能还未缓存触发时刻t之后的视频数据,在此情况下,可以进行异步处理。In a possible implementation manner, when the predetermined event is triggered, the video data after the trigger time t may not be cached in the cache queue, and in this case, asynchronous processing may be performed.
在示例中,在到达时间区间的结束时刻(t+n)的情况下,从所述缓存队列的视频数据中,获取与该时间区间对应的视频片段;对该视频片段的视频数据进行封装,生成视频文件。In the example, when the end moment (t+n) of the time interval is reached, from the video data in the cache queue, obtain the video segment corresponding to the time interval; encapsulate the video data of the video segment, Generate video files.
在一种可能的实现方式中,在步骤S14中,可将该视频文件存储到预设的存储空间中,建立该视频文件与预定事件之间的关联关系,得到与预定事件相关联的视频片段,以便相关人员进行事件回溯。In a possible implementation, in step S14, the video file can be stored in a preset storage space, and the association between the video file and the predetermined event can be established to obtain the video segment associated with the predetermined event , so that relevant personnel can trace back the event.
在示例中,预设的存储空间可为电子设备本身的存储空间,或者云端的存储服务器中的存储空间,本公开实施例对此不作限制。In an example, the preset storage space may be a storage space of the electronic device itself, or a storage space of a storage server in the cloud, which is not limited in this embodiment of the present disclosure.
本公开的实施例,在缓存队列中缓存视频流的视频数据;在发生预定事件时确定与预定事件对应的时间区间;从缓存队列中获取对应的视频片段的视频文件并存储,将存储的视频文件与对应的预定事件相关联,方便用户高效回溯事件发生时的视频画面,存储真正有用的视频,节省大量存储资源。In the embodiment of the present disclosure, the video data of the video stream is cached in the cache queue; when a predetermined event occurs, the time interval corresponding to the predetermined event is determined; the video file of the corresponding video segment is obtained from the cache queue and stored, and the stored video The file is associated with the corresponding scheduled event, which is convenient for users to efficiently review the video screen when the event occurred, store the really useful video, and save a lot of storage resources.
以下,对本公开实施例提供的视频生成方法进行展开说明。Hereinafter, the video generation method provided by the embodiment of the present disclosure will be described in detail.
在一种可能的实现方式中,可在相同或不同的电子设备中,分别运行视觉分析服务和视频剪辑服务。视觉分析服务和视频剪辑服务可分别获取视频流。其中,获取到的视频流可包括一路或多路视频流,例如商场不同区域的视频流。In a possible implementation manner, the visual analysis service and the video editing service may be respectively run on the same or different electronic devices. The visual analysis service and the video editing service can obtain video streams respectively. Wherein, the acquired video stream may include one or more video streams, for example, video streams of different areas of a shopping mall.
在示例中,视觉分析服务和视频剪辑服务可对各路视频流分别进行处理。本公开实施例对视频流的数量不作限制。对于获取到的任意一路视频流,可对该视频流进行检测。In an example, the visual analysis service and the video editing service can process each video stream separately. The embodiment of the present disclosure does not limit the number of video streams. For any acquired video stream, the video stream can be detected.
在一种可能的实现方式中,本公开实施例的视频生成方法,还可以包括以下步骤:对所述视频流的视频帧进行事件检测,确定所述视频帧中是否发生预定事件;在所述视频帧中发生预定事件的情况下,根据所述视频帧的时间信息,确定所述预定事件的触发时刻;发送针对所述视频流的事件消息,所述事件消息包括所述预定事件及所述触发时刻。In a possible implementation manner, the video generation method in the embodiment of the present disclosure may further include the following steps: performing event detection on the video frame of the video stream, and determining whether a predetermined event occurs in the video frame; When a predetermined event occurs in a video frame, determine the triggering moment of the predetermined event according to the time information of the video frame; send an event message for the video stream, the event message includes the predetermined event and the trigger moment.
在示例中,可对视频流解码,得到视频流的多个视频帧,对各个视频帧进行事件检测。例如,对连续的视频帧进行事件检测;先对连续的视频帧进行抽帧,再对抽取到的视频帧进行事件检测;对视频帧中的关键帧进行事件检测,本公开实施例对此不作限制。In an example, the video stream may be decoded to obtain multiple video frames of the video stream, and event detection is performed on each video frame. For example, event detection is performed on continuous video frames; frame extraction is first performed on continuous video frames, and then event detection is performed on the extracted video frames; event detection is performed on key frames in video frames, which is not covered in the embodiments of the present disclosure. limit.
在一种可能的实现方式中,可根据待检测的各种预定事件的类型,设置不同的事件检测方式。例如,在检测电动扶梯的行人逆行事件时,可识别视频帧中的行人,并分析行人与电动扶梯之间的相对速度,从而判断是否发生行人逆行事件;例如,在检测电动扶梯的行人跌倒事件时,可识别视频帧中的行人,分析行人的身体姿态,判断是否发生行人跌倒事件。本公开实施例对事件检测的具体方式不作限制。In a possible implementation manner, different event detection modes may be set according to types of various predetermined events to be detected. For example, when detecting the pedestrian retrograde event of the escalator, the pedestrian in the video frame can be identified, and the relative speed between the pedestrian and the escalator can be analyzed to determine whether the pedestrian retrograde event occurs; for example, when the pedestrian fall event of the escalator is detected , it can identify pedestrians in the video frame, analyze the body posture of pedestrians, and judge whether pedestrians fall. The embodiment of the present disclosure does not limit the specific manner of event detection.
在一种可能的实现方式中,可通过已训练的事件检测网络实现预定事件的检测,该事件检测网络可以采用一个或多个卷积神经网络,本公开实施例对事件检测网络的数量、网络类型及网络结构均不作限制。In a possible implementation, the detection of predetermined events can be realized through a trained event detection network, and the event detection network can use one or more convolutional neural networks. The type and network structure are not limited.
在一种可能的实现方式中,检测到视频帧中发生预定事件,则可根据视频帧的时间信息,确定预定事件的触发时刻。In a possible implementation manner, when it is detected that a predetermined event occurs in a video frame, the triggering moment of the predetermined event may be determined according to time information of the video frame.
在示例中,在该预定事件为单个视频帧中的事件的情况下,可将视频帧的时间信息,直接确定为该预定事件的触发时刻;在该预定事件为多个视频帧中的事件的情况下,可将多个视频帧的最后一帧或中间帧的时间信息,确定为预定事件的触发时刻。本公开实施例对此不作限制。In an example, when the predetermined event is an event in a single video frame, the time information of the video frame can be directly determined as the trigger moment of the predetermined event; In some cases, the time information of the last frame or the middle frame of multiple video frames may be determined as the triggering moment of the predetermined event. Embodiments of the present disclosure do not limit this.
在一种可能的实现方式中,可发送针对该视频流的事件消息,该事件消息包括该预定事件及该预定事件的触发时刻,以便对缓存队列中的视频数据进行剪辑。这样,能够实现预定事件的检测,提高事件检测的准确性。In a possible implementation manner, an event message for the video stream may be sent, where the event message includes the scheduled event and the triggering moment of the scheduled event, so as to clip the video data in the buffer queue. In this way, the detection of predetermined events can be realized, and the accuracy of event detection can be improved.
在一种可能的实现方式中,在通过视觉分析服务对视频流进行检测的情况下,所述视觉分析服务被配置为:对所述视频流的视频帧进行事件检测,确定所述视频帧中是否发生预定事件;在所述视频帧中发生预定事件的情况下,根据所述视频帧的时间信息,确定所述预定事件的触发时刻;向所述视频剪辑服务发送所述事件消息。In a possible implementation manner, when the video stream is detected by the visual analysis service, the visual analysis service is configured to: perform event detection on video frames of the video stream, and determine Whether a predetermined event occurs; if the predetermined event occurs in the video frame, determine the triggering moment of the predetermined event according to the time information of the video frame; and send the event message to the video editing service.
在示例中,视觉分析服务可对获取到的视频流的视频帧进行事件检测,确定所述视频帧中是否发生预定事件;在所述视频帧中发生预定事件的情况下,根据所述视频帧的时间信息,确定所述预定事件的触发时刻。In an example, the visual analysis service may perform event detection on video frames of the acquired video stream, and determine whether a predetermined event occurs in the video frame; if a predetermined event occurs in the video frame, according to the video frame time information to determine the trigger moment of the predetermined event.
在一种可能的实现方式中,视觉分析服务可向视频剪辑服务发送事件消息,该事件消息包括该预定事件及该预定事件的触发时刻,以使视频剪辑服务对缓存队列中的视频数据进行剪辑。In a possible implementation, the visual analysis service may send an event message to the video clipping service, where the event message includes the scheduled event and the triggering time of the scheduled event, so that the video clipping service clips the video data in the cache queue .
在示例中,将视觉分析过程与视频剪辑过程分离,使得视觉分析过程能够根据业务系统的需求类型进行设置,不影响视频剪辑的过程。视觉分析服务和视频剪辑服务能够分别获取视频流,不依赖于原视频流的按时间获取视频片段的功能,在原视频流不支持按时间获取视频片段的情况下,也能够正常实现视频剪辑过程。In the example, the visual analysis process is separated from the video editing process, so that the visual analysis process can be set according to the requirements of the business system without affecting the video editing process. The visual analysis service and the video editing service can obtain video streams separately, and do not rely on the function of obtaining video clips by time from the original video stream. Even if the original video stream does not support video clips by time, the video editing process can also be implemented normally.
在一种可能的实现方式中,可通过视频剪辑服务实现步骤S11-S14的处理过程。视频剪辑服务可被配置为:将视频流的视频数据写入到预设的缓存队列中;在接收到所述视觉分析服务发送的事件消息的情况下,根据所述预定事件的触发时刻,确定与所述预定事件对应的时间区间;从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件;将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段。In a possible implementation manner, the processing procedures of steps S11-S14 may be realized through a video editing service. The video clip service can be configured to: write the video data of the video stream into a preset cache queue; upon receiving the event message sent by the visual analysis service, according to the triggering moment of the predetermined event, determine The time interval corresponding to the predetermined event; from the video data in the cache queue, obtain the video file of the video segment corresponding to the time interval; store the video file of the video segment into a preset storage space , to get the video clip associated with the predetermined event.
在示例中,视频剪辑服务可为每路视频流设置一个视频处理实例,每个视频处理实例中设置有基于内存的缓存队列。视频处理实例的视频读取模块持续读取对应视频流的视频数据,将接收到的视频数据小包和该视频数据小包的时间信息组合成一个新的数据包,写入到预设的缓存队列中。该视频数据小包的时间信息可以为接收到该视频数据小包的接收时间,也可以为该视频数据小包的采集时间,本公开实施例对此不作限制。In an example, the video editing service may set up a video processing instance for each video stream, and a memory-based cache queue is set in each video processing instance. The video reading module of the video processing instance continuously reads the video data of the corresponding video stream, combines the received video data packet and the time information of the video data packet into a new data packet, and writes it into the preset cache queue . The time information of the video data packet may be the receiving time of the video data packet, or may be the collection time of the video data packet, which is not limited in the embodiments of the present disclosure.
在一种可能的实现方式中,该缓存队列可为环形队列。通过采用环形队列,在队列已存满的情况下,新的视频数据能够自动覆盖最早缓存的视频数据,从而能够自动实现视频数据的循环缓存,节省处理资源。In a possible implementation manner, the buffer queue may be a ring queue. By adopting a circular queue, when the queue is full, new video data can automatically overwrite the earliest cached video data, thereby automatically realizing circular buffering of video data and saving processing resources.
在示例中,该环形队列可以缓存60s的视频数据,本公开实施例对该环形队列的长度不作限制。In an example, the ring queue can buffer 60s of video data, and the embodiment of the present disclosure does not limit the length of the ring queue.
在一种可能的实现方式中,视频剪辑服务会持续监听来自视觉分析服务的事件消息。在步骤S12中接收到事件消息时,视频剪辑服务可对事件消息进行验证,确认是否是关注的预定事件。In a possible implementation manner, the video editing service will continuously monitor event messages from the visual analysis service. When the event message is received in step S12, the video editing service may verify the event message to confirm whether it is a scheduled event of interest.
应理解,视觉分析服务和视频剪辑服务关注的预定事件可以不相同,例如,视觉分析服务关注的预定事件包括A、B、C,而视频剪辑服务关注的预定事件包括A、B。本公开实施例对此不作限制。It should be understood that the predetermined events concerned by the visual analysis service and the video clip service may be different, for example, the predetermined events concerned by the visual analysis service include A, B, and C, while the predetermined events concerned by the video clip service include A and B. Embodiments of the present disclosure do not limit this.
在一种可能的实现方式中,如果事件消息中的预定事件是关注的事件,则验证通过。视频剪辑服务可根据事件消息中的触发时刻,确定与该预定事件对应的时间区间,即待剪辑的视频片段对应的时间区间。In a possible implementation manner, if the predetermined event in the event message is a concerned event, the verification is passed. The video editing service can determine the time interval corresponding to the predetermined event, that is, the time interval corresponding to the video segment to be edited, according to the trigger time in the event message.
在示例中,假设预定事件的触发时刻为时刻t,则可基于预定事件的触发时刻t,向前追溯m秒并向后追溯n秒,则待剪辑的视频片段对应的时间区间为[t-m,t+n]。该时间区间的时长(m+n)小于或等于缓存队列中的视频数据的时长。例如,m可取值为3s,n可取值为6s,本公开实施例对m,n的具体取值不作限制。In the example, assuming that the triggering moment of the scheduled event is time t, based on the triggering moment t of the scheduled event, m seconds can be traced forward and n seconds can be traced backward, then the time interval corresponding to the video segment to be edited is [t-m, t+n]. The duration (m+n) of the time interval is less than or equal to the duration of the video data in the cache queue. For example, m may take a value of 3s, and n may take a value of 6s. Embodiments of the present disclosure do not limit specific values of m and n.
在一种可能的实现方式中,触发时刻t处于所述时间区间[t-m,t+n]内,时间区间[t-m,t+n]包括起始时刻(t-m)和结束时刻(t+n)。In a possible implementation manner, the trigger moment t is within the time interval [t-m, t+n], and the time interval [t-m, t+n] includes a start moment (t-m) and an end moment (t+n) .
在一种可能的实现方式中,可在步骤S13中进行视频剪辑处理。其中,步骤S13可包括:In a possible implementation manner, video editing may be performed in step S13. Wherein, step S13 may include:
在当前时刻到达所述结束时刻的情况下,从所述缓存队列的视频数据中,复制与所述时间区间对应的视频片段的数据包;对所述视频片段的数据包进行封装,得到所述视频片段的视频文件。When the current moment reaches the end moment, from the video data in the cache queue, copy the data packets of the video segments corresponding to the time interval; encapsulate the data packets of the video segments to obtain the The video file of the video clip.
在示例中,在预定事件被触发时,缓存队列中可能还未缓存触发时刻t之后的视频数据,可以进行异步处理。视频剪辑服务在接收到事件消息且校验通过时,可启动一个异步的视频剪辑处理过程。In an example, when the predetermined event is triggered, the video data after the trigger time t may not be cached in the cache queue, and asynchronous processing may be performed. When the video clip service receives the event message and passes the verification, it can start an asynchronous video clip processing process.
在一种可能的实现方式中,在到达时间区间的结束时刻(t+n)的情况下,该处理过程可从缓存队列的视频数据中,复制出该时间区间对应的视频片段的数据包;对视频片段的数据包进行封装,生成视频片段的视频文件。In a possible implementation, when the end moment (t+n) of the time interval is reached, the processing can copy the data packets of the video segment corresponding to the time interval from the video data in the cache queue; Encapsulate the data packet of the video segment to generate a video file of the video segment.
应理解,该视频文件可临时缓存在电子设备的内存中,以便后续存储到存储空间。这样,能够实现异步的视频剪辑处理,从而有效截取与预定事件对应的视频片段,提高处理效率和准确性。It should be understood that the video file may be temporarily cached in the memory of the electronic device for subsequent storage in the storage space. In this way, asynchronous video clip processing can be realized, thereby effectively intercepting video segments corresponding to predetermined events, and improving processing efficiency and accuracy.
在一种可能的实现方式中,可在步骤S14中存储视频片段并关联事件。其中,步骤S14可包括以下步骤:将所述视频片段的视频文件存储到所述存储空间中;建立所述预定事件与所述视频文件在所述存储空间中的存储地址之间的关联关系,以得到与所述预定事件相关联的视频片段。In a possible implementation manner, video clips may be stored and associated with events in step S14. Wherein, step S14 may include the following steps: storing the video file of the video segment in the storage space; establishing an association between the predetermined event and the storage address of the video file in the storage space, to obtain video clips associated with the predetermined event.
在示例中,可将生成的视频文件上传到存储空间中,上传成功后删除内存中临时缓存的视频文件。存储空间可向电子设备返回视频文件在存储空间中的存储地址。这里,存储空间可以是云端的存储服务器的存储空间。In the example, the generated video file can be uploaded to the storage space, and the video file temporarily cached in the memory is deleted after the upload is successful. The storage space can return the storage address of the video file in the storage space to the electronic device. Here, the storage space may be a storage space of a cloud storage server.
在一种可能的实现方式中,在确定视频文件在存储空间中的存储地址后,视频剪辑服务可建立预定事件与视频文件的存储地址之间的关联关系,结束本次事件的异步视频剪辑处理过程。这样,能够得到与预定事件相关联的视频片段,以便于相关人员回溯预定事件的视频画面。In a possible implementation, after determining the storage address of the video file in the storage space, the video clip service can establish an association between the scheduled event and the storage address of the video file, and end the asynchronous video clip processing of this event process. In this way, video clips associated with the scheduled event can be obtained, so that relevant personnel can look back at the video screen of the scheduled event.
这样,能够存储视频片段并实现预定事件与视频片段之间的关联,因此,可以仅持久化存储预定事件关联的视频片段,从而节省大量的存储资源。In this way, video clips can be stored and the association between predetermined events and video clips can be realized. Therefore, only video clips associated with predetermined events can be persistently stored, thereby saving a lot of storage resources.
图2示出本公开实施例的视频生成方法的处理过程的示意图。如图2所示,存在n 路视频流:视频流1、视频流2、…、视频流n。视频剪辑服务可为每路视频流设置一个视频处理实例,存在n个视频处理实例:实例1、实例2、…、实例n,每个视频处理实例设置有基于内存的环形队列。Fig. 2 shows a schematic diagram of the processing procedure of the video generation method of the embodiment of the present disclosure. As shown in FIG. 2, there are n video streams: video stream 1, video stream 2, . . . , video stream n. The video editing service can set up a video processing instance for each video stream, and there are n video processing instances: instance 1, instance 2, ..., instance n, and each video processing instance is provided with a memory-based ring queue.
在示例中,视觉分析服务和视频剪辑服务可分别读取各路视频流,分别进行处理。下面以视频流1为例进行说明。In the example, the visual analysis service and the video editing service can respectively read and process each video stream. The video stream 1 is taken as an example for description below.
在示例中,视频剪辑服务在步骤1中,通过实例1的视频读取模块,读取视频流1的视频数据;在步骤2中,将接收到的视频数据小包和该视频数据小包的时间信息组合成一个新的数据包,写入环形队列中。In the example, in step 1, the video clip service reads the video data of video stream 1 through the video reading module of instance 1; in step 2, the received video data packet and the time information of the video data packet Combine into a new data packet and write it into the ring queue.
在示例中,视觉分析服务可读取视频流1的视频数据,解码得到视频流的多个视频帧,对各个视频帧进行事件检测。如果检测到预定事件,则在步骤3中触发预定事件,向视频剪辑服务发送事件消息,消息中包括预定事件及其触发时刻。In an example, the visual analysis service may read video data of video stream 1, decode multiple video frames of the video stream, and perform event detection on each video frame. If a predetermined event is detected, the predetermined event is triggered in step 3, and an event message is sent to the video editing service, and the message includes the predetermined event and its triggering time.
在示例中,视频剪辑服务在接收到事件消息且校验通过时,确定预定事件对应的时间区间,并启动一个异步的视频剪辑处理过程。在达到时间区间的结束时刻时,在步骤4中,从环形队列中获取对应的视频片段,生成视频片段的文件。In an example, when the video editing service receives the event message and passes the verification, it determines the time interval corresponding to the predetermined event, and starts an asynchronous video editing process. When the end moment of the time interval is reached, in step 4, the corresponding video segment is obtained from the circular queue, and a file of the video segment is generated.
应理解,视频剪辑服务可以存储视频片段并关联预定事件,将视频片段的文件上传到存储空间,建立预定事件与视频文件的存储地址之间的关联关系,结束异步的视频剪辑处理过程。这样,能够得到与预定事件相关联的视频片段,以便于相关人员回溯预定事件的视频画面。It should be understood that the video editing service can store video clips and associate scheduled events, upload the files of the video clips to the storage space, establish the association between the scheduled events and the storage addresses of the video files, and end the asynchronous video editing process. In this way, video clips associated with the scheduled event can be obtained, so that relevant personnel can look back at the video picture of the scheduled event.
在一种可能的实现方式中,本公开实施例的视频生成方法,还可以包括以下步骤:响应于针对所述预定事件的查看操作,从所述存储空间读取与所述预定事件相关联的视频片段的视频文件;播放所述视频文件。In a possible implementation manner, the video generation method of the embodiment of the present disclosure may further include the following step: in response to a viewing operation on the predetermined event, reading the information associated with the predetermined event from the storage space The video file of the video clip; play said video file.
例如,如果相关人员需要回溯某个预定事件,则可触发针对该预定事件的查看操作,例如点击该预定事件的图标,或点击与查看该预定事件对应的控件等,本公开具体的触发方式此不作限制。For example, if relevant personnel need to look back at a scheduled event, they can trigger a viewing operation for the scheduled event, such as clicking the icon of the scheduled event, or clicking a control corresponding to viewing the scheduled event, etc. The specific triggering method of the present disclosure is described in No limit.
在一种可能的实现方式中,响应于针对该预定事件的查看操作,电子设备可根据该预定事件与视频文件的存储地址之间的关联关系,从存储空间读取相关联的视频片段的视频文件。例如,向云端的存储服务器发送文件读取请求,以使存储服务器返回相应的视频文件。In a possible implementation, in response to the viewing operation on the predetermined event, the electronic device can read the associated video file of the video segment from the storage space according to the association between the predetermined event and the storage address of the video file. document. For example, a file read request is sent to a storage server in the cloud, so that the storage server returns a corresponding video file.
在一种可能的实现方式中,电子设备在接收到视频文件后,可播放视频文件,以使相关人员能够观看到与该预定事件对应的视频画面。这样,能够提高预定事件回溯的便利性,并使得相关人员能够快速观察到更多事件细节。In a possible implementation manner, after receiving the video file, the electronic device may play the video file, so that relevant personnel can watch the video picture corresponding to the predetermined event. In this way, the convenience of going back to the scheduled event can be improved, and relevant personnel can quickly observe more details of the event.
本公开实施例的视频生成方法,能够设置视觉感知规则设置感兴趣的预定事件,规则触发时输出对应的事件;视频剪辑服务能够在缓存队列中缓存视频流的视频数据,在接收到触发的预定事件时,确定与预定事件对应的时间区间;从缓存队列中剪辑对应的视频片段并存储,将存储的视频片段和对应的预定事件相关联,从而方便用户高效回溯事件发生时的视频画面,存储真正有用的视频,节省大量存储资源。The video generation method of the embodiment of the present disclosure can set visual perception rules to set interested scheduled events, and output the corresponding events when the rules are triggered; the video clip service can cache the video data of the video stream in the cache queue, When an event occurs, determine the time interval corresponding to the scheduled event; clip and store the corresponding video clips from the cache queue, and associate the stored video clips with the corresponding scheduled event, so that users can efficiently look back at the video screen when the event occurs, and store Really useful video, save a lot of storage resources.
本公开实施例的视频生成方法,能够基于计算机视觉的方式自动触发视频片段的截取,不需要人为筛查感兴趣的视频片段;视频流的视频数据会被缓存到基于内存的环形队列中,不需要NVR(Network Video Recorder,网络视频录像设备)等类型的设备对所有视频进行存储,仅持久化存储与预定事件相关联的视频片段,大大节省存储空间;通常事件仅仅和抓拍图关联,本方案中预定事件和视频片段关联,方便由事件索引到相关视频,可以快速观察到更多事件细节。The video generation method of the embodiment of the present disclosure can automatically trigger the interception of video clips based on computer vision, and does not need to manually screen the video clips of interest; the video data of the video stream will be cached in a memory-based circular queue, without NVR (Network Video Recorder, network video recording equipment) and other types of devices are required to store all videos, and only persistently store video clips associated with scheduled events, which greatly saves storage space; usually events are only associated with snapshots, this solution Predetermined events are associated with video clips, so that events can be indexed to related videos, and more event details can be quickly observed.
本公开实施例的视频生成方法,能够应用于智能视频分析、安防监控、智慧城市、智慧社区等应用场景中,从海量的视频数据中筛选出感兴趣的视频片段,在存储空间受限的情况下仅存储感兴趣的视频,并能够在在线视频流触发告警事件等情况下,快速查 看当时的视频画面。The video generation method of the embodiment of the present disclosure can be applied to application scenarios such as intelligent video analysis, security monitoring, smart city, and smart community, and can filter out interesting video clips from massive video data. Only the videos you are interested in can be stored, and you can quickly view the video images at that time when the online video stream triggers an alarm event.
应理解,本公开提及的上述各个方法实施例,在不违背原理逻辑的情况下,均可以彼此相互结合形成结合后的实施例,限于篇幅,本公开不再赘述。本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。It should be understood that the above-mentioned method embodiments mentioned in the present disclosure can all be combined with each other to form a combined embodiment without violating the principles and logics. Due to space limitations, the present disclosure will not repeat them here. Those skilled in the art can understand that, in the above method in the specific implementation manner, the specific execution order of each step should be determined according to its function and possible internal logic.
本公开还提供了视频生成装置、电子设备、计算机可读存储介质、程序,上述均可用来实现本公开提供的任一种视频生成方法,相应技术方案和描述和参见方法部分的相应记载。The present disclosure also provides a video generating device, electronic equipment, computer-readable storage medium, and program, all of which can be used to realize any video generating method provided in the present disclosure, corresponding technical solutions and descriptions, and corresponding records in the method section.
图3示出本公开实施例的视频生成装置的框图,如图3所示,本公开实施例提供的视频生成装置包括:FIG. 3 shows a block diagram of a video generation device in an embodiment of the present disclosure. As shown in FIG. 3 , the video generation device provided in an embodiment of the present disclosure includes:
数据缓存模块31,配置为将视频流的视频数据写入到预设的缓存队列中,所述视频数据包括所述视频流的数据包和所述数据包的时间信息;The data cache module 31 is configured to write the video data of the video stream into a preset cache queue, the video data including the data packets of the video stream and the time information of the data packets;
时间区间确定模块32,配置为在接收到针对所述视频流的事件消息的情况下,根据所述事件消息中预定事件的触发时刻,确定与所述预定事件对应的时间区间,所述时间区间的时长小于或等于所述缓存队列中的视频数据的时长;The time interval determination module 32 is configured to determine the time interval corresponding to the predetermined event according to the triggering moment of the predetermined event in the event message when receiving the event message for the video stream, the time interval The duration is less than or equal to the duration of the video data in the cache queue;
视频文件获取模块33,配置为从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件;The video file obtaining module 33 is configured to obtain the video file of the video segment corresponding to the time interval from the video data in the cache queue;
存储及关联模块34,配置为将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段。The storing and associating module 34 is configured to store the video file of the video segment in a preset storage space, so as to obtain the video segment associated with the predetermined event.
在一种可能的实现方式中,所述触发时刻处于所述时间区间内,所述时间区间包括起始时刻和结束时刻,其中,所述视频文件获取模块33配置为:在当前时刻到达所述结束时刻的情况下,从所述缓存队列的视频数据中,复制与所述时间区间对应的视频片段的数据包;对所述视频片段的数据包进行封装,得到所述视频片段的视频文件。In a possible implementation manner, the trigger moment is within the time interval, and the time interval includes a start moment and an end moment, wherein the video file acquisition module 33 is configured to: reach the In the case of the end moment, from the video data in the cache queue, copy the data packets of the video segments corresponding to the time interval; encapsulate the data packets of the video segments to obtain the video files of the video segments.
在一种可能的实现方式中,所述存储及关联模块34配置为:将所述视频片段的视频文件存储到所述存储空间中;建立所述预定事件与所述视频文件在所述存储空间中的存储地址之间的关联关系,以得到与所述预定事件相关联的视频片段。In a possible implementation manner, the storage and association module 34 is configured to: store the video file of the video segment in the storage space; In order to obtain the video clips associated with the predetermined event.
在一种可能的实现方式中,所述装置还包括:事件检测模块,配置为对所述视频流的视频帧进行事件检测,确定所述视频帧中是否发生预定事件;时刻确定模块,配置为在所述视频帧中发生预定事件的情况下,根据所述视频帧的时间信息,确定所述预定事件的触发时刻;消息发送模块,配置为发送针对所述视频流的事件消息,所述事件消息包括所述预定事件及所述触发时刻。In a possible implementation manner, the device further includes: an event detection module configured to perform event detection on a video frame of the video stream, and determine whether a predetermined event occurs in the video frame; a time determination module configured to When a predetermined event occurs in the video frame, according to the time information of the video frame, determine the triggering moment of the predetermined event; the message sending module is configured to send an event message for the video stream, the event The message includes the predetermined event and the triggering moment.
在一种可能的实现方式中,所述装置应用于电子设备中,所述电子设备中运行有视觉分析服务和视频剪辑服务,所述视觉分析服务被配置为:对所述视频流的视频帧进行事件检测,确定所述视频帧中是否发生预定事件;在所述视频帧中发生预定事件的情况下,根据所述视频帧的时间信息,确定所述预定事件的触发时刻;向所述视频剪辑服务发送所述事件消息。In a possible implementation manner, the apparatus is applied to an electronic device, and a visual analysis service and a video editing service are run in the electronic device, and the visual analysis service is configured to: analyze the video frame of the video stream Perform event detection to determine whether a predetermined event occurs in the video frame; if a predetermined event occurs in the video frame, determine the triggering moment of the predetermined event according to the time information of the video frame; The clipping service sends the event message.
在一种可能的实现方式中,所述视频剪辑服务被配置为:将所述视频流的视频数据写入到预设的缓存队列中;在接收到所述视觉分析服务发送的事件消息的情况下,根据所述预定事件的触发时刻,确定与所述预定事件对应的时间区间;从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件;将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段。In a possible implementation manner, the video editing service is configured to: write the video data of the video stream into a preset cache queue; when receiving the event message sent by the visual analysis service Next, according to the triggering moment of the predetermined event, determine the time interval corresponding to the predetermined event; from the video data in the cache queue, obtain the video file of the video segment corresponding to the time interval; The video files of the segment are stored in a preset storage space, so as to obtain the video segment associated with the predetermined event.
在一种可能的实现方式中,所述装置还包括:视频文件读取模块,配置为响应于针对所述预定事件的查看操作,从所述存储空间读取与所述预定事件相关联的视频片段的视频文件;视频播放模块,配置为播放所述视频文件。In a possible implementation manner, the device further includes: a video file reading module configured to read a video file associated with the predetermined event from the storage space in response to a viewing operation on the predetermined event A video file of the segment; a video playing module configured to play the video file.
在一种可能的实现方式中,所述视频流包括一路或多路视频流,所述缓存队列包括 环形队列,所述预定事件包括行人跌倒事件、行人逆行事件、行人蹲坐事件、吸烟事件中的至少一种。In a possible implementation manner, the video stream includes one or more video streams, the buffer queue includes a circular queue, and the predetermined event includes a pedestrian fall event, a pedestrian retrograde event, a pedestrian squatting event, and a smoking event. at least one of .
在一种可能的实现方式中,本公开实施例提供的装置具有的功能或包含的模块可以配置为执行上文方法实施例描述的方法,其具体实现可以参照上文方法实施例的描述,为了简洁,这里不再赘述。In a possible implementation manner, the functions or modules included in the apparatus provided by the embodiments of the present disclosure can be configured to execute the methods described in the above method embodiments, and its specific implementation can refer to the descriptions of the above method embodiments. It is concise and will not be repeated here.
本公开实施例还提出一种计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现上述方法。计算机可读存储介质可以是易失性或非易失性计算机可读存储介质。Embodiments of the present disclosure also provide a computer-readable storage medium, on which computer program instructions are stored, and the above-mentioned method is implemented when the computer program instructions are executed by a processor. Computer readable storage media may be volatile or nonvolatile computer readable storage media.
本公开实施例还提出一种电子设备,包括:存储器,所述存储器配置为存储可执行指令;处理器,所述处理器被配置为调用所述存储器存储的指令,以执行上述视频生成方法。An embodiment of the present disclosure also proposes an electronic device, including: a memory configured to store executable instructions; a processor configured to call the instructions stored in the memory to execute the above video generation method.
在示例中,电子设备的类型可以为终端设备、服务器或其它形态的设备。In an example, the type of the electronic device may be a terminal device, a server or other types of devices.
本公开实施例还提供了一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备的处理器中运行时,所述电子设备中的处理器执行上述方法。An embodiment of the present disclosure also provides a computer program product, including computer-readable codes, or a non-volatile computer-readable storage medium carrying computer-readable codes, when the computer-readable codes are stored in a processor of an electronic device When running in the electronic device, the processor in the electronic device executes the above method.
图4示出本公开实施例的一种电子设备400的框图。电子设备400的设备类型可以包括以下任一项:移动电话、计算机、数字广播终端、消息收发设备、游戏控制台、平板设备、医疗设备、健身设备、个人数字助理。FIG. 4 shows a block diagram of an electronic device 400 according to an embodiment of the present disclosure. The device type of the electronic device 400 may include any of the following: mobile phone, computer, digital broadcast terminal, messaging device, game console, tablet device, medical device, fitness device, personal digital assistant.
参照图4,电子设备400可以包括以下一个或多个组件:处理组件402,存储器404,电源组件406,多媒体组件408,音频组件410,输入/输出(I/O)的接口412,传感器组件414,以及通信组件416。4, electronic device 400 may include one or more of the following components: processing component 402, memory 404, power supply component 406, multimedia component 408, audio component 410, input/output (I/O) interface 412, sensor component 414 , and the communication component 416 .
其中,处理组件402通常控制电子设备400的整体操作,诸如与显示,电话呼叫,数据通信,相机操作和记录操作相关联的操作。处理组件402可以包括一个或多个处理器420来执行指令,以完成上述的方法的全部或部分步骤。此外,处理组件402可以包括一个或多个模块,便于处理组件402和其他组件之间的交互。例如,处理组件402可以包括多媒体模块,以方便多媒体组件408和处理组件402之间的交互。Among other things, the processing component 402 generally controls the overall operations of the electronic device 400, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 402 may include one or more processors 420 to execute instructions to complete all or part of the steps of the above method. Additionally, processing component 402 may include one or more modules that facilitate interaction between processing component 402 and other components. For example, processing component 402 may include a multimedia module to facilitate interaction between multimedia component 408 and processing component 402 .
存储器404被配置为存储各种类型的数据以支持在电子设备400的操作。这些数据的示例包括用于在电子设备400上操作的任何应用程序或方法的指令,联系人数据,电话簿数据,消息,图片,视频等。存储器404可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。The memory 404 is configured to store various types of data to support operations at the electronic device 400 . Examples of such data include instructions for any application or method operating on the electronic device 400, contact data, phonebook data, messages, pictures, videos, and the like. The memory 404 can be implemented by any type of volatile or non-volatile storage device or their combination, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable Programmable Read Only Memory (EPROM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), Magnetic Memory, Flash Memory, Magnetic or Optical Disk.
电源组件406为电子设备400的各种组件提供电力。电源组件406可以包括电源管理系统,一个或多个电源,及其他与为电子设备400生成、管理和分配电力相关联的组件。The power supply component 406 provides power to various components of the electronic device 400 . Power components 406 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for electronic device 400 .
多媒体组件408包括在所述电子设备400和用户之间的提供一个输出接口的屏幕。屏幕可以包括液晶显示器(LCD)和触摸面板(TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自用户的输入信号。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。所述触摸传感器可以不仅感测触摸或滑动动作的边界,而且还检测与所述触摸或滑动操作相关的持续时间和压力。The multimedia component 408 includes a screen providing an output interface between the electronic device 400 and the user. The screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may not only sense a boundary of a touch or swipe action, but also detect duration and pressure associated with the touch or swipe action.
在一些实施例中,多媒体组件408包括一个前置摄像头和/或后置摄像头。当电子设备400处于操作模式,如拍摄模式或视频模式时,前置摄像头和/或后置摄像头可以接收外部的多媒体数据。每个前置摄像头和后置摄像头可以是一个固定的光学透镜系统或具有焦距和光学变焦能力。In some embodiments, the multimedia component 408 includes a front camera and/or a rear camera. When the electronic device 400 is in an operation mode, such as a shooting mode or a video mode, the front camera and/or the rear camera can receive external multimedia data. Each front camera and rear camera can be a fixed optical lens system or have focal length and optical zoom capability.
音频组件410被配置为输出和/或输入音频信号。例如,音频组件410包括一个麦克 风(MIC),当电子设备400处于操作模式,如呼叫模式、记录模式和语音识别模式时,麦克风被配置为接收外部音频信号。所接收的音频信号可以被进一步存储在存储器404或经由通信组件416发送。音频组件410还可以包括一个扬声器,用于输出音频信号。The audio component 410 is configured to output and/or input audio signals. For example, the audio component 410 includes a microphone (MIC), which is configured to receive external audio signals when the electronic device 400 is in operation modes, such as call mode, recording mode and voice recognition mode. Received audio signals may be further stored in memory 404 or sent via communication component 416 . The audio component 410 may also include a speaker for outputting audio signals.
I/O接口412为处理组件402和外围接口模块之间提供接口,上述外围接口模块可以是键盘,点击轮,按钮等。这些按钮可包括但不限于:主页按钮、音量按钮、启动按钮和锁定按钮。The I/O interface 412 provides an interface between the processing component 402 and a peripheral interface module. The peripheral interface module may be a keyboard, a click wheel, a button, and the like. These buttons may include, but are not limited to: a home button, volume buttons, start button, and lock button.
传感器组件414包括一个或多个传感器,用于为电子设备400提供各个方面的状态评估。例如,传感器组件414可以检测到电子设备400的打开/关闭状态,组件的相对定位,例如所述组件为电子设备400的显示器和小键盘,传感器组件414还可以检测电子设备400或电子设备400一个组件的位置改变,用户与电子设备400接触的存在或不存在,电子设备400方位或加速/减速和电子设备400的温度变化。 Sensor assembly 414 includes one or more sensors for providing various aspects of status assessment for electronic device 400 . For example, the sensor assembly 414 can detect the open/close state of the electronic device 400, the relative positioning of the components, such as the display and the keypad of the electronic device 400, the sensor assembly 414 can also detect the electronic device 400 or one of the electronic device 400 Changes in position of components, presence or absence of user contact with electronic device 400 , electronic device 400 orientation or acceleration/deceleration and temperature changes in electronic device 400 .
传感器组件414可以包括接近传感器,被配置用来在没有任何的物理接触时检测附近物体的存在。传感器组件414还可以包括光传感器,如互补金属氧化物半导体(CMOS)或电荷耦合装置(CCD)图像传感器,用于在成像应用中使用。传感器组件414还可以包括加速度传感器,陀螺仪传感器,磁传感器,压力传感器或温度传感器。The sensor assembly 414 may include a proximity sensor configured to detect the presence of nearby objects in the absence of any physical contact. Sensor assembly 414 may also include an optical sensor, such as a complementary metal-oxide-semiconductor (CMOS) or charge-coupled device (CCD) image sensor, for use in imaging applications. The sensor assembly 414 may also include an acceleration sensor, a gyro sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
通信组件416被配置为便于电子设备400和其他设备之间有线或无线方式的通信。电子设备400可以接入基于通信标准的无线网络,如无线网络(WiFi),第二代移动通信技术(2G)或第三代移动通信技术(3G),或它们的组合。在一个示例性实施例中,通信组件416经由广播信道接收来自外部广播管理系统的广播信号或广播相关信息。在一个示例性实施例中,所述通信组件416还包括近场通信(NFC)模块,以促进短程通信。例如,在NFC模块可基于射频识别(RFID)技术,红外数据协会(IrDA)技术,超宽带(UWB)技术,蓝牙(BT)技术和其他技术来实现。The communication component 416 is configured to facilitate wired or wireless communication between the electronic device 400 and other devices. The electronic device 400 can access a wireless network based on a communication standard, such as a wireless network (WiFi), a second generation mobile communication technology (2G) or a third generation mobile communication technology (3G), or a combination thereof. In an exemplary embodiment, the communication component 416 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 416 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wide Band (UWB) technology, Bluetooth (BT) technology and other technologies.
在一些实施例中,电子设备400可以被一个或多个应用专用集成电路(ASIC)、数字信号处理器(DSP)、数字信号处理设备(DSPD)、可编程逻辑器件(PLD)、现场可编程门阵列(FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述方法。In some embodiments, the electronic device 400 may be programmed by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable A gate array (FPGA), controller, microcontroller, microprocessor or other electronic component implementation for performing the methods described above.
本公开实施例提供了一种非易失性计算机可读存储介质,例如包括计算机程序指令的存储器404,上述计算机程序指令可由电子设备400的处理器420执行以完成上述视频生成方法。An embodiment of the present disclosure provides a non-volatile computer-readable storage medium, such as a memory 404 including computer program instructions, which can be executed by the processor 420 of the electronic device 400 to complete the above video generation method.
图5示出本公开实施例的一种电子设备500的框图。例如,电子设备500可以被提供为一服务器。参照图5,电子设备500包括处理组件522,其进一步包括一个或多个处理器,以及由存储器532所代表的存储器资源,用于存储可由处理组件522的执行的指令,例如应用程序。存储器532中存储的应用程序可以包括一个或一个以上的每一个对应于一组指令的模块。此外,处理组件522被配置为执行指令,以执行上述方法。FIG. 5 shows a block diagram of an electronic device 500 according to an embodiment of the present disclosure. For example, the electronic device 500 may be provided as a server. Referring to FIG. 5 , electronic device 500 includes processing component 522 , which further includes one or more processors, and a memory resource represented by memory 532 for storing instructions executable by processing component 522 , such as application programs. The application program stored in memory 532 may include one or more modules each corresponding to a set of instructions. In addition, the processing component 522 is configured to execute instructions to perform the above method.
在示例中,电子设备500还可以包括一个电源组件526被配置为执行电子设备500的电源管理,一个有线或无线网络接口550被配置为将电子设备500连接到网络,和一个输入输出(I/O)接口558。电子设备500可以操作基于存储在存储器532的操作系统,例如微软服务器操作系统(Windows ServerTM),苹果公司推出的基于图形用户界面操作系统(Mac OS XTM),多用户多进程的计算机操作系统(UnixTM),自由和开放原代码的类Unix操作系统(LinuxTM),开放原代码的类Unix操作系统(FreeBSDTM)或类似。In an example, the electronic device 500 may further include a power supply component 526 configured to perform power management of the electronic device 500, a wired or wireless network interface 550 configured to connect the electronic device 500 to a network, and an input/output (I/O O) Interface 558. The electronic device 500 can operate based on the operating system stored in the memory 532, such as the Microsoft server operating system (Windows ServerTM), the graphical user interface-based operating system (Mac OS XTM) introduced by Apple Inc., the multi-user and multi-process computer operating system (UnixTM). ), a free and open source Unix-like operating system (LinuxTM), an open source Unix-like operating system (FreeBSDTM), or similar.
本公开实施例提供了一种非易失性计算机可读存储介质,例如包括计算机程序指令的存储器532,上述计算机程序指令可由电子设备500的处理组件522执行以完成上述方法。An embodiment of the present disclosure provides a non-volatile computer-readable storage medium, such as a memory 532 including computer program instructions, which can be executed by the processing component 522 of the electronic device 500 to complete the above method.
本公开实施例提供了一种计算机程序,包括计算机可读代码,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器执行用于实现上述任意一种视频生成 方法。An embodiment of the present disclosure provides a computer program, including computer readable codes. When the computer readable codes are run in an electronic device, a processor in the electronic device executes any one of the video generation methods described above. .
本申请所提供的各方法实施例中所揭露的方法,在不冲突的情况下可以任意组合,得到新的方法实施例。The methods disclosed in the various method embodiments provided in this application can be combined arbitrarily without conflict to obtain new method embodiments.
本申请所提供的各产品实施例中所揭露的特征,在不冲突的情况下可以任意组合,得到新的产品实施例。The features disclosed in the various product embodiments provided in this application can be combined arbitrarily without conflict to obtain new product embodiments.
本申请所提供的各方法或设备实施例中所揭露的特征,在不冲突的情况下可以任意组合,得到新的方法实施例或设备实施例。The features disclosed in each method or device embodiment provided in this application can be combined arbitrarily without conflict to obtain a new method embodiment or device embodiment.
在本申请所提供的几个实施例中,应该理解到,所揭露的设备和方法,可以通过其它的方式实现。以上所描述的设备实施例仅仅是示意性的,示例性地,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,如:多个单元或组件可以结合,或可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的各组成部分相互间的耦合、或直接耦合、或通信连接可以是通过一些接口,设备或单元的间接耦合或通信连接,可以是电性的、机械的或其它形式的。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods may be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or May be integrated into another system, or some features may be ignored, or not implemented. In addition, the mutual coupling, or direct coupling, or communication connection of the various components shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be electrical, mechanical or other forms .
上述作为分离部件说明的单元可以是、或也可以不是物理上分开的,作为单元显示的部件可以是、或也可以不是物理单元,即可以位于一个地方,也可以分布到多个网格单元上;可以根据实际的可以选择其中的部分或全部单元来实现本实施例方案的目的。The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed to multiple grid units ; Some or all of the units can be selected according to the actual situation to realize the purpose of the solution of this embodiment.
另外,在本申请各实施例中的各功能单元可以全部集成在一个处理模块中,也可以是各单元分别单独作为一个单元,也可以两个或两个以上单元集成在一个单元中;上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application can be integrated into one processing module, or each unit can be used as a single unit, or two or more units can be integrated into one unit; the above-mentioned integration The unit can be realized in the form of hardware or in the form of hardware plus software functional unit.
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤。Those of ordinary skill in the art can understand that all or part of the steps for realizing the above-mentioned method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the The steps of the above method embodiments are included.
以上,仅为本申请的具体实施方式,但本申请的保护范围不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围内。因此,本申请的保护范围应以权利要求的保护范围为准。The above is only a specific embodiment of the application, but the scope of protection of the application is not limited thereto. Any person familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the application, and should be covered within the protection scope of this application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
工业实用性Industrial Applicability
本公开涉及一种视频生成方法、装置、电子设备、存储介质和程序,所述方法包括:将视频流的视频数据写入到预设的缓存队列中,所述视频数据包括所述视频流的数据包和所述数据包的时间信息;在接收到针对所述视频流的事件消息的情况下,根据所述事件消息中预定事件的触发时刻,确定与所述预定事件对应的时间区间,所述时间区间的时长小于或等于所述缓存队列中的视频数据的时长;从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件;将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段。本公开实施例可以在视频分析时提高事件回溯的效率。The present disclosure relates to a video generation method, device, electronic equipment, storage medium and program, the method comprising: writing the video data of the video stream into a preset cache queue, the video data including the A data packet and the time information of the data packet; in the case of receiving an event message for the video stream, according to the triggering moment of the predetermined event in the event message, determine the time interval corresponding to the predetermined event, so The duration of the time interval is less than or equal to the duration of the video data in the cache queue; from the video data in the cache queue, obtain the video file of the video segment corresponding to the time interval; The file is stored in a preset storage space, so as to obtain video clips associated with the predetermined event. The embodiments of the present disclosure can improve the efficiency of event backtracking during video analysis.

Claims (12)

  1. 一种视频生成方法,包括:A video generation method, comprising:
    将视频流的视频数据写入到预设的缓存队列中,所述视频数据包括所述视频流的数据包和所述数据包的时间信息;Writing video data of the video stream into a preset buffer queue, the video data including data packets of the video stream and time information of the data packets;
    在接收到针对所述视频流的事件消息的情况下,根据所述事件消息中预定事件的触发时刻,确定与所述预定事件对应的时间区间,所述时间区间的时长小于或等于所述缓存队列中的视频数据的时长;When an event message for the video stream is received, determine a time interval corresponding to the predetermined event according to the triggering moment of the predetermined event in the event message, and the duration of the time interval is less than or equal to the buffer The duration of the video data in the queue;
    从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件;From the video data in the cache queue, obtain the video file of the video segment corresponding to the time interval;
    将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段。The video file of the video segment is stored in a preset storage space, so as to obtain the video segment associated with the predetermined event.
  2. 根据权利要求1所述的方法,其中,所述触发时刻处于所述时间区间内,所述时间区间包括起始时刻和结束时刻,The method according to claim 1, wherein the trigger moment is within the time interval, and the time interval includes a start moment and an end moment,
    其中,所述从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件,包括:Wherein, the acquisition of the video file of the video segment corresponding to the time interval from the video data in the cache queue includes:
    在当前时刻到达所述结束时刻的情况下,从所述缓存队列的视频数据中,复制与所述时间区间对应的视频片段的数据包;When the current moment reaches the end moment, from the video data in the buffer queue, copy the data packet of the video segment corresponding to the time interval;
    对所述视频片段的数据包进行封装,得到所述视频片段的视频文件。Encapsulate the data packet of the video segment to obtain a video file of the video segment.
  3. 根据权利要求1或2所述的方法,其中,所述将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段,包括:The method according to claim 1 or 2, wherein the storing the video file of the video segment in a preset storage space to obtain the video segment associated with the predetermined event comprises:
    将所述视频片段的视频文件存储到所述存储空间中;storing the video file of the video segment in the storage space;
    建立所述预定事件与所述视频文件在所述存储空间中的存储地址之间的关联关系,以得到与所述预定事件相关联的视频片段。Establishing an association between the predetermined event and the storage address of the video file in the storage space, so as to obtain a video segment associated with the predetermined event.
  4. 根据权利要求1-3中任意一项所述的方法,其中,所述方法还包括:The method according to any one of claims 1-3, wherein the method further comprises:
    对所述视频流的视频帧进行事件检测,确定所述视频帧中是否发生预定事件;Perform event detection on the video frame of the video stream, and determine whether a predetermined event occurs in the video frame;
    在所述视频帧中发生预定事件的情况下,根据所述视频帧的时间信息,确定所述预定事件的触发时刻;When a predetermined event occurs in the video frame, determine the triggering moment of the predetermined event according to the time information of the video frame;
    发送针对所述视频流的事件消息,所述事件消息包括所述预定事件及所述触发时刻。sending an event message for the video stream, where the event message includes the predetermined event and the trigger moment.
  5. 根据权利要求4所述的方法,其中,所述方法应用于电子设备,所述电子设备中运行有视觉分析服务和视频剪辑服务,所述视觉分析服务被配置为:The method according to claim 4, wherein the method is applied to an electronic device, and a visual analysis service and a video clip service are run in the electronic device, and the visual analysis service is configured to:
    对所述视频流的视频帧进行事件检测,确定所述视频帧中是否发生预定事件;Perform event detection on the video frame of the video stream, and determine whether a predetermined event occurs in the video frame;
    在所述视频帧中发生预定事件的情况下,根据所述视频帧的时间信息,确定所述预定事件的触发时刻;When a predetermined event occurs in the video frame, determine the triggering moment of the predetermined event according to the time information of the video frame;
    向所述视频剪辑服务发送所述事件消息。Send the event message to the video clipping service.
  6. 根据权利要求5所述的方法,其中,所述视频剪辑服务被配置为:The method of claim 5, wherein the video clipping service is configured to:
    将所述视频流的视频数据写入到预设的缓存队列中;Writing the video data of the video stream into a preset buffer queue;
    在接收到所述视觉分析服务发送的事件消息的情况下,根据所述预定事件的触发时刻,确定与所述预定事件对应的时间区间;In the case of receiving the event message sent by the visual analysis service, according to the triggering moment of the predetermined event, determine the time interval corresponding to the predetermined event;
    从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件;From the video data in the cache queue, obtain the video file of the video segment corresponding to the time interval;
    将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段。The video file of the video segment is stored in a preset storage space, so as to obtain the video segment associated with the predetermined event.
  7. 根据权利要求1-6中任意一项所述的方法,其中,所述方法还包括:The method according to any one of claims 1-6, wherein the method further comprises:
    响应于针对所述预定事件的查看操作,从所述存储空间读取与所述预定事件相关联的视频片段的视频文件;reading a video file of a video segment associated with the predetermined event from the storage space in response to a viewing operation for the predetermined event;
    播放所述视频文件。Play said video file.
  8. 根据权利要求1-7中任意一项所述的方法,其中,所述视频流包括一路或多路视频流,所述缓存队列包括环形队列,所述预定事件包括行人跌倒事件、行人逆行事件、行人蹲坐事件、吸烟事件中的至少一种。The method according to any one of claims 1-7, wherein the video stream includes one or more video streams, the buffer queue includes a circular queue, and the predetermined events include pedestrian fall events, pedestrian retrograde events, At least one of pedestrian squatting incidents and smoking incidents.
  9. 一种视频生成装置,包括:A video generating device, comprising:
    数据缓存模块,配置为将视频流的视频数据写入到预设的缓存队列中,所述视频数据包括所述视频流的数据包和所述数据包的时间信息;The data cache module is configured to write the video data of the video stream into a preset cache queue, the video data including the data packets of the video stream and the time information of the data packets;
    时间区间确定模块,配置为在接收到针对所述视频流的事件消息的情况下,根据所述事件消息中预定事件的触发时刻,确定与所述预定事件对应的时间区间,所述时间区间的时长小于或等于所述缓存队列中的视频数据的时长;The time interval determination module is configured to determine the time interval corresponding to the predetermined event according to the triggering moment of the predetermined event in the event message when the event message for the video stream is received, and the time interval of the time interval The duration is less than or equal to the duration of the video data in the cache queue;
    视频文件获取模块,配置为从所述缓存队列的视频数据中,获取与所述时间区间对应的视频片段的视频文件;A video file obtaining module configured to obtain a video file of a video segment corresponding to the time interval from the video data in the cache queue;
    存储及关联模块,配置为将所述视频片段的视频文件存储到预设的存储空间中,以得到与所述预定事件相关联的视频片段。The storing and associating module is configured to store the video file of the video segment in a preset storage space, so as to obtain the video segment associated with the predetermined event.
  10. 一种电子设备,包括:An electronic device comprising:
    存储器,所述存储器用于存储处理器可执行指令;a memory for storing processor-executable instructions;
    处理器,所述处理器被配置为调用所述存储器存储的指令,以执行权利要求1至8中任意一项所述的方法。A processor configured to invoke instructions stored in the memory to perform the method of any one of claims 1-8.
  11. 一种计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现权利要求1至8中任意一项所述的方法。A computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.
  12. 一种计算机程序,包括计算机可读代码,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器执行用于实现权利要求1至8中任一所述的图像处理方法。A computer program, comprising computer-readable codes, when the computer-readable codes are run in an electronic device, a processor in the electronic device executes the image processing described in any one of claims 1 to 8 method.
PCT/CN2022/074117 2021-07-23 2022-01-26 Video generation method and apparatus, electronic device, storage medium, and program WO2023000639A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110837802.8A CN113556485A (en) 2021-07-23 2021-07-23 Video generation method and device, electronic equipment and storage medium
CN202110837802.8 2021-07-23

Publications (1)

Publication Number Publication Date
WO2023000639A1 true WO2023000639A1 (en) 2023-01-26

Family

ID=78104289

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/074117 WO2023000639A1 (en) 2021-07-23 2022-01-26 Video generation method and apparatus, electronic device, storage medium, and program

Country Status (2)

Country Link
CN (1) CN113556485A (en)
WO (1) WO2023000639A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116361254A (en) * 2023-06-02 2023-06-30 禾多科技(北京)有限公司 Image storage method, apparatus, electronic device, and computer-readable medium

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113556485A (en) * 2021-07-23 2021-10-26 上海商汤智能科技有限公司 Video generation method and device, electronic equipment and storage medium
CN114500658A (en) * 2021-12-27 2022-05-13 广州极飞科技股份有限公司 Data transmission method and device and data transmission method and device of aircraft
CN114554110B (en) * 2022-01-25 2023-12-29 北京百度网讯科技有限公司 Video generation method, device, electronic equipment and storage medium
CN115129927B (en) * 2022-08-17 2023-05-02 广东龙眼数字科技有限公司 Monitoring video stream backtracking method, electronic equipment and storage medium
CN115474005A (en) * 2022-10-28 2022-12-13 通号通信信息集团有限公司 Data processing method, data processing device, electronic apparatus, and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070217761A1 (en) * 2006-03-07 2007-09-20 Coban Research And Technologies, Inc. Method for video/audio recording using unrestricted pre-event/post-event buffering with multiple bit and frame rates buffer files
US20120027379A1 (en) * 2010-01-29 2012-02-02 Raymond Thompson Video processing methods and systems
US20130278620A1 (en) * 2012-04-20 2013-10-24 Aptos Technology Inc. Method of storing videos and portable device
US20200029133A1 (en) * 2018-07-23 2020-01-23 NRS Systems Camera Capture in an Organization Information Distribution System
US20210185289A1 (en) * 2019-12-11 2021-06-17 At&T Intellectual Property I, L.P. Event-triggered video creation with data augmentation
CN113556485A (en) * 2021-07-23 2021-10-26 上海商汤智能科技有限公司 Video generation method and device, electronic equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106803987B (en) * 2015-11-26 2021-09-07 腾讯科技(深圳)有限公司 Video data acquisition method, device and system
CN109194978A (en) * 2018-10-15 2019-01-11 广州虎牙信息科技有限公司 Live video clipping method, device and electronic equipment
CN112788266B (en) * 2020-10-28 2022-04-15 深圳真伊科技有限公司 Video recording method, system, terminal equipment and computer readable storage medium
CN112437233B (en) * 2021-01-26 2021-04-16 北京深蓝长盛科技有限公司 Video generation method, video processing device and camera equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070217761A1 (en) * 2006-03-07 2007-09-20 Coban Research And Technologies, Inc. Method for video/audio recording using unrestricted pre-event/post-event buffering with multiple bit and frame rates buffer files
US20120027379A1 (en) * 2010-01-29 2012-02-02 Raymond Thompson Video processing methods and systems
US20130278620A1 (en) * 2012-04-20 2013-10-24 Aptos Technology Inc. Method of storing videos and portable device
US20200029133A1 (en) * 2018-07-23 2020-01-23 NRS Systems Camera Capture in an Organization Information Distribution System
US20210185289A1 (en) * 2019-12-11 2021-06-17 At&T Intellectual Property I, L.P. Event-triggered video creation with data augmentation
CN113556485A (en) * 2021-07-23 2021-10-26 上海商汤智能科技有限公司 Video generation method and device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116361254A (en) * 2023-06-02 2023-06-30 禾多科技(北京)有限公司 Image storage method, apparatus, electronic device, and computer-readable medium
CN116361254B (en) * 2023-06-02 2023-09-12 禾多科技(北京)有限公司 Image storage method, apparatus, electronic device, and computer-readable medium

Also Published As

Publication number Publication date
CN113556485A (en) 2021-10-26

Similar Documents

Publication Publication Date Title
WO2023000639A1 (en) Video generation method and apparatus, electronic device, storage medium, and program
EP3817395A1 (en) Video recording method and apparatus, device, and readable storage medium
CN106231259B (en) Display methods, video player and the server of monitored picture
CN106911961B (en) Multimedia data playing method and device
EP3182716A1 (en) Method and device for video display
WO2017113660A1 (en) Application program management method and device
KR101677607B1 (en) Method, device, program and recording medium for video browsing
CN105845124B (en) Audio processing method and device
WO2018000711A1 (en) Method and apparatus for outputting image
WO2017084183A1 (en) Information displaying method and device
WO2019206243A1 (en) Material display method, terminal, and computer storage medium
EP3179397A1 (en) Methods and devices for managing automatic parallel login and logout in several applications
CN107888965B (en) Image gift display method and device, terminal, system and storage medium
WO2018228422A1 (en) Method, device, and system for issuing warning information
EP2985994A1 (en) Method and apparatus for backing up video and medium
US20210266633A1 (en) Real-time voice information interactive method and apparatus, electronic device and storage medium
CN113259226B (en) Information synchronization method and device, electronic equipment and storage medium
WO2017080084A1 (en) Font addition method and apparatus
US20170090684A1 (en) Method and apparatus for processing information
CN112153396A (en) Page display method, device and system and storage medium
CN110807393A (en) Early warning method and device based on video analysis, electronic equipment and storage medium
CN109495765B (en) Video interception method and device
CN108984098B (en) Information display control method and device based on social software
CN106547462A (en) Camera control method, device and mobile terminal
WO2024067468A1 (en) Interaction control method and apparatus based on image recognition, and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22844813

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE