Video data split storage method, device, electronic equipment and storage medium

By using a step-by-step storage method, the first thread and the second thread are used to handle the writing and transfer of video data respectively, which solves the problem of video discontinuity in video surveillance equipment and achieves continuous video images and efficient storage of SD cards.

CN115774796BActive Publication Date: 2026-06-30NINGBO SIMSHINE INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NINGBO SIMSHINE INTELLIGENT TECH CO LTD
Filing Date
2022-07-29
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing video surveillance equipment has a time lag in the creation of temporary folders during the transfer process when storing real-time video images to SD cards. This can cause cached image frames to overflow, resulting in video discontinuity and affecting security and user experience.

Method used

A step-by-step storage method is adopted. The first thread writes the image data frames from the cache queue into the memory area to create a temporary video, and the second thread transfers the temporary video to the storage. The operations of the first and second threads are handled independently, which shortens the interval between closing and creating a new file and avoids the loss of image frames.

Benefits of technology

By using a step-by-step storage method, the continuity of video images is ensured, image frame loss is reduced, and the storage efficiency and lifespan of the SD card are improved. In particular, it significantly improves storage efficiency and space utilization in special devices such as infant care and dashcams.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115774796B_ABST
    Figure CN115774796B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of image storage technology and solves the technical problem of video discontinuity caused by existing storage methods that transfer real-time video images from different folders to SD cards. It provides a method, apparatus, electronic device, and medium for step-by-step video data storage. The method includes transferring video images from the cache queue to the memory area using a first thread, and then transferring the video files from the memory area to a storage device such as an SD card using a second thread. This ensures that the processes of storing video images from the cache queue into the memory area and further transferring them to the SD card are independent. The first thread continuously creates files in the memory area to write the cached video images to the cache queue, while the second thread performs a second transfer of temporary video from the memory area. This controls the time interval between closing the current file and creating the next file in the memory area, preventing data frames corresponding to previously cached images from overflowing and being lost, thus ensuring video continuity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image storage technology, and in particular to a method, apparatus, electronic device, and storage medium for video data split-processing storage. Background Technology

[0002] With the continuous development of the economy and society, video surveillance cameras are widely used in households. As an important tool for home security, video surveillance cameras typically record video continuously in chronological order and write the video data continuously to an SD (Secure Digital Card) for storage, making it convenient for users to record various events happening in their homes.

[0003] SD cards are independent storage devices used in mobile phones, digital cameras, laptops, MP3 players, dashcams, and other digital products. They are generally card-shaped, hence the name "memory card," also known as "digital memory card," "storage card," etc. The storage logic of an SD card is to write one video file per minute. When the SD card is full, it begins to cyclically delete and overwrite the oldest non-event videos, greatly reducing user costs. The steps for storing real-time footage captured by an electronic device to an SD card are as follows: First, a file for storing video images, such as an MP4 file, is created in a temporary file storage area. Then, each frame of video image cached in real-time is stored in this MP4 file. When the number of image frames stored in the MP4 file reaches a preset value, the MP4 file is closed, and then transferred to the SD card or to a target storage path on the SD card. The relevant filename and timestamp information are stored in the recording database. Writing data directly to the SD card frame by frame affects the SD card's storage efficiency, increases the burden on the main controller, and reduces the SD card's lifespan. Simultaneously, after writing to a file, the file is closed, the event information during the recording process of that file is collected and inserted into the database, and then a new file is created to start the next recording task. This linear processing often results in a certain time difference between two recordings. Consequently, video images captured by the cached electronic device during the time difference period are not written to the new file in time, causing dropped frames and affecting the continuity of the footage. This poses a significant risk to the use of security systems, infant care, and dashcams. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide a method, apparatus, electronic device and medium for step-by-step storage of video data, in order to solve the technical problem that existing storage methods, which temporarily store real-time video images to temporary files and then transfer them to a designated folder on an SD card, have a time difference in the creation of new temporary folders during the transfer process, resulting in video discontinuity caused by overflow of cached image frames.

[0005] The technical solution adopted in this invention is:

[0006] This invention provides a method for step-by-step storage of video data, the method comprising:

[0007] S1: Retrieve video data that is cached in the cache queue and is ready to be stored;

[0008] S2: The first thread continuously writes the image data frames of each frame of the image cached in real time in the cache queue into a file created in the memory area to obtain each temporary video;

[0009] S3: The temporary videos in the memory area are transferred to the memory using a second thread that is different from the first thread, to obtain the target videos;

[0010] The data processed by the second thread includes transferring the temporary video from the memory area to the storage device, and recording the file information of the target video.

[0011] Preferably, S2 includes:

[0012] S21: Retrieve the video data to be stored in the cache queue and store it in the video format of a video;

[0013] S22: Based on the video format, create a file in the memory area to store video data using the current timestamp;

[0014] S23: The first thread writes each frame image cached in real time in the cache queue to the file. When the video data stored in the file meets the preset storage rules, the folder is closed to obtain the temporary video.

[0015] S24: Repeat S21 to S23, continuously writing each frame of video image cached in real time in the cache queue to the current file to obtain each temporary video;

[0016] The preset storage rules include at least one of the following: number of image frames, video file size, video duration, and event information recorded during video file recording.

[0017] Preferably, S23 includes:

[0018] S231: Obtain the total number of image frames that can be stored in the file corresponding to the preset storage rule;

[0019] S232: Real-time acquisition of the number of first image frames corresponding to the image frames currently stored in the file;

[0020] S233: When the number of the first image frames equals the total number of images, close the current file to obtain the temporary video.

[0021] Preferably, the 232 includes:

[0022] S2321: Obtain the video frame rate and the read / write speed for transferring video images from the cache queue to the memory area;

[0023] S2322: Determine the number of the first image frames based on the video frame rate and the read / write speed.

[0024] Preferably, S3 includes:

[0025] S31: Obtain the threshold value for the number of times the target event is contained in the target video;

[0026] S32: Perform target detection on each frame of the temporary video to obtain the actual number of times the target event is contained in each temporary video;

[0027] S33: At least two consecutive temporary videos whose actual number of occurrences is less than the event number threshold are spliced ​​together according to the shooting sequence to obtain a video to be transferred;

[0028] S34: Use the second thread to transfer the video to be transferred to the memory to obtain the target video.

[0029] Preferably, S34 includes:

[0030] S341: Obtain each frame of video image of the non-target event in each of the videos to be transferred;

[0031] S342: Perform similarity detection on each frame of the video image of the non-target event, and delete similar video images in the video to be transferred to obtain the basic video;

[0032] S343: Use the second thread to transfer the base video to the memory to obtain the target video.

[0033] Preferably, S342 includes;

[0034] S3421: Obtain the overlap threshold of adjacent video frames;

[0035] S3422: Perform target detection on each frame of video image to obtain the image overlap between two adjacent video images;

[0036] S3423: Video images with an overlap degree greater than or equal to the overlap threshold are recorded as similar images;

[0037] S3424: Similar images of the video to be transferred are deleted according to a preset deletion rule to obtain the basic video.

[0038] The present invention also provides a data storage device, comprising:

[0039] Storage Analysis Module: Used to retrieve video data cached in the cache queue and ready for storage;

[0040] First storage module: Used to continuously write image data frames of each frame of image cached in real time in the cache queue to files created in the memory area through the first thread, so as to obtain each temporary video;

[0041] Second storage module: used to transfer each of the temporary videos in the memory area to the memory through a second thread different from the first thread, so as to obtain each target video;

[0042] The data processed by the second thread includes transferring the temporary video from the memory area to the storage device, and recording the file information of the target video.

[0043] The present invention also provides an electronic device, comprising: at least one processor, at least one memory, and computer program instructions stored in the memory, wherein the computer program instructions, when executed by the processor, implement the method described in any of the preceding embodiments.

[0044] The present invention also provides a storage medium having stored thereon computer program instructions that, when executed by a processor, implement the method described in any of the preceding claims.

[0045] In summary, the beneficial effects of the present invention are as follows:

[0046] This invention provides a method, apparatus, electronic device, and storage medium for step-by-step storage of video data. It stores image data frames of each frame in a cache queue to a memory device such as an SD card or for playback. The method includes first writing the image data frames of each frame in the cache queue into a memory area using a first thread, and then transferring the video file from the memory area to a memory device such as an SD card using a second thread, for later playback and retrieval by an app. The process of writing the image data frames of each frame cached in the cache queue into the memory area and further transferring the temporary video from the memory area to a memory device such as an SD card or for playback are independent of each other. While the first thread creates a new file in the memory area to write the image data frames of the latest cached frames in the cache queue, the second thread can perform a second transfer of the temporary video from the memory area after writing the image data frames of each frame to the target path of the SD card or other memory device, or perform playback operations. This controls the time between closing the current file and creating the next file in the memory area, significantly shortening the interval and preventing the loss of image frames due to overflow caused by the cache queue not being retrieved in time, thus ensuring the continuity of the video images. Attached Figure Description

[0047] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments of the present invention will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort, and these are all within the protection scope of the present invention.

[0048] Figure 1 This is a flowchart illustrating the video data step-by-step storage method in Embodiment 1 of the present invention;

[0049] Figure 2 This is a schematic diagram of the process for obtaining temporary video in Embodiment 1 of the present invention;

[0050] Figure 3 This is a schematic diagram of the process of acquiring the target video in Embodiment 1 of the present invention;

[0051] Figure 4 This is a schematic diagram of the video data step-by-step storage device in Embodiment 2 of the present invention;

[0052] Figure 5 This is a schematic diagram of the electronic device in Embodiment 3 of the present invention. Detailed Implementation

[0053] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. In the description of the present invention, it should be understood that the terms "center," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. Where there is no conflict, the various features in the embodiments and examples of this invention can be combined with each other, all of which are within the scope of protection of this invention.

[0054] As described above, the current methods for storing real-time video data suffer from frame skipping during playback, resulting in the loss of some image frames, causing discontinuity in the video and affecting the user experience.

[0055] To address this problem, the inventors have developed a method, apparatus, device, and storage medium for step-by-step storage of video data. This method divides the video images to be stored in the cache queue into several steps using different threads: First, a first thread performs a first transfer to transfer the image data frames of each frame in the cache queue to a temporary file in memory; then, a second thread performs a second transfer to transfer the temporary video from memory to the target path on an SD card or other storage device for playback. This reduces the correlation between the first and second transfers, significantly shortening the interval between closing the file containing the image data frames of the previously cached frames in memory and creating the next file. This prevents the image data frames of the cached frames captured in real-time by the electronic device from not being stored in the temporary file in memory in a timely manner, ensuring that all image data frames of the cached frames in the cache queue are stored in the corresponding file in memory, thus guaranteeing the integrity and continuity of the video.

[0056] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, other embodiments obtained by those skilled in the art without creative effort are all within the scope of protection of the present invention.

[0057] Example 1

[0058] Please see Figure 1 , Figure 1 This is a flowchart illustrating the video data step-by-step storage method in an embodiment of the present invention. The video data step-by-step storage method of the present invention includes:

[0059] S1: Retrieve video data that is cached in the cache queue and is ready to be stored;

[0060] S2: The first thread continuously writes the image data frames of each frame of the image cached in real time in the cache queue into a file created in the memory area to obtain each temporary video;

[0061] S3: The temporary videos in the memory area are transferred to the memory using a second thread that is different from the first thread, to obtain the target videos;

[0062] The data processed by the second thread includes transferring the temporary video from the memory area to the storage device, and recording the file information of the target video.

[0063] Specifically, the process involves storing image data frames from real-time captured images from electronic devices into storage devices such as SD cards. This includes establishing a cache queue, creating a file in memory to store the image data frames, retrieving cached image data frames from the cache queue and writing them into that file, and closing the folder when the stored image data frames in the memory meet the storage requirements (e.g., at a frame rate of 20fps, recording one video file per minute, closing the file after storing 1200 frames, resulting in a temporary video). This temporary video is then transferred to the target path on the SD card or other storage device, and its timestamp, message event information, video duration, and filename are simultaneously inserted into the storage device. The video database records the data. This application employs a first thread to write the image data frames of each frame in the cache queue into the currently created file in the memory area. A second thread transfers the temporary video corresponding to the previous file in the memory area to the target path of a storage device such as an SD card. This achieves step-by-step independent operation of video data storage, allowing the first thread to continuously extract image data frames from the cache queue and write them into the newly created file in the memory area immediately after the previous file in the memory area is closed. The temporary video corresponding to the file in the memory area that has completed video storage is then processed further (analyzing each frame to determine whether different temporary videos need to be merged, image frames deleted, etc.). The data is transferred directly to the SD card or played back via the second thread. The first and second threads are two independent threads, which can belong to the same thread pool or different thread pools. This method reduces the waiting time in the memory area when transferring a file to the SD card after the current file in the memory area is closed, due to the read / write speed of the SD card and the file size. It also avoids the electronic device continuously caching image data frames of each captured frame, which could lead to the overflow of the first cached image frame. Furthermore, it avoids the need to use multiple threads for file creation in the memory area, thus saving computer resources and reducing the waiting time from closing the current file to creating the next file. Additionally, the use of independent threads... The process involves transferring files from the memory area. For certain special files in the memory area, further processing is required before transferring them to storage devices such as SD cards, thus achieving flexibility in video data storage. Special files include video data captured by infant smart monitoring devices when infants are asleep. Because infants' activity levels decrease during sleep, multiple video files may contain very similar content. Therefore, images in these folders can be deleted and merged in the memory area before being transferred to the SD card. This reduces unnecessary video storage and improves the utilization rate of SD card storage space. Special files include, but are not limited to, video data from the infant monitoring process; they can also include video data collected by dashcams, without specific limitations.Performing content analysis on video data stored in memory before deciding whether to transfer it directly or further edit and synthesize it before transfer has a significant effect on improving storage efficiency and reducing the frequency of data erasure for devices using circular storage.

[0064] It should be noted that the electronic device is at least one of the following: intelligent infant care device, ordinary camera, dashcam, mobile phone, tablet computer, or other mobile or fixed terminal with image acquisition function.

[0065] This embodiment provides a step-by-step video data storage method that stores image data frames of each frame of an image to be stored in a cache queue to a storage device such as an SD card or for playback. The method includes first writing the image data frames of each frame of an image in the cache queue into a memory area using a first thread, and then transferring the video file from the memory area to a storage device such as an SD card using a second thread, so that the APP can later play back or query the video. The process of writing the image data frames of each frame of an image cached in the cache queue into the memory area, and further transferring the temporary video from the memory area to a storage device such as an SD card or for playback, are independent of each other. While the first thread creates a new file in the memory area to write the image data frames of the latest cached frames of an image in the cache queue, the second thread can perform a second transfer of the temporary video from the memory area after the image data frames of each frame of an image have been written to the target path of the SD card or other storage device, or perform playback operations. This controls the time from closing the current file in the memory area to creating the next file, and greatly shortens the interval, avoiding the loss of image frames due to overflow caused by the cache queue not being retrieved in time, thus ensuring the continuity of the video images.

[0066] In one embodiment, please refer to Figure 2 S2 includes:

[0067] S21: Obtain the video format for storing the video data to be stored in the cache queue as a video;

[0068] S22: Based on the video format, create a file in the memory area to store video data using the current timestamp;

[0069] S23: The first thread writes each frame image cached in real time in the cache queue to the file. When the video data stored in the file meets the preset storage rules, the folder is closed to obtain the temporary video.

[0070] S24: Repeat S21 to S23, continuously writing the image data frames of each frame of the image cached in real time in the cache queue to the current file to obtain each temporary video;

[0071] The preset storage rules include at least one of the following: number of image frames, video file size, video duration, and event information recorded during video file recording.

[0072] Specifically, video formats include, but are not limited to, MP4 format and raw stream files. Raw stream files generally refer to video data that the acquisition device itself and its corresponding App can directly read or play. When the video data is a raw stream file, it needs to be decrypted into other video formats before it can be played by the corresponding playback software. After determining that the image frames in the buffer queue will be stored in the corresponding format, a file for storing the image data frames of each frame is created in the memory area with the current timestamp. Then, the image data frames of each frame cached in the buffer queue are continuously written to this file in the corresponding format. After the current file finishes writing the video data, the file is closed to obtain a temporary video. The first thread is immediately used to create a new file to continue writing the image data frames of each frame cached in the buffer queue. This shortens the interval between closing the current file in the memory area and creating the next file, avoiding the loss of image frames due to overflow caused by the buffer queue not being retrieved in time, and ensuring the continuity of the video images.

[0073] In one embodiment, S23 includes:

[0074] S231: Obtain the total number of image frames or the total amount of video data that can be stored in the file corresponding to the preset storage rule;

[0075] S232: Real-time acquisition of the number of first image frames corresponding to the image frames currently stored in the file or the real-time data volume of video data;

[0076] S233: When the number of the first image frames is equal to the total number of images, or the amount of real-time data is equal to the total amount of data, close the current file to obtain the temporary video.

[0077] Specifically, the timing of closing a file is determined by the maximum number of image frames that the file created in the memory area can store or the amount of data that the file can store. When the number of the first image frames of the video images stored in the file reaches the total number of images or the amount of data stored in the file reaches the total amount of data, the file is closed to prevent the image data in the buffer queue from being written to the file, resulting in a temporary video. For example, if the total number of images is 1200 frames, at a frame rate of 20fps, the required video recording duration is 60 seconds.

[0078] In one embodiment, if the preset storage rule is the amount of video data to be written to the memory area file, then step S233 includes:

[0079] S2331: When the real-time data volume is equal to the total data volume, determine whether the last written first video data and the second video data in the cache queue to be written are the same frame image;

[0080] S2332: If they belong to the same frame image, then analyze the data volume of the second video data and / or the first video data to obtain the analysis result;

[0081] S2333: Based on the analysis results, determine whether to write the second video data and the first video data into the current file of the memory area or into the next file of the memory area, so as to obtain the temporary video corresponding to the current file.

[0082] Specifically, after the amount of video data written to the current file in the memory area reaches the preset total amount of data, the last written video data is recorded as the first video data, and the video data about to be written in the cache queue is recorded as the second video data. If the first video data and the second video data belong to the same frame image, the amount of the first video data and / or the second video data is judged. Based on the analysis result, it is determined whether the first video data and the second video data of the frame image are written to the previous folder or the next folder. The specific analysis method includes, but is not limited to: obtaining the amount of data of the frame image, setting the threshold of the amount of first data already written to the memory area as 'a', and if the amount of data of the first video data accounts for the amount of data of the frame image... If the percentage of the second video data is greater than 'a', then all data of the frame image is written to the current folder; if it is less than 'a', then all data of the frame image is written to the next folder. Alternatively, set the threshold for the amount of second data not written to the memory area to 'b'. If the percentage of the second video data to the amount of the frame image is greater than 'b', then all data of the frame image is written to the next folder; if it is less than 'b', then all data of the frame image is written to the current folder. Or compare the first video data and the second video data. If the first video data is greater than or equal to the second video data, then the first video data and the second video data are written to the current folder of the memory area; otherwise, both the first video data and the second video data are written to the next folder of the memory area.

[0083] In one embodiment, 232 includes:

[0084] S2321: Obtain the video frame rate and the read / write speed for transferring video images from the cache queue to the memory area;

[0085] S2322: Determine the number of the first image frames to be written to the file based on the video frame rate and the read / write speed.

[0086] Specifically, the video frame rate is the number of image frames captured per second by an electronic device (camera). For example, a video frame rate of 20 frames / second means that the camera captures 20 images per second. The read / write speed determines the time required to write data from the cache queue to the memory area or from the memory area to a storage device such as an SD card. The number of image frames currently stored in the memory area is calculated based on the data write speed.

[0087] In one embodiment, please refer to Figure 3 S3 includes:

[0088] S31: Obtain the threshold value for the number of times the target event is contained in the target video;

[0089] S32: Perform target detection on each frame of the temporary video to obtain the actual number of times the target event is contained in each temporary video;

[0090] S33: At least two consecutive temporary videos whose actual number of occurrences is less than the event number threshold are spliced ​​together according to the shooting sequence to obtain a video to be transferred;

[0091] S34: Use the second thread to transfer the video to be transferred to the memory to obtain the target video.

[0092] Specifically, whether it's the 24-hour monitoring of infants by smart baby care devices or the recordings of vehicles by dashcams, a large amount of meaningless video data exists. This type of data occupies too much storage space, such as video data collected when the infant is asleep or when the vehicle is stationary. This causes SD cards or other storage devices to quickly run out of space and be erased, consuming computer resources and shortening the lifespan of the memory. After video images in the cache queue are written to the memory area, target detection is performed on each frame. When at least two consecutive video files in the memory area contain a target... If the number of video files is less than the preset value, the two video files will be combined into one file, which helps improve the efficiency of transferring video files to SD cards or other storage devices. At the same time, during loop recording, multiple unimportant videos are combined into one video. When the storage device needs to erase this part of the video data, only one erase is required to free up a lot of storage space, reducing the number of erases and extending the life of the storage device. Target events include, but are not limited to: crying, laughing, crawling, eating, sleeping, etc. of infants and toddlers corresponding to infant and toddler smart care devices, and lane changing, emergency braking, etc. of vehicles corresponding to dashcams, etc., which are not listed here.

[0093] In one embodiment, S34 includes:

[0094] S341: Obtain each frame of video image of the non-target event in each of the videos to be transferred;

[0095] S342: Perform similarity detection on each frame of the video image of the non-target event, and delete similar video images in the video to be transferred to obtain the basic video;

[0096] S343: Use the second thread to transfer the base video to the memory to obtain the target video.

[0097] Specifically, target analysis is performed on each video file in the memory area, dividing each frame of the video file into frames of non-target time periods and frames of target events. Similarity detection is performed on the frames of non-target events; if the similarity of multiple consecutive frames meets the requirements, they are deleted, retaining only the event information that can represent that time period. This reduces the size of the base video, saving storage space on SD cards or other memory devices. For example, when an infant is in a static sleeping state, the captured images are long-term still images; therefore, only a portion of the image frames need to be retained to represent the infant's sleeping state, while other image frames can be deleted to free up memory space. Similarly, for dashcams, when a vehicle is parked in an enclosed space for a long time, the captured still images can also be processed accordingly to free up storage space.

[0098] In one embodiment, S342 includes;

[0099] S3421: Obtain the overlap threshold of adjacent video frames;

[0100] S3422: Perform target detection on each frame of video image to obtain the image overlap between two adjacent video images;

[0101] S3423: Video images with an overlap degree greater than or equal to the overlap threshold are recorded as similar images;

[0102] S3424: Similar images of the video to be transferred are deleted according to a preset deletion rule to obtain the basic video.

[0103] Specifically, the similarity between different image frames is determined by detecting the overlap between two adjacent image frames. For example, in the detection of infants and young children, the overlap between different image frames can be determined by the imaging position of the infant's face or other body parts in the image. Multiple consecutive images with an overlap greater than the overlap threshold are deleted, thereby reducing the file size of the base video.

[0104] This embodiment provides a step-by-step video data storage method that stores image data frames of each frame of an image to be stored in a cache queue to a storage device such as an SD card or for playback. The method includes first writing the image data frames of each frame of an image in the cache queue into a memory area using a first thread, and then transferring the video file from the memory area to a storage device such as an SD card using a second thread, so that the APP can later play back or query the video. The process of writing the image data frames of each frame of an image cached in the cache queue into the memory area, and further transferring the temporary video from the memory area to a storage device such as an SD card or for playback, are independent of each other. While the first thread creates a new file in the memory area to write the image data frames of the latest cached frames of an image in the cache queue, the second thread can perform a second transfer of the temporary video from the memory area after the image data frames of each frame of an image have been written to the target path of the SD card or other storage device, or perform playback operations. This controls the time from closing the current file in the memory area to creating the next file, and greatly shortens the interval, avoiding the loss of image frames due to overflow caused by the cache queue not being retrieved in time, thus ensuring the continuity of the video images.

[0105] Example 2

[0106] Embodiment 2 of the present invention also provides a video data storage device, such as... Figure 4 As shown, the device includes:

[0107] Storage Analysis Module: Used to retrieve video data cached in the cache queue and ready for storage;

[0108] First storage module: Used to continuously write image data frames of each frame of image cached in real time in the cache queue to files created in the memory area through the first thread, so as to obtain each temporary video;

[0109] Second storage module: used to transfer each of the temporary videos in the memory area to the memory through a second thread different from the first thread, so as to obtain each target video;

[0110] The data processed by the second thread includes transferring the temporary video from the memory area to the storage device, and recording the file information of the target video.

[0111] The video data step-by-step storage device of this embodiment stores the image data frames of each frame of the image to be stored in the cache queue to a memory such as an SD card or for playback. This includes firstly writing the image data frames of each frame of the image in the cache queue into the memory area using a first thread, and then using a second thread to transfer the video file in the memory area to a memory such as an SD card for later playback and query by the APP. The process of writing the image data frames of each frame of the image in the cache queue into the memory area and further transferring the temporary video in the memory area to a memory such as an SD card or for playback are independent of each other. While the first thread creates a new file in the memory area to write the image data frames of the latest cached frames of the image in the cache queue, the second thread can transfer the temporary video in the memory area after the image data frames of each frame of the image have been written to the target path of the SD card or other memory for the second time, or perform playback operations, so that the time from closing the current file in the memory area to the creation of the next file is controlled and the interval time is greatly shortened. This avoids the loss of image frames due to overflow caused by the image frames cached earlier in the cache queue not being retrieved in time, thus ensuring the continuity of video images.

[0112] In one embodiment, the first storage module includes:

[0113] Format acquisition unit: Acquires the video format for storing video data to be stored in the cache queue as a video file;

[0114] File creation unit: Based on the video format, create a file in the memory area to store video data using the current timestamp;

[0115] File storage unit: The first thread writes each frame image cached in real time in the cache queue to the file. When the video data stored in the file meets the preset storage rules, the folder is closed to obtain the temporary video.

[0116] Continuous storage unit: Repeat the above steps to continuously write each frame of video image cached in real time in the cache queue to the current file to obtain each temporary video;

[0117] The preset storage rules include at least one of the following: number of image frames, video file size, video duration, and event information recorded during video file recording.

[0118] In one embodiment, the file storage unit includes:

[0119] Image Count Acquisition Unit: Acquires the total number of image frames that can be stored in the file corresponding to the preset storage rule;

[0120] Image storage counting unit: Real-time acquisition of the number of first image frames corresponding to the image frames currently stored in the file;

[0121] Temporary file generation unit: When the number of the first image frames is equal to the total number of images, the current file is closed to obtain the temporary video.

[0122] In one embodiment, the image storage counting unit includes:

[0123] Parameter acquisition unit: acquires the video frame rate and the read / write speed for transferring video images from the cache queue to the memory area;

[0124] Image Count Calculation Unit: Determines the number of the first image frames based on the video frame rate and the read / write speed.

[0125] In one embodiment, the second storage unit includes:

[0126] Target event threshold unit: Obtains the threshold number of events containing the target event in the target video;

[0127] Target event counting unit: Performs target detection on each frame of the temporary video to obtain the actual number of times the target event is contained in each temporary video;

[0128] Video stitching unit: stitches together at least two consecutive temporary videos whose actual number of occurrences is less than the event number threshold according to the shooting time sequence to obtain a video to be transferred;

[0129] Target video storage unit: The second thread is used to transfer the video to be transferred to the memory to obtain the target video.

[0130] In one embodiment, the target video storage unit includes:

[0131] Target image acquisition unit: acquires video images of each frame of non-target events in each of the videos to be transferred;

[0132] Image deletion unit: performs similarity detection on each frame of video images of the non-target event, and deletes similar video images in the video to be transferred to obtain the basic video;

[0133] Second transfer unit: The second thread is used to transfer the basic video to the memory to obtain the target video.

[0134] In one embodiment, the image reduction unit includes;

[0135] Overlap threshold unit: Obtain the overlap threshold of adjacent video images;

[0136] Overlap calculation unit: Performs target detection on each frame of video image and obtains the overlap between two adjacent video images;

[0137] Similar image filtering unit: Video images with an overlap degree greater than or equal to the overlap threshold are recorded as similar images;

[0138] Basic video generation unit: Deletes similar images of the video to be transferred according to preset deletion rules to obtain the basic video.

[0139] The video data step-by-step storage device of this embodiment stores the image data frames of each frame of the image to be stored in the cache queue to a memory such as an SD card or for playback. This includes firstly writing the image data frames of each frame of the image in the cache queue into the memory area using a first thread, and then using a second thread to transfer the video file in the memory area to a memory such as an SD card for later playback and query by the APP. The process of writing the image data frames of each frame of the image in the cache queue into the memory area and further transferring the temporary video in the memory area to a memory such as an SD card or for playback are independent of each other. While the first thread creates a new file in the memory area to write the image data frames of the latest cached frames of the image in the cache queue, the second thread can transfer the temporary video in the memory area after the image data frames of each frame of the image have been written to the target path of the SD card or other memory for the second time, or perform playback operations, so that the time from closing the current file in the memory area to the creation of the next file is controlled and the interval time is greatly shortened. This avoids the loss of image frames due to overflow caused by the image frames cached earlier in the cache queue not being retrieved in time, thus ensuring the continuity of video images.

[0140] This invention provides an electronic device and a storage medium, such as Figure 5 As shown, it includes at least one processor, at least one memory, and computer program instructions stored in the memory.

[0141] Specifically, the processor may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of the present invention. The electronic device includes at least one of the following: a smart camera, a mobile device with a smart camera, or a wearable device with a smart camera.

[0142] The memory may include a large-capacity storage device for data or instructions. For example, and not limitingly, the memory may include a hard disk drive (HDD), a floppy disk drive, flash memory, an optical disk drive, a magneto-optical disk drive, magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory may include removable or non-removable (or fixed) media. Where appropriate, the memory may be internal or external to a data processing device. In a particular embodiment, the memory is a non-volatile solid-state memory. In a particular embodiment, the memory includes a read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or flash memory, or a combination of two or more of these.

[0143] The processor reads and executes computer program instructions stored in the memory to implement any of the video data step-by-step storage methods in Embodiment 1 above.

[0144] In one example, the electronic device may also include a communication interface and a bus. The processor, memory, and communication interface are connected via the bus and communicate with each other.

[0145] The communication interface is mainly used to enable communication between various modules, devices, units and / or equipment in the embodiments of the present invention.

[0146] A bus, including hardware, software, or both, couples components of an electronic device together. For example, and not limitingly, a bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, a bus may include one or more buses. While specific buses are described and illustrated in embodiments of the invention, the invention contemplates any suitable bus or interconnect.

[0147] In summary, the embodiments of the present invention provide a method, apparatus, device, and storage medium for video data splitting and storage.

[0148] It should be clarified that the present invention is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of the present invention.

[0149] The functional blocks shown in the above-described structural diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this invention are programs or code segments used to perform the required tasks. The programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.

[0150] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for storing video data in stages, characterized in that, The method includes: S1: Retrieve video data that is cached in the cache queue and is ready to be stored; S2: The first thread continuously writes the image data frames of each frame of the image cached in real time in the cache queue into a file created in the memory area to obtain each temporary video; S3: The temporary videos in the memory area are transferred to the memory using a second thread that is different from the first thread, to obtain the target videos; The data processed by the second thread includes transferring the temporary video from the memory area to the storage device, and recording the file information of the target video. Wherein, S3 includes: S31: Obtain the threshold value for the number of times the target event is contained in the target video; S32: Perform target detection on each frame of the temporary video to obtain the actual number of times the target event is contained in each temporary video; S33: At least two consecutive temporary videos whose actual number of occurrences is less than the event number threshold are spliced ​​together according to the shooting sequence to obtain a video to be transferred; S34: Use the second thread to transfer the video to be transferred to the memory to obtain the target video.

2. The video data step-by-step storage method according to claim 1, characterized in that, S2 includes: S21: Obtain the video format for storing the video data to be stored in the cache queue as a video; S22: Based on the video format, create a file in the memory area to store video data using the current timestamp; S23: The first thread writes the image data frames of each frame of the real-time cached image in the cache queue to the file. When the video data stored in the file meets the preset storage rules, the file is closed to obtain the temporary video. S24: Repeat S21 to S23, continuously writing the image data frames of each frame of the image cached in real time in the cache queue to the current file to obtain each temporary video; The preset storage rules include at least one of the following: number of image frames, video file size, video duration, and event information recorded during video file recording.

3. The video data step-by-step storage method according to claim 2, characterized in that, S23 includes: S231: Obtain the total number of image frames that can be stored in the file corresponding to the preset storage rule; S232: Real-time acquisition of the number of first image frames corresponding to the image frames currently stored in the file; S233: When the number of the first image frames equals the total number of images, close the current file to obtain the temporary video.

4. The video data step-by-step storage method according to claim 3, characterized in that, The 232 includes: S2321: Obtain the video frame rate and the read / write speed for transferring video images from the cache queue to the memory area; S2322: Determine the number of the first image frames based on the video frame rate and the read / write speed.

5. The video data step-by-step storage method according to claim 1, characterized in that, S34 includes: S341: Obtain each frame of video image of the non-target event in each of the videos to be transferred; S342: Perform similarity detection on each frame of the video image of the non-target event, and delete similar video images in the video to be transferred to obtain the basic video; S343: Use the second thread to transfer the base video to the storage device to obtain the target video.

6. The video data step-by-step storage method according to claim 5, characterized in that, S342 includes; S3421: Obtain the overlap threshold of adjacent video frames; S3422: Perform target detection on each frame of video image to obtain the image overlap between two adjacent video images; S3423: Video images with an overlap degree greater than or equal to the overlap threshold are recorded as similar images; S3424: Similar images of the video to be transferred are deleted according to a preset deletion rule to obtain the basic video.

7. A data storage device, characterized in that, include: Storage Analysis Module: Used to retrieve video data cached in the cache queue and ready for storage; First storage module: Used to continuously write image data frames of each frame of image cached in real time in the cache queue to files created in the memory area through the first thread, so as to obtain each temporary video; Second storage module: used to transfer each of the temporary videos in the memory area to the memory through a second thread different from the first thread, so as to obtain each target video; The data processed by the second thread includes transferring the temporary video from the memory area to the storage device, and recording the file information of the target video. The step of transferring each temporary video from the memory area to the storage device using a second thread different from the first thread to obtain each target video includes: Obtain the threshold number of events containing the target event in the target video; Target detection is performed on each frame of the temporary video to obtain the actual number of times the target event is contained in each temporary video; At least two consecutive temporary videos whose actual number of occurrences is less than the event number threshold are stitched together according to their shooting time sequence to obtain a video to be transferred. The second thread is used to transfer the video to be transferred to the memory to obtain the target video.

8. An electronic device, characterized in that, include: At least one processor, at least one memory, and computer program instructions stored in the memory, which, when executed by the processor, implement the method as described in any one of claims 1-6.

9. A storage medium storing computer program instructions thereon, characterized in that, The method as described in any one of claims 1-6 is implemented when the computer program instructions are executed by the processor.