Video file storage method and device, streaming media server, storage medium and program product
By setting multiple levels for the video files to be uploaded in the streaming server memory, and selecting according to the file size level and the average time to write to different storage addresses, the problem of increasing memory usage and streaming service crash caused by the inability to upload video files in time is solved, and the stability and reliability of streaming cloud recording is achieved.
Patent Information
- Application Number
- CN202411702802.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-11-26
AI Technical Summary
During the recording process of streaming media cloud, the recording files cannot be uploaded to cloud storage in time due to excessive generation, fluctuations in cloud storage performance, and limited network bandwidth, resulting in increased memory usage of streaming media servers, which may eventually lead to streaming service crashes and data loss.
By setting multiple levels for the video file to be uploaded, selecting according to the file size level and the average time to write to different storage addresses, and determining the storage address of the file. Specifically, the larger the file size level, the more diverse the selection of storage addresses, including cloud storage, preparatory cloud storage, and local disks for streaming servers.
It effectively shares the pressure on the streaming media server memory, prevents program crashes caused by memory overload, and ensures the stability and reliability of streaming cloud recording.
Smart Images

Figure CN119520712A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of streaming media cloud recording, and in particular to a method and device for storing video files, a streaming media server, a storage medium, and a computer program product. Background Art
[0002] Video surveillance data can effectively help users review the scene and find problems. Streaming media cloud recording is one of the methods to generate video surveillance data. This method receives media stream data and records it into a video file, and then uploads the video file to cloud storage, meeting the long-term storage needs of massive video data. Since it is related to 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 many aspects.
[0003] One of the problems is that in the process of uploading video files to cloud storage, due to various factors such as too many video files generated, fluctuating cloud storage performance, and limited network bandwidth, the video files cannot be uploaded to the cloud storage in time, and are blocked in the memory of the streaming media server. The memory occupied continues to increase, which may eventually cause the streaming media service to crash and the data in the memory to be directly lost. Summary of the invention
[0004] Based on this, it is necessary to provide a method, device, streaming media server, storage medium and computer program product for storing video files in response to the above technical problems.
[0005] The present application provides a method for storing a video file, the method comprising:
[0006] Get the video files to be uploaded in the memory of the streaming media server;
[0007] Determine the file size level of the video file to be uploaded, and obtain a write timeout threshold;
[0008] If the file size level belongs to the first level, the video file to be uploaded is written into the cloud storage for storage;
[0009] If the file size level belongs to the second level, and the average writing time of the cloud storage is less than the average writing time of the local disk of the streaming media server, the video file to be uploaded is written into the cloud storage for storage;
[0010] If the file size level belongs to the second level, and the average writing time of the cloud storage is greater than the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage is less than or equal to the writing time timeout threshold, then the video file to be uploaded is written into the cloud storage for storage;
[0011] If the file size level belongs to the third level, and the average writing time of the cloud storage is the minimum average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server, then the video file to be uploaded is written into the cloud storage for storage;
[0012] If the file size level belongs to the third level, and the average writing time of the standby cloud storage is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server, then the video file to be uploaded is written into the standby cloud storage for storage;
[0013] If the file size level belongs to the third level, and the average writing time of the local disk of the streaming media server is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage and the average writing time of the standby cloud storage are both greater than the writing time timeout threshold, then the video file to be uploaded is written to the local disk of the streaming media server for storage;
[0014] The file sizes corresponding to the first level, the second level and the third level increase in sequence.
[0015] In one embodiment, the method further comprises:
[0016] If the file size level belongs to the fourth level, an alarm reminder message is sent to the operation and maintenance personnel; the file size corresponding to the fourth level is larger 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] Acquire a preset first threshold, a second threshold, and a third threshold; the first threshold is smaller than the second threshold, and the second threshold is smaller 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, determining that the file size level of the video file to be uploaded belongs 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, it is determined that the file size level of the video file to be uploaded belongs 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, it is determined that the file size level of the video file to be uploaded belongs to the third level;
[0022] If the file size of the video file to be uploaded is greater than the third threshold, it is determined that the file size level of the video file to be uploaded belongs to the fourth level.
[0023] In one embodiment, the method further comprises:
[0024] If the file size level belongs to the second level, and the average writing time of the cloud storage is greater than the average writing time of the local disk of the streaming server, and the average writing time of the cloud storage is greater than the writing time timeout threshold, then the video file to be uploaded is written to the local disk of the streaming server for storage.
[0025] In one embodiment, the step of obtaining the average time consumed for writing to the cloud storage includes:
[0026] Obtain the total time consumed to write the video files stored in the cloud storage and the total number of video files in the historical period;
[0027] The average time consumption for writing to the cloud storage is obtained according to the total time consumption and the total number.
[0028] In one embodiment, obtaining a write timeout threshold includes:
[0029] Get the preset timeout period;
[0030] Divide the random number by the timeout period to obtain an integer of the division result;
[0031] According to the integer, a write timeout threshold is obtained.
[0032] The present application provides a storage device for video files, the device comprising:
[0033] The video file acquisition module is used to acquire the video file to be uploaded in the memory of the streaming media server;
[0034] A level determination module, used to determine the file size level of the video file to be uploaded;
[0035] A threshold acquisition module is used to obtain a write timeout threshold;
[0036] A writing processing module, used for writing the video file to be uploaded into the 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 to-be-uploaded video file into the cloud storage for storage if the file size level belongs to the second level and the average writing time of the cloud storage is less than the average writing time of the local disk of the streaming media server;
[0038] The write processing module is further configured to write the to-be-uploaded video file into the cloud storage for storage if the file size level belongs to the second level, and the average writing time of the cloud storage is greater than the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage is less than or equal to the writing time timeout threshold;
[0039] The write processing module is further configured to write the to-be-uploaded video file into the cloud storage for storage if the file size level belongs to the third level and the average writing time of the cloud storage is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server;
[0040] The write processing module is further configured to write the to-be-uploaded video file into the standby cloud storage for storage if the file size level belongs to the third level and the average writing time of the standby cloud storage is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage and the average writing 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 writing time of the local disk of the streaming media server is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage and the average writing time of the standby cloud storage are both greater than the write time timeout threshold;
[0042] The file sizes corresponding to the first level, the second level and the third level increase in sequence.
[0043] The present 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 method.
[0044] The present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to execute the above method.
[0045] The present application provides a computer program product, on which a computer program is stored, and the computer program is executed by a processor to perform the above method.
[0046] The above-mentioned video file storage method, device, streaming media server, storage medium and computer program product obtain the video file to be uploaded in 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 belongs to the first level, 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, then 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 time timeout threshold, then 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 in the cloud storage is the average write time of the cloud storage, the average write time of the standby cloud storage and the streaming media If the average writing time of the server's local disk is the minimum among the average writing time of the server's local disk, the video file to be uploaded is written to the cloud storage for storage; if the file size level belongs to the third level, and the average writing time of the standby cloud storage is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage and the average writing time of the local disk of the streaming media server, the video file to be uploaded is written to the standby cloud storage for storage; if the file size level belongs to the third level, and the average writing time of the local disk of the streaming media server is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage and the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage and the average writing time of the standby cloud storage are both greater than the write time timeout threshold, the video file to be uploaded is written to the local disk of the streaming media server for storage; wherein, the file sizes corresponding to the first level, the second level and the third level increase in sequence.The solution provided by the present 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 files to be uploaded belongs to the first level, they are directly written into the cloud storage; when the file size level of the video files to be uploaded belongs to the second level, one of the cloud storage and the local disk of the streaming media server is selected for writing; when the file size level of the video files to be uploaded belongs to the third level, one of the cloud storage, the standby cloud storage and the local disk of the streaming media server is selected for writing; and in the selection process, the average writing time of each is compared, so that a storage method with better performance can be selected, and the pressure is shared by each other to reduce the impact of the performance bottleneck of a single writing method; considering that the local disk space of the streaming media server is limited, when the average writing time of the cloud storage and the standby cloud storage is greater than the average writing time of the local disk, if the average writing time of the cloud storage or the average writing time of the standby cloud storage does not exceed the write time timeout threshold, the video files to be uploaded can still be written into the cloud storage or the standby cloud storage. Through the solution provided in this application, the size of the video files to be uploaded in the memory of the streaming media server is monitored and the pressure of writing storage is shared, so as to prevent the program crash caused by memory overload of the streaming media server and ensure the stability and reliability of streaming media cloud recording. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0048] Figure 1 A schematic diagram of a process flow of a method for storing video files in one embodiment;
[0049] Figure 2 A schematic diagram of a process for generating a video file in one embodiment;
[0050] Figure 3 A schematic diagram of a flow chart of a method for storing video files in another embodiment;
[0051] Figure 4 A structural block diagram of a storage device for video files in one embodiment;
[0052] Figure 5 FIG. 4 is an internal structure diagram of a streaming media server in one embodiment. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0054] The storage method of the video file provided by this application includes: Figure 1 The steps shown in the method can be executed by a processor of the streaming media server.
[0055] Step S101, obtaining the video file to be uploaded in the memory of the streaming media server.
[0056] Reference Figure 2 , Figure 2 The present invention shows a flow chart of a processor of a streaming media server generating a video file; specifically, in steps S201 and S202, the processor of the streaming media server can receive media stream data and parse the media stream data, and determine the relative size between the duration t1 of the received media stream data and the preset duration t2; if the duration t1 of the media stream data is less than the preset duration t2, then the process returns to step S201 to continue receiving the media stream data; if the duration t1 of the media stream data is greater than or equal to the preset duration t2, then the process enters step S203 to generate a single video file according to the media stream data and store it in a video queue of the memory of the streaming media server; step S204 to determine whether the video processing thread is turned on; if the video processing thread is turned on, the video file is written to the corresponding storage address through the video processing thread, and then the process returns to step S201 to continue receiving the media stream data; if the video processing thread is not turned on, then the process enters step S205 to turn on the video processing thread to write the video file to the corresponding storage address through the video processing thread.
[0057] After the video processing thread is started, the processor of the streaming media server can obtain the video file to be uploaded from the video queue of the memory of the streaming media server through the video processing thread.
[0058] Step S102, determining the file size level of the video file to be uploaded, and obtaining a 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 level of the video file to be uploaded according to the file size; the processor of the streaming media server can also obtain the write timeout threshold, wherein the write timeout threshold can be a fixed value or a random value.
[0060] The embodiment of the present application is divided into at least three levels, which can be called 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 in sequence.
[0061] Step S103: If the file size level belongs to the first level, the video file to be uploaded is written into the cloud storage for storage.
[0062] If the file size level belongs to the first level, it means that the file size of the video file to be uploaded is small, and the video file to be uploaded can be directly written into the cloud storage for storage.
[0063] Step S104: if the file size level belongs to the second level and the average writing time of the cloud storage is less than the average writing time of the local disk of the streaming media server, the video file to be uploaded is written into the cloud storage for storage.
[0064] If the file size level belongs to the second level, 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 writing time of the cloud storage and the average writing time of the local disk of the streaming media server can be compared.
[0065] If the average writing time of the cloud storage is less than the average writing time of the local disk of the streaming media server, the video file to be uploaded can be written into the cloud storage for storage.
[0066] Step S105, if the file size level belongs to the second level, and the average writing time of the cloud storage is greater than the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage is less than or equal to the writing time timeout threshold, then the video file to be uploaded is written to the cloud storage for storage.
[0067] If the file size level belongs to the second level and the average writing time of the cloud storage is greater than the average writing time of the local disk of the streaming server, the relative size between the average writing time of the cloud storage and the writing time timeout threshold can be compared.
[0068] If the average time consumed for writing to the cloud storage is less than or equal to the time-consuming threshold for writing, it indicates that the average time consumed for writing to the cloud storage is within an acceptable range, and the video file to be uploaded can be written to the cloud storage for storage.
[0069] Step S106, if the file size level belongs to the third level, and the average writing time of the cloud storage is the minimum average writing time among the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing 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.
[0070] If the file size level belongs to the third level, indicating that the file size of the video file to be uploaded is relatively large, the backup cloud storage can be introduced in the storage address option; at this time, the storage address options include cloud storage, backup cloud storage and the local disk of the streaming media server.
[0071] The processor of the streaming media server may compare the average writing time of the cloud storage, the average writing time of the prepared cloud storage, and the average writing time of the local disk of the streaming media server.
[0072] If the average writing time of the cloud storage is the minimum average writing time, the video file to be uploaded can be written into the cloud storage for storage.
[0073] Step S107, if the file size level belongs to the third level, and the average writing time of the standby cloud storage is the minimum average writing time among the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server, then the video file to be uploaded is written to the standby cloud storage for storage.
[0074] If the file size level belongs to the third level, the processor of the streaming media server compares the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server, and determines that the average writing time of the standby cloud storage is the minimum average writing time. In this case, the video file to be uploaded can be written into the standby cloud storage for storage.
[0075] Step S108: If the file size level belongs to the third level, and the average writing time of the local disk of the streaming media server is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage and the average writing time of the standby cloud storage are both greater than the writing time timeout threshold, then the video file to be uploaded is written to the local disk of the streaming media server for storage;
[0076] If the file size level belongs to the third level, the processor of the streaming media server determines that the average write time of the local disk of the streaming media server is the minimum average write time after comparing the average write time of the cloud storage, the average write time of the standby cloud storage and the average write time of the local disk of the streaming media server; considering that the storage space of the local disk of the streaming media server is limited, storage on the local disk is avoided as much as possible. Therefore, the processor of the streaming media server can also first compare the relative size between the average write time of the cloud storage and the write time timeout threshold, as well as the relative size between the average write time of the standby cloud storage and the write time timeout threshold.
[0077] If the average writing time of the cloud storage is less than or equal to the writing time timeout threshold, and the average writing time of the standby cloud storage is greater than the writing time timeout threshold, the video file to be uploaded can be written to the cloud storage.
[0078] If the average writing time of the cloud storage is greater than the writing time timeout threshold, and the average writing time of the standby cloud storage is less than or equal to the writing time timeout threshold, the video file to be uploaded can be written to the standby cloud storage.
[0079] If the average writing time of the cloud storage is less than or equal to the writing time timeout threshold, and the average writing time of the standby cloud storage is less than or equal to the writing time timeout threshold, the relative size between the average writing time of the cloud storage and the average writing time of the standby cloud storage can be determined; if the average writing time of the cloud storage is less than the average writing time of the standby cloud storage, the video files to be uploaded can be written to the cloud storage; if the average writing time of the cloud storage is greater than the average writing time of the standby cloud storage, the video files to be uploaded can be written to the standby cloud storage.
[0080] If the average writing time of the cloud storage is greater than the writing time timeout threshold, and the average writing time of the standby cloud storage is greater than the writing time timeout threshold, 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 video file processing method, the video file to be uploaded in the memory of the streaming media server is obtained; the file size level of the video file to be uploaded is determined, and the write timeout threshold is obtained; if the file size level belongs to the first level, the video file to be uploaded is written to the cloud storage for storage; if the file size level belongs to the second level, and the average writing time of the cloud storage is less than the average writing time of the local disk of the streaming media server, the video file to be uploaded is written to the cloud storage for storage; if the file size level belongs to the second level, and the average writing time of the cloud storage is greater than the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage is less than or equal to the write time timeout threshold, the video file to be uploaded is written to the cloud storage for storage; if the file size level belongs to the third level, and the average writing time in the cloud storage is the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the writing time of the local disk of the streaming media server If the minimum average writing time is the average writing time, the video file to be uploaded will be written to the cloud storage for storage; if the file size level belongs to the third level, and the average writing time of the standby cloud storage is the minimum average writing time among the average writing time of the cloud storage, the average writing time of the standby cloud storage and the average writing time of the local disk of the streaming media server, the video file to be uploaded will be written to the standby cloud storage for storage; if the file size level belongs to the third level, and the average writing time of the local disk of the streaming media server is the minimum average writing time among the average writing time of the cloud storage, the average writing time of the standby cloud storage and the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage and the average writing time of the standby cloud storage are both greater than the writing time timeout threshold, the video file to be uploaded will be written to the local disk of the streaming media server for storage; wherein, the file sizes corresponding to the first level, the second level and the third level increase in sequence. The solution provided by the present 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 files to be uploaded belongs to the first level, they are directly written into the cloud storage; when the file size level of the video files to be uploaded belongs to the second level, one of the cloud storage and the local disk of the streaming media server is selected for writing; when the file size level of the video files to be uploaded belongs to the third level, one of the cloud storage, the standby cloud storage and the local disk of the streaming media server is selected for writing; and in the selection process, the average writing time of each is compared, so that a storage method with better performance can be selected, and the pressure is shared by each other to reduce the impact of the performance bottleneck of a single writing method; considering that the local disk space of the streaming media server is limited, when the average writing time of the cloud storage and the standby cloud storage is greater than the average writing time of the local disk, if the average writing time of the cloud storage or the average writing time of the standby cloud storage does not exceed the write time timeout threshold, the video files to be uploaded can still be written into the cloud storage or the standby cloud storage.Through the solution provided in this application, the size of the video files to be uploaded in the memory of the streaming media server is monitored and the pressure of writing storage is shared, so as to prevent the program crash caused by memory overload of the streaming media server and ensure the stability and reliability of streaming media cloud recording.
[0082] In one embodiment, the method provided by the present application further includes:
[0083] If the file size level belongs to the fourth level, an alarm reminder message is sent to the operation and maintenance personnel; the file size corresponding to the fourth level is larger than the file size corresponding to the third level.
[0084] This embodiment divides the file into at least four levels, which may be referred to as the first level, the second level, the third level and the fourth level; wherein the file sizes corresponding to the first level, the second level, the third level and the fourth level increase in sequence.
[0085] If the processor of the streaming media server determines that the file size level 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 reminder message can be sent to the operation and maintenance personnel to allow the operation and maintenance personnel to intervene in time.
[0086] In one embodiment, determining the file size level of the video file to be uploaded includes:
[0087] A first threshold, a second threshold and a third threshold that are set in advance are obtained; 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, it is determined that the file size level of the video file to be uploaded belongs 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, it is determined that the file size level of the video file to be uploaded belongs 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, it is determined that the file size level of the video file to be uploaded belongs to the third level; if the file size of the video file to be uploaded is greater than the third threshold, it is determined that the file size level of the video file to be uploaded belongs to the fourth level.
[0088] In this embodiment, a pre-set first threshold (which may be recorded as s1), a second threshold (which may be recorded as s2), and a third threshold (which may be recorded as s3) may be obtained, and 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 may be recorded as s. In some scenarios, the first threshold s1 may be set to 100GB, the second threshold s2 may be set to 200GB, and the third threshold s3 may 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, it is determined that the file size level of the video file to be uploaded belongs to the first level. 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, it is determined that the file size level of the video file to be uploaded belongs to the second level. 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, it is determined that the file size level of the video file to be uploaded belongs to the third level; if the file size s of the video file to be uploaded is greater than the third threshold s3, it is determined that the file size level of the video file to be uploaded belongs to the fourth level.
[0090] In one embodiment, the method provided by the present application further includes:
[0091] If the file size level belongs to the second level, and the average writing time of the cloud storage is greater than the average writing time of the local disk of the streaming server, and the average writing time of the cloud storage is greater than the writing time timeout threshold, the video file to be uploaded will be written to the local disk of the streaming server for storage.
[0092] If the file size level belongs to the second level, the processor of the streaming media server may compare the relative sizes between the average writing time of the cloud storage and the average writing time of the local disk of the streaming media server.
[0093] If the average writing time of the cloud storage is greater than the average writing time of the local disk of the streaming media server, the processor of the streaming media server may compare the relative size between the average writing time of the cloud storage and the writing time timeout threshold.
[0094] If the average cloud storage writing time is greater than the writing time timeout threshold, indicating that the average cloud storage writing time is beyond an acceptable range, the video file to be uploaded may be written to the local disk of the streaming media server for storage.
[0095] In one embodiment, the step of obtaining the average writing time of the local disk of the streaming media server includes:
[0096] Get the total time consumption for writing video files to the local disk and the total number of video files in the historical period; based on the total time consumption and the total number, get the average time consumption for writing to the local disk.
[0097] The historical period may be a historical period close to the current time, for example, one minute before the current time.
[0098] The processor of the streaming media server can obtain the total time consumed to write the video files to the local disk in the previous minute (which can be recorded as tas), and can also obtain the total number of video files written to the local disk in the previous minute (which can be recorded as na); the total time consumed to write the video files to the local disk tas is divided by the total number of video files written to the local disk na, and the result is taken as the average time consumed to write to the local disk. If the average time consumed to write to the local disk is recorded as ta, it can be expressed as ta=tas / na; among them, if the total number of video files written to the local disk na is 0, the average time consumed to write to the local disk ta is also 0.
[0099] In one embodiment, the step of obtaining the average time consumed for writing to the cloud storage includes:
[0100] Obtain the total time consumption for writing video files to cloud storage and the total number of video files in the historical period; obtain the average time consumption for writing to cloud storage based on the total time consumption and the total number of video files.
[0101] The historical period may be a historical period close to the current time, for example, one minute before the current time.
[0102] The processor of the streaming media server can obtain the total time consumed to write the video files to the cloud storage in the previous minute (which can be recorded as tbs), and can also obtain the total number of video files written to the cloud storage in the previous minute (which can be recorded as nb); the total time consumed to write the video files to the cloud storage tbs is divided by the total number of video files written to the cloud storage nb, and the result is taken as the average time consumed to write to the cloud storage. If the average time consumed to write to the cloud storage is recorded as tb, it can be expressed as tb=tbs / nb; among them, if the total number of video files written to the cloud storage nb is 0, the average time consumed to write to the cloud storage tb is also 0.
[0103] In one embodiment, the step of obtaining the average writing time of the prepared cloud storage includes:
[0104] The total time consumption for writing video files in the standby cloud storage and the total number of video files in the historical period are obtained; based on the total time consumption and the total number, the average time consumption for writing to the standby cloud storage is obtained.
[0105] The historical period may be a historical period close to the current time, for example, one minute before the current time.
[0106] The processor of the streaming media server can obtain the total time consumption (which can be recorded as tcs) for writing the video files in the previous minute to the standby cloud storage, and can also obtain the total number of video files written to the standby cloud storage in the previous minute (which can be recorded as nc); the total time consumption tcs for writing the video files in the standby cloud storage is divided by the total number of video files written to the standby cloud storage nc, and the result is taken as the average time consumption for writing to the standby cloud storage. If the average time consumption for writing to the standby cloud storage is recorded as tc, it can be expressed as tc=tcs / nc; where, if the total number of video files written to the standby cloud storage nc is 0, the average time consumption tc for writing to the standby cloud storage is also 0.
[0107] In one embodiment, obtaining a write timeout threshold includes:
[0108] Get the preset timeout time; divide the random number by the timeout time to get the integer of the division result; and get the write timeout threshold according to the integer.
[0109] The preset timeout time can be recorded as to, and the timeout time to can be set to 600 milliseconds. A random number can be generated by a random number generation function, and the random number is divided by the timeout time to to obtain an integer of the division result, and the integer is determined as the write timeout threshold (which can be recorded as tr). The write timeout threshold obtained in this way is a random value. The random number generation function can be rand().
[0110] In order to better understand the above method, an application example of the storage method of the video file of the present application is described in detail below. The first threshold, the second threshold and the third threshold involved in this application example are respectively denoted as s1, s2 and s3. Figure 3 , Figure 3 A schematic diagram of the process provided in this application.
[0111] Step S301, the processor of the streaming media server obtains the video file to be uploaded from the video queue in the memory of the streaming media server;
[0112] Step S302, the processor may determine the file size s of the video file to be uploaded;
[0113] Step S303, the processor may calculate an average writing time ta of the local disk of the streaming media server;
[0114] Step S304, the processor may write a time-consuming 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, the process proceeds to step S306; if yes, the process proceeds to step S307;
[0116] Step S306, the processor writes the video file to be uploaded into 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, the process proceeds to step S308; if yes, the process proceeds to step S312;
[0118] Step S308, the processor calculates the average time tb consumed for writing to the cloud storage;
[0119] Step S309, the processor determines whether the average writing time ta of the local disk is greater than the average writing time tb of the cloud storage; if so, proceed to step S310; if not, proceed to step S306;
[0120] Step S310, the processor determines whether the average writing time tb of the cloud storage is greater than the writing time timeout threshold tr; if so, proceed to step S311; if not, 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, the process proceeds to step S313; if yes, the process proceeds to step S318;
[0123] Step S313, the processor calculates the average writing time tc of the prepared cloud storage;
[0124] Step S314, the processor determines whether the average writing time tb of the cloud storage is greater than the average writing time tc of the standby cloud storage; if not, proceed to step S309; if yes, proceed to step S315;
[0125] Step S315, the processor determines whether the average writing time tc of the prepared cloud storage is greater than the average writing 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 writing time tc of the prepared cloud storage is greater than the writing time timeout threshold tr; if so, proceed to step S311; if not, proceed to step S317;
[0127] Step S317, the processor writes the video file to be uploaded into the prepared cloud storage;
[0128] Step S318: The processor sends an alarm reminder message.
[0129] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0130] Based on the same inventive concept, the embodiment of the present application also provides a video file storage device for implementing the video file storage method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in the embodiment of the storage device for one or more video files provided below can refer to the limitations of the video file storage method above, and will not be repeated here.
[0131] In one embodiment, 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 in the memory of the streaming media server;
[0133] A level determination module 402 is used to determine the file size level of the video file to be uploaded;
[0134] The threshold acquisition module 403 is used to obtain a write timeout threshold;
[0135] A write processing module 404, configured to write the video file to be uploaded into the 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 to-be-uploaded video file into the cloud storage for storage if the file size level belongs to the second level and the average writing time of the cloud storage is less than the average writing time of the local disk of the streaming media server;
[0137] The write processing module 404 is further configured to write the to-be-uploaded video file into the cloud storage for storage if the file size level belongs to the second level, and the average writing time of the cloud storage is greater than the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage is less than or equal to the writing time timeout threshold;
[0138] The write processing module 404 is further configured to write the to-be-uploaded video file into the cloud storage for storage if the file size level belongs to the third level and the average writing time of the cloud storage is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server;
[0139] The write processing module 404 is further configured to write the to-be-uploaded video file into the standby cloud storage for storage if the file size level belongs to the third level and the average writing time of the standby cloud storage is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing 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 writing time of the local disk of the streaming media server is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage and the average writing time of the standby cloud storage are both greater than the write time timeout threshold;
[0141] The file sizes corresponding to the first level, the second level and the third level increase in sequence.
[0142] In one embodiment, the device further comprises an alarm module, configured to:
[0143] If the file size level belongs to the fourth level, an alarm reminder message is sent to the operation and maintenance personnel; the file size corresponding to the fourth level is larger than the file size corresponding to the third level.
[0144] In one embodiment, the level determination module 402 is further configured to:
[0145] A first threshold, a second threshold and a third threshold which are set in advance are obtained; 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, it is determined that the file size level of the video file to be uploaded belongs 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, it is determined that the file size level of the video file to be uploaded belongs 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, it is determined that the file size level of the video file to be uploaded belongs to the third level; if the file size of the video file to be uploaded is greater than the third threshold, it is determined that the file size level of the video file to be uploaded belongs to the fourth level.
[0146] In one embodiment, the write processing module 404 is further configured to:
[0147] If the file size level belongs to the second level, and the average writing time of the cloud storage is greater than the average writing time of the local disk of the streaming server, and the average writing time of the cloud storage is greater than the writing time timeout threshold, then the video file to be uploaded is written to the local disk of the streaming server for storage.
[0148] In one embodiment, the device further includes a write average time acquisition module, which is used to:
[0149] The total time consumption for writing the video files in the cloud storage and the total number of video files in the historical period are obtained; and the average time consumption for writing the cloud storage is obtained according to the total time consumption and the total number.
[0150] In one embodiment, the threshold acquisition module 403 is further used to:
[0151] Obtain a preset timeout time; divide the random number by the timeout time to obtain an integer of the division result; and obtain a write time-consuming timeout threshold based on the integer.
[0152] Each module in the storage device of the video file can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of the processor in the streaming media server in the form of hardware, or can be stored in the memory of the streaming media server in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0153] In an exemplary embodiment, a streaming media server is provided, and its internal structure diagram can be shown as follows: Figure 5As shown. The streaming media server includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the streaming media server is used to provide computing and control capabilities. The memory of the streaming media server includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the streaming media server is used to store data involved in the above method. The input / output interface of the streaming media server is used to exchange information between the processor and an external device. The communication interface of the streaming media server is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for storing video files is implemented.
[0154] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the streaming media server to which the solution of the present application is applied. The specific streaming media server may include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0155] In one embodiment, a streaming media server is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps in the above-mentioned various method embodiments when executing the computer program.
[0156] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0157] In one embodiment, a computer program product is provided, on which a computer program is stored, and the computer program is used by a processor to execute the steps in the above-mentioned various method embodiments.
[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, stored data, displayed data, 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 relevant data must comply with relevant regulations.
[0159] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present 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. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0160] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, 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 above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for storing video files, characterized in that: The method comprises: Get the video files to be uploaded in the memory of the streaming media server; Determine the file size level of the video file to be uploaded, and obtain a write timeout threshold; If the file size level belongs to the first level, the video file to be uploaded is written into the cloud storage for storage; If the file size level belongs to the second level, and the average writing time of the cloud storage is less than the average writing time of the local disk of the streaming media server, the video file to be uploaded is written into the cloud storage for storage; If the file size level belongs to the second level, and the average writing time of the cloud storage is greater than the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage is less than or equal to the writing time timeout threshold, then the video file to be uploaded is written into the cloud storage for storage; If the file size level belongs to the third level, and the average writing time of the cloud storage is the minimum average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server, then the video file to be uploaded is written into the cloud storage for storage; If the file size level belongs to the third level, and the average writing time of the standby cloud storage is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server, then the video file to be uploaded is written into the standby cloud storage for storage; If the file size level belongs to the third level, and the average writing time of the local disk of the streaming media server is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage and the average writing time of the standby cloud storage are both greater than the writing time timeout threshold, then the video file to be uploaded is written to the local disk of the streaming media server for storage; The file sizes corresponding to the first level, the second level and the third level increase in sequence.
2. The method according to claim 1, characterized in that The method further comprises: If the file size level belongs to the fourth level, an alarm reminder message is sent to the operation and maintenance personnel; the file size corresponding to the fourth level is larger 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: Acquire a preset first threshold, a second threshold, and a third threshold; the first threshold is smaller than the second threshold, and the second threshold is smaller than the third threshold; If the file size of the video file to be uploaded is less than or equal to the first threshold, determining that the file size level of the video file to be uploaded belongs 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, it is determined that the file size level of the video file to be uploaded belongs 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, it is determined that the file size level of the video file to be uploaded belongs to the third level; If the file size of the video file to be uploaded is greater than the third threshold, it is determined that the file size level of the video file to be uploaded belongs to the fourth level.
4. The method according to claim 1, characterized in that: The method further comprises: If the file size level belongs to the second level, and the average writing time of the cloud storage is greater than the average writing time of the local disk of the streaming server, and the average writing time of the cloud storage is greater than the writing time timeout threshold, then the video file to be uploaded is written to the local disk of the streaming server for storage.
5. The method according to claim 1, characterized in that The steps to obtain the average writing time of cloud storage include: Obtain the total time consumed to write the video files stored in the cloud storage and the total number of video files in the historical period; The average time consumption for writing to the cloud storage is obtained according to the total time consumption 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 to obtain an integer of the division result; According to the integer, a write timeout threshold is obtained.
7. A storage device for video files, characterized in that: The device comprises: The video file acquisition module is used to acquire the video file to be uploaded in the memory of the streaming media server; A level determination module, used to determine the file size level of the video file to be uploaded; A threshold acquisition module is used to obtain a write timeout threshold; A writing processing module, used for writing the video file to be uploaded into the cloud storage for storage if the file size level belongs to the first level; The write processing module is further configured to write the to-be-uploaded video file into the cloud storage for storage if the file size level belongs to the second level and the average writing time of the cloud storage is less than the average writing time of the local disk of the streaming media server; The write processing module is further configured to write the to-be-uploaded video file into the cloud storage for storage if the file size level belongs to the second level, and the average writing time of the cloud storage is greater than the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage is less than or equal to the writing time timeout threshold; The write processing module is further configured to write the to-be-uploaded video file into the cloud storage for storage if the file size level belongs to the third level and the average writing time of the cloud storage is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server; The write processing module is further configured to write the to-be-uploaded video file into the standby cloud storage for storage if the file size level belongs to the third level and the average writing time of the standby cloud storage is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage and the average writing 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 writing time of the local disk of the streaming media server is the minimum of the average writing time of the cloud storage, the average writing time of the standby cloud storage, and the average writing time of the local disk of the streaming media server, and the average writing time of the cloud storage and the average writing time of the standby cloud storage are both greater than the write time timeout threshold; The file sizes corresponding to the first level, the second level and the third level increase in sequence.
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, the method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method, system and device for offline uploading to cloud storage server
CN103873505A
File storage method and system
CN109981702A
Data storage method, system and device, storage medium and program product
CN116126209A
Efficiently storing data in a cloud storage
US20220075544A1