Video data storage method, reading method, electronic device and storage medium

By determining whether the video data contains moving targets and adjusting the storage period according to the inter-frame difference value, efficient storage of video data of the monitoring device and accurate monitoring of slowly changing targets is achieved, and the storage space occupation and monitoring difficulty in the prior art is solved. The problem.

CN115396618BActive Publication Date: 2025-01-07HANGZHOU HUACHENG SOFTWARE TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210590509.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-26
Publication Date
2025-01-07
Estimated Expiration
2042-05-26

AI Technical Summary

Technical Problem

When the video data is stored in the monitoring device, the prior art cannot effectively reduce the storage space occupied by slowly changing targets, resulting in an increase in the difficulty of monitoring the slowly changing targets.

Method used

By determining whether the video data contains a moving target, if included, all first video frames will be stored frame by frame; if not included, the second video frame of the preset duration will be stored frame by frame with a variable duration, and according to the difference between frames, The value adjusts to variable duration to accommodate subtle changes in the target.

Benefits of technology

It effectively reduces the use of video data storage space, while improving the monitoring accuracy and efficiency of slow-changing targets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115396618B_ABST
    Figure CN115396618B_ABST
Patent Text Reader

Abstract

The present application discloses a video data storage method, a reading method, an electronic device and a storage medium, the video data storage method comprising: obtaining video data, determining whether the video data includes a moving target; in response to the video data including a moving target, obtaining all first video frames in the video data including the moving target, and storing all first video frames frame by frame in a time sequence; in response to the video data not including a moving target, obtaining all second video frames of a preset duration within a variable duration corresponding to each period with a variable duration as a cycle in the video data not including the moving target, and storing all second video frames frame by frame in a time sequence; wherein the variable duration is determined based on at least part of the second video frames within the preset duration adjacent in the time sequence. The above scheme can reduce the storage space occupied by video data storage, and at the same time facilitate the monitoring of slowly changing targets.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a video data storage method, a reading method, an electronic device and a storage medium. Background Art

[0002] With the increasing popularity of monitoring equipment in different application sites, the amount of video data collected by monitoring equipment is increasing. However, in most application sites, there are no moving targets all the time. Therefore, it is extremely wasteful to store video data continuously. In order to reduce the storage space occupied, the existing technology usually adopts a technical means of storing only part of the video data including the moving targets. However, after a large amount of video data is lost, it is difficult to effectively monitor the slowly changing targets. For example, the target such as flowers from blooming to decaying changes very little in a short period of time. The flowers in the picture will not be lost as moving targets, so it is impossible to monitor the slowly changing targets. In view of this, how to reduce the storage space occupied by video data storage and facilitate the monitoring of slowly changing targets has become an urgent problem to be solved. Summary of the invention

[0003] The main technical problem solved by the present application is to provide a video data storage method, a reading method, an electronic device and a storage medium, which can reduce the storage space occupied by video data when storing it, and at the same time facilitate the monitoring of slowly changing targets.

[0004] To solve the above technical problems, the first aspect of the present application provides a video data storage method, which includes: obtaining video data and determining whether the video data includes a moving target; in response to the video data including a moving target, obtaining all first video frames in the video data including the moving target, and storing all the first video frames frame by frame in time sequence; in response to the video data not including a moving target, obtaining all second video frames of a preset time length within the variable time length corresponding to each period in the video data not including the moving target with a variable time length as a period, and storing all the second video frames frame by frame in time sequence; wherein the variable time length is determined based on at least part of the second video frames within the preset time length that are adjacent in time sequence.

[0005] In order to solve the above-mentioned technical problems, the second aspect of the present application provides a video data reading method, which is used to read the video data stored based on the video data storage method described in the first aspect, including: in response to obtaining a first video frame including a moving target, decoding the first video frame frame by frame, and playing the decoded first video frame at a first speed; wherein all the first video frames in the video data including the moving target are stored frame by frame in time sequence; in response to obtaining a second video frame that does not include a moving target, playing at least part of the second video frames of a preset duration within a variable duration corresponding to each period at a second speed; wherein, in the video data that does not include the moving target, with the variable duration as a period, all the second video frames of the preset duration within the variable duration corresponding to each period are stored frame by frame in time sequence.

[0006] To solve the above technical problems, the third aspect of the present application provides an electronic device, which includes: a memory and a processor coupled to each other, wherein the memory stores program data, and the processor calls the program data to execute the method described in the first aspect or the second aspect.

[0007] In order to solve the above technical problems, the fourth aspect of the present application provides a computer storage medium on which program data is stored, and when the program data is executed by a processor, the method described in the first aspect or the second aspect is implemented.

[0008] In the above scheme, after obtaining the video data, it is first determined whether the video data includes a moving target. When the video data includes a moving target, all first video frames including the moving target are obtained from the video data, so that all the first video frames are stored frame by frame in time sequence, so that when reading the video data, a complete video stream corresponding to the moving target can be obtained, and a variable duration is used as a period, and second video frames of a preset duration are extracted from the video data within the variable duration, and all the second video frames are stored frame by frame in time sequence, so as to reduce the storage space occupied when storing video frames without moving targets, and when reading the video data, some video frames without moving targets can be obtained, and targets that may change slowly are monitored, wherein the variable duration is determined based on at least some second video frames within the preset duration that are adjacent in time sequence, so that when the video data does not include a moving target, based on the slight changes between at least some second video frames within the preset duration that are adjacent in time sequence, the period for storing the video frames that do not include the moving target is adaptively adjusted, thereby improving the accuracy of monitoring the slowly changing targets. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:

[0010] Figure 1 This is a flow chart of an implementation method of a video data storage method of the present application;

[0011] Figure 2 It is a flowchart of another implementation method of the video data storage method of the present application;

[0012] Figure 3 yes Figure 2 A schematic diagram of an application scenario of an implementation method corresponding to step S203;

[0013] Figure 4 It is a flowchart of an implementation method of the video data reading method of the present application;

[0014] Figure 5 It is a structural schematic diagram of an embodiment of the electronic device of the present application;

[0015] Figure 6 It is a structural schematic diagram of an implementation method of a computer storage medium of the present application. DETAILED DESCRIPTION

[0016] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0017] The terms "system" and "network" are often used interchangeably in this article. The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship. In addition, "many" in this article means two or more than two.

[0018] See also Figure 1 , Figure 1 This is a flow chart of an implementation method of a video data storage method of the present application, the method comprising:

[0019] S101: Obtain video data.

[0020] Specifically, the video data may be collected in real time by the monitoring device or the video data uploaded by the monitoring device with a delay may be received.

[0021] In one application scenario, the monitoring device is a network camera, and the acquisition module of the network camera collects video data and uploads it to the processing module, wherein the processing module can be integrated into the network camera or set in a network video recorder (NVR). The processing module receives the video data uploaded in real time or with delay and processes the video data.

[0022] S102: Determine whether the video data includes a moving object.

[0023] Specifically, motion detection is performed on the video data to determine whether the video data includes a moving target. If the video data includes a moving target, the process proceeds to step S103 , otherwise, the process proceeds to step S104 .

[0024] In an application scenario, the target in the video data is calibrated based on the calibration algorithm, and the target calibrated in the current frame of the video data is compared with the target calibrated in the historical frame to determine whether the position change of the target exceeds the position change threshold. If the position change threshold is exceeded, it is determined that the current frame includes a moving target, otherwise, the current frame does not include a moving target. The historical frame can be a video frame that is before the current frame and adjacent to the current frame, or a key frame that is before the current frame and closest to the current frame.

[0025] In another application scenario, the current frame and the historical frame in the video data are compared to determine the changed pixels that differ between the current frame and the historical frame, calculate the ratio of the changed pixels to all pixels in the current frame, obtain the change ratio, and determine whether the change ratio exceeds the ratio threshold. If it exceeds, it is determined that the current frame includes a moving target, otherwise, the current frame does not include a moving target. The historical frame can be a video frame that is before the current frame and adjacent to the current frame, or it can be a key frame that is before the current frame and closest to the current frame.

[0026] S103: In response to the video data including the moving target, all first video frames are obtained in the video data including the moving target, and all first video frames are stored frame by frame in time sequence.

[0027] Specifically, when the video data includes a moving target, all first video frames including the moving target are extracted from the video data including the moving target to obtain a video stream from the beginning of the moving target's appearance to leaving the monitoring area or moving to a stationary state, and all first video frames are stored one by one in time sequence so that the complete video stream corresponding to the moving target can be obtained when the video data is read.

[0028] In one application, at least a portion of the video frames before the current frame are cached in the cache space. If a moving target is detected in the current frame, the video frames in the cache space and the first video frame from the current frame until the moving target disappears are stored frame by frame, so that part of the video frames before the moving target appears are also stored to better detect the moving target.

[0029] In another application method, the video data is a delayed uploaded video frame. If a moving target is detected in the current frame, all first video frames including the moving target are extracted from the video data including the moving target, and video frames within a preset time period before and after all the first video frames corresponding to the moving target are searched from the video data and stored frame by frame in chronological order together with the first video frame, so as to observe the time points when the moving target appears and leaves.

[0030] S104: In response to the video data not including a moving target, in the video data not including the moving target, with a variable time length as a period, all second video frames of a preset time length are obtained within the variable time length corresponding to each period, and all the second video frames are stored frame by frame in time sequence, wherein the variable time length is determined based on at least part of the second video frames within the preset time length that are adjacent in time sequence.

[0031] Specifically, when the video data does not include a moving target, the current variable duration is obtained, and the variable duration is used as a period. A second video frame of a preset duration is extracted within the variable duration corresponding to each period, and all second video frames are stored frame by frame in chronological order to reduce the storage space occupied when storing video frames without moving targets.

[0032] In one application, the time length of the variable duration is greater than the preset duration, the preset duration corresponds to the time of a group of GOPs, and a group of GOPs is extracted within the variable duration, so that key frames and non-key frames in a group of GOPs are stored in time sequence.

[0033] In another application method, the video data is frame-sampled within the current variable time length according to the current variable time length as a period, so as to extract and store the second video frame within the preset time length, wherein the second video frame within the preset time length includes at least one key frame and a non-key frame thereafter, thereby effectively reducing the storage space occupied when storing video data within the variable time length.

[0034] Further, the variable duration is determined based on a first difference between at least part of the second video frames within a preset duration that are temporally adjacent.

[0035] Optionally, the first difference corresponds to a change threshold, and the variable duration is updated based on the first difference and the change threshold.

[0036] In one application, two second video frames with the longest interval are respectively extracted from temporally adjacent preset time periods for comparison, thereby determining a first difference between the temporally adjacent video frames within the temporally adjacent preset time periods.

[0037] In another application, two key frames with the longest interval are extracted from the second video frames within the preset time length that are temporally adjacent to each other for comparison, thereby determining the first difference between the video frames within the preset time length that are temporally adjacent to each other.

[0038] Furthermore, the first difference is obtained by comparing pixels in the video frame.

[0039] In one application scenario, the first difference corresponds to a change threshold, and the first difference is compared with the change threshold. When the first difference is greater than or equal to the change threshold, the current variable duration can be reduced, thereby updating the variable duration to shorten the period of the next acquisition of the second video frame within the preset duration, and acquire more second video frames to capture subtly changing images.

[0040] Furthermore, when the first difference is less than the change threshold, the current variable duration can be increased, thereby updating the variable duration to extend the period of the next capture of the second video frame within the preset duration, reducing the capture of the second video frame, so as to reduce the capture of unchanged images, and further reduce the storage space occupied when storing video data.

[0041] In a specific application scenario, the RGB values ​​of the pixels in the second video frame for comparison are obtained, and the RGB values ​​are compared to obtain a first difference, so that the first difference can feedback the difference between the second video frames at the pixel level, and improve the sensitivity of detecting subtle changes of the target, so as to detect small movements of the petals of flowers, or detect the color changes of flowers, so as to monitor subtle changes that are different from moving targets. When the first difference is greater than or equal to the change threshold, the current variable time length is halved, and when the first difference is less than the change threshold, the current variable time length is doubled. If the value of the variable time length is reduced to less than the preset time length, the video data is stored frame by frame, so as to change the period of storing the second video frame by adjusting the variable time length, so as to store more second video frames when there are subtle changes in the video frame to facilitate the detection of targets with subtle changes, and store fewer second video frames when there are no changes in the video frame to reduce the storage space occupied when the video data is stored.

[0042] In the above scheme, after obtaining the video data, it is first determined whether the video data includes a moving target. When the video data includes a moving target, all first video frames including the moving target are obtained from the video data, so that all the first video frames are stored frame by frame in time sequence, so that when reading the video data, a complete video stream corresponding to the moving target can be obtained, and a variable duration is used as a period, and second video frames of a preset duration are extracted from the video data within the variable duration, and all the second video frames are stored frame by frame in time sequence, so as to reduce the storage space occupied when storing video frames without moving targets, and when reading the video data, some video frames without moving targets can be obtained, and targets that may change slowly are monitored, wherein the variable duration is determined based on at least some second video frames within the preset duration that are adjacent in time sequence, so that when the video data does not include a moving target, based on the slight changes between at least some second video frames within the preset duration that are adjacent in time sequence, the period for storing the video frames that do not include the moving target is adaptively adjusted, thereby improving the accuracy of monitoring the slowly changing targets.

[0043] See also Figure 2 , Figure 2 This is a flow chart of another embodiment of the video data storage method of the present application, the method comprising:

[0044] S201: Obtain video data.

[0045] Specifically, video data collected by the current device is obtained, wherein the current device can exist independently or be cascaded with other devices, so as to jointly control a preset monitoring area.

[0046] S202: Determine whether the video data includes a moving object.

[0047] Specifically, motion detection is performed on the video data to determine whether the current frame of the video data includes a moving target. If a moving target is included, the process proceeds to step S203 , otherwise, the process proceeds to step S204 .

[0048] In one application method, motion detection is performed on video data collected by the current device, and a second difference between the current frame and the historical frame is obtained based on targets in the current frame and historical frames of the video data; and the motion detection result corresponding to the current device is determined based on the second difference and a motion threshold corresponding to the second difference.

[0049] Specifically, the video data collected by the current device is obtained, the background and target in the current frame of the video data are calibrated, and the target in the current frame is compared with the target in the historical frame, so as to determine the second difference between the current frame and the historical frame based on the change of the target position. The historical frame is a video frame that is before the current frame in time sequence. The second difference is compared with the motion threshold. In response to the second difference being greater than the motion threshold, it is determined that a moving target is detected in the current frame of the video data. In response to the second difference being less than or equal to the motion threshold, it is determined that no moving target is detected in the current frame of the video data.

[0050] Furthermore, an alarm tag is set for the first video frame in which a moving target is detected, so that the video stream consisting of all the first video frames including the moving target is used as an alarm video to facilitate the control of the moving target, and other video frames other than the alarm video are used as non-alarm videos for monitoring slowly changing targets.

[0051] S203: In response to the video data including the moving target, all first video frames are obtained in the video data including the moving target, and all first video frames are stored frame by frame in time sequence.

[0052] Specifically, when the video data includes a moving target, the video frame including the moving target is taken as the first video frame, all first video frames are extracted from the video data and stored frame by frame in time sequence, so that the complete video stream corresponding to the moving target can be obtained when reading the video data.

[0053] In one application scenario, the current device is cascaded with other devices to perform motion detection on the video data collected by the current device, and before obtaining a second difference between the current frame and the historical frame based on the targets in the current frame and the historical frame of the video data, it also includes: in response to other devices detecting a moving target before the current device detects the moving target, receiving the motion detection results of the other devices; before the current device detects the moving target, storing the video data collected by the current device frame by frame in time sequence until the first video frame including the moving target is obtained.

[0054] Specifically, see Figure 3 , Figure 3 yes Figure 2 Schematic diagram of an application scenario of an implementation method corresponding to step S203 in the embodiment, wherein the current device is a monitoring device, and the other devices can be monitoring devices or any other intelligent devices, such as Figure 3As described in, the current device is an IPC, and other devices include IPC, doorbells, and sweepers. When the current device is cascaded with other identifications, before the current device detects a moving target, if any other device detects a moving target, the motion detection result is shared with the cascaded devices so that the current device can obtain the motion detection results of other devices. Among them, other devices can upload the motion detection results to the cloud platform through a router, and the cloud platform broadcasts the motion detection results to the devices connected to the cloud platform. After the current device receives the motion detection results of other devices, it immediately stores the video data collected by the current device frame by frame in time sequence, or after the current device receives the motion detection results of other devices, it waits for the user to send an extraction and storage instruction through the APP end, so that before obtaining the first video frame, the video frame is stored in advance to obtain the video data before the moving target appears, so that the time point when the moving target appears can be monitored more accurately.

[0055] S204: In response to the video data not including a moving target, in the video data not including the moving target, using a variable time length as a period, obtaining all second video frames of a preset time length within the variable time length corresponding to each period, and storing all the second video frames frame by frame in time sequence.

[0056] Specifically, when the video data does not include a moving target, the current variable duration is obtained and used as a period, a second video frame of a preset duration is extracted from the video data within the current variable duration, and all second video frames within the preset duration are stored frame by frame in chronological order.

[0057] In one application, at least one key frame within a variable duration corresponding to each period and a non-key frame after the key frame are used as a second video frame to obtain a second video frame set; all key frames in the second video frame set and their corresponding timestamps, as well as non-key frames after each key frame, are stored frame by frame in chronological order.

[0058] Specifically, the length of the variable duration is greater than or equal to the preset duration, and the earliest key frame in the variable duration is searched, and the earliest key frame and the non-key frames thereafter are used as the second video frames of the preset duration. When the preset duration is greater than the time of a group of GOPs, at least one group of GOPs is used as the second video frames to obtain a second video frame set.

[0059] Furthermore, when the duration corresponding to the video frame from the earliest key frame in the variable duration to the end of the current cycle is less than the preset duration, the earliest key frame in the variable duration to the last video frame in the current variable duration is taken as the second video frame to obtain a second video frame set. All second video frames in the second video frame set are stored frame by frame, wherein the timestamps corresponding to the key frames in the second video frame set are stored together with the key frames, and the timestamps of the non-key frames after the key frames are not stored, so as to improve the storage efficiency if the non-key frames in the second video frames do not need to be played later.

[0060] In a specific application scenario, the preset duration is the duration corresponding to a group of GOPs, and the earliest key frame in the current variable duration is searched. When the length from the earliest key frame to the last video frame in the current variable duration is greater than or equal to a group of GOPs, the earliest key frame and the non-key frames thereafter are used together to form a group of GOPs as the second video frame. When the length from the earliest key frame to the last video frame in the current variable duration is less than a group of GOPs, the earliest key frame to the last video frame in the current variable duration is used as the second video frame to obtain a second video frame set, and the key frames and their corresponding timestamps in the second video frame set are stored, and the non-key frames after the key frames are stored frame by frame in chronological order. Wherein, if the length of the variable duration is greater than or equal to the preset duration, then each second video frame stored in the variable duration includes at least one key frame, so that the key frames can be used for comparison or playback.

[0061] S205: Obtain a first difference based on at least part of the second video frames within a preset time length that are temporally adjacent.

[0062] Specifically, the corresponding second video frames within the preset time length that are adjacent in time sequence include at least one key frame, so that the key frames are respectively extracted within the preset time length for comparison to obtain the first difference.

[0063] In one application, a key frame corresponding to each of the second video frame sets corresponding to the preset durations adjacent in time sequence is extracted respectively; and the key frames extracted from the preset durations adjacent in time sequence are compared to obtain a first difference.

[0064] Specifically, within the preset duration corresponding to each variable duration, the second video frame includes at least a key frame, and a key frame in the second video frame set is extracted, so as to compare the key frames extracted from two adjacent preset durations, thereby improving the comparison efficiency and obtaining the first difference based on the difference between the key frames.

[0065] Furthermore, the first difference is determined based on pixel or brightness changes, and the second difference is determined based on the position change of the target. The first difference is used to compare subtle changes between video frames, and the second difference is used to compare large changes of the target in the video frame.

[0066] In one application scenario, the first difference is determined based on pixel changes, and the first difference is obtained by comparing pixels between key frames, thereby adapting to scenarios where there are slight changes between key frames, such as application scenarios for monitoring the growth status of plants.

[0067] In another application scenario, the first difference is determined based on the brightness change. The pixels between the key frames are converted to the YUV domain, and the brightness values ​​are extracted for comparison to obtain the first difference, thereby adapting to scenarios where there are brightness changes between key frames, such as application scenarios for monitoring sunlight changes.

[0068] S206: Update the variable duration based on the size relationship between the first difference and the change threshold corresponding to the first difference, and the size relationship between the current variable duration and the initial value, wherein the updated variable duration is greater than or equal to the preset duration.

[0069] Specifically, the change threshold is smaller than the motion threshold, and the first difference is compared with the change threshold to determine whether a slight change occurs, thereby detecting a target that changes slowly.

[0070] Furthermore, the variable duration corresponds to an initial value and the initial value is greater than the preset duration. If the first difference is less than the change threshold and the variable duration is less than or equal to the initial value, the variable duration is updated to the initial value. When no detectable changes occur between video frames, the initial value is used as a cycle to reduce the storage space occupied by video data during storage. If the first difference is greater than the change threshold and the variable duration is between the preset duration and the initial value, the variable duration is shortened. When there are detectable changes between video frames, the current variable duration is shortened, thereby increasing the frequency of acquisition for images with subtle changes, and obtaining more video data to improve the accuracy of monitoring.

[0071] In one application, in response to the first difference being less than the change threshold and the current variable duration being equal to the initial value, the initial value is used as the new variable duration; in response to the first difference being greater than or equal to the change threshold and the current variable duration being less than or equal to the initial value, the current variable duration is multiplied by a first coefficient to obtain a first duration value; if the first duration value is greater than a preset duration, the first duration value is used as the new variable duration; otherwise, the preset duration is used as the new variable duration; in response to the first difference being less than the change threshold and the current variable duration being less than the initial value, the current variable duration is multiplied by a second coefficient to obtain a second duration value; if the second duration value is greater than the initial value, the initial value is used as the new variable duration; otherwise, the second duration value is used as the new variable duration; wherein the first coefficient is less than 1, and the second coefficient is the reciprocal of the first coefficient.

[0072] Specifically, for ease of explanation, it is assumed that the initial value of the variable duration is T and the first coefficient is 1 / 2. In other application scenarios, the first coefficient can be any value between 0 and 1. When the first difference is less than the change threshold and the current variable duration is equal to the initial value T, the initial value T continues to be used as the new variable duration, that is, when there is no change between adjacent video frames within the preset duration and the current variable duration is the initial value T, the initial value T continues to be used to reduce the storage space occupied by the video data when it is stored.

[0073] Furthermore, when the first difference is greater than or equal to the change threshold and the current variable duration is equal to the initial value, the current variable duration is multiplied by the first coefficient to obtain a first duration value of T / 2, thereby shortening the current variable duration, and then increasing the frequency of acquisition for images with slight changes. If the first difference corresponding to the preset durations between subsequent T / 2 cycles is still greater than the change threshold, T / 4 is used as the new variable duration, and so on. It should be noted that after obtaining the first duration value, the first duration value is compared with the preset duration. If the first duration value is greater than or equal to the preset duration, the first duration value is used as the new variable duration. If the first duration value is less than the preset duration, the preset duration is used as the new variable duration. When the variable duration is equal to the preset duration, the video data collected by the current device is stored frame by frame in the sequence of the video frames.

[0074] Furthermore, when the first difference is less than the change threshold and the current variable duration is less than the initial value, the current variable duration is multiplied by the second coefficient to obtain a second duration value. Assuming that the current variable duration is T / 4, the new variable duration is updated to T / 2, thereby gradually expanding the period for collecting the second video frame to reduce the storage space occupied when the video data is stored, and so on. It should be noted that after obtaining the second duration value, the second duration value is compared with the initial value. If the second duration value is less than or equal to the initial value, the second duration value is used as the new variable duration. If the second duration value is greater than the initial value, the initial value is used as the new variable duration, thereby maintaining the stability of the entire variable duration change.

[0075] Specifically, by adaptively adjusting the variable duration, the rationality of storing the second video frame is improved. When the difference between the second video frames within adjacent preset durations is greater than the change threshold, the length of the variable duration is gradually reduced. When the difference between the second video frames within adjacent preset durations is less than the change threshold, the length of the variable duration is gradually increased, thereby achieving a balance between effectively monitoring slowly changing targets and reducing the storage space occupied when storing video data.

[0076] Optionally, in response to the first difference being less than the change threshold and the current variable duration being equal to the initial value, after taking the initial value as the new variable duration, the method further includes: in response to the first difference being less than the change threshold and the initial value being used as the variable duration for consecutive times exceeding a times threshold, multiplying the initial value by a third coefficient to obtain a third duration value, and taking the third duration value as the new variable duration; wherein the third coefficient is greater than 1; in response to the first difference being greater than or equal to the change threshold and the current variable duration being greater than the initial value, taking the initial value as the new variable duration.

[0077] Specifically, when the variable duration is the initial value and the first difference is less than the change threshold value, the condition occurs for more than the number of times, it is determined that the video data has not changed for a long time, and therefore, the variable duration can be further increased to reduce the storage space occupied when the video data is stored, and the initial value is multiplied by the third coefficient to obtain a third duration value, and the third duration value is used as the new variable duration, wherein the third coefficient is greater than 1. When the first difference is greater than or equal to the change threshold value and the current variable duration is greater than the initial value, that is, when a slight change in the picture is detected again after no change is detected for a long time, the variable duration is reset to the initial value, thereby maintaining the stability of the entire variable duration change.

[0078] In a specific application scenario, the third coefficient is 1.5, assuming that the initial value is T, when the first difference is less than the change threshold and the number of times the initial value is used as the variable duration exceeds the number threshold, the variable duration is set to 1.5T, thereby increasing the period for storing the second video frame. In other application scenarios, the third coefficient may also be any other value greater than 1.

[0079] In this embodiment, when storing the second video frame that does not include a moving target, the period of storing the second video frame is adaptively adjusted to improve the rationality of storing the second video frame. When the difference between the second video frames within adjacent preset time lengths is greater than a change threshold, the length of the variable time length is gradually reduced. When the difference between the second video frames within adjacent preset time lengths is less than the change threshold, the length of the variable time length is gradually increased, thereby achieving a balance between effectively monitoring slowly changing targets and reducing the storage space occupied when storing video data.

[0080] See also Figure 4 , Figure 4 : is a flow chart of an implementation method of a video data reading method of the present application, wherein the video data is stored based on the method described in any of the above embodiments, and the video data reading method includes:

[0081] S401: In response to obtaining a first video frame including a moving target, decoding the first video frame frame by frame, and playing the decoded first video frame at a first speed.

[0082] Specifically, all first video frames in the video data including the moving target are stored frame by frame in time sequence. When the stored video data needs to be read, if the first video frame including the moving target is obtained, the first video frame is decoded frame by frame, and the decoded first video frame is played at a first speed, wherein the first speed can be customized by the user, thereby realizing the control of the moving target.

[0083] S402: In response to obtaining a second video frame that does not include a moving target, playing at least a portion of the second video frames of a preset duration within a variable duration corresponding to each period at a second speed.

[0084] Specifically, in the video data that does not include moving targets, a variable time length is used as a period. Within the variable time length corresponding to each period, all second video frames of a preset time length are stored frame by frame in chronological order. If a second video frame that does not include moving targets is obtained, the second video frame corresponds to a variable time length as a period when stored, and all or part of the second video frames of the preset time length within the variable time length corresponding to each period are played at a second speed, so as to monitor whether the second video frame that does not include moving targets includes slowly changing targets.

[0085] Optionally, the second speed is greater than the first speed, so that for a slowly changing target, the changing process of the slowly changing target can be more intuitively presented through playing at a higher speed.

[0086] In one application, key frames and their corresponding timestamps in the second video frame within the variable duration are extracted, the key frames are repeatedly played at a second speed within the variable duration, and an estimated timestamp corresponding to the repeatedly played key frames is generated based on the timestamps.

[0087] Specifically, the key frames in the second video frame within the variable duration and the timestamps corresponding to the key frames are extracted, the key frames are played repeatedly at the second speed within the variable duration, and based on the initial timestamps of the key frames and the second speed, the estimated timestamps corresponding to the repeatedly played key frames are generated. Assuming that the variable duration is 1 minute and the second speed is 10 times, the repeatedly played key frames are changed based on the timestamps of the initial key frames. Within the current variable duration, when playing the second video frame, the key frames are played repeatedly but the timestamps are played at 10 times the speed, so that the 1 minute variable duration is completed in 6 seconds, and the next variable duration or the first video frame is entered, thereby improving the playback efficiency.

[0088] In another application mode, a key frame and its corresponding time stamp are respectively extracted from the second video frames within a preset number of variable durations in time sequence, and the preset number of key frames are played sequentially at the second speed.

[0089] Specifically, a key frame is extracted from each of the second video frames within a preset value of variable durations that are adjacent in time sequence, thereby obtaining a preset value of key frames and their corresponding timestamps, and the preset value of key frames are played at the second speed, thereby achieving ultra-high speed playback of multiple key frames, so as to monitor targets that change extremely slowly. Assuming the preset value is 25, the key frames within the preset duration in 25 consecutive variable durations are played at the second speed, and the key frames within 25 consecutive variable durations are played at high speed, wherein the second speed may be 25 frames per second, and if there are less than 25 frames between the current variable duration and the next group of first video frames, some of the key frames are repeatedly played to make up for 25 frames, thereby achieving a frame rate playback of 25 frames per second, which is suitable for scenarios such as plant growth monitoring. It is understandable that the frame rate can be customized in different application scenarios.

[0090] In another application method, the key frames and their corresponding timestamps in the second video frames within each variable duration, as well as the non-key frames after the key frames, are decoded, the key frames and the non-key frames after them are played at least once at the second speed within the variable duration, and the estimated timestamps corresponding to the non-key frames and the repeatedly played video frames are generated based on the timestamps.

[0091] Specifically, the key frames and their corresponding timestamps in the second video frame within the variable duration are extracted, and the non-key frames after the key frames are decoded based on the key frames. When the variable duration is greater than or equal to the preset duration, the key frames and the non-key frames after them are played at least once at the second speed within the variable duration, and based on the initial timestamps of the key frames and the second speed, the estimated timestamps corresponding to the non-key frames are generated, and when the second video frame within the variable duration is repeatedly played, the estimated timestamps corresponding to the repeatedly played video frames are generated. Assuming that the variable duration is 1 minute and the second video frame is a group of GOPs, the decoded group of GOPs is repeatedly played at the second speed until it reaches 1 minute, wherein the second speed can be 1 speed, so as to monitor scenes with obvious changes, especially sudden changes in brightness.

[0092] In this embodiment, different playback strategies are set for the first video frame and the second video frame to facilitate the deployment of moving targets and monitor video frames that do not include moving targets. When monitoring slowly changing targets, the video frames can be played at double speed, so that the changing process of the slowly changing targets can be more intuitively displayed through higher speed playback. For monitoring scenes with sudden changes in brightness, decoding and normal speed playback can be performed to detect video frames with sudden changes in brightness.

[0093] See also Figure 5 , Figure 5 It is a structural diagram of an embodiment of an electronic device of the present application, wherein the electronic device 50 includes a memory 501 and a processor 502 coupled to each other, wherein the memory 501 stores program data (not shown), and the processor 502 calls the program data to implement the method in any of the above embodiments. For descriptions of related contents, please refer to the detailed description of the above method embodiments, which will not be repeated here.

[0094] See also Figure 6 , Figure 6 It is a structural diagram of an implementation method of a computer storage medium of the present application. The computer storage medium 60 stores program data 600. When the program data 600 is executed by a processor, the method in any of the above embodiments is implemented. For an explanation of the relevant content, please refer to the detailed description of the above method embodiments, which will not be repeated here.

[0095] It should be noted that the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present implementation scheme.

[0096] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0097] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.

[0098] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A video data storage method, characterized in that: The method comprises: Obtaining video data, and determining whether the video data includes a moving target; In response to the video data including a moving target, obtaining all first video frames in the video data including the moving target, and storing all the first video frames frame by frame in time sequence; In response to the video data not including a moving target, in the video data not including the moving target, with a variable duration as a period, all second video frames of a preset duration are obtained within the variable duration corresponding to each period, and all the second video frames are stored frame by frame in a time sequence; wherein the variable duration is determined based on at least part of the second video frames within the preset duration that are adjacent in time sequence; wherein the variable duration corresponds to an initial value and the initial value is greater than the preset duration, and the variable duration is obtained based on the following steps, including: Obtaining a first difference based on at least part of the second video frames within the preset duration that are temporally adjacent; The variable duration is updated based on the size relationship between the first difference and the change threshold corresponding to the first difference, and the size relationship between the current variable duration and the initial value; wherein the updated variable duration is greater than or equal to the preset duration; if the first difference is less than the change threshold and the variable duration is less than the initial value, the variable duration is increased; if the first difference is greater than the change threshold and the variable duration is between the preset duration and the initial value, the variable duration is shortened.

2. The video data storage method according to claim 1, characterized in that: The updating of the variable duration based on the magnitude relationship between the first difference and the change threshold corresponding to the first difference, and the magnitude relationship between the current variable duration and the initial value, includes: In response to the first difference being less than the change threshold and the current variable duration being equal to the initial value, taking the initial value as a new variable duration; In response to the first difference being greater than or equal to the change threshold and the current variable duration being less than or equal to the initial value, multiplying the current variable duration by a first coefficient to obtain a first duration value, and if the first duration value is greater than the preset duration, taking the first duration value as a new variable duration, otherwise taking the preset duration as a new variable duration; In response to the first difference being less than the change threshold and the current variable duration being less than the initial value, multiplying the current variable duration by a second coefficient to obtain a second duration value, and if the second duration value is greater than the initial value, taking the initial value as a new variable duration, otherwise taking the second duration value as a new variable duration; The first coefficient is less than 1, and the second coefficient is the reciprocal of the first coefficient.

3. The video data storage method according to claim 2, characterized in that: In response to the first difference being less than the change threshold and the current variable duration being equal to the initial value, after the initial value is used as the new variable duration, the method further includes: In response to the first difference being less than the change threshold and the number of times the initial value is used as the variable duration continuously exceeding a number threshold, multiplying the initial value by a third coefficient to obtain a third duration value, and using the third duration value as a new variable duration; wherein the third coefficient is greater than 1; In response to the first difference being greater than or equal to the change threshold and the current variable duration being greater than the initial value, the initial value is used as a new variable duration.

4. The video data storage method according to claim 1, characterized in that: The step of obtaining all second video frames of a preset duration within the variable duration corresponding to each cycle, and storing all second video frames frame by frame in time sequence, includes: Taking at least one key frame within the variable duration corresponding to each period and a non-key frame after the key frame as the second video frame, to obtain a second video frame set; All the key frames in the second video frame set and their corresponding timestamps, as well as non-key frames after each key frame, are stored frame by frame in chronological order.

5. The video data storage method according to claim 4, characterized in that: The obtaining of a first difference value based on at least part of the second video frames within the preset duration that are temporally adjacent comprises: Extracting a key frame corresponding to each of the second video frame sets corresponding to the preset durations that are adjacent in time sequence; The key frames extracted from the preset durations that are adjacent in time sequence are compared to obtain the first difference.

6. The video data storage method according to claim 1, characterized in that: The determining whether the video data includes a moving target comprises: Performing motion detection on the video data collected by the current device, and obtaining a second difference between the current frame and the historical frame based on the targets in the current frame and the historical frame of the video data; Determine a motion detection result corresponding to the current device based on the second difference and a motion threshold corresponding to the second difference; The change threshold is smaller than the motion threshold, the first difference is determined based on pixel or brightness change, and the second difference is determined based on the position change of the target.

7. The video data storage method according to claim 6, characterized in that: Before performing motion detection on the video data collected by the current device and obtaining a second difference between the current frame and the historical frame based on the target in the current frame and the historical frame of the video data, the method further includes: In response to another device detecting a moving target before the current device detects the moving target, receiving a motion detection result of the other device; Before the current device detects the moving target, the video data collected by the current device is stored frame by frame in time sequence until a first video frame including the moving target is obtained.

8. A video data reading method, characterized in that: The method is used to read the video data stored by the video data storage method according to any one of claims 1 to 7 above, and the video data reading method comprises: In response to obtaining a first video frame including a moving target, decoding the first video frame frame by frame, and playing the decoded first video frame at a first speed; wherein all the first video frames in the video data including the moving target are stored frame by frame in time sequence; In response to obtaining a second video frame that does not include a moving target, at least part of the second video frames of a preset duration within the variable duration corresponding to each period are played at a second speed; wherein, in the video data that does not include the moving target, the variable duration is used as a period, and within the variable duration corresponding to each period, all second video frames of a preset duration are stored frame by frame in chronological order.

9. The video data reading method according to claim 8, characterized in that: The step of playing at least part of the second video frames of a preset duration within the variable duration corresponding to each period at the second speed includes: Extracting a key frame and its corresponding timestamp in the second video frame within the variable duration, repeatedly playing the key frame at the second speed within the variable duration, and generating an estimated timestamp corresponding to the repeatedly played key frame based on the timestamp; or, Extract a key frame and its corresponding timestamp from each of the second video frames within a preset number of variable durations in time sequence, and play the preset number of key frames in sequence at the second speed; or Decode the key frames and their corresponding timestamps in the second video frames within each of the variable durations, as well as the non-key frames after the key frames, play the key frames and the non-key frames after them at least once at the second speed within the variable duration, and generate estimated timestamps corresponding to the non-key frames and the repeatedly played video frames based on the timestamps.

10. An electronic device, characterized in that: include: A memory and a processor coupled to each other, wherein the memory stores program data, and the processor calls the program data to execute the method as claimed in any one of claims 1-7 or 8-9.

11. A computer-readable storage medium having program data stored thereon, characterized in that: When the program data is executed by a processor, the method according to any one of claims 1 to 7 or 8 to 9 is implemented.

Citation Information

Patent Citations

  • Method for compressing video image and corresponding method for decoding video

    CN101330619A