CN115774796A - Video data step-by-step storage method and device, electronic equipment and storage medium - Google Patents

Video data step-by-step storage method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115774796A
CN115774796A CN202210908664.2A CN202210908664A CN115774796A CN 115774796 A CN115774796 A CN 115774796A CN 202210908664 A CN202210908664 A CN 202210908664A CN 115774796 A CN115774796 A CN 115774796A
Authority
CN
China
Prior art keywords
video
image
file
frame
data
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
CN202210908664.2A
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.)
Ningbo Xingxun Intelligent Technology Co ltd
Original Assignee
Ningbo Xingxun Intelligent Technology 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 Ningbo Xingxun Intelligent Technology Co ltd filed Critical Ningbo Xingxun Intelligent Technology Co ltd
Priority to CN202210908664.2A priority Critical patent/CN115774796A/en
Publication of CN115774796A publication Critical patent/CN115774796A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Television Signal Processing For Recording (AREA)

Abstract

The invention belongs to the technical field of image storage, solves the technical problem of video discontinuity in the existing storage mode that real-time video images are transferred to an SD card after being stored in different folders, and provides a method, a device, electronic equipment and a medium for storing video data step by step. The method comprises the steps that video images of a cache queue are transferred to a memory area through a first thread, and then video files in the memory area are transferred to a memory such as an SD card through a second thread; the processes of storing the video images in the cache queue into the memory area and further transferring the video images to the SD card are mutually independent, so that a first thread continuously establishes a file in the memory area for writing the video images cached in the cache queue, and a second thread is used for transferring the temporary video in the memory area for the second time, so that the time interval from the closing of the current file in the memory area to the creation of the next file is controlled, the loss of data frames corresponding to the images cached in the cache queue in advance due to overflow is avoided, and the continuity of the video is ensured.

Description

Video data step-by-step storage method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of image storage, in particular to a method and a device for storing video data step by step, electronic equipment and a storage medium.
Background
With the continuous development of economic society, video surveillance cameras are widely applied to thousands of households. As an important tool for home security, a video monitoring camera usually records video continuously according to a time sequence, and writes video data into an SD (Secure Digital Card) Card continuously for storage, so as to facilitate a user to record various events occurring at home.
The SD card is suitable for independent memories on mobile phones, digital cameras, portable computers, MP3 s, automobile data recorders, and other digital products, and is generally in the form of a card, and is called a "memory card", which is also called a "digital memory card", a "memory card", and the like. The storage logic of the SD card is that one video file is written every minute; when the SD card is full, the method starts to circularly delete and cover the earliest non-event video, so that the use cost of a user is greatly reduced, and the steps required for storing the real-time pictures acquired by the electronic equipment to the SD are as follows: firstly, establishing a file for storing video images, such as an MP4 file, in a temporary file storage area; and then storing each frame of video image cached in the cache queue in real time into the MP4 file, closing the MP4 file when the number of image frames stored in the MP4 file reaches a preset value, then transferring the MP4 file to the SD card or transferring the MP4 file to a target storage path in the SD card, and storing related file name and time stamp information into a recording database, wherein the operation of directly writing data on the SD card frame by frame can influence the storage efficiency of the SD card, increase the burden of main control, and reduce the service life of the SD card. And after a file is written, closing the file, counting event information in the file recording process, inserting the counted event information into the database, and then creating a new file to start the next video recording task. The linear processing process often causes a certain time difference between two videos, so that a video image acquired by the electronic equipment is not written into a new file in time within a time period corresponding to the time difference, image frame loss is caused, and continuity of the image is affected, which has great hidden danger for security protection, infant care and use of a drive recorder.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, an electronic device, and a medium for storing video data step by step, so as to solve the technical problem that in the existing storage manner in which a real-time video image is temporarily stored in a temporary file and then is transferred to an SD card designated folder, there is a time difference between establishment of a new temporary folder in the transfer process, so that the video is discontinuous due to overflow of a cached image frame.
The technical scheme adopted by the invention is as follows:
the invention provides a method for storing video data step by step, which comprises the following steps:
s1: acquiring video data to be stored cached in a cache queue;
s2: continuously writing the image data frames of each frame of image cached in the cache queue in real time into a file created in the memory area through the first thread to obtain each temporary video;
s3: transferring each temporary video in a memory area to a memory through a second thread different from the first thread to obtain each target video;
the data processed by the second thread comprises the temporary video in the memory area is transferred to a memory, and the file information of the target video is recorded.
Preferably, the S2 includes:
s21: acquiring video data to be stored in a cache queue and storing the video data as a video format of a video;
s22: according to the video format, creating a file for storing video data in a memory area by using a current timestamp;
s23: writing each frame of image cached in a cache queue in real time into the file through the first thread, and closing the folder to obtain the temporary video after video data stored in the file conforms to a preset storage rule;
s24: repeating S21 to S23, and continuously writing each frame of video image cached in the cache queue in real time into the current file to obtain each temporary video;
wherein the preset storage rule at least comprises one of the following rules: the number of image frames, the size of a video file, the video duration and event information recorded in the recording process of the video file.
Preferably, the S23 includes:
s231: acquiring the total number of images of image frames which can be stored in the file corresponding to the preset storage rule;
s232: acquiring the number of first image frames corresponding to the stored image frames in the current file in real time;
s233: and when the number of the first image frames is equal to the total number of the images, closing the current file to obtain the temporary video.
Preferably, the 232 includes:
s2321: acquiring a video frame rate and a reading and writing speed for transferring the video images of the cache queue to a memory area;
s2322: and determining the number of the first image frames according to the video frame rate and the read-write speed.
Preferably, the S3 includes:
s31: acquiring an event number threshold value containing a target event in the target video;
s32: performing target detection on each frame of video image of each temporary video to obtain the actual times of each temporary video including the target event;
s33: splicing at least two continuous temporary videos of which the actual times are smaller than the event time threshold value according to a shooting time sequence to obtain a video to be stored;
s34: and transferring the video to be transferred and stored to a memory by utilizing the second thread to obtain the target video.
Preferably, the S34 includes:
s341: acquiring each frame of video image of a non-target event in each video to be stored;
s342: carrying out similarity detection on each frame of video image of the non-target event, and deleting similar video images in the video to be dumped to obtain a basic video;
s343: and transferring the basic video to a memory by utilizing the second thread to obtain the target video.
Preferably, said S342 comprises;
s3421, acquiring a coincidence degree threshold value of adjacent frame video images;
s3422: carrying out target detection on each frame of video image to obtain the image coincidence ratio of two adjacent frames of video images;
s3423: recording the video image with the contact ratio greater than or equal to the contact ratio threshold value as a similar image;
s3424: and deleting the similar images of the video to be unloaded and stored according to a preset deleting rule to obtain the basic video.
The present invention also provides a data storage device comprising:
a storage analysis module: the video data caching device is used for acquiring video data to be stored cached in a caching queue;
a first storage module: the image data frames of each frame of image cached in the cache queue in real time are continuously written into a file created in the memory area through the first thread to obtain each temporary video;
a second storage module: the temporary videos in the memory area are transferred to a memory through a second thread different from the first thread, and target videos are obtained;
the data processed by the second thread comprises the temporary video in the memory area transferred to the memory and the file information of the target video recorded.
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 that, when executed by the processor, implement the method of any of the above.
The present invention also provides a storage medium having stored thereon computer program instructions which, when executed by a processor, implement the method of any one of the above.
In conclusion, the beneficial effects of the invention are as follows:
the invention provides a video data step-by-step storage method, a device, electronic equipment and a storage medium, which are used for storing image data frames of each frame of image to be stored in a cache queue into a memory such as an SD card or playing the image data frames, and comprise the steps of firstly writing the image data frames of each frame of image in the cache queue into a memory area by using a first thread and transferring a video file in the memory area to the memory such as the SD card by using a second thread so as to facilitate the playback and query of an APP end at the later stage; the invention writes the image data frames of each frame of image cached in the cache queue into the memory area, and further transfers and plays the temporary video of the memory area to the storage such as the SD card and the like independently, when a first thread establishes a new file in the memory area for writing the image data frame of each frame of image cached latest in the cache queue, a second thread can transfer and store the temporary video written by the image data frames of each frame of image in the memory area for the second time to the SD card or the target path of other storage or play and the like, so that the creation time from the closing of the current file to the next file in the memory area is controlled, the interval time is greatly shortened, the image frame loss caused by the overflow of the image frame cached in the cache queue before is avoided because the image frame is not taken out in time, and the continuity of the video image is ensured.
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, and for those skilled in the art, without making creative efforts, other drawings can be obtained according to the drawings, and these drawings are all within the protection scope of the present invention.
Fig. 1 is a schematic flow chart of a method for storing video data step by step in embodiment 1 of the present invention;
fig. 2 is a schematic flowchart of acquiring a temporary video in embodiment 1 of the present invention;
fig. 3 is a schematic flowchart of acquiring a target video according to embodiment 1 of the present invention;
FIG. 4 is a schematic structural diagram of a video data step-by-step storage apparatus according to embodiment 2 of the present invention;
fig. 5 is a schematic structural diagram of an electronic device in embodiment 3 of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention. It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. In the description of the present invention, it is to be understood that the terms "center", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", and the like indicate orientations or positional relationships based on those shown in the drawings, and are only for convenience of description and simplicity of description, and do not indicate or imply that the referenced devices or elements must have a particular orientation, be constructed in a particular orientation, and be operated, and thus, are not to be construed as limiting the present invention. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising … …" does not exclude the presence of another like element in a process, method, article, or apparatus that comprises the element. In case of conflict, it is intended that the embodiments of the present invention and the individual features of the embodiments may be combined with each other within the scope of the present invention.
As described above, the current method for storing real-time video data has the problem of image frame skipping during playback, which causes image discontinuity due to partial image frame loss and affects user experience.
In order to solve the problem, the inventor provides a method, a device, equipment and a storage medium for storing video data step by step, and divides video images to be stored in a cache queue into: the image data frames of each frame of image in the cache queue are transferred to a temporary file of the memory area through first transfer by using a first thread, and then the temporary video of the memory area is transferred to a target path of a storage such as an SD card or the like or played by using a second thread through second transfer; the relevance of the first unloading and the second unloading is reduced, so that the interval time from the closing of a previous file for storing the image data frame of each frame of image cached in the cache queue in real time in the memory area to the establishment of a next file is greatly shortened, the situation that the image data frame of each frame of image cached in the electronic equipment is not timely stored in a temporary file of the memory area is avoided, the situation that the image data frame of each frame of image cached in the cache queue is stored in a file corresponding to the memory area is ensured, and the integrity and the continuity of the video are ensured.
In order to make those skilled in the art better understand the technical solutions of the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all the embodiments. Other embodiments, which can be derived by one of ordinary skill in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example 1
Referring to fig. 1, fig. 1 is a schematic flow chart of a step-by-step video data storage method according to an embodiment of the present invention, where the step-by-step video data storage method includes:
s1: acquiring video data to be stored cached in a cache queue;
s2: continuously writing the image data frames of each frame of image cached in the cache queue in real time into a file created in the memory area through a first thread to obtain each temporary video;
s3: transferring each temporary video in a memory area to a memory through a second thread different from the first thread to obtain each target video;
the data processed by the second thread comprises the temporary video in the memory area transferred to the memory and the file information of the target video recorded.
Specifically, the method comprises the steps of establishing a buffer queue, establishing a file for storing image data frames of each frame of image in a memory area, extracting the image data frames of each frame of image from the buffer queue, writing the image data frames of each frame of image into the file, closing a folder when the image data frames stored in the file in the memory area meet the storage requirement (for example, a video file is recorded at a frame rate of 20fps every minute, namely, the file is closed after the file is stored in 1200 frames of images to obtain a temporary video), transferring the temporary video to a target path of the memory such as SD, and simultaneously inserting information such as a timestamp, message event information, video duration, file name and the like of the temporary video into a video database for recording; the method comprises the steps that a first thread is adopted to write image data frames of each frame of image in a cache queue into a file currently established in a memory area, a second thread is adopted to transfer a temporary video corresponding to the previous file in which the video is stored in the memory area to a target path of a storage such as an SD card and the like, and step-by-step independent operation of video data storage is realized, so that after the first thread is continuously closed in the previous file in the memory area, a new file is immediately established to continuously extract the image data frames of each frame of image from the cache queue and write the image data frames into the newly-established file in the memory area, the temporary video corresponding to the file in which the video is stored in the memory area is subjected to next processing (analysis of each frame of image is carried out, whether different temporary videos need to be combined, image frame deletion and the like or not) or is directly transferred from the second thread to the SD or played, the first thread and the second thread are two independent threads, and the first thread and the second thread can belong to the same thread pool or different thread pools; by the method, the waiting time for establishing a new file in the memory area due to the reading-writing speed and the file size of the SD card when the current file in the memory area is closed and the file is transferred to the SD card can be reduced; the method has the advantages that the phenomenon that the image frame cached at first overflows due to the fact that the electronic equipment caches the image data frames of all the acquired frames of images continuously is avoided, meanwhile, the situation that a plurality of threads are used for establishing the files in the memory area is avoided, waiting time caused by closing the current files in the memory area to establishing the next files is reduced, computer resources are saved, meanwhile, the independent threads are adopted for transferring the files in the memory area, and the files can be transferred to memories such as an SD card and the like after being further processed aiming at some special files in the memory area, so that the flexibility of storing video data is realized; special documents are as follows: the contents of a plurality of video files are very close to each other due to the fact that the activity of the infant is reduced when the infant is sleeping, and therefore the video data shot by the infant intelligent nursing device can be transferred to the SD card after the image deletion and combination of the folders are carried out in the memory area, so that unnecessary video storage is reduced, and the utilization rate of the storage space of the SD card is improved; the special file comprises part of video data not limited to the nursing process of the infant, and also can be part of video data collected by a vehicle event data recorder, which is not particularly limited; the video data stored in the memory area is firstly subjected to content analysis and then determined to be directly transferred, or is further transferred after deletion and synthesis, so that the method has very remarkable effects of improving the storage efficiency and reducing the erasing frequency of the stored data for equipment adopting circular storage.
It should be noted that: the electronic device is at least one of: infant intelligent nursing equipment, ordinary camera, vehicle event data recorder, cell-phone, panel computer etc. have the mobile terminal or the fixed terminal of image acquisition function.
The method for storing the video data step by step, which is provided by the embodiment, stores the image data frames of each frame of image to be stored in a buffer queue into a memory such as an SD card or plays the image data frames, includes that firstly, the image data frames of each frame of image in the buffer queue are written into a memory area by using a first thread and a video file in the memory area is transferred to the memory such as the SD card by using a second thread, so that an APP terminal at a later stage can play back and inquire the video file; the invention writes the image data frames of each frame of image cached in the cache queue into the memory area, and further transfers and plays the temporary video of the memory area to the storage such as the SD card and the like independently, when a first thread establishes a new file in the memory area for writing the image data frame of each frame of image cached latest in the cache queue, a second thread can transfer and store the temporary video written by the image data frames of each frame of image in the memory area for the second time to the SD card or the target path of other storage or play and the like, so that the creation time from the closing of the current file to the next file in the memory area is controlled, the interval time is greatly shortened, the image frame loss caused by the overflow of the image frame cached in the cache queue before is avoided because the image frame is not taken out in time, and the continuity of the video image is ensured.
In an embodiment, referring to fig. 2, the S2 includes:
s21: acquiring a video format for storing video data to be stored in a cache queue as a video;
s22: according to the video format, creating a file for storing video data in a memory area by using a current timestamp;
s23: writing each frame of image cached in a cache queue in real time into the file through the first thread, and closing the folder to obtain the temporary video after video data stored in the file conforms to a preset storage rule;
s24: repeating S21 to S23, and continuously writing the image data frames of each frame of image cached in the cache queue in real time into the current file to obtain each temporary video;
wherein the preset storage rule at least comprises one of the following rules: the number of image frames, the size of a video file, the video duration and event information recorded in the recording process of the video file.
In particular, video formats include, but are not limited to: the video data can be played by corresponding playing software only by being re-decoded into other video formats when the video data is the naked stream file; after the image frames in the cache queue are stored in the corresponding format, a file for storing the image data frames of the frames of images is established in the memory area by the current timestamp, then the image data frames of the frames of images cached in the cache queue are continuously written into the file in the corresponding format, after the current file finishes the writing of the video data, the file is closed to obtain a temporary video, a first thread is immediately used for creating a new file to continuously write the image data frames of the frames of images cached in the cache queue, the interval time from the closing of the current file to the establishment of the next file in the memory area is shortened, the loss of the image frames caused by the overflow of the image frames cached in the cache queue before being taken out is avoided, and the continuity of the video images is ensured.
In one embodiment, the S23 includes:
s231: acquiring the total number of images of image frames or the total data volume of video data which can be stored in the file corresponding to the preset storage rule;
s232: acquiring the number of first image frames or the real-time data volume of video data corresponding to the stored image frames in the current file in real time;
s233: and when the number of the first image frames is equal to the total number of the images or the real-time data volume is equal to the total data volume, closing the current file to obtain the temporary video.
Specifically, the closing time of the file is determined by the maximum image frame number which can be stored in the file established in the memory area or the data volume which can be stored in the file, when the first image frame number of the video image stored in the file reaches the requirement of the total number of images or the data volume stored in the file reaches the requirement of the total data volume, the file is closed at the moment, and the image data in the cache queue is prevented from being continuously written into the file to obtain a temporary video; such as: when the total number of the images is 1200 frames, the frame rate is 20fps, and the time length of the video to be recorded is 60s.
In an embodiment, if the preset storage rule is the data amount of the video data written in the memory area file, the step S233 includes:
s2331: when the real-time data volume is equal to the total data volume, judging whether the first video data written last and the second video data to be written into the cache queue are the same frame of image;
s2332: if the images belong to the same frame of image, analyzing the data volume of the second video data and/or the first video data to obtain an analysis result;
s2333: and according to the analysis result, determining a current file for writing the second video data and the first video data into a memory area or a next file for writing the second video data and the first video data into the memory area, and obtaining the temporary video corresponding to the current file.
Specifically, after the data amount of the video data written in the current file in the memory area reaches a preset data total amount, recording the last written video data as first video data, recording the video data to be written in the cache queue as second video data, if the first video data and the second video data belong to the same frame image, judging the data amount of the first video data and/or the second video data, and determining whether to write the first video data and the second video data of the frame image into a previous folder or a next folder according to an analysis result, wherein the specific analysis mode is not limited to: acquiring the data volume of the frame of image, setting a first data volume threshold value written into a memory area as a, and if the data volume of the first video data accounts for a percentage of the data volume of the frame of image which is larger than a, writing all data of the frame of image into a current folder; if the frame image is smaller than the preset frame image, writing all data of the frame image into a next folder; or setting a second data volume threshold value which is not written into the memory area as b, and if the data volume of the second video data accounts for a percentage of the data volume of the frame image which is greater than b, writing all data of the frame image into a next folder; if the current folder is smaller than the second folder, writing all data of the frame of image into the current folder, or comparing the first video data with the second video data, if the first video data is larger than or equal to the second video data, writing the first video data and the second video data into the current folder of the memory area, otherwise, writing the first video data and the second video data into the next folder of the memory area.
In one embodiment, the 232 comprises:
s2321: acquiring a video frame rate and a reading and writing speed for transferring the video images of the cache queue to a memory area;
s2322: and determining the number of the first image frames written into the file according to the video frame rate and the read-write speed.
Specifically, the video frame rate is the number of image frames acquired by an electronic device (camera) per second, for example, the video frame rate is 20 frames/second, which indicates that the camera acquires 20 frames of images per second, the read-write speed determines the time required for writing the data in the buffer queue into the memory area or writing the data from the memory area into a memory such as an SD card, and the number of image frames currently stored in the memory area is calculated according to the write-in speed of the data.
In an embodiment, referring to fig. 3, the S3 includes:
s31: acquiring an event number threshold value containing a target event in the target video;
s32: performing target detection on each frame of video image of each temporary video to obtain the actual times of each temporary video including the target event;
s33: splicing at least two continuous temporary videos of which the actual times are smaller than the event time threshold value according to a shooting time sequence to obtain a video to be stored;
s34: and transferring the video to be transferred and stored to a memory by utilizing the second thread to obtain the target video.
Specifically, no matter whether infant's intelligence nurse equipment nurses the in-process to infant 24 hours, still in the driving record of vehicle to the vehicle record, can have a large amount of video data that do not have practical meaning, this type of data has taken up too much storage space, for example: video data collected when an infant is in a sleeping state, video data collected when a vehicle is in a stopped state and the like, so that the storage space of an SD card or other memories is quickly used up and erased, computer resources are consumed, and the service life of the memories is prolonged; after the video images in the cache queue are written into the memory area, target detection is carried out on each frame of image, when target events contained in at least two continuous video files in the memory area are smaller than a preset value, the two video files are spliced to form a file, and the unloading efficiency of unloading the video files to an SD card or other storages is improved; meanwhile, when the cyclic recording is carried out, a plurality of unimportant videos are spliced into one video, when the memory needs to erase the part of video data, a large amount of storage space can be released only by once erasing, the erasing times are reduced, and the service life of the memory is prolonged; target events include, but are not limited to: the infant intelligent nursing device corresponds to crying, laughing, climbing, eating, sleeping and the like of the infant, and the automobile data recorder corresponds to vehicle doubling, vehicle lane changing, sudden braking and the like, which are not listed.
In one embodiment, the S34 includes:
s341: acquiring each frame of video image of a non-target event in each video to be stored;
s342: carrying out similarity detection on each frame of video image of the non-target event, and deleting similar video images in the video to be unloaded to obtain a basic video;
s343: and transferring the basic video to a memory by utilizing the second thread to obtain the target video.
Specifically, target analysis is performed on each video file in the memory area, and each frame of video image of the video file is divided into each frame of image in non-target time and each frame of image in a target event; similarity detection is carried out on each frame of image of the non-target event, if the similarity of continuous multi-frame images meets the requirement, deletion is carried out, and only event information capable of representing the time period is reserved, so that the obtained basic video is reduced, and the storage space of an SD card or other memories can be saved; if the infant is in a static sleep state, the acquired infant pictures are long-time static pictures, so that only part of the image frames need to be reserved to represent the sleep state of the infant, and other image frames can be deleted to release the storage space of the memory; for example, when the vehicle is parked in a closed place for a long time, the acquired still picture can be processed correspondingly, so that the storage space is released.
In one embodiment, the S342 includes;
s3421, acquiring a coincidence degree threshold value of adjacent frame video images;
s3422: carrying out target detection on each frame of video image to obtain the image coincidence degree of two adjacent frames of video images;
s3423: recording the video image with the contact ratio greater than or equal to the contact ratio threshold value as a similar image;
s3424: and deleting the similar images of the video to be stored according to a preset deleting rule to obtain the basic video.
Specifically, the similarity between different image frames is determined by detecting the degree of coincidence of two adjacent image frames, for example, in infant detection, the degree of coincidence between different image frames can be determined by the imaging positions of the infant face or other body parts in the images, and a plurality of continuous images with the degree of coincidence larger than a threshold value of the degree of coincidence are deleted, so that the size of the base video is reduced.
The method for storing video data step by step provided by this embodiment stores image data frames of each frame of image to be stored in a buffer queue into a memory such as an SD card or plays the image data frames, and includes writing the image data frames of each frame of image in the buffer queue into a memory area by using a first thread, and transferring a video file in the memory area to the memory such as the SD card by using a second thread, so that an APP end at a later stage plays back and queries the video file; the invention writes the image data frames of each frame of image cached in the cache queue into the memory area, and further transfers and plays the temporary video of the memory area to the storage such as the SD card and the like independently, when a first thread establishes a new file in the memory area for writing the image data frame of each frame of image cached latest in the cache queue, a second thread can transfer and store the temporary video written by the image data frames of each frame of image in the memory area for the second time to the SD card or the target path of other storage or play and the like, so that the creation time from the closing of the current file to the next file in the memory area is controlled, the interval time is greatly shortened, the image frame loss caused by the overflow of the image frame cached in the cache queue before is avoided because the image frame is not taken out in time, and the continuity of the video image is ensured.
Example 2
Embodiment 2 of the present invention further provides a storage apparatus for video data, as shown in fig. 4, the apparatus includes:
a storage analysis module: the video data caching device is used for acquiring video data to be stored cached in a caching queue;
a first storage module: the image data frames of each frame of image which are cached in the cache queue in real time are continuously written into a file created in the memory area through the first thread to obtain each temporary video;
a second storage module: the temporary videos in the memory area are transferred to a memory through a second thread different from the first thread, and target videos are obtained;
the data processed by the second thread comprises the temporary video in the memory area transferred to the memory and the file information of the target video recorded.
The video data stepped storage device of the embodiment is adopted to store or play the image data frames of each frame of image to be stored in the buffer queue into a memory such as an SD card and the like, and comprises the steps of firstly writing the image data frames of each frame of image in the buffer queue into a memory area by using a first thread and transferring a video file in the memory area to the memory such as the SD card and the like by using a second thread so as to facilitate the playback and query of an APP end at the later stage; the invention writes the image data frames of each frame of image cached in the cache queue into the memory area, and further transfers and plays the temporary video of the memory area to the storage such as the SD card and the like independently, when a first thread establishes a new file in the memory area for writing the image data frame of each frame of image cached latest in the cache queue, a second thread can transfer and store the temporary video written by the image data frames of each frame of image in the memory area for the second time to the SD card or the target path of other storage or play and the like, so that the creation time from the closing of the current file to the next file in the memory area is controlled, the interval time is greatly shortened, the image frame loss caused by the overflow of the image frame cached in the cache queue before is avoided because the image frame is not taken out in time, and the continuity of the video image is ensured.
In one embodiment, the first storage module comprises:
a format acquisition unit: acquiring a video format for storing video data to be stored in a cache queue as a video file;
a file establishing unit: according to the video format, creating a file for storing video data in a memory area by using a current timestamp;
a file storage unit: writing each frame of image cached in a cache queue in real time into the file through the first thread, and closing the folder to obtain the temporary video after video data stored in the file conforms to a preset storage rule;
a continuous storage unit: repeating the steps, and continuously writing each frame of video image cached in the cache queue in real time into the current file to obtain each temporary video;
wherein the preset storage rule at least comprises one of the following rules: the number of image frames, the size of a video file, the video duration and event information recorded in the recording process of the video file.
In one embodiment, the file storage unit includes:
an image number acquisition unit: acquiring the total number of images of image frames into which the file corresponding to the preset storage rule can be stored;
an image storage counting unit: acquiring the number of first image frames corresponding to the stored image frames in the current file in real time;
a temporary file generation unit: and when the number of the first image frames is equal to the total number of the images, closing the current file to obtain the temporary video.
In one embodiment, the image storage counting unit includes:
a parameter acquisition unit: acquiring a video frame rate and a reading and writing speed for transferring the video images of the cache queue to a memory area;
an image number calculation unit: and determining the number of the first image frames according to the video frame rate and the read-write speed.
In one embodiment, the second storage unit includes:
target event threshold unit: acquiring an event number threshold value containing a target event in the target video;
a target event counting unit: performing target detection on each frame of video image of each temporary video to obtain the actual times of each temporary video including the target event;
a video splicing unit: splicing at least two continuous temporary videos of which the actual times are smaller than the event time threshold value according to a shooting time sequence to obtain a video to be stored;
a target video storage unit: and transferring the video to be transferred and stored to a memory by utilizing the second thread to obtain the target video.
In one embodiment, the target video storage unit comprises:
a target image acquisition unit: acquiring each frame of video image of a non-target event in each video to be stored;
an image deletion unit: carrying out similarity detection on each frame of video image of the non-target event, and deleting similar video images in the video to be dumped to obtain a basic video;
a second unloading unit: and transferring the basic video to a memory by utilizing the second thread to obtain the target video.
In one embodiment, the image pruning unit includes;
a coincidence degree threshold unit for acquiring the coincidence degree threshold of the adjacent frame video images;
a contact ratio calculation unit: carrying out target detection on each frame of video image to obtain the image coincidence ratio of two adjacent frames of video images;
similar graph screening unit: recording the video image with the contact ratio greater than or equal to the contact ratio threshold value as a similar image;
a base video generation unit: and deleting the similar images of the video to be unloaded and stored according to a preset deleting rule to obtain the basic video.
The video data stepped storage device of the embodiment is adopted to store or play the image data frames of each frame of image to be stored in the buffer queue into a memory such as an SD card and the like, and comprises the steps of firstly writing the image data frames of each frame of image in the buffer queue into a memory area by using a first thread and transferring a video file in the memory area to the memory such as the SD card and the like by using a second thread so as to facilitate the playback and query of an APP end at the later stage; the invention writes the image data frame of each frame image cached in the cache queue into the memory area, and further transfers and stores the temporary video of the memory area into the storage such as the SD card or the like or plays the image data frame independently, when the first thread establishes a new file in the memory area for writing the image data frame of each frame image cached latest in the cache queue, the second thread can transfer and store the temporary video written by the image data frame of each frame image in the memory area into the target path of the SD card or other storage for the second time or play the image data frame, so that the creation time from the current file closing to the next file in the memory area is controlled, the interval time is greatly shortened, the image frame loss caused by the overflow of the image frame cached in the cache queue in advance because the image frame is not taken out in time is avoided, and the continuity of the video image is ensured.
The present invention provides an electronic device and storage medium, as shown in fig. 5, comprising at least one processor, at least one memory, and computer program instructions stored in the memory.
In particular, the processor may include a Central Processing Unit (CPU), or an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits configured to implement an embodiment of the present invention, and the electronic device includes at least one of: the wearing equipment that has intelligent camera, the mobile device that has intelligent camera.
The memory may include mass storage for data or instructions. By way of example, and not limitation, memory may include a Hard Disk Drive (HDD), floppy Disk Drive, flash memory, optical Disk, magneto-optical Disk, magnetic tape, or Universal Serial Bus (USB) Drive or a combination of two or more of these. The memory may include removable or non-removable (or fixed) media, where appropriate. The memory may be internal or external to the data processing apparatus, where appropriate. In a particular embodiment, the memory is non-volatile solid-state memory. In a particular embodiment, the memory includes Read Only Memory (ROM). Where appropriate, the ROM may be mask-programmed ROM, programmable ROM (PROM), erasable PROM (EPROM), electrically Erasable PROM (EEPROM), electrically rewritable ROM (EAROM), or flash memory, or a combination of two or more of these.
The processor reads and executes the computer program instructions stored in the memory to realize the step storage method of the video data in any one of the above embodiment modes.
In one example, the electronic device may also include a communication interface and a bus. The processor, the memory and the communication interface are connected through a bus and complete mutual communication.
The communication interface is mainly used for realizing communication among modules, devices, units and/or equipment in the embodiment of the invention.
A bus comprises hardware, software, or both that couple components of an electronic device to one another. By way of example, and not limitation, 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), a Hypertransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an infiniband interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel 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 bus or a combination of two or more of these. A bus may include one or more buses, where appropriate. Although specific buses have been described and shown in the embodiments of the invention, any suitable buses or interconnects are contemplated by the invention.
In summary, embodiments of the present invention provide a method, an apparatus, a device, and a storage medium for storing video data step by step.
It is to be understood that the invention is not limited to the precise arrangements and instrumentalities shown. A detailed description of known methods is omitted herein for the sake of brevity. In the above embodiments, several specific steps are described and shown as examples. However, the method processes of the present invention are not limited to the specific steps described and illustrated, and those skilled in the art can make various changes, modifications and additions or change the order between the steps after comprehending the spirit of the present invention.
The functional blocks shown in the above-described structural block diagrams may be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, it may be, for example, an electronic circuit, an Application Specific Integrated Circuit (ASIC), suitable firmware, plug-in, function card, or the like. When implemented in software, the elements of the invention are the programs or code segments used to perform the required tasks. The program or code segments may be stored in a machine-readable medium or transmitted by a data signal carried in a carrier wave over a transmission medium or a communication link. A "machine-readable medium" may include any medium that can store or transfer information. Examples of a machine-readable medium 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, and so forth. The code segments may be downloaded via computer networks such as the internet, intranet, etc.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A method for storing video data in steps, the method comprising:
s1: acquiring video data to be stored cached in a cache queue;
s2: continuously writing the image data frames of each frame of image cached in the cache queue in real time into a file created in the memory area through a first thread to obtain each temporary video;
s3: transferring each temporary video in a memory area to a memory through a second thread different from the first thread to obtain each target video;
the data processed by the second thread comprises the temporary video in the memory area transferred to the memory and the file information of the target video recorded.
2. The method for storing video data in steps according to claim 1, wherein said S2 comprises:
s21: acquiring a video format for storing video data to be stored in a cache queue as a video;
s22: according to the video format, creating a file for storing video data in a memory area by using a current timestamp;
s23: writing the image data frames of each frame of image cached in the cache queue in real time into the file through the first thread, and closing the file to obtain the temporary video after the video data stored in the file conforms to a preset storage rule;
s24: repeating S21 to S23, and continuously writing the image data frames of each frame of image cached in the cache queue in real time into the current file to obtain each temporary video;
wherein the preset storage rule at least comprises one of the following rules: the number of image frames, the size of a video file, the video duration and event information recorded in the recording process of the video file.
3. The method for storing video data in steps according to claim 2, wherein said S23 comprises:
s231: acquiring the total number of images of image frames which can be stored in the file corresponding to the preset storage rule;
s232: acquiring the number of first image frames corresponding to the stored image frames in the current file in real time;
s233: and when the number of the first image frames is equal to the total number of the images, closing the current file to obtain the temporary video.
4. The method for fractional storage of video data according to claim 3, wherein said 232 comprises:
s2321: acquiring a video frame rate and a reading and writing speed for transferring the video images of the cache queue to a memory area;
s2322: and determining the number of the first image frames according to the video frame rate and the read-write speed.
5. The method for storing video data in steps according to any one of claims 1 to 4, wherein said S3 comprises:
s31: acquiring an event number threshold value containing a target event in the target video;
s32: performing target detection on each frame of video image of each temporary video to obtain the actual times of each temporary video including the target event;
s33: splicing at least two continuous temporary videos of which the actual times are smaller than the event time threshold value according to a shooting time sequence to obtain videos to be stored;
s34: and transferring the video to be transferred and stored to a memory by utilizing the second thread to obtain the target video.
6. The method for storing video data in steps according to claim 5, wherein said S34 comprises:
s341: acquiring each frame of video image of a non-target event in each video to be stored;
s342: carrying out similarity detection on each frame of video image of the non-target event, and deleting similar video images in the video to be unloaded to obtain a basic video;
s343: and transferring the basic video to a storage by utilizing the second thread to obtain the target video.
7. The video data step storage method according to claim 6, wherein said S342 comprises;
s3421, acquiring a coincidence degree threshold value of adjacent frame video images;
s3422: carrying out target detection on each frame of video image to obtain the image coincidence degree of two adjacent frames of video images;
s3423: recording the video image with the contact ratio greater than or equal to the contact ratio threshold value as a similar image;
s3424: and deleting the similar images of the video to be stored according to a preset deleting rule to obtain the basic video.
8. A data storage device, comprising:
a storage analysis module: the video data caching device is used for acquiring video data to be stored cached in a caching queue;
a first storage module: the image data frames of each frame of image which are cached in the cache queue in real time are continuously written into a file created in the memory area through the first thread to obtain each temporary video;
a second storage module: the temporary videos in the memory area are transferred to a memory through a second thread different from the first thread, and target videos are obtained;
the data processed by the second thread comprises the temporary video in the memory area is transferred to a memory, and the file information of the target video is recorded.
9. An electronic device, comprising: at least one processor, at least one memory, and computer program instructions stored in the memory that, when executed by the processor, implement the method of any of claims 1-7.
10. A storage medium having computer program instructions stored thereon, which when executed by a processor implement the method of any one of claims 1-7.
CN202210908664.2A 2022-07-29 2022-07-29 Video data step-by-step storage method and device, electronic equipment and storage medium Pending CN115774796A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210908664.2A CN115774796A (en) 2022-07-29 2022-07-29 Video data step-by-step storage method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210908664.2A CN115774796A (en) 2022-07-29 2022-07-29 Video data step-by-step storage method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115774796A true CN115774796A (en) 2023-03-10

Family

ID=85388335

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210908664.2A Pending CN115774796A (en) 2022-07-29 2022-07-29 Video data step-by-step storage method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115774796A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116016805A (en) * 2023-03-27 2023-04-25 四川弘和通讯集团有限公司 Data processing method, device, electronic equipment and storage medium
CN117156172A (en) * 2023-10-30 2023-12-01 江西云眼视界科技股份有限公司 Video slice reporting method, system, storage medium and computer

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116016805A (en) * 2023-03-27 2023-04-25 四川弘和通讯集团有限公司 Data processing method, device, electronic equipment and storage medium
CN117156172A (en) * 2023-10-30 2023-12-01 江西云眼视界科技股份有限公司 Video slice reporting method, system, storage medium and computer
CN117156172B (en) * 2023-10-30 2024-01-16 江西云眼视界科技股份有限公司 Video slice reporting method, system, storage medium and computer

Similar Documents

Publication Publication Date Title
CN115774796A (en) Video data step-by-step storage method and device, electronic equipment and storage medium
US7133599B2 (en) Realtime data recording method
KR100620932B1 (en) Data recording method, data deletion method, data display method, recording apparatus, and recording medium
US6594442B1 (en) Optical disk recording still image data, a method and apparatus for recording and playing back still image data to and from the optical disk
CN101355674B (en) Recording apparatus, reproducing apparatus, recording/reproducing apparatus, image pickup apparatus, recording method
US20050267656A1 (en) Timeline random access for multi-format time-based file recording and playback
US11250888B1 (en) Flash memory and method for storing and retrieving embedded audio video data
US8639087B2 (en) Moving image editing system and moving image editing method
CN100471247C (en) Picture management method, picture management apparatus, picture management system
US8761573B2 (en) Recording device, imaging and recording device, recording method, and program
CN100559487C (en) The method and system of the recording capacity of management accounts equipment
CN106648447B (en) The data extraction method of embedded security device
KR100762580B1 (en) Method for controlling storage space personal video recorder
EP1274239B1 (en) Video recording/reproducing apparatus and video recording/reproducing method
US6775466B1 (en) Disk control apparatus dividing a recording area into recorded and unrecorded areas
CN110602464A (en) Method and device for saving image storage space during monitoring
TWI321952B (en) Time shifting in video recoder
CN112203031B (en) Digital video caching system and method
CN111225169B (en) Storage method and device for small video files
KR101799832B1 (en) Control system of the image data stored in the memory card
JP3955258B2 (en) Image recording device
JP2003009049A (en) Method for information recording and information recorder
CN114974314A (en) Audio and video frame processing method, device and medium
JP5474413B2 (en) Data recording device
US20050141852A1 (en) Recording/reproducing 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