Video storage compression method, device and storage medium

By detecting and deleting video frames that meet the conditions in the video storage space, the problem of low utilization of video file storage space in memory is solved, and more efficient utilization of storage space is achieved.

CN118803175BActive Publication Date: 2024-12-06ZHEJIANG DAHUA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411262960.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2024-12-06
Estimated Expiration
2044-09-10

AI Technical Summary

Technical Problem

In the prior art, when storing video files in memory, the storage space utilization rate is low, and the entire video file needs to be deleted in order to store new files, resulting in wasted resources.

Method used

By responding to the space cleaning instructions of the video storage space, the video file and frame deletion conditions in the video storage space are obtained, and video frames that meet the conditions are detected and deleted based on the frame attribute information of the video frame. Only some frames are selected for deletion to free up space.

Benefits of technology

While keeping the storage space unchanged, extend the storage time, save more content, and improve the storage space utilization of the memory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118803175B_ABST
    Figure CN118803175B_ABST
Patent Text Reader

Abstract

The present application discloses a video storage compression method, device and storage medium. The video storage compression method includes: in response to a space cleanup instruction of a video storage space, obtaining video files stored in the video storage space and obtaining video frame deletion conditions; based on the frame attribute information of each video frame in the video file, detecting whether the video frame meets the video frame deletion conditions; taking the video frames that meet the video frame deletion conditions as pre-deleted video frames, and deleting the pre-deleted video frames in the video file respectively. Compared with the prior art of directly deleting the entire video file, the present application takes into account the attribute information of the video frames in the video file more deeply, and only selects to delete some video frames in the video file. From the perspective of the timeline, while the storage space remains unchanged, information with longer time and more content can be saved, thereby improving the storage space utilization of the memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of video storage technology, and in particular to a method, device and storage medium for compressing video storage. Background Art

[0002] At present, each video file stored in the memory is considered separately. When the storage space of the memory is used, the earliest stored video file will be deleted. For example, in the current memory, three video files A, B, and C are stored in chronological order from early to late. At this time, if a new video file is to be stored, if the remaining storage space is insufficient, the entire file A will be deleted first, and then the new video file will be stored.

[0003] This storage strategy has simple logic and is easy to implement; however, the utilization rate of storage resources is still low. Summary of the invention

[0004] In order to solve the above technical problems, the present application at least provides a video storage compression method, device and storage medium.

[0005] The first aspect of the present application provides a video storage compression method, the method comprising: in response to a space cleanup instruction of the video storage space, obtaining video files stored in the video storage space, and obtaining a video frame deletion condition; based on the frame attribute information of each video frame in the video file, detecting whether the video frame satisfies the video frame deletion condition; taking the video frames that satisfy the video frame deletion condition as pre-deleted video frames, and deleting the pre-deleted video frames in the video file respectively.

[0006] In one embodiment, there are multiple video frame deletion conditions; based on the frame attribute information of each video frame in the video file, detecting whether the video frame meets the video frame deletion condition, including: treating all stored video files as a global video file, and segmenting the global video file according to the storage time of each video frame to obtain multiple video segments; based on the video frame deletion conditions used in the video frame deletion record corresponding to each video segment, and / or the remaining storage space corresponding to the video storage space, determining the video frame deletion condition that matches each video segment; detecting whether the frame attribute information of the video frame in the video segment meets the matching video frame deletion condition.

[0007] In one embodiment, based on the video frame deletion conditions used in the video frame deletion record corresponding to each video segment and / or the remaining storage space corresponding to the video storage space, the video frame deletion conditions matching each video segment are determined respectively, including: based on the video frame deletion conditions used in the video frame deletion record corresponding to each video segment and / or the remaining storage space corresponding to the video storage space, a target video frame deletion condition is selected from multiple video frame deletion conditions; and the target video frame deletion conditions are used as the video frame deletion conditions matching each video segment.

[0008] In one embodiment, each video frame deletion condition corresponds to a different condition level; based on the video frame deletion conditions used in the video frame deletion record corresponding to each video segment, the video frame deletion conditions matching each video segment are determined respectively, including: sorting each video segment according to the storage time of each video segment, selecting a preset number of video segments with high ranking from the sorting result to obtain a priority deletion video segment; obtaining the video frame deletion conditions used in the video frame deletion record corresponding to the priority deletion video segment; if the video frame deletion record indicates that the priority deletion video segment has not used up the video frame deletion conditions of all condition levels, then the video frame deletion condition with the lowest condition level among the unused video frame deletion conditions is used as the video frame deletion condition matching the priority deletion video segment; if the video frame deletion record indicates that the priority deletion video segment has used up the video frame deletion conditions of all condition levels, then the priority deletion video segment is removed from the sorting result, and a preset number of video segments with high ranking are selected from the sorting result after removal to obtain a new priority deletion video segment, and the video frame deletion condition with the lowest condition level is used as the new video frame deletion condition matching the priority deletion video segment.

[0009] In one embodiment, before sorting each video segment according to the storage time of each video segment, selecting a preset number of video segments with a high ranking from the sorting results, and obtaining the priority deletion video segments, the method also includes: obtaining the video frame deletion conditions that have been used in the video frame deletion records corresponding to each video segment; if the video frame deletion records indicate that each video segment has used the video frame deletion conditions of a preset condition level, performing the steps of sorting each video segment according to the storage time of each video segment, selecting a preset number of video segments with a high ranking from the sorting results, and obtaining the priority deletion video segments; if the video frame deletion records indicate that each video segment has not used the video frame deletion conditions of the preset condition level, using the video frame deletion conditions with the lowest condition level among the unused video frame deletion conditions as the video frame deletion conditions that match each video segment.

[0010] In one embodiment, the frame attribute information includes the frame type of the video frame, and the video frame deletion condition includes the pre-deleted frame type; based on the frame attribute information of each video frame in the video file, detecting whether the video frame meets the video frame deletion condition, including: extracting the frame header flag of the video frame to obtain the frame type of the video frame; detecting whether the pre-deleted frame type contains the frame type of the video frame; if it does, it is determined that the frame attribute information of the video frame meets the video frame deletion condition; if not, it is determined that the frame attribute information of the video frame does not meet the video frame deletion condition.

[0011] In one embodiment, the frame attribute information includes the frame type and storage time of the video frame; based on the frame attribute information of each video frame in the video file, detecting whether the video frame meets the video frame deletion condition, including: calculating the deletion recommendation index of each video frame based on the frame type and storage time of each video frame; detecting whether the deletion recommendation index of the video frame meets the video frame deletion condition.

[0012] In one embodiment, before responding to the space clearing instruction of the video storage space, it also includes: obtaining the remaining storage space corresponding to the video storage space; obtaining a preset space threshold, and if the remaining storage space is less than the preset space threshold, generating a space clearing instruction; or, receiving a video storage request, obtaining the data size of the video to be stored corresponding to the video storage request, and if the data size of the video to be stored is larger than the remaining storage space, generating a space clearing instruction.

[0013] The second aspect of the present application provides a video storage compression device, which includes: an instruction response module, which is used to respond to a space clearing instruction of the video storage space, obtain the video files stored in the video storage space, and obtain the video frame deletion condition; a video frame detection module, which is used to detect whether the video frame meets the video frame deletion condition based on the frame attribute information of each video frame in the video file; a video frame deletion module, which is used to take the video frames that meet the video frame deletion condition as pre-deleted video frames, and delete the pre-deleted video frames in the video file respectively.

[0014] A third aspect of the present application provides an electronic device, including a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the above-mentioned video storage compression method.

[0015] A fourth aspect of the present application provides a computer-readable storage medium having program instructions stored thereon, which implement the above-mentioned video storage compression method when the program instructions are executed by a processor.

[0016] The above scheme obtains the video files stored in the video storage space and the video frame deletion conditions by responding to the space cleanup instruction of the video storage space; detects whether the video frames meet the video frame deletion conditions based on the frame attribute information of each video frame in the video file; takes the video frames that meet the video frame deletion conditions as pre-deleted video frames, and deletes the pre-deleted video frames in the video file respectively. Compared with the prior art of directly deleting the entire video file, the present application takes the attribute information of the video frames in the video file more deeply into consideration, and only chooses to delete some video frames in the video file, in exchange for more information storage at the cost of losing some video frames. From the timeline level, while the storage space remains unchanged, information with longer time and more content can be saved, thereby improving the storage space utilization rate of the memory.

[0017] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0019] Figure 1 It is a schematic diagram of an implementation environment of a solution provided by an embodiment of the present application;

[0020] Figure 2 is a flow chart of a video storage compression method shown in an exemplary embodiment of the present application;

[0021] Figure 3 is a schematic diagram of video segmentation shown in an exemplary embodiment of the present application;

[0022] Figure 4 is a flowchart of video frame deletion shown in an exemplary embodiment of the present application;

[0023] Figure 5 is a schematic diagram of video frame deletion shown in an exemplary embodiment of the present application;

[0024] Figure 6 is a schematic diagram of video frame deletion shown in another exemplary embodiment of the present application;

[0025] Figure 7 is a schematic diagram of video frame deletion shown in another exemplary embodiment of the present application;

[0026] Figure 8 is a block diagram of a video storage compression device shown in an exemplary embodiment of the present application;

[0027] Fig. 9 is a schematic structural diagram of an electronic device shown in an exemplary embodiment of the present application;

[0028] Fig.10 It is a schematic diagram of the structure of a computer-readable storage medium shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0029] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.

[0030] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.

[0031] The term "and / or" in this article is only an association information describing the associated objects, indicating that there may be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the characters " / ", "," in this article generally indicate that the objects associated before and after are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, and can mean including any one or more elements selected from the set consisting of A, B, and C.

[0032] The following is an explanation of the video compression method provided in the embodiment of the present application.

[0033] Please refer to Figure 1 , which shows a schematic diagram of a solution implementation environment provided by an embodiment of the present application. The solution implementation environment may include a terminal 110 and a server 120, and the terminal 110 and the server 120 are connected to each other in communication.

[0034] The number of the terminal 110 may be one or more. The terminal 110 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart watch, etc., but is not limited thereto.

[0035] Server 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.

[0036] In an example, the server 120 may store the video file obtained from the terminal 110 . Of course, the terminal 110 may also store the video file obtained from the server 120 .

[0037] In the video storage compression method provided in the embodiment of the present application, the execution subject of each step can be the terminal 110, or the server 120, or the terminal 110 and the server 120 can cooperate with each other to execute, that is, part of the steps of the method are executed by the terminal 110 and the other steps are executed by the server 120.

[0038] See also Figure 2 , Figure 2 is a flowchart of a video storage compression method shown in an exemplary embodiment of the present application. The video storage compression method can be applied to Figure 1 It should be understood that the method can also be applied to other exemplary implementation environments and be specifically executed by devices in other implementation environments, and this embodiment does not limit the implementation environment to which the method is applicable.

[0039] like Figure 2 As shown, the video compression method for saving to disk includes at least steps S210 to S230, which are described in detail as follows:

[0040] Step S210: In response to a space clearing instruction of the video storage space, the video files stored in the video storage space are obtained, and a video frame deletion condition is obtained.

[0041] Detect whether it is necessary to clean up the video storage space, and if necessary, generate a space cleaning instruction. The video storage space is used to store video files.

[0042] In some implementations, whether space clearing is required may be determined based on the remaining storage space corresponding to the video storage space.

[0043] For example, it is determined whether the remaining storage space is less than a preset space threshold. If it is less than the preset space threshold, it is determined that the video storage space needs to be cleaned up, and a space cleaning instruction is generated. The remaining storage space determination may be performed once every preset time period, or may be performed once when a change in the remaining storage space is detected.

[0044] For another example, a video storage request is received, where the video storage request is used to request storage of a video to be stored, and the data size of the video to be stored is obtained. If the data size of the video to be stored is larger than the remaining storage space, it is determined that the video storage space needs to be cleared, and a space clearing instruction is generated.

[0045] In some implementations, a space clearing instruction may be generated periodically, such as generating a space clearing instruction every 10 days.

[0046] In some implementations, the storage duration of each video file in the video storage space may also be obtained, and if the storage duration exceeds a preset duration threshold, a space clearing instruction is generated.

[0047] Optionally, the space cleaning judgment strategy corresponding to each video file may be different, and each video file is judged according to the corresponding space cleaning judgment strategy to generate a space cleaning instruction. For example, the importance level of the video file is determined according to the type of the video file, the size of the video file, etc. Different importance levels correspond to different space cleaning judgment strategies, and all video files contained in the importance level corresponding to the space cleaning judgment strategy are judged to determine whether to generate a space cleaning instruction, and the space cleaning instruction is used to instruct all video files contained in the importance level corresponding to the space cleaning judgment strategy to be cleaned.

[0048] It should be noted that the method for generating space cleaning instructions can be flexibly set according to the actual application scenario, and this application does not limit this.

[0049] In response to a space cleanup instruction of the video storage space, video files stored in the video storage space are obtained, and video frame deletion conditions are obtained.

[0050] Among them, all stored video files can be obtained and used as video files that need to be cleaned up, or some stored video files can be obtained and used as video files that need to be cleaned up; the video frame deletion condition is used to limit the video frames that need to be deleted.

[0051] Step S220: Based on the frame attribute information of each video frame in the video file, detecting whether the video frame satisfies the video frame deletion condition.

[0052] The frame attribute information includes but is not limited to one or more of the frame type of the video frame, the storage time of the video frame, the data size of the video frame, the number of decoding and playback times corresponding to the video frame, and the like.

[0053] The number of video frame deletion conditions is one or more.

[0054] In some implementations, it may be directly detected whether each video frame in the video file satisfies one or more video frame deletion conditions.

[0055] In some implementations, there are multiple video frame deletion conditions, and one or more currently matched video frame deletion conditions may be selected from the multiple video frame deletion conditions to detect whether each video frame in the video file satisfies the matched video frame deletion conditions.

[0056] For example, one or more currently matched video frame deletion conditions can be flexibly determined based on the frame attribute information of the video frame, the remaining storage space, the data size of the video to be stored, the video file to which it belongs, or the video segment to which it belongs, so as to detect whether each video frame satisfies the matched video frame deletion condition. The video frame deletion conditions matched by each video frame can be the same or different, and this application does not limit this.

[0057] Step S230: taking the video frames that meet the video frame deletion condition as pre-deleted video frames, and performing deletion processing on the pre-deleted video frames in the video file respectively.

[0058] The video frames to be deleted in the video file are screened out according to the video frame deletion condition, and the video frames to be deleted in the video file are deleted respectively.

[0059] That is, only the pre-deleted video frames in the video file are deleted, rather than directly deleting the entire video file.

[0060] In the prior art, the entire video file is directly deleted, which is limited to the video file level. Compared with the prior art, the present application takes into account the information of the video frames in the video file more deeply, and only chooses to delete some video frames in the video file, at the cost of losing some video frames in exchange for more information storage. From the perspective of the timeline, while the storage space remains unchanged, information with longer time and more content can be saved, thereby improving the storage space utilization of the memory.

[0061] Next, some embodiments of the present application are described in detail.

[0062] In some embodiments, there are multiple video frame deletion conditions; in step S220, based on the frame attribute information of each video frame in the video file, detecting whether the video frame meets the video frame deletion condition, including: treating all stored video files as a global video file, and segmenting the global video file according to the storage time of each video frame to obtain multiple video segments; based on the video frame deletion conditions used in the video frame deletion record corresponding to each video segment, and / or the remaining storage space corresponding to the video storage space, determining the video frame deletion condition that matches each video segment; detecting whether the frame attribute information of the video frame in the video segment meets the matching video frame deletion condition.

[0063] For example, see Figure 3 , Figure 3A schematic diagram of video segmentation is shown as an exemplary embodiment of the present application. Figure 3 As shown, all stored video files are taken as a global video file, and the global video file is segmented according to the storage time of each video frame to obtain multiple video segments, such as video segment 1, video segment 2 and video segment 3.

[0064] The number of video segments obtained by division or the length of each video segment may be preset or flexibly set.

[0065] For example, the number of video segments is set to N, and the global video file is evenly segmented to obtain N video segments.

[0066] For another example, the length of a video segment is determined according to the storage time. The farther the storage time is from the current time, the longer the length of the corresponding video segment is. The closer the storage time is to the current time, the shorter the length of the corresponding video segment is. This allows for a more fine-grained analysis of new video data, thereby improving the flexibility and accuracy of video frame deletion.

[0067] The video frame deletion condition matched by each video segment is determined respectively.

[0068] For example, the video frame deletion conditions used by each video segment are recorded to obtain a video frame deletion record, and the video frame deletion condition matching each video segment can be determined according to the video frame deletion record.

[0069] For example, each video frame deletion condition corresponds to a different condition level, and the currently matched video frame deletion condition is selected for the video segment level by level. For example, the video frame deletion conditions are sorted in ascending order according to the condition level, including: deleting the video frame whose flag indicates non-motion detection data (condition level 1), deleting non-key frames at intervals (condition level 2), deleting all non-key frames (condition level 3), deleting other video frames except key frames (condition level 4), and deleting all video frames (condition level 5). If the video frame deletion record of video segment 1 indicates that video segment 1 does not use the video frame deletion condition, the video frame deletion condition of condition level 1 is selected; if the video frame deletion record of video segment 1 indicates that video segment 1 uses the video frame deletion condition of condition level 1, the video frame deletion condition of condition level 2 is selected. Among them, non-key frames include the first type of non-key frame BASE frame and the second type of non-key frame ENHANCE frame, both of which belong to predictive coded frames (Predictive-coded Frame, P frame). In addition, key frames are also called I frames (I-frame).

[0070] By using the video frame deletion conditions level by level to achieve video frame deletion, video frames with low importance can be deleted first, so that video frames with high importance are retained preferentially.

[0071] For another example, the remaining storage space corresponding to the video storage space is obtained, and the video frame deletion condition matching each video segment is determined according to the remaining storage space, such as determining the number of video frame deletion conditions and / or the condition level of the video frame deletion conditions.

[0072] For example, the difference between the remaining storage space and the preset space threshold is calculated, or the difference between the remaining storage space and the data size of the video to be stored is calculated, and the number of video frame deletion conditions and / or the condition level of the video frame deletion conditions are determined according to the calculated difference. For example, the larger the difference, the more the number of video frame deletion conditions and / or the higher the condition level of the video frame deletion conditions; the smaller the difference, the fewer the number of video frame deletion conditions and / or the lower the condition level of the video frame deletion conditions.

[0073] Some embodiments of determining the video frame deletion conditions that match each video segment are described by way of example:

[0074] Embodiment 1: Based on the video frame deletion conditions used in the video frame deletion record corresponding to each video segment, and / or the remaining storage space corresponding to the video storage space, a target video frame deletion condition is selected from multiple video frame deletion conditions; the target video frame deletion condition is used as the video frame deletion condition matching each video segment.

[0075] For example, see Figure 4 , Figure 4 A flowchart of video frame deletion is shown as an exemplary embodiment of the present application. Figure 4 As shown, including:

[0076] Step S401: It is detected that there are videos to be stored and the remaining storage space is insufficient, and all video files are segmented as a global video file to obtain multiple video segments.

[0077] Step S402: Delete the video frames in each video segment whose flag indicates non-motion detection data.

[0078] At this time, if it is detected that the video frame deletion conditions of condition level 1 are not all used in the video frame deletion records corresponding to each video segment, the video frame deletion conditions of condition level 1 are used as target video frame deletion conditions.

[0079] Step S403: determining whether the remaining storage space is sufficient for storing the video to be stored, if not, proceeding to step S404, otherwise, proceeding to step S411;

[0080] After the video frame deletion conditions of condition level 1 are executed for all current video segments, if the storage space still does not satisfy the storage of the video to be stored, the video frame deletion conditions of a higher condition level are continued to be executed.

[0081] Step S404: intermittently delete the video frames whose flag bits are non-key frames in each video segment.

[0082] For example, see Figure 5 , Figure 5 A schematic diagram of video frame deletion is shown as an exemplary embodiment of the present application. Figure 5 As shown, the second type of non-key frame ENHANCE frames of each video segment are deleted at intervals.

[0083] Step S405: determining whether the remaining storage space is sufficient for storing the video to be stored, if not, proceeding to step S406, otherwise proceeding to step S411;

[0084] Step S406: Delete all video frames in each video segment whose flags are non-key frames.

[0085] For example, see Figure 6 , Figure 6 A schematic diagram of video frame deletion is shown in another exemplary embodiment of the present application. Figure 6 As shown, all the second type of non-key frame ENHANCE frames of each video segment are deleted.

[0086] Step S407: determining whether the remaining storage space is sufficient for storing the video to be stored, if not, proceeding to step S408, otherwise proceeding to step S411;

[0087] Step S408: Delete all video frames in each video segment whose flags do not belong to key frames.

[0088] For example, see Figure 7 , Figure 7 A schematic diagram of video frame deletion is shown in another exemplary embodiment of the present application. Figure 7 As shown, all video frames except the I frame in each video segment are deleted.

[0089] Step S409: Check whether the remaining storage space is sufficient for storing the video to be stored. If not, proceed to step S410; otherwise, proceed to step S411.

[0090] Step S410: Delete all video frames.

[0091] Step S411: completing the storage of the video to be stored.

[0092] By gradually deleting less important video frames, information with longer time and more content can be saved, which improves the storage space utilization of the memory. Based on the reference relationship between frames, some video frames in the file can be continuously deleted without affecting the parsing of other video frames in the code stream.

[0093] In addition to determining the currently matched video frame deletion conditions based on the used video frame deletion conditions, the number and / or condition level of the video frame deletion conditions can also be determined based on the remaining storage space to obtain one or more matched video frame deletion conditions, and the filtered pre-deleted video frames can be deleted at one time according to the one or more video frame deletion conditions to improve the video frame deletion efficiency.

[0094] Embodiment 2: Each video frame deletion condition corresponds to a different condition level; each video segment is sorted according to the storage time of each video segment, and a preset number of video segments with high ranking are selected from the sorting results to obtain priority deletion video segments; the used video frame deletion conditions in the video frame deletion record corresponding to the priority deletion video segment are obtained; if the video frame deletion record indicates that the priority deletion video segment has not used up the video frame deletion conditions of all condition levels, the video frame deletion condition with the lowest condition level among the unused video frame deletion conditions is used as the video frame deletion condition matching the priority deletion video segment; if the video frame deletion record indicates that the priority deletion video segment has used up the video frame deletion conditions of all condition levels, the priority deletion video segment is removed from the sorting results, and a preset number of video segments with high ranking are selected from the sorting results after removal to obtain a new priority deletion video segment, and the video frame deletion condition with the lowest condition level is used as the video frame deletion condition matching the new priority deletion video segment.

[0095] Among them, the preset number can be pre-set, such as 1, 2, etc., and the preset number can also be flexibly calculated, such as flexibly determining the value of the preset number based on the size of the remaining storage space, the data size of the video to be stored, etc. The smaller the remaining storage space and the larger the video to be stored, the larger the preset number.

[0096] For example, the preset number is 1, and each video segment is sorted according to the storage time of each video segment. The sorting results are video segment 1, video segment 2, and video segment 3, and video segment 1 is selected as the priority deletion video segment. The used video frame deletion conditions in the video frame deletion record corresponding to video segment 1 are obtained; if the video frame deletion record indicates that video segment 1 has not used up all the video frame deletion conditions of the condition levels, the video frame deletion condition with the lowest condition level among the unused video frame deletion conditions is used as the video frame deletion condition matching the priority deletion video segment; if the video frame deletion record indicates that video segment 1 has used up all the video frame deletion conditions of the condition levels, video segment 1 is removed from the sorting results, and a video segment with a high ranking is selected from the sorting results after removal, so that the new priority deletion video segment is video segment 2, and the video frame deletion condition with the lowest condition level (i.e., the video frame deletion condition of condition level 1) is used as the video frame deletion condition matching video segment 2.

[0097] Through the above method, the video frame deletion conditions of all condition levels can be completely executed on video segment 1 in sequence, and then the video frame deletion conditions of all condition levels can be completely executed on video segment 2 in sequence, and so on, until the video frame deletion conditions of all condition levels are completely executed on all video segments in sequence, so as to retain video frames with high importance and new storage time.

[0098] Embodiment 3: before sorting each video segment according to the storage time of each video segment, selecting a preset number of video segments with the highest ranking from the sorting results, and obtaining the priority deletion video segments, the method also includes: obtaining the video frame deletion conditions that have been used in the video frame deletion records corresponding to each video segment; if the video frame deletion records indicate that each video segment does not use the video frame deletion conditions of the preset condition level, then the video frame deletion conditions with the lowest condition level among the unused video frame deletion conditions are used as the video frame deletion conditions that match each video segment; if the video frame deletion records indicate that each video segment has used the video frame deletion conditions of the preset condition level, then the matching video frame deletion conditions are determined in the manner of the above-mentioned embodiment 2.

[0099] Among them, the preset condition level can be pre-set, such as condition level 1, condition level 2, etc., and the preset condition level can also be flexibly calculated, such as flexibly determining the preset condition level based on the size of the remaining storage space, the data size of the video to be stored, the type of stored video files, the number of decoded playbacks of the stored video files, etc.

[0100] For example, the preset condition level is condition level 1 (the deletion flag indicates the video frame of non-motion detection data), and the video segments include video segment 1, video segment 2, and video segment 3. If the video frames of non-motion detection data are not deleted from video segment 1, video segment 2, and video segment 3, then the video frames of non-motion detection data are deleted from video segment 1, video segment 2, and video segment 3 in sequence. Otherwise, according to the method of the above-mentioned embodiment 2, the video frame deletion conditions of all other condition levels are first completely executed in sequence for video segment 1, and then the video frame deletion conditions of all other condition levels are completely executed in sequence for video segment 2, and so on, until the video frame deletion conditions of all condition levels are completely executed in sequence for all video segments.

[0101] In summary, the video frame deletion conditions matched to each video segment can be flexibly combined, and this application does not limit this.

[0102] In some embodiments, there are multiple video frame deletion conditions; in step S220, based on the frame attribute information of each video frame in the video file, detecting whether the video frame satisfies the video frame deletion condition, including: determining the matching video frame deletion condition based on the video frame deletion condition already used in the video frame deletion record corresponding to the video file, and / or the remaining storage space corresponding to the video storage space; detecting whether the frame attribute information of the video frame satisfies the matching video frame deletion condition.

[0103] That is, without dividing the video segments, one or more matching video frame deletion conditions are selected from multiple video frame deletion conditions, and the video frames in all video files are filtered according to the matching video frame deletion conditions.

[0104] In some embodiments, the frame attribute information includes the frame type of the video frame, and the video frame deletion condition includes the pre-deleted frame type; in step S220, based on the frame attribute information of each video frame in the video file, detecting whether the video frame meets the video frame deletion condition, including: extracting the frame header flag of the video frame to obtain the frame type of the video frame; detecting whether the pre-deleted frame type contains the frame type of the video frame; if it does, it is determined that the frame attribute information of the video frame meets the video frame deletion condition; if not, it is determined that the frame attribute information of the video frame does not meet the video frame deletion condition.

[0105] For example, the frame types include a BASE frame, an ENHANCE frame, an I frame, a video frame of non-motion detection data, and a video frame of motion detection data.

[0106] According to the video frame deletion condition, video frames of preset types are filtered out for deletion.

[0107] In some embodiments, the frame attribute information includes the frame type and storage time of the video frame; in step S220, based on the frame attribute information of each video frame in the video file, detecting whether the video frame meets the video frame deletion condition, including: calculating the deletion recommendation index of each video frame based on the frame type and storage time of each video frame; detecting whether the deletion recommendation index of the video frame meets the video frame deletion condition.

[0108] For example, the longer the video frame is stored and / or the less important the frame type indicates, the higher the corresponding deletion recommendation index is, and vice versa. Different frame types may correspond to different importance levels, such as I frames having the highest importance level and non-motion detection data video frames having the lowest importance level. The lower the importance level, the less important the corresponding video frame is.

[0109] Check whether the deletion recommendation index of the video frame satisfies the video frame deletion condition.

[0110] For example, the video frame deletion condition is to use video frames whose deletion recommendation index is lower than a preset index threshold as pre-deleted video frames.

[0111] For another example, the video frame deletion condition is to sort the video frames in descending order according to the deletion recommendation index, and select the top M video frames in the sorting as the pre-deleted video frames.

[0112] After the pre-deleted video frames are obtained through the above-mentioned embodiments, the pre-deleted video frames in the video file are deleted respectively.

[0113] The video storage compression method provided by the present application obtains the video files stored in the video storage space and the video frame deletion condition by responding to the space cleaning instruction of the video storage space; detects whether the video frame meets the video frame deletion condition based on the frame attribute information of each video frame in the video file; takes the video frames that meet the video frame deletion condition as pre-deleted video frames, and deletes the pre-deleted video frames in the video file respectively. Compared with the prior art of directly deleting the entire video file, the present application takes the attribute information of the video frame in the video file into more in-depth consideration, and only selects to delete some video frames in the video file, in exchange for more information storage at the cost of losing some video frames. From the perspective of the timeline, while the storage space remains unchanged, information with longer time and more content can be saved, thereby improving the storage space utilization rate of the memory.

[0114] Figure 8 FIG. 1 is a block diagram of a video storage compression device according to an exemplary embodiment of the present application. Figure 8 As shown, the exemplary video compression device 800 includes: an instruction response module 810, a video frame detection module 820 and a video frame deletion module 830. Specifically:

[0115] The instruction response module 810 is used to respond to the space cleaning instruction of the video storage space, obtain the video files stored in the video storage space, and obtain the video frame deletion condition;

[0116] The video frame detection module 820 is used to detect whether the video frame meets the video frame deletion condition based on the frame attribute information of each video frame in the video file;

[0117] The video frame deletion module 830 is used to take the video frames that meet the video frame deletion condition as pre-deleted video frames and perform deletion processing on the pre-deleted video frames in the video file respectively.

[0118] It should be noted that the video storage compression device provided in the above embodiment and the video storage compression method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, and will not be repeated here. In practical applications, the video storage compression device provided in the above embodiment can allocate the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.

[0119] See also Fig. 9 , Fig. 9 1 is a schematic diagram of the structure of an embodiment of an electronic device of the present application. The electronic device 900 includes a memory 901 and a processor 902, and the processor 902 is used to execute program instructions stored in the memory 901 to implement the steps in any of the above-mentioned video storage compression method embodiments. In a specific implementation scenario, the electronic device 900 may include but is not limited to: a microcomputer, a server, and in addition, the electronic device 900 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.

[0120] Specifically, the processor 902 is used to control itself and the memory 901 to implement the steps in any of the above-mentioned video storage compression method embodiments. The processor 902 can also be called a central processing unit (CPU). The processor 902 may be an integrated circuit chip with signal processing capabilities. The processor 902 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 902 can be implemented by an integrated circuit chip.

[0121] See also Fig.10 , Fig.10 The computer-readable storage medium 1000 stores program instructions 1010 that can be executed by a processor, and the program instructions 1010 are used to implement the steps in any of the above-mentioned video compression method embodiments.

[0122] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0123] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.

[0124] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0125] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. 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 part of the contribution 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 several instructions for a computer device (which can be a personal computer, a server, or a 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 (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program code.

Claims

1. A video compression method, characterized in that: include: In response to a space clearing instruction of the video storage space, video files stored in the video storage space are obtained, all the stored video files are used as a global video file, and the global video file is segmented according to the storage time of each video frame in the global video file to obtain a plurality of video segments; The video frame deletion condition that matches each video segment is determined by any of the following methods: Method 1: obtaining the used video frame deletion conditions in the video frame deletion record corresponding to each video segment, and using the video frame deletion condition with the lowest condition level among the unused video frame deletion conditions as the video frame deletion condition matching each video segment; wherein the number of the video frame deletion conditions is multiple, and each video frame deletion condition corresponds to a different condition level; Method 2: sorting each video segment according to the storage time of each video segment, selecting a preset number of video segments with top rankings from the sorting results to obtain priority deletion video segments, obtaining the used video frame deletion conditions in the video frame deletion records corresponding to the priority deletion video segments, and using the video frame deletion condition with the lowest condition level among the unused video frame deletion conditions as the video frame deletion condition matching the priority deletion video segments; Mode 3: If the video frame deletion record corresponding to each video segment indicates that the video frame deletion condition of the preset condition level has been used for each video segment, the video frame deletion condition is obtained according to Mode 2; if the video frame deletion record corresponding to each video segment indicates that the video frame deletion condition of the preset condition level has not been used for each video segment, the video frame deletion condition is obtained according to Mode 1; Based on the frame attribute information of each video frame in the video segment, detecting whether the video frame satisfies the video frame deletion condition; The video frames satisfying the video frame deletion condition are taken as pre-deleted video frames, and the pre-deleted video frames in the video segment are deleted respectively.

2. The method according to claim 1, characterized in that Determine the video frame deletion conditions that each video segment matches, including: Selecting a target video frame deletion condition from a plurality of video frame deletion conditions based on the video frame deletion conditions used in the video frame deletion record corresponding to each video segment and the remaining storage space corresponding to the video storage space; The target video frame deletion conditions are all used as the video frame deletion conditions matched by each video segment.

3. The method according to claim 1, characterized in that The step of sorting each video segment according to the storage time of each video segment, selecting a preset number of video segments with high ranking from the sorting results to obtain priority deletion video segments, obtaining the used video frame deletion conditions in the video frame deletion records corresponding to the priority deletion video segments, and using the video frame deletion condition with the lowest condition level among the unused video frame deletion conditions as the video frame deletion condition matching the priority deletion video segments, includes: If the video frame deletion record indicates that the priority deletion video segment has not used up all the video frame deletion conditions of the condition levels, the video frame deletion condition with the lowest condition level among the unused video frame deletion conditions is used as the video frame deletion condition that matches the priority deletion video segment; If the video frame deletion record indicates that the priority deletion video segment has used up the video frame deletion conditions of all condition levels, the priority deletion video segment is removed from the sorting result, and a preset number of video segments with high rankings are selected from the sorting result after removal to obtain a new priority deletion video segment, and the video frame deletion condition with the lowest condition level is used as the video frame deletion condition that matches the new priority deletion video segment.

4. The method according to claim 1, characterized in that: The frame attribute information includes a frame type of the video frame, and the video frame deletion condition includes a pre-deleted frame type; and detecting whether the video frame satisfies the video frame deletion condition based on the frame attribute information of each video frame in the video segment includes: Extracting a frame header flag of the video frame to obtain a frame type of the video frame; Detecting whether the pre-deleted frame types contain the frame type of the video frame; If it does, it is determined that the frame attribute information of the video frame meets the video frame deletion condition; If not, it is determined that the frame attribute information of the video frame does not satisfy the video frame deletion condition.

5. The method according to claim 1, characterized in that The frame attribute information includes a frame type and a storage time of the video frame; and detecting whether the video frame satisfies the video frame deletion condition based on the frame attribute information of each video frame in the video segment includes: Calculating a deletion recommendation index for each video frame based on a frame type and a storage time of each video frame; It is detected whether the deletion recommendation index of the video frame satisfies the video frame deletion condition.

6. The method according to claim 1, characterized in that Before responding to the space cleaning instruction of the video storage space, the method further includes: Get the remaining storage space corresponding to the video storage space; Obtaining a preset space threshold, and if the remaining storage space is less than the preset space threshold, generating a space cleanup instruction; or, A video storage request is received, and a data size of a video to be stored corresponding to the video storage request is obtained. If the data size of the video to be stored is larger than the remaining storage space, a space clearing instruction is generated.

7. An electronic device, characterized in that: The electronic device comprises a memory and a processor, and the processor is used to execute program instructions stored in the memory to implement the steps in the method according to any one of claims 1 to 6.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program instructions, and the program instructions can be executed by a processor to implement the steps in the method according to any one of claims 1 to 6.