CN114501002A - GOP cache-based pre-alarm video recording method and device - Google Patents

GOP cache-based pre-alarm video recording method and device Download PDF

Info

Publication number
CN114501002A
CN114501002A CN202210005909.0A CN202210005909A CN114501002A CN 114501002 A CN114501002 A CN 114501002A CN 202210005909 A CN202210005909 A CN 202210005909A CN 114501002 A CN114501002 A CN 114501002A
Authority
CN
China
Prior art keywords
gop
video
gops
video recording
alarm
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202210005909.0A
Other languages
Chinese (zh)
Inventor
尚云龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Fonsview Technologies Co ltd
Fiberhome Telecommunication Technologies Co Ltd
Original Assignee
Wuhan Fonsview Technologies Co ltd
Fiberhome Telecommunication Technologies Co Ltd
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 Wuhan Fonsview Technologies Co ltd, Fiberhome Telecommunication Technologies Co Ltd filed Critical Wuhan Fonsview Technologies Co ltd
Priority to CN202210005909.0A priority Critical patent/CN114501002A/en
Publication of CN114501002A publication Critical patent/CN114501002A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/103Selection of coding mode or of prediction mode
    • H04N19/114Adapting the group of pictures [GOP] structure, e.g. number of B-frames between two anchor frames
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/70Information retrieval; Database structures therefor; File system structures therefor of video data
    • G06F16/71Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/146Data rate or code amount at the encoder output
    • H04N19/15Data rate or code amount at the encoder output by monitoring actual compressed data size at the memory before deciding storage at the transmission buffer
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/177Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being a group of pictures [GOP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/42Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
    • H04N19/423Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation characterised by memory arrangements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/76Television signal recording
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N7/00Television systems
    • H04N7/18Closed-circuit television [CCTV] systems, i.e. systems in which the video signal is not broadcast

Abstract

The invention relates to a method and a device for recording before warning video based on GOP cache. The method mainly comprises the following steps: before receiving the alarm signal, the back-end video recording equipment caches the video data before the alarm by taking GOP as a unit; when the number of the cached GOPs exceeds a set value N, eliminating the GOP with the earliest starting time from the memory; after receiving the alarm signal, the back-end video recording equipment quickly drops the cached GOP data to generate a new video recording file. The invention fully considers the problem that the video decoding needs GOP key data to be normally decoded and played, and ensures the integrity of the warning video and normal and timely playing.

Description

GOP cache-based pre-alarm video recording method and device
Technical Field
The invention relates to the technical field of video monitoring, in particular to a method and a device for recording before warning video based on GOP (group of pictures) cache.
Background
A video monitoring system often needs to record videos collected by a front-end camera. At present, there are two ways to record video, one is to record video according to a recording schedule set by a user, the time of recording is determined by the start and end time of the schedule, and such recording generally requires that the backend device has a relatively large disk storage capacity. Another video recording method is event alarm video recording, in which a front-end smart camera generates an alarm when finding out conditions such as suspicious persons, object movement, regional intrusion, and the like, and then notifies a back-end device to record a video.
At present, in the field of video monitoring, the intelligent identification technology of a front-end network camera is more and more abundant, and various alarm events can be generated, such as: motion detection, video loss, occlusion detection, face recognition, regional intrusion, and accident occurrence. These alarm events are often important critical information, and generally, the alarm video is required to be stored for later searching, so as to obtain evidence or trace back the cause of the event. And often a period of time (generally a few seconds to a few minutes) before the alarm is given a video, namely the video before the alarm is particularly important. Therefore, the current better video monitoring integrated management platform (hereinafter referred to as management platform) can store complete video or all pre-alarm video in real time. However, when the management platform and the network cameras are in different wide area network environments, because the number of the network cameras is large, the network environment is complex, and bandwidth resources are often limited, and a large number of network cameras only store important alarm videos, the video content is not complete enough, and the actual significance of installing the network cameras is influenced.
One type of pre-alarm video storage method currently exists is to store pre-alarm video data in a disk. The method also needs to continuously store the video data in the disk when the alarm event does not come. In an NVR (Network Video Recorder) scenario, because the NVR needs to access Video streams transmitted by a plurality of Network cameras, the Video streams are all read from a Network card through a CPU and then sent to a disk through a file system, which will bring some meaningless IO pressure to the system.
Another existing method for storing pre-alarm videos relies on the function of a front-end network camera, and the front-end camera alarms and notifies a rear-end video device. The method depends on a front-end network camera, an alarm is found from the front-end network camera or front-end intelligent equipment, then the back-end equipment is informed to start video recording, and the back-end equipment starts to start the video recording. Due to the delay of transmission and processing, the video recorded last often loses some key video information at the alarm moment.
In conclusion, it is very important that the video in a period before the alarm moment is not lost, accurately recorded and played in time.
In view of this, how to overcome the defects existing in the prior art and solve the above technical problems is a difficult problem to be solved in the technical field.
Disclosure of Invention
In view of the above drawbacks or needs for improvement in the prior art, the present invention provides a method and an apparatus for video recording before alarm based on video GOP (Group of Picture) caching, in which when an alarm signal is not generated by a front-end intelligent camera, a rear-end video recording device caches a certain number of video GOPs in the cache, and establishes indexes (i.e., metadata) of the video GOPs, where the metadata includes start time of the video GOPs, length (i.e., size) of the video GOPs, and location (i.e., starting memory address) of the video GOPs in a memory. When the number of the stored video GOPs exceeds a set value, the video GOPs with the earliest starting time are sequentially found out, the GOPs are eliminated from the buffer space, and when new video data come, a new GOP is established for buffering. When the intelligent camera at the front end generates an alarm signal, the video equipment at the rear end writes the video data into a newly generated video file according to the GOP indexes and the GOP as a unit by the aid of the video equipment at the front end, wherein the video GOPs are cached previously. The chinese meaning of a GOP according to the present invention is a set of video image sequences between two IDR frames (mandatory Refresh frames).
The embodiment of the invention adopts the following technical scheme:
in a first aspect, the present invention provides a GOP cache-based pre-alarm video recording method, including:
before receiving the alarm signal, the back-end video recording equipment caches the video data before the alarm by taking GOP as a unit;
when the number of the cached GOPs exceeds a set value N, eliminating the GOP with the earliest starting time from the memory;
after receiving the alarm signal, the back-end video recording equipment quickly drops the cached GOP data to generate a new video recording file.
Further, before receiving the alarm signal, the caching, by the back-end video recording device, the alarm video data in units of GOPs specifically includes:
the back-end video recording equipment analyzes the video data from the front-end camera to find out the initial position of GOP in the video data;
when the initial position of a GOP is found, each subsequent frame of video data is stored in the memory, and the length of the GOP is accumulated until the initial position of the next GOP is found;
when the back-end video recording equipment finds the end position of a GOP, each frame of video data stored from the start position to the end position of the GOP is packaged into a complete GOP.
Further, while a complete GOP is encapsulated, metadata of the GOP is generated, and the metadata is used for recording the length of the GOP, the starting memory address of the GOP and the starting time of the GOP.
Further, when the number of cached GOPs exceeds the set value N, eliminating the GOP with the earliest start time from the memory specifically includes:
and the rear-end video recording equipment packages the GOPs into complete GOPs through frame accumulation, finds out the GOP with the earliest starting time through the metadata sequencing of the GOPs and eliminates the GOPs from the memory when the number of the packaged GOPs exceeds a set value N, and builds a new GOP for caching when new video data arrives.
Further, the GOP number corresponding to the set value N is the pre-alarm video configuration time frame rate/GOP frame interval.
Further, after receiving the alarm signal, the fast destaging of the cached GOP data by the back-end video recording device to generate a new video file specifically includes:
the rear-end video recording equipment receives an alarm signal sent by the front-end video recording equipment;
sequentially writing the GOPs into a disk according to the sequence of the starting time of the GOPs to generate a new video file;
and after the GOP is written into the disk, releasing the cache space corresponding to the GOP.
Further, in the process of sequentially writing the GOPs into the disk according to the sequence of the start time, the cache of the GOP is released every time one GOP is written until all cached GOPs are written into the disk.
Further, after the back-end video recording device rapidly drops the cached GOP data and generates a video file, subsequent video frames after receiving the alarm signal need to be encapsulated into GOPs and written into the video file.
Further, the start position of the GOP is an IDR frame.
On the other hand, the invention provides a pre-alarm video recording device based on GOP cache, which specifically comprises the following steps: the system comprises at least one processor and a memory, wherein the at least one processor and the memory are connected through a data bus, and the memory stores instructions capable of being executed by the at least one processor, and the instructions are used for completing the GOP cache-based pre-alarm video recording method in the first aspect after being executed by the processor.
Compared with the prior art, the invention has the beneficial effects that: the method caches and eliminates video data before alarm by taking GOP as a unit, writes complete GOP into a disk when an alarm signal comes, and includes an IDR frame which is decoded and played in time. Meanwhile, the invention also takes the GOP as a unit to be landed according to the index of the video GOP, combines the function of writing the disk IO by the recording equipment and improves the storage performance of the video file.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required to be used in the embodiments of the present invention will be briefly described below. It is obvious that the drawings described below are only some embodiments of the invention, and that for a person skilled in the art, other drawings can be derived from them without inventive effort.
Fig. 1 is a flowchart of a pre-alarm video recording method based on GOP cache according to embodiment 1 of the present invention;
FIG. 2 is an expanded flowchart of step 100 provided in embodiment 1 of the present invention;
FIG. 3 is an expanded flowchart of step 300 provided in embodiment 1 of the present invention;
fig. 4 is a schematic block diagram of a pre-alarm video recording system based on GOP cache according to embodiment 2 of the present invention;
fig. 5 is a view of GOP video data provided by embodiment 2 of the present invention when no alarm signal comes;
fig. 6 is a view of GOP metadata provided in embodiment 2 of the present invention when no alarm signal comes;
fig. 7 is a schematic diagram of a cache eviction process according to embodiment 2 of the present invention;
fig. 8 is a schematic diagram of a video data drop process provided in embodiment 2 of the present invention;
fig. 9 is a schematic structural diagram of a pre-alarm video recording device based on GOP cache according to embodiment 3 of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The present invention is a system structure of a specific function system, so the functional logic relationship of each structural module is mainly explained in the specific embodiment, and the specific software and hardware implementation is not limited.
In addition, the technical features involved in the embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other. The invention will be described in detail below with reference to the figures and examples.
Example 1:
as shown in fig. 1, an embodiment of the present invention provides a GOP cache-based pre-alarm video recording method, which includes the following steps.
Step 100: before receiving the alarm signal, the back-end video recording equipment caches the video data before alarm by taking GOP as a unit. In the step, when no alarm signal comes, video frames (namely video data) are packaged into complete GOPs and stored in a cache memory, and the method is very different from the method of directly caching the video data in a disk, so that the pressure of the write operation of the disk can be relieved. In the step, metadata of the GOP is generated while caching one GOP, and the metadata is used for recording the length of the GOP, the initial memory address and the start time of the GOP. The generated metadata is equivalent to the index information of the GOP, so that the generated metadata can be used for storing, eliminating and landing the GOP in the following process.
Step 200: and when the number of the cached GOPs exceeds a set value N, eliminating the GOP with the earliest starting time from the memory. In the step, the back-end video recording equipment encapsulates video data into complete GOPs through frame accumulation, when the number of the encapsulated GOPs exceeds a set value N, the back-end video recording equipment finds out the GOP with the earliest starting time through the metadata sorting of the GOPs and eliminates the GOP from a memory, and when new video data arrives, a new GOP is constructed for caching. The step eliminates the oldest GOP in real time according to the preset N value, so that the stored video data is newest and complete under the condition that the number of the GOPs is kept to be maximum.
Step 300: after receiving the alarm signal, the back-end video recording equipment quickly drops the cached GOP data to generate a new video recording file. In this step, in the process that the back-end video recording device writes the GOPs into the disk in sequence according to the start time sequence of the GOP metadata sorting, the cache of the GOP is released every time one GOP is written into the disk until all cached GOPs are written into the disk. The step uses GOP as a unit, refreshes the disk in a whole block, combines IO, can quickly refresh the cached video data to the disk, and is beneficial to better processing the current video frame by a CPU.
Through the above steps, in the preferred embodiment, when the front-end intelligent camera does not generate an alarm signal, the rear-end video recording device caches a certain number of video GOPs in the cache, and establishes indexes of the video GOPs. And when the number of the stored video GOPs exceeds a set value, sequencing and finding out the video GOP with the earliest starting time, and eliminating the GOP from the buffer space. When the intelligent camera at the front end generates an alarm signal, the video equipment at the rear end writes the video data into a newly generated video file by taking the GOP as a unit according to the GOP index and the GOP, wherein the video data are cached in the GOP.
As shown in fig. 2, in the preferred embodiment, step 100 (before receiving the alarm signal, the back-end video recording device buffers the pre-alarm video data in units of GOPs) specifically includes the following steps.
Step 101: the back-end video recording equipment finds out the initial position of GOP in the video data by analyzing the video data from the front-end camera. In this step, the front-end intelligent camera does not detect an AI event, and does not send an alarm signal to the rear-end video recording device, and the rear-end video recording device analyzes the received video data from the front-end camera to find out the start frame of the GOP in the data as the start position, where it is to be noted that the start frame of the GOP is also the IDR frame.
Step 102: when the start position of a GOP is found, the video data of each subsequent frame is stored in the memory, and the length of the GOP is accumulated until the start position of the next GOP is found. The step starts with the found initial frame of a GOP, and accumulates and stores the video data of each frame until the initial frame of the next GOP is found, and the video data accumulated in the time period is a complete GOP which is packed subsequently.
Step 103: when the back-end video recording equipment finds the end position of a GOP, each frame of video data stored from the start position to the end position of the GOP is packaged into a complete GOP. In the step, a complete GOP is packaged by finding the end position before the start frame of the next GOP, and metadata of the GOP needs to be generated while packaging the complete GOP, so as to record the length of the GOP, the start memory address of the GOP and the start time of the GOP.
In the preferred embodiment, the back-end recording device in step 200 (when the number of buffered GOPs exceeds the set value N, the GOP with the earliest start time is eliminated from the memory) encapsulates the video data into complete GOPs by frame accumulation according to the logic of steps 101 to 103, and when the number of encapsulated GOPs exceeds a certain number N, the back-end recording device sorts and finds out the GOP with the earliest start time from the metadata of the GOPs and eliminates the GOP from the memory. When the GOPs with the earliest starting time are found out from the memory for elimination in the sorting process, the GOPs are eliminated one at a time, then when new video data come, a new GOP is established for caching, then when the number of the GOPs exceeds the number N again, the earliest GOP is eliminated, and the cycle is repeated, so that the number of the cached GOPs does not exceed the threshold value N. It should be noted that, when a GOP is eliminated, the metadata corresponding to the GOP is also deleted from the memory.
In the above elimination process, the threshold N of the number of encapsulated GOPs depends on the pre-alarm video configuration time, the GOP frame interval, and the frame rate. The longer the pre-alarm video configuration time is, the more the number of GOPs needing to be cached is, namely the larger the threshold value N is; the shorter the interval of the GOP frames is, the more the number of GOPs needing to be cached is, namely the larger the threshold value N is; the frame rate is also an important parameter for calculating the number of buffered video GOPs, and generally, the larger the frame rate is, the larger the threshold N is. Specifically, the following formula is shown: and setting the number of GOPs (group of pictures) corresponding to the value N as the configuration time of the pre-alarm video frame rate/GOP frame interval. The unit of the pre-alarm video configuration time in the formula is seconds(s).
In the preferred embodiment, the pre-alarm video configuration time in the above formula can be configured by self-definition according to the requirement and is set in advance manually. According to different scenes, different pre-alarm video configuration time can be set. For example, when a scene of a suspicious person is monitored, a video condition of a long time before the suspicious person appears needs to be observed, and the pre-alarm video configuration time at this time may be set to 300 seconds. If too long pre-alarm video is not needed to observe the article moving situation in the article moving nursing scene, the pre-alarm video configuration time can be set to 60 seconds. The longer the pre-alarm video configuration time, the more GOPs need to be buffered. In addition, the frame rate in the above formula can be derived from the time difference and the sampling rate of two adjacent frames, for example, I frame or P frame, the pts (time stamp) of which is increased, and the frame rate can be calculated from the time difference and the sampling rate of two adjacent frames. The GOP frame interval in the above formula can be calculated by counting the number of B frames and P frames existing between two I frames through the identification of the frame type. I-frames are also IDR-frames (start frames).
In the preferred embodiment, the frame rate is changed, and the sensing logic of the I frame interval is: when the event recording is started each time, the frame rate and the GOP frame interval are sensed once so as to calculate the size of the GOP number required by the event recording. Therefore, when the frame rate of the front-end camera changes and the interval of the I frame changes, corresponding data can be cached according to preset pre-alarm video configuration time, and the method has strong robustness and engineering usability.
As shown in fig. 3, in the preferred embodiment, step 300 (after receiving the alarm signal, the back-end video recording device fast drops the cached GOP data to generate a new video file) specifically includes the following steps.
Step 301: and the rear-end video recording equipment receives the alarm signal sent by the front-end video recording equipment. In this step, the cached GOPs may be sorted according to the start time, specifically, each GOP may be sorted according to the start time of each GOP in the metadata of each GOP stored before in this step, or may be sorted according to the metadata directly at the time of starting caching the GOPs, and then this step refers to the previous sorting, so as to facilitate the subsequent disk write operation and the cache release operation.
Step 302: and sequentially writing the GOPs into a disk according to the start time sequence according to the metadata of the GOPs to generate a new video file.
Step 303: after the GOP is written into the disk, the cache space corresponding to the GOP is released, and the corresponding GOP metadata is deleted.
In the above step 302 and step 303, the GOPs need to be sequentially written into the disk according to the sequence of the start time, in the process, the cached GOPs need to be written into the disk one by one, and the cache of the GOP is released every time a GOP is written into the disk until all the cached GOPs are written into the disk. Thus, the whole writing is carried out by taking the GOP as a unit, so that the disk falling speed of the embodiment is higher than the disk writing speed before other warnings, and the high disk falling speed is beneficial to timely processing of the current video frame.
In addition, in the preferred embodiment, after the back-end video recording device rapidly drops the cached GOP data and generates a video file, it is also necessary to encapsulate the subsequent video frames after receiving the alarm signal into GOPs and write the GOPs into the video file. Therefore, the video data before the alarm and the video data after the alarm of an event can be stored in a video file, so that the follow-up viewing is convenient.
In summary, most players can correctly decode and present images only when finding an IDR frame at the start position of a GOP during playing, and it can be seen from the preferred embodiment that the embodiment of the present invention caches and eliminates the warning video data in units of GOPs, and writes the complete GOP into a disk when a warning signal comes, including the IDR frame that is played in time, and the method fully considers the problem that GOP key data is needed for video decoding to be normally decoded and played, avoids the defect that the stored video data before warning cannot be played due to non-IDR frame dropping, completely saves the video segment at the video warning time, and ensures the integrity of the warning video and the purpose of normal and timely playing.
The embodiment of the invention also eliminates the GOP with the earliest starting time in the memory when no alarm signal comes, and the received new video frame is written into the newly generated GOP. The method does not generate any disk pressure when no alarm signal comes. When the alarm signal comes, the invention also stores the whole falling disk by taking the GOP as a unit according to the index of the video GOP and the start time sequence, combines the disk writing IO function of the recording equipment, has higher falling disk speed compared with other disk writing modes before the alarm, realizes the purpose of quick falling disk, is beneficial to the timely processing of the current video frame and improves the storage performance of the video file.
In addition, when the frame rate of the front-end camera changes and the interval of the I frame changes, the embodiment of the invention can also cache corresponding data according to the set pre-alarm pre-recording time, and has strong robustness and engineering usability. That is, the embodiment of the present invention can adaptively calculate the number of GOPs to be buffered, and accurately store the number of GOPs required by the pre-designed pre-alarm video configuration time.
Example 2:
based on the GOP cache-based pre-alarm video recording method provided in embodiment 1, embodiment 2 provides a GOP cache-based pre-alarm video recording system, as shown in fig. 4, the system includes a video cache and elimination module and a video data drop module, and these two modules may be arranged on a back-end video recording device during actual use. The video cache and elimination module is used for processing the video elimination cache when the alarm signal does not arrive. And the video data falling module is used for processing the video data falling when the alarm signal is triggered.
Specifically, the video caching and elimination module comprises a video data caching module and two video data elimination modules, wherein the video data caching module has the functions of: the method comprises the steps of analyzing video data from a front-end camera to find out the initial position of a GOP in the video data; when the initial position of a GOP is found, each subsequent frame of video data is stored in the memory, and the length of the GOP is accumulated until the initial position of the next GOP is found; when the back-end video recording equipment finds the end position of a GOP, packaging each frame of video data stored from the start position to the end position of the GOP into a complete GOP; and generating metadata of the GOP while packaging a complete GOP, wherein the metadata is used for recording the length of the GOP, the starting memory address of the GOP and the starting time of the GOP. The video data elimination module has the functions of: when the number of the packaged GOPs exceeds a set value N, the GOPs with the earliest starting time are found out through the GOP metadata sequencing and eliminated from a memory, and when new video data come, a new GOP is established for caching.
As shown in fig. 5, a view of GOP video data is shown when no alert signal is coming. The data view includes the buffered GOPs and the eliminated GOPs, and it can be seen that each GOP (GOP 1, GOP2, and GOP3 … … GOPN in the figure) is encapsulated with IDR frames as the starting position, and each GOP is sorted by its start time (pts in the figure), and the eliminated GOP is the head GOP sorted by its start time.
As shown in fig. 6, a GOP metadata view is shown when no alert signal is coming. This view of data corresponds to the view of GOP video data of fig. 5, and also includes N GOPs, such as GOP1, GOP2, GOP3 … … GOPN, etc. Where the GOP1 includes three data: pts (i.e., the start time of the GOP) is 5000; addr _ start (i.e., the starting memory address of the GOP) is Oxf 1000000; the GOP _ size (i.e. the length of the GOP) is 2700000. The three data of the other GOPs are shown in the figure and are not repeated at all. It should be noted that the data design of fig. 5 and 6 is an example, and not a limitation.
As shown in fig. 7, the cache eviction process in the video caching and eviction module is as follows: receiving a video stream, namely receiving video data from a front-end camera; GOP starting detection, namely analyzing the received video data, and finding out an initial position IDR frame of the GOP in the video data; buffering frames, accumulating the GOP size, i.e. accumulating the length of the GOP; detecting the end position of the GOP, namely detecting whether the GOP reaches the end position; if the end position is not detected, continuing caching the frames, accumulating the sizes of the GOPs, if the end position is detected, encapsulating the accumulated GOPs into a new complete GOP, and adding one to the number of the GOPs (which is reflected in the program of GOP _ num + +); and finally, judging whether the number of GOPs is larger than N (the GOP _ num is judged to be larger than N in the program), if not, continuing to cache the frame of the next GOP and accumulating the size of the GOP, if so, eliminating the GOP with the earliest starting time, and then re-caching the frame of the next GOP and accumulating the size of the GOP.
Specifically, the video data dropping module has the functions of: after receiving an alarm signal sent by front-end camera equipment, sequencing the cached GOPs according to the starting time; according to the metadata of the GOP, writing the GOP into a disk in sequence according to the sequence of the start time to generate a new video file; after the GOP is written into the disk, releasing the cache space corresponding to the GOP; in the process of sequentially writing the GOPs into the disk according to the sequence of the starting time, releasing the cache of the GOP every time one GOP is written until all cached GOPs are written into the disk; after the cached GOP data is rapidly downloaded and a video file is generated, subsequent video frames after the alarm signal is received are packaged into GOPs and written into the video file.
As shown in fig. 8, the video data dropping process in the video data dropping module specifically includes the following steps: receiving an alarm signal, namely receiving alarm information from a front-end camera; sequencing the current cached GOPs according to the start time, namely sequencing the current cached GOPs according to the sequence of the start time in the metadata of the GOPs; judging whether the GOP number is larger than 0 (in the aspect of program, judging that the GOP _ num is larger than 0); if the number of GOPs is larger than 0, writing the GOP with the earliest starting time into a disk according to the meta information, generating a new video file, writing one GOP into the disk, reducing the number of GOPs by one (represented by a GOP _ num- -) in a program, releasing the GOP written into the disk in a cache, continuously judging whether the number of GOPs is larger than 0 after the release is finished, until the judgment structure is not larger than the structure, at the moment, indicating that all the GOPs are completely landed, packaging the subsequent video frames after receiving the alarm signal into GOPs and writing the GOPs into the video file, and thus storing the videos before and after the alarm in the video file.
In summary, in this embodiment 2, through the functions and specific operation flows of the video caching and elimination module and the video data destaging module, the video data before warning can be cached and eliminated in units of GOPs, and the complete GOPs are written into the disk when the warning signal comes, so that the defect that the stored video data before warning cannot be played due to non-IDR frame destaging is avoided, the video clip at the time of video warning is completely stored, and the integrity of the video before warning and the purpose of normal and timely playing are ensured. In this embodiment 2, when no alarm signal comes, the GOP with the earliest start time is eliminated from the memory, and the received new video frame is written into the newly generated GOP, so that no disk pressure is generated when no alarm signal comes; when the alarm signal arrives, this embodiment 2 still according to the index of video GOP, according to the start time sequence, use GOP as the whole storage of falling the dish of unit, it is faster to compare the mode of writing the disk before other police, has realized the purpose of quick falling the dish, is favorable to the timely processing of current video frame, has promoted the performance that the video file stored.
Example 3:
on the basis of the GOP cache-based pre-alarm video recording method provided in the above embodiment 1, the present invention further provides a GOP cache-based pre-alarm video recording device that can be used for implementing the above method and system, and as shown in fig. 9, the device architecture diagram of the embodiment of the present invention is shown. The GOP buffer-based pre-alarm video recording apparatus of the present embodiment includes one or more processors 21 and a memory 22. In fig. 9, one processor 21 is taken as an example.
The processor 21 and the memory 22 may be connected by a bus or other means, and fig. 9 illustrates the connection by a bus as an example.
The memory 22, which is a non-volatile computer-readable storage medium, may be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the GOP cache based pre-alarm video recording method in embodiment 1. The processor 21 executes various functional applications and data processing of the GOP cache based pre-alarm video recording device by running the nonvolatile software program, instructions and modules stored in the memory 22, that is, implements the GOP cache based pre-alarm video recording method of embodiment 1.
The memory 22 may include high speed random access memory and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, the memory 22 may optionally include memory located remotely from the processor 21, and these remote memories may be connected to the processor 21 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
Program instructions/modules are stored in memory 22 that, when executed by the one or more processors 21, perform the GOP cache based pre-alarm recording method of embodiment 1 described above, e.g., perform the various steps shown in fig. 1-3 described above.
Those of ordinary skill in the art will appreciate that all or part of the steps of the various methods of the embodiments may be implemented by associated hardware as instructed by a program, which may be stored on a computer-readable storage medium, which may include: a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and the like.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.

Claims (10)

1. A pre-alarm video recording method based on GOP cache is characterized by comprising the following steps:
before receiving the alarm signal, the back-end video recording equipment caches the video data before the alarm by taking GOP as a unit;
when the number of the cached GOPs exceeds a set value N, eliminating the GOP with the earliest starting time from the memory;
after receiving the alarm signal, the back-end video recording equipment quickly drops the cached GOP data to generate a new video recording file.
2. The GOP-cache-based video-before-alarm method according to claim 1, wherein before receiving the alarm signal, the back-end video recording device caches the video data before alarm in units of GOPs, specifically comprising:
the back-end video recording equipment analyzes the video data from the front-end camera to find out the initial position of GOP in the video data;
when the initial position of a GOP is found, each subsequent frame of video data is stored in the memory, and the length of the GOP is accumulated until the initial position of the next GOP is found;
when the back-end video recording equipment finds the end position of a GOP, each frame of video data stored from the start position to the end position of the GOP is packaged into a complete GOP.
3. The method of claim 2, wherein the GOP buffer-based pre-alarm video recording method is characterized in that metadata of a complete GOP is generated while the GOP is encapsulated, and the metadata is used for recording the length of the GOP, the starting memory address of the GOP and the starting time of the GOP.
4. The GOP-cache-based pre-alarm video recording method according to claim 1, wherein when the number of cached GOPs exceeds a set value N, eliminating the GOP with the earliest start time from a memory specifically comprises:
and the rear-end video recording equipment packages the GOPs into complete GOPs through frame accumulation, finds out the GOP with the earliest starting time through the metadata sequencing of the GOPs and eliminates the GOPs from the memory when the number of the packaged GOPs exceeds a set value N, and builds a new GOP for caching when new video data arrives.
5. The method according to claim 4, wherein the number of GOPs corresponding to the setting value N is configured as frame rate/GOP frame interval.
6. The GOP buffer-based pre-alarm video recording method according to claim 1, wherein after receiving the alarm signal, the back-end video recording device fast drops the buffered GOP data to generate a new video file specifically includes:
the rear-end video recording equipment receives an alarm signal sent by the front-end video recording equipment;
sequentially writing the GOPs into a disk according to the sequence of the starting time of the GOPs to generate a new video file;
and after the GOP is written into the disk, releasing the cache space corresponding to the GOP.
7. The method for recording before warning based on GOP cache as claimed in claim 6, wherein in the process of sequentially writing the GOPs into the disk according to the start time sequence, the cache of the GOP is released every time one GOP is written until all the cached GOPs are written into the disk.
8. The GOP cache-based pre-alarm video recording method as claimed in claim 6, wherein the back-end video recording device needs to encapsulate the subsequent video frames after receiving the alarm signal into GOPs and write the GOPs into the video recording file after rapidly dropping the cached GOP data and generating the video recording file.
9. A GOP buffer based pre-alarm video recording method according to any of claims 2 to 8, wherein the start position of the GOP is an IDR frame.
10. The utility model provides a video recording device before warning based on GOP buffer memory which characterized in that:
the system comprises at least one processor and a memory, wherein the at least one processor and the memory are connected through a data bus, and the memory stores instructions capable of being executed by the at least one processor, and the instructions are used for completing the GOP cache-based pre-alarm video recording method of any one of claims 1 to 9 after being executed by the processor.
CN202210005909.0A 2022-01-04 2022-01-04 GOP cache-based pre-alarm video recording method and device Pending CN114501002A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210005909.0A CN114501002A (en) 2022-01-04 2022-01-04 GOP cache-based pre-alarm video recording method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210005909.0A CN114501002A (en) 2022-01-04 2022-01-04 GOP cache-based pre-alarm video recording method and device

Publications (1)

Publication Number Publication Date
CN114501002A true CN114501002A (en) 2022-05-13

Family

ID=81510736

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210005909.0A Pending CN114501002A (en) 2022-01-04 2022-01-04 GOP cache-based pre-alarm video recording method and device

Country Status (1)

Country Link
CN (1) CN114501002A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115361517A (en) * 2022-08-26 2022-11-18 重庆紫光华山智安科技有限公司 Pre-alarm video recording method and device, electronic equipment and readable storage medium
CN115604540A (en) * 2022-09-01 2023-01-13 荣耀终端有限公司(Cn) Video acquisition method and device

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115361517A (en) * 2022-08-26 2022-11-18 重庆紫光华山智安科技有限公司 Pre-alarm video recording method and device, electronic equipment and readable storage medium
CN115361517B (en) * 2022-08-26 2024-03-22 重庆紫光华山智安科技有限公司 Video recording method and device before police, electronic equipment and readable storage medium
CN115604540A (en) * 2022-09-01 2023-01-13 荣耀终端有限公司(Cn) Video acquisition method and device
CN115604540B (en) * 2022-09-01 2023-11-14 荣耀终端有限公司 Video acquisition method, electronic equipment and medium

Similar Documents

Publication Publication Date Title
EP2407943B1 (en) Method for event initiated video capturing and a video camera for capture event initiated video
US9911253B2 (en) Memory management in event recording systems
CN114501002A (en) GOP cache-based pre-alarm video recording method and device
US9041803B2 (en) Method for video/audio recording using multiple resolutions
JP4099973B2 (en) Video data transmission method, video data reception method, and video surveillance system
TWI664855B (en) Method and apparatus for playing back recorded video
CN107093436B (en) Prerecorded audio and video data storage method and device and mobile terminal
CN101729836A (en) Method for videoing bottom acquisition device
CN102376146A (en) Image analysis alarm signal-based method for storing information of alarm event
CN111787256B (en) Management method, device, medium and electronic equipment for pre-alarm video
CN102547221A (en) Video recording and network transmitting method based on motion detection
CN110557553B (en) Data processing method, video acquisition equipment and readable storage medium
JP2021051628A (en) Recording control device, recording control method, and recording control program
CN102938829A (en) Method for realizing prerecording of real-time audio/video stream
CN114125371A (en) Video capture at camera devices by reducing the bit rate of the video by means of neural network input to save bandwidth at intelligent intervals
CN111654672A (en) Method and system for realizing generation processing of alarm pre-trigger video file
WO2009108124A1 (en) A method of recording quality images
JP2004289294A (en) Data processing system, data processor, and data processing method
CN111147729B (en) Information acquisition device and control method thereof
US20220286621A1 (en) Event video sequences
JP2007300462A (en) Device and method for recording image
CN116524431A (en) Method and device for detecting number of people, electronic equipment, storage medium and conference control system
KR101096666B1 (en) Digital video record system for detecting specific object, and method for detecting specific object in the digital video record system
TW201911859A (en) Key fragment recording system and method of the same
KR100969300B1 (en) Moving picture recording method and apparatus

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination