Security and protection storage cache method and device
By separating the video frame data and metadata and storing them in I-frames, the problem of discontinuous video playback in security storage is solved, memory utilization and playback efficiency are improved, and it is suitable for consumer security storage devices with limited resources.
Patent Information
- Application Number
- CN202411085473.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-12-06
AI Technical Summary
Existing security storage technology has frame skipping in video recording, resulting in discontinuous video playback and limited resources in consumer products are inefficient in storage and playback, and cannot fully utilize the characteristics of video.
By separating the video frame data and metadata, using video parsing tools to identify and extract frame header metadata, and each frame data is sliced by I frame, and a ring buffer and microcontroller programming is used to ensure data independence and Effectiveness, reduce the occurrence of frame skipping.
It effectively reduces the occurrence of frame skipping, improves the continuity of video playback, improves memory usage, and reduces resource waste. It is suitable for embedded systems with limited resources.
Smart Images

Figure CN119094675A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of security storage, and in particular relates to a method and device for security storage caching. Background Art
[0002] Security storage products belong to consumer storage products, mainly used to store camera recordings. Camera recordings are divided into scheduled recordings and alarm recordings. Scheduled recordings are characterized by low resolution and low bit rate, while alarm recordings are generally high resolution and high bit rate. Therefore, in the same period of time, scheduled recordings occupy much less disk space than alarm recordings. Therefore, scheduled recordings are used for 7*24 hours of uninterrupted recording, while alarm recordings are used for emergencies.
[0003] The characteristics of consumer products are limited resources, that is, CPU and memory resources are limited, but the requirements are not low, because they are closer to users and are used more frequently, so the requirements for product experience and performance are relatively high. Storage, that is, the core function is recording, which is to write audio and video streams to files. In order to improve disk performance, it is generally written to the cache first, and the common write cache is a large continuous cache or a circular cache.
[0004] However, this does not fully utilize the characteristics of security storage, especially video and audio and video, and is not flexible enough. Moreover, once a problem occurs, the entire cache will be discarded and cleared, resulting in frame loss, and the duration of the frame loss may be the length of the entire cache, causing users to view the video discontinuously, and there will be frame skipping, that is, skipping seconds. Therefore, we need to propose a method and device for security storage caching to solve the above-mentioned problems, so that it can effectively reduce the existence of frame skipping to ensure the continuity of video playback. Summary of the invention
[0005] The object of the present invention is to provide a method and device for secure storage caching, which can effectively reduce the existence of frame skipping to ensure the continuity of video playback and solve the problems raised in the above background technology.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] A method for secure storage caching comprises the following steps:
[0008] S1. Separate the frame data and metadata in the video, specifically:
[0009] S11, identifying and extracting metadata through a video analysis tool to obtain frame header metadata;
[0010] S12, extract the frame header separately and put it into another buffer data;
[0011] S2. Further fragment the cache by I frame for each frame data, specifically:
[0012] S21, decoding the video stream to identify the I frame;
[0013] S22, segmenting the video according to the position of the I frame to obtain segment data;
[0014] S23. Store the segment data so that the header of each segment data contains metadata of the segment data.
[0015] Preferably, the frame data is a time segment in which an audio or video signal is divided into discrete data during audio and video decoding. This time segment is a frame, and each frame contains data for subsequent compression, transmission and playback.
[0016] Preferably, the metadata is information describing frame data, and the metadata includes the length of the frame and the timestamp of the frame. Each metadata is set in one-to-one correspondence with the frame data, and each frame data has corresponding frame header information.
[0017] Preferably, in step S11, when identifying and extracting the metadata, it is necessary to ensure that the video parsing tool is compatible with the encoding format of the video file, and then select a suitable tool to perform video parsing and extract the metadata, and then delay the distribution of the metadata.
[0018] Preferably, during delayed allocation, initialization is performed first. Initialization only requires allocation of one frame segment and metadata segment, and then the second, third, and Nth segments are allocated as needed. If the cache has been read at some point in the middle, a cyclic overwrite is started without the need to allocate new data.
[0019] Preferably, in step S12, the operation steps of extracting the frame header separately and putting it into another cache data are as follows:
[0020] A1. In the data transmission protocol, the frame used to mark the beginning of a frame of data is defined as a frame header, and the position of the frame header is identified by detecting specific bytes in the received data stream;
[0021] A2. Decouple the receiving and processing data, and then temporarily store the decoupled data in a buffer, using a ring buffer to store the frame header;
[0022] A3. Through single-chip computer programming, when receiving data, once the defined frame header is detected, the data after the frame header is received and stored according to the protocol format;
[0023] A4. Define a new buffer area for storing the extracted frame header. After confirming the integrity and correctness of a frame of data, extract the frame header data from the original data and store it in the new buffer.
[0024] Preferably, in step S21, the I frame is a key frame, and the key frame does not contain temporal prediction or motion compensation. The steps of decoding the video stream are as follows:
[0025] B1. Obtain video stream data through the camera;
[0026] B2. Use the video analysis tool to read each frame of the video stream and identify the frame type by analyzing the header frame of the frame data.
[0027] B3. When an I frame is identified, the I frame data is extracted for processing or analysis.
[0028] Preferably, in step S22, when video is segmented according to the position of the I frame, the H.264 encoding method is used to identify the I frame. When the I frame is identified, the position of the video segment is determined according to demand to ensure that each segment can be independently decoded and played, and then the video segment is extracted for memory cropping.
[0029] Preferably, during memory cropping, the frame segments are initially allocated sizes according to the resolution and frame rate, and if the resolution and frame rate are adjusted later, the frame segments are adjusted in the same direction.
[0030] Based on the above-described method for a security storage cache, the present invention further provides a device for a security storage cache, comprising a data storage device, a tag storage body, a valid bit unit, and a single-chip microcomputer, wherein the single-chip microcomputer is electrically connected to the data storage device, the tag storage body, and the valid bit unit, respectively, and the single-chip microcomputer can separate the frame data and metadata in the video, and further slice the cache by I frame for each frame data, wherein the data storage device is used to obtain the video stream in the camera, and the tag storage body is used to identify whether the data block in the cache is the correct data requested by the single-chip microcomputer;
[0031] The valid bit unit is used to identify whether the data in the cache is valid. When data is copied from the data storage to the cache, the corresponding valid bit will be set to 1, indicating that the data is currently valid. If the cache is cleared or the data is replaced, the valid bit will be reset to 0.
[0032] The method and device for secure storage caching proposed by the present invention have the following advantages over the prior art:
[0033] 1. When searching, the present invention uses a video parsing tool to identify and extract metadata, obtains frame header metadata, and then extracts the frame header separately and puts it into another cache data. Then, the video stream is decoded to identify the I frame, and the video is segmented according to the position of the I frame to obtain segment data. The segment data is stored so that the header of each segment data contains the metadata of the segment data. The frame data and metadata in the video are separated first, and then each frame data is further segmented according to the I frame. That is, the segment header of each metadata segment is read first, and there is no need to search from the middle. If the cache is covered in a loop, it only needs to be covered in ABC order, and there is no need to search from the middle. If there is a problem with the data, even if the frame header information is wrong, the greatest impact is only the data of the second corresponding to the I frame, and there is no impact on the data of the other two seconds. This is very important for the situation where embedded system resources are limited. It not only improves the memory utilization rate, but also greatly reduces various memory problems, and effectively reduces the existence of frame skipping to ensure the continuity of video playback. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 It is a flowchart of the present invention;
[0035] Figure 2 A flowchart of extracting a frame header separately and putting it into another buffer data in the present invention;
[0036] Figure 3 A flowchart of decoding a video stream according to the present invention;
[0037] Figure 4 This is a schematic diagram of the structure of the improved alarm pre-recording cache of the present invention;
[0038] Figure 5 This is a structural diagram of the alarm pre-recording cache of the present invention. DETAILED DESCRIPTION
[0039] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. The specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0040] The present invention provides Figure 1-3 A method for secure storage caching is shown, comprising the following steps:
[0041] S1. Separate the frame data and metadata in the video. The frame data refers to the time segments in which the audio or video signal is divided into discrete data during the audio and video decoding process. The time segments are called frames. Each frame contains data for subsequent compression, transmission and playback.
[0042] The metadata is information describing the frame data. The metadata includes the length of the frame and the timestamp of the frame. Only in this way can the position of the frame (data) and the time point (usually milliseconds) corresponding to the frame be found. It is also very useful. For subsequent search and playback, each metadata is set in one-to-one correspondence with the frame data. Each frame data has corresponding frame header information, so each frame data has corresponding frame header information;
[0043] Extract the frame header separately and put it into another buffer. Separate the data and metadata, which is a good improvement. If there is a problem with one frame data, it will not affect other frame data, but the defect still exists. If there is a problem with the metadata, it will also affect all data.
[0044] Specifically:
[0045] S11, identifying and extracting metadata through a video analysis tool to obtain frame header metadata;
[0046] When identifying and extracting the metadata, it is necessary to ensure that the video parsing tool is compatible with the encoding format of the video file, and then select a suitable tool to parse the video and extract the metadata, and then delay the distribution of the metadata;
[0047] When allocating data in a delayed manner, the system first performs initialization. It only requires allocating one frame segment and one metadata segment. Then, it allocates the second, third, and Nth segments as needed. If the cache is read at a certain point in the middle, it starts to be overwritten in a loop without allocating new data. In this way, two I-frame segments, or a total of four segments, may be enough, instead of the six segments expected before. This allows for on-demand allocation and saves memory usage.
[0048] S12, extract the frame header separately and put it into another buffer data;
[0049] The steps to extract the frame header separately and put it into another cache data are as follows:
[0050] A1. In the data transmission protocol, the frame used to mark the beginning of a frame of data is defined as a frame header, and the position of the frame header is identified by detecting specific bytes in the received data stream;
[0051] A2. Decouple the receiving and processing data, and then temporarily store the decoupled data in a buffer, using a ring buffer to store the frame header;
[0052] A3. Through single-chip computer programming, when receiving data, once the defined frame header is detected, the data after the frame header is received and stored according to the protocol format;
[0053] A4. Define a new buffer area for storing the extracted frame header. After confirming the integrity and correctness of a frame of data, extract the frame header data from the original data and store it in the new buffer.
[0054] S2. Further fragment the cache by I frame for each frame data, specifically:
[0055] S21, decoding the video stream to identify the I frame;
[0056] The I frame is a key frame, which does not contain temporal prediction or motion compensation. The steps for decoding the video stream are as follows:
[0057] B1. Obtain video stream data through the camera;
[0058] B2. Use the video parsing tool to read each frame of data in the video stream and identify the frame type by analyzing the header frame of the frame data; the frame types include I frame, P frame and B frame, among which I frame is a key frame, which is encoded completely independently of other frames and only relies on the pixel information of the frame itself. It does not contain temporal prediction or motion compensation, so it can be used as the starting point for video decoding.
[0059] P frames rely on previous I frames or P frames for temporal prediction, reducing the amount of data by comparing the difference between the current frame and the reference frame.
[0060] B frames rely on the previous and next I frames or P frames for bidirectional predictive coding, which has higher compression efficiency, but the decoding process is more complicated.
[0061] B3. When an I frame is identified, the I frame data is extracted for processing or analysis;
[0062] S22, segmenting the video according to the position of the I frame to obtain segment data;
[0063] By decoding the video stream, identifying the position of I frames, and accurately segmenting the video according to these key frames, multiple video clips that can be independently decoded and played can be obtained. This process not only improves the flexibility of video processing, but also provides an efficient solution for video storage, transmission and playback. By utilizing the characteristics of I frames for video segmentation, more efficient and high-quality video processing can be achieved in a variety of application scenarios.
[0064] When the video is segmented according to the position of the I frame, the H.264 encoding method is used to identify the I frame. When the I frame is identified, the position of the video segment is determined according to the needs to ensure that each segment can be decoded and played independently, and then the video segment is extracted for memory cropping.
[0065] If the video is segmented according to I-frame, the duration is 3 seconds. Figure 5 As shown, it is divided into three segments, ABC. Of course, the frame header and frame data are further separated, that is, six segments. The frame header cache is called metadata segment, and the frame data cache is called frame segment.
[0066] H.264 coding is a new video coding standard jointly developed by the two major standardization organizations 150 / IEC and ITU-T. The coding efficiency can be improved by more than 50%, and it has better fault tolerance and network adaptability. This makes it have broad application prospects in the future video coding and communication fields. H.264 coding adopts a block-based hybrid coding model. At the same time, H.264 uses many advanced technologies, such as spatial prediction in intra-frame coding, motion compensation of variable block size, 4×4 integer transform, multi-reference frame prediction and content-adaptive binary arithmetic coding. Therefore, the computational complexity of H.264 is much higher than other existing standards. In order to better meet the application requirements of real-time video communication in different environments, the algorithm must be optimized to reduce the complexity.
[0067] When cropping memory, frame fragments are initially allocated sizes based on resolution and frame rate. If the resolution and frame rate are adjusted later, the frame fragments are adjusted in the same direction. For example, when the resolution is increased, the fragment space is increased, otherwise it can be reduced. This is on-demand allocation, saving memory usage and improving memory utilization. The effect is more obvious when there are a large number of connected IPCs (IPcamera, digital cameras), because the more connected the ipcs are, the different resolutions of the ipcs are, and the allocated space is also different.
[0068] S23, storing the segment data so that the header of each segment data contains metadata of the segment data;
[0069] In order to make the header of each data segment contain the metadata of the data segment, the metadata is stored together with the data segment. The method of storing the metadata together with the data segment specifically includes determining the content of the metadata, packaging the data segment and the metadata, transparency and access control, and data segmentation and allocation strategy, wherein determining the content of the metadata:
[0070] Metadata should include the identification information of the data fragment, creation time, size, and other relevant information that may be helpful for data management and retrieval. For example, in a distributed system, metadata can also include the storage location of the data fragment, access control information, etc. Designing a structured format (such as XML, JSON, or a specific binary format) to store metadata helps to maintain the consistency and parsability of metadata.
[0071] Packaging data fragments and metadata:
[0072] Embed metadata directly in the header of the data segment file. In this case, the file structure of the data segment needs to support pre-set metadata blocks, such as reserving specific bytes at the beginning of the file for storing metadata;
[0073] Transparency and access control:
[0074] Ensure that users do not need to care about the existence of metadata when using data fragments. For example, when the application reads data, it automatically parses the metadata in the header and uses this information for subsequent processing; in order to manage different versions of data fragments, version information can be added to the metadata. This helps with data update and migration operations and ensures data consistency and traceability.
[0075] Data sharding and allocation strategy:
[0076] Choose a suitable data sharding strategy, such as horizontal sharding, vertical sharding, or hash-based sharding. The sharding strategy should maximize the manageability and access efficiency of data, design an effective allocation mechanism, and reasonably distribute data fragments and their metadata to different storage nodes. This is crucial for load balancing and high availability of the system.
[0077] The above method has the following advantages:
[0078] First, it is very convenient to find I frames when searching. You only need to read the fragment header of each metadata fragment first, without having to search in the middle.
[0079] Secondly, if the cache is covered in a loop, it only needs to be covered in ABC order, and there is no need to search from the middle.
[0080] Secondly, if there is a problem with the data, even if the frame header information is wrong, the biggest impact is only the data of the second corresponding to the I frame, and it has no effect on the data of the other two seconds.
[0081] Finally, the granularity of memory allocation is greatly reduced. Figure 4 Allocating 6M frame data now only requires 3 times of 2M, and the granularity is reduced by three times. This is very important for embedded systems with limited resources. It not only improves memory utilization, but also greatly reduces various memory problems.
[0082] Based on the above-described method for a security storage cache, the present invention further provides a device for a security storage cache, including a data storage device, a tag storage body, a valid bit unit, and a single-chip microcomputer, wherein the single-chip microcomputer is electrically connected to the data storage device, the tag storage body, and the valid bit unit, respectively, and the single-chip microcomputer can separate the frame data and metadata in the video, and further slice the cache by I frame for each frame data, wherein the data storage device is used to obtain the video stream in the camera, and the data storage device is the main part of the cache, and is usually implemented using a static random access memory, because the access speed of the memory is fast and can meet the high performance requirements; the tag storage body is used to identify whether the data block in the cache is the correct data requested by the single-chip microcomputer, and the number of tag bits is different under different mapping modes, such as in direct mapping, group associative mapping, and fully associative mapping, the setting of the tag bit will be adjusted according to actual needs;
[0083] The valid bit unit is used to identify whether the data in the cache is valid. When data is copied from the data storage device to the cache, the corresponding valid bit will be set to 1, indicating that the data is currently valid. If the cache is cleared or the data is replaced, the valid bit will be reset to 0. The cache is located between the microcontroller and the data storage body to temporarily store frequently accessed data and instructions, thereby reducing the number of accesses to the slower main memory and improving the overall system performance.
[0084] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for secure storage caching, Features: The steps include: S1. Separate the frame data and metadata in the video, specifically: S11, identifying and extracting metadata through a video analysis tool to obtain frame header metadata; S12, extract the frame header separately and put it into another buffer data; S2. Further fragment the cache by I frame for each frame data, specifically: S21, decoding the video stream to identify the I frame; S22, segmenting the video according to the position of the I frame to obtain segment data; S23. Store the segment data so that the header of each segment data contains metadata of the segment data.
2. A method for secure storage caching according to claim 1, Features: The frame data refers to the time segments of discrete data that the audio or video signal is divided into during the audio and video decoding process. This time segment is a frame, and each frame contains data for subsequent compression, transmission and playback.
3. A method for secure storage caching according to claim 2, Features: The metadata is information describing the frame data. The metadata includes the length of the frame and the timestamp of the frame. Each metadata is set in one-to-one correspondence with the frame data, and each frame data has corresponding frame header information.
4. A method for secure storage caching according to claim 3, Features: In step S11, when identifying and extracting the metadata, it is necessary to ensure that the video parsing tool is compatible with the encoding format of the video file, and then select a suitable tool to perform video parsing and extract the metadata, and then delay the distribution of the metadata.
5. A method for secure storage caching according to claim 4, Features: During delayed allocation, initialization is performed first. Initialization only requires the allocation of one frame fragment and metadata fragment, and then the second, third, and Nth fragments are allocated as needed. If the cache has been read at some point in the middle, a cyclic overwrite is started without the need to allocate new data.
6. A method for secure storage caching according to claim 5, Features: In step S12, the operation steps of extracting the frame header separately and putting it into another buffer data are as follows: A1. In the data transmission protocol, the frame used to mark the beginning of a frame of data is defined as a frame header, and the position of the frame header is identified by detecting specific bytes in the received data stream; A2. Decouple the receiving and processing data, and then temporarily store the decoupled data in a buffer, using a ring buffer to store the frame header; A3. Through single-chip computer programming, when receiving data, once the defined frame header is detected, the data after the frame header is received and stored according to the protocol format; A4. Define a new buffer area for storing the extracted frame header. After confirming the integrity and correctness of a frame of data, extract the frame header data from the original data and store it in the new buffer.
7. A method for secure storage caching according to claim 6, Features: In step S21, the I frame is a key frame, which does not contain temporal prediction or motion compensation. The steps of decoding the video stream are as follows: B1. Obtain video stream data through the camera; B2. Use the video analysis tool to read each frame of the video stream and identify the frame type by analyzing the header frame of the frame data. B3. When an I frame is identified, the I frame data is extracted for processing or analysis.
8. A method for secure storage caching according to claim 7, Features: Step S22, when video is segmented according to the position of I frame, H.264 encoding method is used to identify I frame. When I frame is identified, the position of video segment is determined according to demand to ensure that each segment can be decoded and played independently, and then the video segment is extracted for memory cropping.
9. A method for secure storage caching according to claim 8, Features: When cropping in memory, the frame segments are initially allocated sizes based on the resolution and frame rate. If the resolution and frame rate are adjusted later, the frame segments are adjusted in the same direction.
10. A secure storage cache device, based on a secure storage cache method according to any one of claims 1 to 9, Features: It includes a data memory, a tag storage body, a valid bit unit and a single-chip microcomputer, wherein the single-chip microcomputer is electrically connected to the data memory, the tag storage body and the valid bit unit respectively, the single-chip microcomputer can separate the frame data and metadata in the video, and further slice the cache by I frame for each frame data, the data memory is used to obtain the video stream in the camera, and the tag storage body is used to identify whether the data block in the cache is the correct data requested by the single-chip microcomputer; The valid bit unit is used to identify whether the data in the cache is valid. When data is copied from the data storage to the cache, the corresponding valid bit will be set to 1, indicating that the data is currently valid. If the cache is cleared or the data is replaced, the valid bit will be reset to 0.
