Methods, devices, streaming media servers, storage media, and software products for storing video files

By selecting the optimal storage method based on the size level of the video file and the average write time of the storage device, the memory consumption problem caused by the inability to upload video files in a timely manner is solved, thus achieving stability and reliability of cloud recording of streaming media.

CN119520712BActive Publication Date: 2025-10-31CHINA TELECOM CLOUD TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411702802.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-10-31
Estimated Expiration
2044-11-26

AI Technical Summary

Technical Problem

During the upload process to cloud storage, factors such as excessive generation, fluctuations in cloud storage performance, and limited network bandwidth can cause video files to fail to upload in a timely manner, consuming streaming media server memory and potentially leading to service crashes and data loss.

Method used

Based on the size and average write time of the video files and the storage device, select the optimal storage method to write the video files to cloud storage, backup cloud storage, or the local disk of the streaming media server to distribute the storage pressure and prevent memory overload.

Benefits of technology

By employing a multi-tiered storage strategy, the performance bottleneck of a single storage method is mitigated, ensuring the stability and reliability of cloud-based streaming media recording and preventing program crashes caused by memory overload.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119520712B_ABST
    Figure CN119520712B_ABST
Patent Text Reader

Abstract

This application relates to the field of cloud recording technology for streaming media, and provides a method, apparatus, streaming media server, storage medium, and program product for storing video files. In this application, if the file size level of the video file to be uploaded in the memory of the streaming media server is at the first level, the video file to be uploaded is written to cloud storage; if the file size level is at the second level, and the average write time of the cloud storage is less than the average write time of the local disk of the streaming media server, the video file to be uploaded is written to cloud storage; if the file size level is at the third level, and the average write time of the preliminary cloud storage is the minimum average write time, the video file to be uploaded is written to the preliminary cloud storage; if the file size level is at the third level, the average write time of the local disk is the minimum average write time, and both the average write time of the cloud storage and the average write time of the preliminary cloud storage are greater than the write timeout threshold, the video file to be uploaded is written to the local disk.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cloud recording technology for streaming media, and in particular to a method, apparatus, streaming media server, storage medium, and computer program product for storing video files. Background Technology

[0002] Video surveillance data can effectively help users review the scene and identify problems. Streaming media cloud recording is one method for generating video surveillance data. This method receives media stream data, records it into video files, and then uploads the video files to cloud storage, meeting the long-term storage needs of massive amounts of video data. Because it involves the recording and storage of user data, the stability and reliability of streaming media cloud recording are very important and need to be guaranteed from multiple aspects.

[0003] One problem is that during the process of uploading video files to cloud storage, various factors such as generating too many video files, fluctuations in cloud storage performance, and limited network bandwidth can cause video files to fail to be uploaded to cloud storage in a timely manner, becoming stuck in the memory of the streaming media server. As a result, the memory usage continues to increase, which may eventually cause the streaming media service to crash and the data in memory to be lost directly. Summary of the Invention

[0004] Therefore, it is necessary to provide a method, apparatus, streaming media server, storage medium, and computer program product for storing video files to address the aforementioned technical problems.

[0005] This application provides a method for storing video files, the method comprising:

[0006] Retrieve the video recording file to be uploaded from the memory of the streaming media server;

[0007] Determine the file size level of the video file to be uploaded, and obtain the write timeout threshold;

[0008] If the file size level is the first level, then the video file to be uploaded will be written to cloud storage for storage;

[0009] If the file size level is in the second level, and the average write time of the cloud storage is less than the average write time of the local disk of the streaming media server, then the video file to be uploaded will be written to the cloud storage for storage.

[0010] If the file size level is the second level, and the average write time of the cloud storage is greater than the average write time of the local disk of the streaming media server, and the average write time of the cloud storage is less than or equal to the write timeout threshold, then the video file to be uploaded will be written to the cloud storage for storage.

[0011] If the file size level is the third level, and the average write time of the cloud storage is the minimum average write time among the average write time of the cloud storage, the average write time of the pre-cloud storage, and the average write time of the local disk of the streaming media server, then the video file to be uploaded will be written to the cloud storage for storage.

[0012] If the file size level is the third level, and the average write time of the prepared cloud storage is the minimum average write time among the average write time of the cloud storage, the average write time of the prepared cloud storage, and the average write time of the local disk of the streaming media server, then the video file to be uploaded will be written to the prepared cloud storage for storage.

[0013] If the file size level is the third level, and the average write time of the local disk of the streaming media server is the minimum average write time among the average write time of cloud storage, the average write time of the prepared cloud storage, and the average write time of the local disk of the streaming media server, and both the average write time of cloud storage and the average write time of the prepared cloud storage are greater than the write timeout threshold, then the video file to be uploaded will be written to the local disk of the streaming media server for storage.

[0014] The file sizes for the first, second, and third levels increase sequentially.

[0015] In one embodiment, the method further includes:

[0016] If the file size level is at the fourth level, an alarm message will be sent to the operations and maintenance personnel; the file size corresponding to the fourth level is greater than the file size corresponding to the third level.

[0017] In one embodiment, determining the file size level of the video file to be uploaded includes:

[0018] Obtain a pre-set first threshold, a second threshold, and a third threshold; the first threshold is less than the second threshold, and the second threshold is less than the third threshold;

[0019] If the file size of the video file to be uploaded is less than or equal to the first threshold, then the file size level of the video file to be uploaded is determined to belong to the first level;

[0020] If the file size of the video file to be uploaded is greater than the first threshold and less than or equal to the second threshold, then the file size level of the video file to be uploaded is determined to belong to the second level.

[0021] If the file size of the video file to be uploaded is greater than the second threshold and less than or equal to the third threshold, then the file size level of the video file to be uploaded is determined to belong to the third level.

[0022] If the file size of the video file to be uploaded is greater than the third threshold, then the file size level of the video file to be uploaded is determined to belong to the fourth level.

[0023] In one embodiment, the method further includes:

[0024] If the file size level is the second level, and the average write time of the cloud storage is greater than the average write time of the local disk of the streaming media server, and the average write time of the cloud storage is greater than the write timeout threshold, then the video file to be uploaded will be written to the local disk of the streaming media server for storage.

[0025] In one embodiment, the step of obtaining the average write time of cloud storage includes:

[0026] Obtain the total time spent writing video files to the cloud storage and the total number of video files within the historical time period;

[0027] The average write time for cloud storage is obtained based on the total time and the total number.

[0028] In one embodiment, obtaining the write timeout threshold includes:

[0029] Get the preset timeout period;

[0030] Divide the random number by the timeout period and obtain the integer result of the division;

[0031] The write timeout threshold is obtained based on the integer.

[0032] This application provides a storage device for video files, the device comprising:

[0033] The video file acquisition module is used to acquire the video files to be uploaded from the memory of the streaming media server;

[0034] The grade determination module is used to determine the file size grade of the video file to be uploaded;

[0035] The threshold acquisition module is used to obtain the write timeout threshold;

[0036] The write processing module is used to write the video file to be uploaded to cloud storage for storage if the file size level belongs to the first level.

[0037] The write processing module is further configured to write the video file to be uploaded into the cloud storage for storage if the file size level belongs to the second level and the average write time of the cloud storage is less than the average write time of the local disk of the streaming media server.

[0038] The write processing module is further configured to write the video file to be uploaded into the cloud storage for storage if the file size level belongs to the second level, and the average write time of the cloud storage is greater than the average write time of the local disk of the streaming media server, and the average write time of the cloud storage is less than or equal to the write timeout threshold.

[0039] The write processing module is further configured to write the video file to be uploaded into the cloud storage for storage if the file size level belongs to the third level and the average write time of the cloud storage is the minimum average write time among the average write time of the cloud storage, the average write time of the pre-cloud storage, and the average write time of the local disk of the streaming media server.

[0040] The write processing module is further configured to write the video file to be uploaded into the prepared cloud storage for storage if the file size level belongs to the third level and the average write time of the prepared cloud storage is the minimum average write time among the average write time of the cloud storage, the average write time of the prepared cloud storage, and the average write time of the local disk of the streaming media server.

[0041] The write processing module is further configured to write the video file to be uploaded to the local disk of the streaming media server for storage if the file size level belongs to the third level, and the average write time of the local disk of the streaming media server is the minimum average write time among the average write time of cloud storage, the average write time of the preparatory cloud storage, and the average write time of the local disk of the streaming media server, and both the average write time of cloud storage and the average write time of the preparatory cloud storage are greater than the write timeout threshold.

[0042] The file sizes for the first, second, and third levels increase sequentially.

[0043] This application provides a streaming media server, including a memory and a processor, wherein the memory stores a computer program and the processor executes the above-described method.

[0044] This application provides a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor using the methods described above.

[0045] This application provides a computer program product having a computer program stored thereon, the computer program being executed by a processor using the above-described method.

[0046] The aforementioned method, apparatus, streaming media server, storage medium, and computer program product for storing video files acquire the video file to be uploaded from the memory of the streaming media server; determine the file size level of the video file to be uploaded and obtain the write timeout threshold; if the file size level is the first level, then the video file to be uploaded is written to cloud storage for storage; if the file size level is the second level, and the average write time of cloud storage is less than the average write time of the local disk of the streaming media server, then the video file to be uploaded is written to cloud storage for storage; if the file size level is the second level, and the average write time of cloud storage is greater than the average write time of the local disk of the streaming media server, and the average write time of cloud storage is less than or equal to the write timeout threshold, then the video file to be uploaded is written to cloud storage for storage; if the file size level is the third level, and the average write time of cloud storage is equal to the average write time of cloud storage, the average write time of the pre-cloud storage, and the average write time of the streaming media server... If the average write time of the server's local disk is the minimum among the average write times of the cloud storage, the video file to be uploaded will be written to cloud storage for storage. If the file size level belongs to the third level, and the average write time of the prepared cloud storage is the minimum among the average write times of cloud storage, the average write times of the prepared cloud storage, and the average write times of the streaming media server's local disk, the video file to be uploaded will be written to the prepared cloud storage for storage. If the file size level belongs to the third level, and the average write time of the streaming media server's local disk is the minimum among the average write times of cloud storage, the average write times of the prepared cloud storage, and the average write times of the streaming media server's local disk, and both the average write times of cloud storage and the average write times of the prepared cloud storage are greater than the write timeout threshold, the video file to be uploaded will be written to the streaming media server's local disk for storage. The file sizes corresponding to the first, second, and third levels increase sequentially.The solution provided in this application sets multiple levels for the video files to be uploaded in the memory of the streaming media server to distinguish different write storage addresses. When the file size level of the video file to be uploaded belongs to the first level, it is directly written to cloud storage. When the file size level of the video file to be uploaded belongs to the second level, it is written to either cloud storage or the local disk of the streaming media server. When the file size level of the video file to be uploaded belongs to the third level, it is written to either cloud storage, backup cloud storage, or the local disk of the streaming media server. In the selection process, the average write time of each is compared to select the storage method with better performance and share the pressure, reducing the impact of the performance bottleneck of a single write method. Considering that the local disk space of the streaming media server is limited, if the average write time of cloud storage and backup cloud storage is greater than the average write time of local disk, but the average write time of cloud storage or backup cloud storage does not exceed the write timeout threshold, the video file to be uploaded can still be written to cloud storage or backup cloud storage. The solution provided in this application monitors the size of the video files to be uploaded in the memory of the streaming media server and distributes the pressure of writing to storage, preventing the program from crashing due to memory overload of the streaming media server, and ensuring the stability and reliability of cloud recording of streaming media. Attached Figure Description

[0047] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0048] Figure 1 This is a flowchart illustrating a method for storing video files in one embodiment;

[0049] Figure 2 This is a schematic diagram of the process for generating video files in one embodiment;

[0050] Figure 3 This is a flowchart illustrating a method for storing video files in another embodiment;

[0051] Figure 4 This is a structural block diagram of a video file storage device in one embodiment;

[0052] Figure 5 This is a diagram of the internal structure of a streaming media server in one embodiment. Detailed Implementation

[0053] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0054] The method for storing video files provided in this application includes Figure 1 The steps shown in the method can be executed by the processor of the streaming media server.

[0055] Step S101: Obtain the video file to be uploaded from the memory of the streaming media server.

[0056] Reference Figure 2 , Figure 2 The flowchart illustrates the process of a streaming media server's processor generating a video file. Specifically, in steps S201 and S202, the streaming media server's processor receives and parses the media stream data, determining the relative size between the received media stream data's duration t1 and a preset duration t2. If the media stream data's duration t1 is less than the preset duration t2, the process returns to step S201 to continue receiving media stream data. If the media stream data's duration t1 is greater than or equal to the preset duration t2, the process proceeds to step S203, where a single video file is generated based on the media stream data and stored in the streaming media server's memory's video queue. In step S204, the process determines whether the video processing thread is enabled. If the video processing thread is enabled, the video file is written to the corresponding storage address via the video processing thread, and the process returns to step S201 to continue receiving media stream data. If the video processing thread is not enabled, the process proceeds to step S205, where the video processing thread is enabled to write the video file to the corresponding storage address via the video processing thread.

[0057] Once the recording processing thread is started, the processor of the streaming media server can retrieve the recording files to be uploaded from the recording queue in the memory of the streaming media server through the recording processing thread.

[0058] Step S102: Determine the file size level of the video file to be uploaded and obtain the write timeout threshold.

[0059] The processor of the streaming media server can obtain the file size of the video file to be uploaded and determine the file size classification based on the file size. The processor can also obtain the write timeout threshold. This write timeout threshold can be a fixed value or a random value.

[0060] This application's embodiments divide the file into at least three levels, which can be referred to as the first level, the second level, and the third level; wherein the file sizes corresponding to the first level, the second level, and the third level increase sequentially.

[0061] Step S103: If the file size level is the first level, then the video file to be uploaded is written to cloud storage for storage.

[0062] If the file size level is at the first level, it means that the file size of the video file to be uploaded is relatively small, and the video file to be uploaded can be directly written to cloud storage for storage.

[0063] Step S104: If the file size level is in the second level and the average write time of the cloud storage is less than the average write time of the local disk of the streaming media server, then the video file to be uploaded is written to the cloud storage for storage.

[0064] If the file size level is in the second category, it means that the file size of the video file to be uploaded is slightly larger; at this time, the relative size between the average write time of cloud storage and the average write time of the local disk of the streaming media server can be compared.

[0065] If the average write time of cloud storage is less than the average write time of the local disk of the streaming media server, then the video files to be uploaded can be written to cloud storage for storage.

[0066] Step S105: If the file size level is the second level, and the average write time of cloud storage is greater than the average write time of the local disk of the streaming media server, and the average write time of cloud storage is less than or equal to the write timeout threshold, then the video file to be uploaded will be written to cloud storage for storage.

[0067] If the file size level is in the second category, and the average write time of cloud storage is greater than the average write time of the local disk of the streaming media server, then the relative size between the average write time of cloud storage and the write timeout threshold can be compared.

[0068] If the average write time of cloud storage is less than or equal to the write timeout threshold, it indicates that the average write time of cloud storage is within an acceptable range, and the video file to be uploaded can be written to cloud storage for storage.

[0069] Step S106: If the file size level is the third level, and the average write time of the cloud storage is the minimum average write time among the average write time of the cloud storage, the average write time of the preparatory cloud storage, and the average write time of the local disk of the streaming media server, then the video file to be uploaded will be written to the cloud storage for storage.

[0070] If the file size level is at level three, it indicates that the file size of the video file to be uploaded is relatively large. In this case, you can introduce backup cloud storage in the storage address options. At this time, the storage address options include cloud storage, backup cloud storage, and the local disk of the streaming media server.

[0071] The streaming media server's processor can compare the average write time of cloud storage, the average write time of pre-cloud storage, and the average write time of the streaming media server's local disk.

[0072] If the average write time of cloud storage is the minimum average write time, then the video file to be uploaded can be written to cloud storage for storage.

[0073] Step S107: If the file size level is the third level, and the average write time of the prepared cloud storage is the minimum average write time among the average write time of the cloud storage, the average write time of the prepared cloud storage, and the average write time of the local disk of the streaming media server, then the video file to be uploaded is written to the prepared cloud storage for storage.

[0074] If the file size level is the third level, the streaming media server's processor compares the average write time of cloud storage, the average write time of pre-cloud storage, and the average write time of the streaming media server's local disk. If it determines that the average write time of pre-cloud storage is the minimum average write time, then the video file to be uploaded can be written to the pre-cloud storage for storage.

[0075] Step S108: If the file size level belongs to the third level, and the average write time of the local disk of the streaming media server is the minimum average write time among the average write time of cloud storage, the average write time of the prepared cloud storage, and the average write time of the local disk of the streaming media server, and the average write time of cloud storage and the average write time of the prepared cloud storage are both greater than the write timeout threshold, then the recording file to be uploaded is written to the local disk of the streaming media server for storage.

[0076] If the file size level is at the third level, the streaming media server's processor compares the average write time of cloud storage, the average write time of the prepared cloud storage, and the average write time of the streaming media server's local disk, and determines the average write time of the streaming media server's local disk as the minimum average write time. Considering that the storage space of the streaming media server's local disk is limited, and storage on the local disk should be avoided as much as possible, the streaming media server's processor can also first compare the relative size between the average write time of cloud storage and the write timeout threshold, as well as the relative size between the average write time of the prepared cloud storage and the write timeout threshold.

[0077] If the average write time of cloud storage is less than or equal to the write timeout threshold, and the average write time of the cloud storage to be uploaded is greater than the write timeout threshold, then the video file to be uploaded can be written to cloud storage.

[0078] If the average write time of the cloud storage is greater than the write timeout threshold, and the average write time of the pre-cloud storage is less than or equal to the write timeout threshold, then the video file to be uploaded can be written to the pre-cloud storage.

[0079] If the average write time of cloud storage is less than or equal to the write timeout threshold, and the average write time of the pre-cloud storage is less than or equal to the write timeout threshold, then the relative size between the average write time of cloud storage and the average write time of the pre-cloud storage can be determined. If the average write time of cloud storage is less than the average write time of the pre-cloud storage, then the video file to be uploaded can be written to cloud storage. If the average write time of cloud storage is greater than the average write time of the pre-cloud storage, then the video file to be uploaded can be written to the pre-cloud storage.

[0080] If the average write time of cloud storage is greater than the write timeout threshold, and the average write time of the prepared cloud storage is greater than the write timeout threshold, then the video file to be uploaded can be written to the local disk of the streaming media server for storage.

[0081] In the above-mentioned method for processing video files, the following steps are taken: The video file to be uploaded is retrieved from the memory of the streaming media server; the file size level of the video file to be uploaded is determined, and a write timeout threshold is obtained; if the file size level is the first level, the video file to be uploaded is written to cloud storage; if the file size level is the second level, and the average write time of cloud storage is less than the average write time of the local disk of the streaming media server, the video file to be uploaded is written to cloud storage; if the file size level is the second level, and the average write time of cloud storage is greater than the average write time of the local disk of the streaming media server, and the average write time of cloud storage is less than or equal to the write timeout threshold, the video file to be uploaded is written to cloud storage; if the file size level is the third level, and the average write time of cloud storage is equal to the average write time of cloud storage, the average write time of the pre-cloud storage, and the write time of the local disk of the streaming media server... If the minimum average write time is selected from the average write times, the video file to be uploaded will be written to cloud storage for storage. If the file size level belongs to the third level, and the average write time of the preparatory cloud storage is the minimum average write time among the average write times of cloud storage, preparatory cloud storage, and the local disk of the streaming media server, then the video file to be uploaded will be written to the preparatory cloud storage for storage. If the file size level belongs to the third level, and the average write time of the local disk of the streaming media server is the minimum average write time among the average write times of cloud storage, preparatory cloud storage, and the local disk of the streaming media server, and both the average write time of cloud storage and the average write time of preparatory cloud storage are greater than the write timeout threshold, then the video file to be uploaded will be written to the local disk of the streaming media server for storage. The file sizes corresponding to the first, second, and third levels increase sequentially. The solution provided in this application sets multiple levels for the video files to be uploaded in the memory of the streaming media server to distinguish different write storage addresses. When the file size level of the video file to be uploaded belongs to the first level, it is directly written to cloud storage. When the file size level of the video file to be uploaded belongs to the second level, it is written to either cloud storage or the local disk of the streaming media server. When the file size level of the video file to be uploaded belongs to the third level, it is written to either cloud storage, backup cloud storage, or the local disk of the streaming media server. In the selection process, the average write time of each is compared to select the storage method with better performance and share the pressure, reducing the impact of the performance bottleneck of a single write method. Considering that the local disk space of the streaming media server is limited, if the average write time of cloud storage and backup cloud storage is greater than the average write time of local disk, but the average write time of cloud storage or backup cloud storage does not exceed the write timeout threshold, the video file to be uploaded can still be written to cloud storage or backup cloud storage.The solution provided in this application monitors the size of the video files to be uploaded in the memory of the streaming media server and distributes the pressure of writing to storage, preventing the program from crashing due to memory overload of the streaming media server, and ensuring the stability and reliability of cloud recording of streaming media.

[0082] In one embodiment, the method provided in this application further includes:

[0083] If the file size is classified as Level 4, an alarm message will be sent to the operations and maintenance personnel; the file size corresponding to Level 4 is greater than the file size corresponding to Level 3.

[0084] This embodiment divides the file into at least four levels, which can be referred to as Level 1, Level 2, Level 3, and Level 4; wherein the file sizes corresponding to Level 1, Level 2, Level 3, and Level 4 increase sequentially.

[0085] If the processor of the streaming media server determines that the file size of the video file to be uploaded belongs to the fourth level, it means that the current situation is out of control. Therefore, an alarm message can be sent to the maintenance personnel so that they can intervene in time.

[0086] In one embodiment, determining the file size level of the video file to be uploaded includes:

[0087] Obtain a pre-set first threshold, second threshold, and third threshold; the first threshold is less than the second threshold, and the second threshold is less than the third threshold; if the file size of the video file to be uploaded is less than or equal to the first threshold, then the file size level of the video file to be uploaded is determined to be the first level; if the file size of the video file to be uploaded is greater than the first threshold and less than or equal to the second threshold, then the file size level of the video file to be uploaded is determined to be the second level; if the file size of the video file to be uploaded is greater than the second threshold and less than or equal to the third threshold, then the file size level of the video file to be uploaded is determined to be the third level; if the file size of the video file to be uploaded is greater than the third threshold, then the file size level of the video file to be uploaded is determined to be the fourth level.

[0088] In this embodiment, a pre-set first threshold (which can be denoted as s1), a second threshold (which can be denoted as s2), and a third threshold (which can be denoted as s3) can be obtained, where the first threshold s1 is greater than the second threshold s2, and the second threshold s2 is greater than the third threshold s3. The file size of the video file to be uploaded can be denoted as s. In some scenarios, the first threshold s1 can be set to 100GB, the second threshold s2 can be set to 200GB, and the third threshold s3 can be set to 300GB.

[0089] If the file size *s* of the video file to be uploaded is less than or equal to the first threshold *s1*, then the file size level of the video file to be uploaded is determined to be Level 1. If the file size *s* of the video file to be uploaded is greater than the first threshold *s1* and less than or equal to the second threshold *s2*, then the file size level of the video file to be uploaded is determined to be Level 2. If the file size *s* of the video file to be uploaded is greater than the second threshold *s2* and less than or equal to the third threshold *s3*, then the file size level of the video file to be uploaded is determined to be Level 3; if the file size *s* of the video file to be uploaded is greater than the third threshold *s3*, then the file size level of the video file to be uploaded is determined to be Level 4.

[0090] In one embodiment, the method provided in this application further includes:

[0091] If the file size is in the second category, and the average write time of cloud storage is greater than the average write time of the local disk of the streaming media server, and the average write time of cloud storage is greater than the write timeout threshold, then the recording file to be uploaded will be written to the local disk of the streaming media server for storage.

[0092] If the file size level is in the second category, the streaming media server's processor can compare the relative size between the average write time of cloud storage and the average write time of the streaming media server's local disk.

[0093] If the average write time of cloud storage is greater than the average write time of the local disk of the streaming media server, the processor of the streaming media server can compare the relative size between the average write time of cloud storage and the write timeout threshold.

[0094] If the average write time of cloud storage is greater than the write timeout threshold, it indicates that the average write time of cloud storage is outside the acceptable range. In this case, the video files to be uploaded can be written to the local disk of the streaming media server for storage.

[0095] In one embodiment, the step of obtaining the average write time of the local disk of the streaming media server includes:

[0096] Get the total time spent writing video files to the local disk and the total number of video files within the historical time period; based on the total time and the total number of files, get the average write time to the local disk.

[0097] Historical time periods can be those close to the current time, such as the minute before the current time.

[0098] The streaming media server's processor can obtain the total time spent writing recording files to the local disk in the previous minute (denoted as tas), and also the total number of recording files written to the local disk in the previous minute (denoted as na). The total time spent writing recording files to the local disk (tas) is divided by the total number of recording files written to the local disk (na), and the result is taken as the average write time to the local disk. If the average write time to the local disk is denoted as ta, it can be expressed by the formula ta = tas / na; where, if the total number of recording files written to the local disk (na) is 0, then the average write time to the local disk (ta) is also 0.

[0099] In one embodiment, the step of obtaining the average write time of cloud storage includes:

[0100] Obtain the total time spent writing video files to cloud storage and the total number of video files within the historical time period; based on the total time spent and the total number of files, obtain the average write time to cloud storage.

[0101] Historical time periods can be those close to the current time, such as the minute before the current time.

[0102] The streaming media server's processor can obtain the total time spent writing video files to cloud storage in the previous minute (denoted as tbs), and also the total number of video files written to cloud storage in the previous minute (denoted as nb). The total time spent writing video files to cloud storage (tbs) is divided by the total number of video files written to cloud storage (nb), and the result is taken as the average write time to cloud storage. If the average write time to cloud storage is denoted as tb, it can be expressed by the formula tb = tbs / nb; where, if the total number of video files written to cloud storage (nb) is 0, then the average write time to cloud storage (tb) is also 0.

[0103] In one embodiment, the step of obtaining the average write time of the prepared cloud storage includes:

[0104] Obtain the total time spent writing video files to the cloud storage within the historical time period, as well as the total number of video files; based on the total time and the total number, obtain the average write time to the cloud storage.

[0105] Historical time periods can be those close to the current time, such as the minute before the current time.

[0106] The processor of the streaming media server can obtain the total time spent writing video files to the cloud storage in the previous minute (denoted as tcs), and also the total number of video files written to the cloud storage in the previous minute (denoted as nc). The total time spent writing video files to the cloud storage (tcs) is divided by the total number of video files written to the cloud storage (nc), and the result is taken as the average write time to the cloud storage. If the average write time to the cloud storage is denoted as tc, it can be expressed as tc = tcs / nc; where, if the total number of video files written to the cloud storage (nc) is 0, then the average write time to the cloud storage (tc) is also 0.

[0107] In one embodiment, obtaining the write timeout threshold includes:

[0108] Get the preset timeout period; divide the random number by the timeout period and get the integer result; based on the integer, get the write timeout threshold.

[0109] The preset timeout period can be denoted as 'to', and 'to' can be set to 600 milliseconds. A random number can be generated using a random number generator. This random number is then divided by the timeout period 'to', and the integer result is used as the write timeout threshold (denoted as 'tr'). The write timeout threshold obtained in this way is a random value. The random number generator can be 'rand()'.

[0110] To better understand the above method, the following details an application example of the video file storage method of this application. The first threshold, second threshold, and third threshold involved in this application example are denoted as s1, s2, and s3, respectively. (Refer to...) Figure 3 , Figure 3 A flowchart illustrating the method provided in this application.

[0111] Step S301: The processor of the streaming media server retrieves the recording file to be uploaded from the recording queue in the memory of the streaming media server;

[0112] In step S302, the processor can determine the file size s of the video recording file to be uploaded;

[0113] In step S303, the processor can calculate the average write time ta of the local disk of the streaming media server.

[0114] In step S304, the processor can write the timeout threshold tr.

[0115] Step S305: The processor determines whether the file size s of the video file to be uploaded is greater than the first threshold s1; if not, proceed to step S306; if yes, proceed to step S307.

[0116] Step S306: The processor writes the video file to be uploaded to the cloud storage;

[0117] Step S307: The processor determines whether the file size s of the video file to be uploaded is greater than the second threshold s2; if not, proceed to step S308; if yes, proceed to step S312.

[0118] Step S308: The processor calculates the average write time tb for cloud storage;

[0119] Step S309: The processor determines whether the average write time ta of the local disk is greater than the average write time tb of the cloud storage; if yes, proceed to step S310; if no, proceed to step S306.

[0120] In step S310, the processor determines whether the average write time tb of the cloud storage is greater than the write timeout threshold tr; if yes, proceed to step S311; if no, proceed to step S306.

[0121] Step S311: The processor writes the video file to be uploaded to the local disk;

[0122] Step S312: The processor determines whether the file size s of the video file to be uploaded is greater than the third threshold s3; if not, proceed to step S313; if yes, proceed to step S318.

[0123] Step S313: The processor calculates the average write time tc of the prepared cloud storage.

[0124] Step S314: The processor determines whether the average write time tb of the cloud storage is greater than the average write time tc of the prepared cloud storage; if not, proceed to step S309; ​​if yes, proceed to step S315.

[0125] Step S315: The processor determines whether the average write time tc of the cloud storage to be prepared is greater than the average write time ta of the local disk; if not, proceed to step S317; if yes, proceed to step S316.

[0126] Step S316: The processor determines whether the average write time tc of the cloud storage to be prepared is greater than the write timeout threshold tr; if yes, proceed to step S311; if no, proceed to step S317.

[0127] Step S317: The processor writes the video file to be uploaded to the pre-cloud storage;

[0128] In step S318, the processor sends an alarm notification message.

[0129] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0130] Based on the same inventive concept, this application also provides a video file storage device for implementing the video file storage method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more video file storage device embodiments provided below can be found in the limitations of the video file storage method described above, and will not be repeated here.

[0131] In one embodiment, such as Figure 4 As shown, a storage device for video files is provided, comprising:

[0132] The video file acquisition module 401 is used to acquire the video file to be uploaded from the memory of the streaming media server;

[0133] The grade determination module 402 is used to determine the file size grade of the video file to be uploaded;

[0134] The threshold acquisition module 403 is used to acquire the write timeout threshold.

[0135] The write processing module 404 is used to write the video file to be uploaded to cloud storage for storage if the file size level belongs to the first level.

[0136] The write processing module 404 is further configured to write the video file to be uploaded into the cloud storage for storage if the file size level belongs to the second level and the average write time of the cloud storage is less than the average write time of the local disk of the streaming media server.

[0137] The write processing module 404 is further configured to write the video file to be uploaded into the cloud storage for storage if the file size level belongs to the second level, and the average write time of the cloud storage is greater than the average write time of the local disk of the streaming media server, and the average write time of the cloud storage is less than or equal to the write timeout threshold.

[0138] The write processing module 404 is further configured to write the video file to be uploaded into the cloud storage for storage if the file size level belongs to the third level and the average write time of the cloud storage is the minimum average write time among the average write time of the cloud storage, the average write time of the pre-cloud storage, and the average write time of the local disk of the streaming media server.

[0139] The write processing module 404 is further configured to write the video file to be uploaded into the prepared cloud storage for storage if the file size level belongs to the third level and the average write time of the prepared cloud storage is the minimum average write time among the average write time of the cloud storage, the average write time of the prepared cloud storage, and the average write time of the local disk of the streaming media server.

[0140] The write processing module 404 is further configured to write the video file to be uploaded to the local disk of the streaming media server for storage if the file size level belongs to the third level, and the average write time of the local disk of the streaming media server is the minimum average write time among the average write time of cloud storage, the average write time of the preparatory cloud storage, and the average write time of the local disk of the streaming media server, and both the average write time of cloud storage and the average write time of the preparatory cloud storage are greater than the write timeout threshold.

[0141] The file sizes for the first, second, and third levels increase sequentially.

[0142] In one embodiment, the device further includes an alarm module for:

[0143] If the file size level is at the fourth level, an alarm message will be sent to the operations and maintenance personnel; the file size corresponding to the fourth level is greater than the file size corresponding to the third level.

[0144] In one embodiment, the level determination module 402 is further configured to:

[0145] Obtain a pre-set first threshold, a second threshold, and a third threshold; the first threshold is less than the second threshold, and the second threshold is less than the third threshold; if the file size of the video file to be uploaded is less than or equal to the first threshold, then the file size level of the video file to be uploaded is determined to belong to the first level; if the file size of the video file to be uploaded is greater than the first threshold and less than or equal to the second threshold, then the file size level of the video file to be uploaded is determined to belong to the second level; if the file size of the video file to be uploaded is greater than the second threshold and less than or equal to the third threshold, then the file size level of the video file to be uploaded is determined to belong to the third level; if the file size of the video file to be uploaded is greater than the third threshold, then the file size level of the video file to be uploaded is determined to belong to the fourth level.

[0146] In one embodiment, the write processing module 404 is further configured to:

[0147] If the file size level is the second level, and the average write time of the cloud storage is greater than the average write time of the local disk of the streaming media server, and the average write time of the cloud storage is greater than the write timeout threshold, then the video file to be uploaded will be written to the local disk of the streaming media server for storage.

[0148] In one embodiment, the apparatus further includes a write average time acquisition module, configured to:

[0149] Obtain the total time spent writing video files to the cloud storage during the historical time period and the total number of video files; based on the total time spent and the total number of files, obtain the average write time to the cloud storage.

[0150] In one embodiment, the threshold acquisition module 403 is further configured to:

[0151] Obtain the preset timeout period; divide the random number by the timeout period to obtain the integer result of the division; obtain the write timeout threshold based on the integer.

[0152] Each module in the aforementioned video file storage device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of the streaming media server in hardware form or independent of it, or stored in the memory of the streaming media server in software form, so that the processor can call and execute the operations corresponding to each module.

[0153] In one exemplary embodiment, a streaming media server is provided, the internal structure of which can be shown in the following diagram. Figure 5As shown, the streaming media server includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores the data involved in the aforementioned methods. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for storing video files.

[0154] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the solution of this application and does not constitute a limitation on the streaming media server to which the solution of this application is applied. A specific streaming media server may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0155] In one embodiment, a streaming media server is provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps in the various method embodiments described above.

[0156] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the various method embodiments described above.

[0157] In one embodiment, a computer program product is provided having a computer program stored thereon, the computer program being executed by a processor of the steps described in the various method embodiments above.

[0158] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0159] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0160] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0161] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for storing video files, characterized in that, The method includes: Retrieve the video recording file to be uploaded from the memory of the streaming media server; Determine the file size level of the video file to be uploaded, and obtain the write timeout threshold; If the file size level is the first level, then the video file to be uploaded will be written to cloud storage for storage; If the file size level is in the second level, and the average write time of the cloud storage is less than the average write time of the local disk of the streaming media server, then the video file to be uploaded will be written to the cloud storage for storage. If the file size level is the second level, and the average write time of the cloud storage is greater than the average write time of the local disk of the streaming media server, and the average write time of the cloud storage is less than or equal to the write timeout threshold, then the video file to be uploaded will be written to the cloud storage for storage. If the file size level is the third level, and the average write time of the cloud storage is the minimum average write time among the average write time of the cloud storage, the average write time of the pre-cloud storage, and the average write time of the local disk of the streaming media server, then the video file to be uploaded will be written to the cloud storage for storage. If the file size level is the third level, and the average write time of the prepared cloud storage is the minimum average write time among the average write time of the cloud storage, the average write time of the prepared cloud storage, and the average write time of the local disk of the streaming media server, then the video file to be uploaded will be written to the prepared cloud storage for storage. If the file size level is the third level, and the average write time of the local disk of the streaming media server is the minimum average write time among the average write time of cloud storage, the average write time of the prepared cloud storage, and the average write time of the local disk of the streaming media server, and both the average write time of cloud storage and the average write time of the prepared cloud storage are greater than the write timeout threshold, then the video file to be uploaded will be written to the local disk of the streaming media server for storage. The file sizes for the first, second, and third levels increase sequentially.

2. The method according to claim 1, characterized in that, The method further includes: If the file size level is at the fourth level, an alarm message will be sent to the operations and maintenance personnel; the file size corresponding to the fourth level is greater than the file size corresponding to the third level.

3. The method according to claim 2, characterized in that, Determining the file size level of the video file to be uploaded includes: Obtain a pre-set first threshold, a second threshold, and a third threshold; the first threshold is less than the second threshold, and the second threshold is less than the third threshold; If the file size of the video file to be uploaded is less than or equal to the first threshold, then the file size level of the video file to be uploaded is determined to belong to the first level; If the file size of the video file to be uploaded is greater than the first threshold and less than or equal to the second threshold, then the file size level of the video file to be uploaded is determined to belong to the second level. If the file size of the video file to be uploaded is greater than the second threshold and less than or equal to the third threshold, then the file size level of the video file to be uploaded is determined to belong to the third level. If the file size of the video file to be uploaded is greater than the third threshold, then the file size level of the video file to be uploaded is determined to belong to the fourth level.

4. The method according to claim 1, characterized in that, The method further includes: If the file size level is the second level, and the average write time of the cloud storage is greater than the average write time of the local disk of the streaming media server, and the average write time of the cloud storage is greater than the write timeout threshold, then the video file to be uploaded will be written to the local disk of the streaming media server for storage.

5. The method according to claim 1, characterized in that, The steps to obtain the average write time for cloud storage include: Obtain the total time spent writing video files to the cloud storage and the total number of video files within the historical time period; The average write time for cloud storage is obtained based on the total time and the total number.

6. The method according to any one of claims 1 to 5, characterized in that, Get the write timeout threshold, including: Get the preset timeout period; Divide the random number by the timeout period and obtain the integer result of the division; The write timeout threshold is obtained based on the integer.

7. A storage device for video recordings, characterized in that, The device includes: The video file acquisition module is used to acquire the video files to be uploaded from the memory of the streaming media server; The grade determination module is used to determine the file size grade of the video file to be uploaded; The threshold acquisition module is used to obtain the write timeout threshold; The write processing module is used to write the video file to be uploaded to cloud storage for storage if the file size level belongs to the first level. The write processing module is further configured to write the video file to be uploaded into the cloud storage for storage if the file size level belongs to the second level and the average write time of the cloud storage is less than the average write time of the local disk of the streaming media server. The write processing module is further configured to write the video file to be uploaded into the cloud storage for storage if the file size level belongs to the second level, and the average write time of the cloud storage is greater than the average write time of the local disk of the streaming media server, and the average write time of the cloud storage is less than or equal to the write timeout threshold. The write processing module is further configured to write the video file to be uploaded into the cloud storage for storage if the file size level belongs to the third level and the average write time of the cloud storage is the minimum average write time among the average write time of the cloud storage, the average write time of the pre-cloud storage, and the average write time of the local disk of the streaming media server. The write processing module is further configured to write the video file to be uploaded into the prepared cloud storage for storage if the file size level belongs to the third level and the average write time of the prepared cloud storage is the minimum average write time among the average write time of the cloud storage, the average write time of the prepared cloud storage, and the average write time of the local disk of the streaming media server. The write processing module is further configured to write the video file to be uploaded to the local disk of the streaming media server for storage if the file size level belongs to the third level, and the average write time of the local disk of the streaming media server is the minimum average write time among the average write time of cloud storage, the average write time of the pre-cloud storage and the average write time of the local disk of the streaming media server, and the average write time of cloud storage and the average write time of the pre-cloud storage are both greater than the write timeout threshold. The file sizes for the first, second, and third levels increase sequentially.

8. A streaming media server, comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method, system and device for offline uploading to cloud storage server

    CN103873505A

  • File storage method and system

    CN109981702A