Method, device, equipment and medium for storing multimedia file

By converting live streams into block files of the target format and writing them in parallel to a writable disk, the problem of low efficiency in writing massive video streams to disk in streaming media services is solved, achieving efficient storage and seamless switching capabilities.

CN116506413BActive Publication Date: 2026-02-13BOE TECHNOLOGY GROUP CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202310332079.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2022-06-27
Filing Date
2023-03-30
Publication Date
2026-02-13
Estimated Expiration
2043-03-30

AI Technical Summary

Technical Problem

In streaming media services, during the process of writing massive video streams to disk, existing technologies struggle to effectively balance factors such as the format of the stored files, the storage strategy of the stream, the start and stop of stream storage, and the addition or removal of system disks, resulting in unsatisfactory performance when writing data to disk.

Method used

By converting the live stream into multiple block files in the target format and dynamically adjusting the block file size based on the length of the cache queue and the number of writable disks, the storage process is optimized by using a thread pool to write to the writable disks in parallel.

Benefits of technology

It improves the efficiency of live stream disk writing, achieving enhanced storage performance and seamless switching capabilities perceived by users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116506413B_ABST
    Figure CN116506413B_ABST
Patent Text Reader

Abstract

The application discloses a multimedia file storage method, device, equipment and medium, wherein the multimedia file storage method comprises the following steps: obtaining a live stream of a multimedia file; converting the live stream into a plurality of block files in a target format, wherein the size of the block files changes with the length of a cache queue and / or the number of writable disks; sequentially writing the plurality of block files into the cache queue, and scheduling a plurality of threads in a thread pool to write the block files in the cache queue into the writable disks in parallel, the optimal block file size can be calculated according to the length of the cache queue and the number of the writable disks, then the block files are read from the cache queue and written into the writable disks in parallel through thread scheduling, so that the threads reach the optimal scheduling frequency and the disks reach the optimal writing speed, and the efficiency of writing the live stream into a disk is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application generally relates to the field of file processing, and particularly relates to a multimedia file storage method, device, equipment and medium. BACKGROUND

[0002] In a streaming media service, users often need to store live video streams for later viewing or playback. However, the storage of massive video streams not only requires the performance guarantee of hardware, but also needs effective control of the storage mechanism to improve the performance of storage and the utilization rate of hardware. However, the storage process is affected by conditions such as the format of the storage file, the storage strategy of the stream, the start and stop of stream storage, and the increase and decrease of the system disk. In order to ensure the separation of the business side from the underlying transcoding and scheduling or achieve the non-awareness of the business, while achieving the non-delay switching capability of configuration update. In actual application, these problems cannot be well considered and solved, resulting in unsatisfactory performance when data is stored. SUMMARY

[0003] In view of the above defects or deficiencies in the prior art, it is desirable to provide a multimedia file storage method, device, equipment and medium, which can effectively improve the efficiency of live stream storage.

[0004] In a first aspect, an embodiment of the present application provides a multimedia file storage method, comprising:

[0005] obtaining a live stream of a multimedia file;

[0006] converting the live stream into a plurality of block files in a target format, wherein the size of the block file changes with the change of the length of the cache queue and / or the number of writable disks;

[0007] writing the plurality of block files into the cache queue in sequence, and scheduling a plurality of threads in a thread pool to write the block files in the cache queue into the writable disks in parallel.

[0008] In some examples, before converting the live stream into a plurality of block files in a target format, further comprising:

[0009] obtaining the length of the cache queue and the total size of the plurality of block files;

[0010] determining the size of the block file according to the length of the cache queue and the total size of the plurality of block files;

[0011] and / or,

[0012] obtaining the number of writable disks and the writing speed of the writable disks;

[0013] obtaining a total write speed of the writable disks according to the number of the writable disks and write speeds of the writable disks;

[0014] determining the size of the chunk file according to a comparison result between a total write speed of the plurality of threads in the thread pool and the total write speed of the writable disks in a case that the size of the chunk file is different.

[0015] In some examples, the length of the cache queue is not less than the number of threads in the thread pool.

[0016] In some examples, before scheduling the plurality of threads in the thread pool to write the chunk files in the cache queue to the writable disks in parallel, further comprising:

[0017] determining the number of threads in the thread pool according to the number of the writable disks, wherein the number of threads is not less than the number of the writable disks;

[0018] performing an initialization operation on the thread pool according to the number of threads.

[0019] In some examples, the converting the live stream into a plurality of chunk files in a target format comprises:

[0020] reading frame data of the live stream from a cache;

[0021] converting the frame data into a file in the target format;

[0022] splitting the file into a plurality of chunk files according to the size of the chunk file.

[0023] In some examples, the scheduling the plurality of threads in the thread pool to write the chunk files in the cache queue to the writable disks in parallel comprises:

[0024] randomly scheduling an idle thread in the thread pool to write the chunk files in the cache queue to the writable disks in parallel.

[0025] In some examples, the randomly scheduling the idle thread in the thread pool to write the chunk files in the cache queue to the writable disks in parallel comprises:

[0026] obtaining a storage path of the writable disks;

[0027] randomly scheduling the idle thread in the thread pool to write the chunk files in the cache queue to the writable disks in parallel according to the storage path.

[0028] In some examples, after the sequentially writing the plurality of chunk files to the cache queue and scheduling the plurality of threads in the thread pool to write the chunk files in the cache queue to the writable disks in parallel, further comprising:

[0029] after uploading the chunk files written on the writable disk to a server, receiving a request for obtaining a target segment, the request including an identification of a multimedia file, the target segment being at least a part of the multimedia file;

[0030] obtaining a target index file corresponding to the target segment from an index file table according to the identification, the index file table including at least one index file, the index file including characteristics of segments, the segments being obtained by packetizing the multimedia file;

[0031] obtaining position information of the target segment in the multimedia file according to the characteristics of the segments in the target index file;

[0032] streaming from data of the multimedia file according to the position information.

[0033] In some examples, the obtaining the target index file corresponding to the target segment from the index file table according to the identification includes:

[0034] determining the multimedia file according to the identification;

[0035] retrieving an index file of the multimedia file from the index file table;

[0036] obtaining the target index file corresponding to the target segment from the index file of the multimedia file according to a time period corresponding to the target segment.

[0037] In some examples, the obtaining the position information of the target segment in the multimedia file according to the characteristics of the segments in the target index file includes:

[0038] obtaining a start time and an end time of the target segment;

[0039] determining a start position and an end position of the target segment in the multimedia file according to the characteristics of the segments in the target index file, the start time and the end time of the target segment.

[0040] In some examples, the determining the start position and the end position of the target segment in the multimedia file according to the characteristics of the segments in the target index file, the start time and the end time of the target segment includes:

[0041] obtaining a start frame of the target segment in the multimedia file according to the characteristics of the segments in the target index file, the start time of the target segment;

[0042] According to the feature of the segment in the target index file, the end time of the target segment, an end frame of the target segment in the multimedia file is obtained.

[0043] In some examples, the streaming from the data of the multimedia file according to the position information comprises:

[0044] According to the start frame and the end frame of the target segment, the data of the multimedia file is streamed.

[0045] In some examples, before obtaining the target index file corresponding to the target segment from the index file table according to the identification, the method further comprises:

[0046] According to the packet of the multimedia file, a segment of the multimedia file is obtained;

[0047] A feature of the segment of the multimedia file is extracted;

[0048] According to the feature, the index file is obtained, and the index file is stored in the index file table.

[0049] In some examples, the method further comprises:

[0050] The multimedia file is converted into a block file, and data of the multimedia file is obtained;

[0051] The data of the multimedia file is stored.

[0052] In a second aspect, embodiments of the present application provide a storage device of a multimedia file, comprising:

[0053] An obtaining module is configured to obtain a live stream of a multimedia file;

[0054] A converting module is configured to convert the live stream into a plurality of block files in a target format, wherein the size of the block files changes with the length of a cache queue and / or the number of writable disks;

[0055] A writing module is configured to sequentially write the plurality of block files into the cache queue, and schedule a plurality of threads in a thread pool to write the block files in the cache queue into the writable disks in parallel.

[0056] In a third aspect, embodiments of the present application provide an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the storage method of the multimedia file as described in the embodiments of the first aspect of the present application when executing the program.

[0057] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, having stored thereon a computer program, which, when executed by a processor, implements the multimedia file storage method according to the embodiment of the first aspect of the present application.

[0058] In a fifth aspect, an embodiment of the present application provides a computer program product, having stored thereon a computer program, which, when executed by a processor, implements the multimedia file storage method according to the embodiment of the first aspect of the present application.

[0059] The multimedia file storage method, device, equipment and medium provided by the embodiment of the present application can calculate the optimal block file size according to the length of the cache queue and the number of writable disks, and then read the block file from the cache queue and write it into the writable disk in parallel through thread scheduling, so as to make the thread reach the optimal scheduling frequency and the disk reach the optimal writing speed, and further effectively improve the efficiency of the live stream disk landing.

[0060] Additional aspects and advantages of the application will be set forth in part in the description which follows, and in part will become apparent to those skilled in the art upon examination of the following and / or can be learned by practice of the application. BRIEF DESCRIPTION OF DRAWINGS

[0061] Other features, objects, and advantages of the application will become more apparent from the following detailed description when read in conjunction with the accompanying drawings:

[0062] Figure 1 Flowchart of the multimedia file storage method of one embodiment of the present application;

[0063] Figure 2 Implementation diagram of the multimedia file storage method of one embodiment of the present application;

[0064] Figure 3 Flow ID structure diagram of the multimedia file storage method of one embodiment of the present application;

[0065] Figure 4 Block cache queue diagram of the multimedia file storage method of one embodiment of the present application;

[0066] Figure 5 Thread scheduling diagram of the thread pool of the multimedia file storage method of one embodiment of the present application;

[0067] Figure 6 Implementation step diagram of the multimedia file storage method of one embodiment of the present application;

[0068] Figure 7 Block diagram of the multimedia file storage device in another embodiment of the present application;

[0069] Figure 8 A structural schematic diagram of a computer system of an electronic device or a server for implementing an embodiment of the present application. DETAILED DESCRIPTION

[0070] The present application will be further described below in conjunction with the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related application, and not to limit the application. In addition, it should be noted that only the parts related to the application are shown in the drawings for ease of description.

[0071] It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict. The present application will be described in detail below with reference to the drawings and in conjunction with the embodiments.

[0072] When using a streaming service, a user often needs to store a live multimedia file (such as video and audio) to a disk. The storage efficiency in the process of storing to the disk not only involves the format of the stored file, the storage strategy of the stream, the start and stop of the stream storage, etc., but also relates to the number of available local disks, etc. Generally, to ensure the separation of the business side from the underlying transcoding and scheduling or to achieve the non-perception of the business, while achieving the non-delay switching capability of configuration update. In actual application, it is not easy to achieve a good balance, for example: either the storage efficiency is low, or the user perception is obvious, resulting in poor performance in storage performance. Therefore, the multimedia file storage method of the embodiments of the present application refers to how to improve the performance of storing the live stream and other data of the multimedia file to the local disk (i.e. disk landing) after processing.

[0073] It should be noted that after disk landing, the data in the local disk can be uploaded to a server, such as a remote storage server. In this way, when live playback is needed, it can be downloaded from the server for playback.

[0074] Figure 1 is a flowchart of a multimedia file storage method according to an embodiment of the present application. As shown in Figure 1 The multimedia file storage method according to an embodiment of the present application includes the following steps:

[0075] S101: Obtain a live stream of a multimedia file.

[0076] The multimedia file includes but is not limited to video and / or audio, i.e. video stream and / or audio stream. In the following description, the video and audio stream refers to the sum of the video stream, the audio stream or the video stream and the audio stream.

[0077] As shown in Figure 2As shown, when the user needs to store a live stream of a certain path, the user can call the business API (Application Programming Interface) to use the storage service. For example, for a live stream live / 001 to be stored, the user sets the storage strategy in advance, and then starts the storage start-stop function. The data of the corresponding live stream live / 001 is stored in the cache Cache. The cache Cache is used to cache the frame data of the live stream frame by frame. It is a scalable queue. The data in the queue is a copy of the live stream live / 001 in time sequence. The consumer is the encapsulation module as shown in the middle of the figure. In this example, a stream ID and the corresponding Cache are set for each live stream. That is, only the stream ID configured with the storage strategy is put into the dictionary A of the storage service. The Cache is used to cache the frame data of the corresponding stream ID of the live stream. Figure 2 As shown in the middle of the figure, the encapsulation module. In this example, a stream ID and the corresponding Cache are set for each live stream. That is, only the stream ID configured with the storage strategy is put into the dictionary A of the storage service. The Cache is used to cache the frame data of the corresponding stream ID of the live stream.

[0078] In the above description, the storage strategy (also referred to as the storage strategy) can be a strategy set according to the time length (for example, a storage file every 120 seconds), the file block size (for example, the file block size is 64 megabytes), and the time period (for example, the storage is performed from 8:00 to 9:00 every day). The time length refers to, for example, a storage file every 120 seconds. The time period refers to, for example, the storage time. That is, when the storage strategy requires the live stream to be stored, the file can be better divided in terms of the time length, the size of the storage file block, and the start and end time period, so as to avoid all data being stored in one file. This facilitates subsequent operations such as uploading, copying, cutting, and downloading of the audio and video files.

[0079] In the storage start-stop, the start refers to running the storage strategy, that is, starting the storage. The storage is performed according to the storage strategy. The deletion of all storage strategies of the live stream refers to stopping the storage. At this time, the storage and other related resources are recycled. That is, the storage start-stop requires that the live stream in the time period of the storage strategy needs to be saved. The live stream after the execution of the storage strategy ends does not need to be saved. After the user issues a storage strategy, the user can also delete the storage strategy. In this way, the storage strategy is invalidated immediately. Thus, the purpose of managing the storage strategy is achieved. Furthermore, the storage of the required live stream can be controlled in real time and flexibly.

[0080] S102: converting the live stream into a plurality of block files in a target format, wherein the size of the block file changes with the change of the length of the cache queue and / or the number of writable disks.

[0081] The size of the block file is not fixed and can change with the length of the cache queue and / or the number of writable disks, so before converting the live stream into a plurality of block files in the target format, the method further comprises: obtaining the length of the cache queue and the total size of the plurality of block files; determining the size of the block file according to the length of the cache queue and the total size of the plurality of block files; and / or obtaining the number of writable disks and the write speed of the writable disks; obtaining the total write speed of the writable disks according to the number of writable disks and the write speed of the writable disks; in the case of different sizes of block files, determining the size of the block file according to the comparison result between the total write speed of the plurality of threads in the thread pool and the total write speed of the writable disks.

[0082] That is, if the size of the file block is not set in advance, the size of the file block is affected by the length of the cache queue and / or the number of writable disks, that is, the size of the block cache (that is, the length of the cache queue) and the total size of the block files to be written (that is, the total size of the plurality of block files), and can also be affected by the number of writable data disks (that is, the number of writable disks) and the write speed of the disk (that is, the write speed of the writable disk).

[0083] Specifically, the size of the block cache determines whether the threads in the thread pool will be idle, and when idle, the resource utilization is insufficient, affecting the disk efficiency. The total size of the block file determines the amount of data to be written to the disk, which determines whether there is room for improvement in disk performance during thread scheduling; the number of writable data disks determines the concurrent write capability of the disk, and the write speed of the disk determines the throughput when continuously writing data to the disk, that is, the maximum concurrent storage capability that can be tolerated.

[0084] For example, when the length of the cache queue is less than 2*N, it means that there may be idle threads, and the size of the packet should be appropriately reduced, that is, the size of the block file is reduced, so that more block files can be divided, thereby increasing the output frequency of the block file, so that there are no idle threads or the number of idle threads is reduced, thereby improving the efficiency of data disk. In this example, N is the number of writable disks, and 2*N refers to the number of threads in the thread pool.

[0085] For another example, after calculating the total write speed according to the number of writable data disks, then in the case of different sizes of block files, the total write speed of the threads in the thread pool is calculated, and thus the current write capacity occupancy ratio is obtained by comparison, and finally the appropriate size of the block file is found to maximize the write capacity, thereby improving the efficiency of data disk.

[0086] It should be noted that, in order to avoid the idle situation of threads in the thread pool affecting the data landing efficiency, the length of the cache queue is usually not less than the number of threads in the thread pool in the embodiment of the application, and the size of the block file is adjusted based on this principle.

[0087] After the size of the block file is determined, the file block can be divided according to the size, so that the live stream is converted into a plurality of block files in the target format, including: reading frame data of the live stream from the cache Cache; converting the frame data of the live stream into a file in the target format; and cutting the file into a plurality of block files according to the size of the block file.

[0088] As shown in Figure 2 The encapsulation module reads each frame from the cache Cache and sets the format for encapsulation. The format can be a default format or a format pre-configured by a user through a preset configuration interface, for example, MP4, FLV, TS, etc. The encapsulation module initializes a corresponding format handle, thereby realizing encapsulation of the format data. When the amount of encapsulated data reaches the size of the block file, the data is written into the cache queue as a block file.

[0089] For the encapsulation module, a thread is started in the encapsulation module for reading frame data from the Cache and encapsulating the frame data into a file block in a format configured by a user and sending the file block to the cache queue in the scheduling module, each time a stream ID is put into the dictionary A. The specific structure of the stream ID is shown in Figure 3 The stream ID includes but is not limited to a policy list, a cache frame number, a frame cache channel queue (i.e., a cache queue), and a state.

[0090] S103: sequentially writing a plurality of block files into the cache queue, and scheduling a plurality of threads in the thread pool to write the block files in the cache queue into the writable disk in parallel.

[0091] In an embodiment of the application, the plurality of threads in the scheduling thread pool write the block files in the cache queue into the writable disk in parallel, including: randomly scheduling idle threads in the thread pool to write the block files in the cache queue into the writable disk in parallel. As shown in Figure 4 The mechanism of the cache queue is as follows: the encapsulation module (encapsulation module) sequentially pushes block files Packet1 to PacketN, and then each service thread reads Packet1 to PacketN from the cache queue according to the first-in first-out principle, and then writes the block files into the writable disk.

[0092] Further, the random scheduling of the idle threads in the thread pool to write the block files in the cache queue to the writable disk in parallel comprises: obtaining a storage path of the writable disk; and according to the storage path, randomly scheduling the idle threads in the thread pool to write the block files in the cache queue to the writable disk in parallel.

[0093] As shown in FIG. 6, the scheduling module schedules multiple threads in the thread pool, reads the block files from the cache queue, and makes the multiple threads write data to the writable disk in parallel. Specifically, when writing to the disk, disk selection and the like need to be performed. For example, the scheduling strategy includes random scheduling and fixed scheduling, wherein the random scheduling means that the block files of one stream randomly exist on different writable disks, and the fixed scheduling means that all the block files of one stream are stored on the same writable disk. In this application, the random scheduling is usually adopted. Figure 2

[0094] The scheduling module uniformly receives the encapsulated file blocks, and then internally maintains a stream ID dictionary B for recording detailed information of the block cache, such as cache size, total memory occupation, and the like. Meanwhile, a thread pool is generated according to the configuration initialization, and the number of threads in the thread pool is determined by the number of writable disks. For example, if the number of writable disks is N, the number of threads can be twice of N, i.e., 2*N. That is, before the multiple threads in the thread pool write the block files in the cache queue to the writable disk in parallel, the number of threads in the thread pool is determined according to the number of writable disks, wherein the number of threads is not less than the number of writable disks, and the thread pool is initialized according to the number of threads.

[0095] For the selection of the writable disk, a current available disk list can be recorded for maintaining the addition and damage of the disk, the performance parameters of the disk such as read-write rate, disk write directory, and disk cache list, and the like, and a disk storage path interface is provided externally. Thus, the scheduling module writes data to the storage path interface through the scheduling thread to realize the disk landing of the data.

[0096] The selected disk during storage and the management mode of the scheduling service to the thread pool are as follows: disk management and maintenance: in order to ensure the accuracy of the disk landing, the system needs to monitor the state of the entire disk (read-write speed, write path, state) in real time, and store it to dictionary C. The storage path of the stream ID allocation is recorded (dictionary D storage), and dictionary C or D is retrieved according to the scheduling strategy and the result is returned. When a new disk is added, the related information in dictionary C needs to be updated, and when a disk goes offline, the state of the disk in dictionary C is updated to be unavailable.

[0097] ​The scheduling service manages the thread pool: the channel queue Q (i.e., the cache queue) is initialized, and an upper limit, such as 1024, can be set to prevent memory overflow. The number N of available data disks is obtained, and the size of the thread pool is initialized to 2*N. The threads are responsible for reading the block files from the channel queue Q. When the number of disks changes, the number of threads in the thread pool changes accordingly and is always 2*N. The scheduling service puts the block files received from the packaging module into the channel queue Q, and waits for the thread pool to process. The threads in the thread pool read the block files from the channel queue Q, and then write the block files into the disk management module to request a storage path. Figure 5 As shown in FIG. 1, thread 1 to thread N obtain the block files from the cache channel queue (the cache queue), and then obtain the corresponding write paths to write the files.

[0098] In the above description, the cache queue is a channel queue. The packaging module writes the block files into the channel queue, and the threads in the thread pool in the scheduling module are responsible for reading the block files from the channel queue. The consumption of the block files is performed in a time sequence, but the actual disk landing is not in sequence. The use of the channel queue ensures the consistency of production and consumption, and ensures the stable and reliable landing of data.

[0099] A specific example is used to describe the implementation of the embodiment of the application, as shown in FIG. 2. Figure 6

[0100] The user configures the storage strategy of the stream ID of a live streaming, and sets the scheduling strategy to random. Necessary initialization operations include: the packaging module generates a thread to wait for the frame data corresponding to the stream ID to arrive, and then initializes the file handle; the scheduling service initializes the thread pool; the disk service is initialized; and the block size calculation is initialized.

[0101] Then, when the frame data is received, the packaging process is started, and the frame data is continuously written into the file handle. The size of the file corresponding to the file handle is detected, and when the size meets the requirement, the file is cut into a block file. The packaging format can be dynamically expanded according to business requirements, such as MP4, FLV, TS, etc.

[0102] Each block file is immediately put into the cache queue after being cut. Finally, through scheduling, the threads in the thread pool read the block files from the cache queue according to the agreed business process, and write the block files into the writable disk, thereby completing the landing of the live streaming.

[0103] According to the multimedia file storage method of the embodiment of the application, the optimal block file size can be calculated according to the length of the cache queue and the number of writable disks, and then the block files are read from the cache queue in parallel through thread scheduling and written into the writable disk, so that the threads achieve the optimal scheduling frequency and the disk achieves the optimal writing speed, thereby effectively improving the efficiency of the landing of the live streaming.​

[0104] After the live stream is locally recorded, a request can be initiated to the server for playback after uploading to the server, specifically:

[0105] A request for obtaining a target segment is received, the request for obtaining includes an identification of a multimedia file, and the target segment is at least a part of the multimedia file.

[0106] The multimedia file includes but is not limited to a video and an audio, i.e., a video stream and an audio stream, in the following description, the video and audio stream refers to a video stream, an audio stream, or a sum of the video stream and the audio stream. Taking a video A as an example, the target segment is a part of the video A, i.e., the target segment is a segment of the video A, for example, the video A is a video with a total playing time of 30 minutes, and the target segment can be a video segment from the 5th minute to the 20th minute in the video A.

[0107] Different multimedia files have different identifications, which can be an ID of the multimedia file, so that different multimedia files can be distinguished by the ID.

[0108] In a specific example, a user wants to play a certain video and audio segment through a terminal device, and can send a request for obtaining the video and audio segment to the server through the terminal device, the request including but not limited to an identification of the requested video and audio segment and time information of the video and audio segment, wherein the time information of the video and audio segment includes, for example, a starting time of the video and audio segment in the video and audio and a time length, for example, the video and audio is a video and audio with a total playing time of 30 minutes, the requested video and audio segment is a video and audio segment with a starting time of 5 minutes and a time length of 10 minutes, and the request is for a video and audio segment from the 5th minute to the 15th minute in the video and audio.

[0109] It can be understood that the server pre-stores the video and audio, in an embodiment of the present application, when the server receives a file such as an RTP / RTMP / RTSP stream, the file is received in a packet form, i.e., the RTP / RTMP / RTSP stream is packetized, then the server receives each data packet, and finally the video and audio are stored through an index file and a block file. Specifically, the server starts a storage service, obtains a segment of the multimedia file according to the packetization of the multimedia file, i.e., according to each data packet of the received multimedia file, one segment corresponds to one data packet; extracts a feature of the segment of the multimedia file (i.e., a feature of the data packet); obtains an index file according to the feature, and stores the index file in an index file table; in addition, converts the multimedia file into a block file to obtain data of the multimedia file; and stores the data of the multimedia file. That is, the index file is written in a sequence, and the block file is written in binary, i.e., the multimedia file is written in a binary block file, and the binary block file is the original data of the multimedia file.

[0110] Wherein, the multimedia file is divided into segments, and the segments are packets. Each packet can include 2 minutes of video and audio segments, for example: a total of 30 minutes of video and audio can be divided into 15 video and audio segments, i.e. 15 packets. Each packet includes a plurality of video and audio frames. The packet structure includes but is not limited to Idx, i.e. channel ID, IskeyFrame, i.e. whether it is a key frame, Payload, i.e. corresponding video and audio segments, Time, i.e. frame decoding time, and CompositionTime, i.e. relative time. Thus, each video and audio segment is formed into a packet and received by the storage service. The index file records the metadata of the video and audio and the characteristics of each packet, i.e. the characteristic data of each packet (i.e. the characteristics of the segment). The characteristic data of each packet can be written into the index file as the content of the index section structure, and the metadata can be written into the index file as the content of the index header. The packet refers to the division of a single message into multiple data blocks in a packet switching network. These data blocks are called packets. After the data packets are transmitted to the destination (such as a server), the server can recombine the data packets into video and audio according to the packet structure. The characteristic data of the packet (i.e. the characteristics of the segment) refers to the characteristics extracted from each packet, including but not limited to Idx, i.e. channel ID, IskeyFrame, i.e. whether it is a key frame, Time, i.e. frame decoding time, and CompositionTime, i.e. relative time.

[0111] The storage of the video and audio as an index file and a binary block file can be achieved in the following way:

[0112] The server starts the storage service and starts an independent thread to receive the video and audio packets in a unified format. It can be understood that, in order not to block the business process, the thread can be set with a certain length of cache C for storing the received packets.

[0113] Initialize the video and audio stream, and use the received packet to perform initialization operation, mainly including: metadata detection, such as whether SPS and PPS exist; if they exist, convert the metadata of the video and audio into a unified format, i.e. Codec, create a write object M of Muxer, and organize the write information of the packet. Read the packet in sequence from the cache C, and extract the characteristic data of the packet, including but not limited to Idx, i.e. channel ID, Key, i.e. whether it is a key frame, Time, i.e. frame decoding time, Serial, i.e. packet serial number, and CompositionTime, i.e. relative time. Initialize the IndexSection object, and perform JSON serialization on the characteristic data of the packet, and write it into the index file in line.

[0114] The segment structure of the index includes fields such as Pos: the starting position in the binary block file, MD5: the MD5 check value of the payload data (i.e. valid data), Len: the length of the payload data, and Description: optional, used to describe the attribute information of the data packet. The payload data in the data packet is continuously written into the binary block file. To ensure the concurrency efficiency and the disk read / write performance, the payload data can be cached, and when the cached data is greater than, for example, 1M, it is written once.

[0115] When switching the storage file, the last IndexHeader information written into the index file needs to be ensured. The fields of the structure of the IndexHeader include but are not limited to: ID: the stream ID, MD5: the MD5 check value of the binary block file, Name: the block file name, Local: the local storage location, Remote: the remote storage file, Codecs: the metadata, Duration: the duration of the block file, Timestamp: the write time stamp, and Description: the description information.

[0116] That is, the index file includes the IndexHeader and the index segment. The IndexHeader records but is not limited to the metadata of the audio / video, and the index segment records but is not limited to the characteristic data (i.e. the characteristics of the segment) of the data packet.

[0117] The generated index file and the binary block file can be stored in the network disk or the local according to the actual storage requirement. It needs to be noted that when stored in the network disk or the local, the Local and Remote fields in the IndexHeader need to be updated. The Local is used to read the data from the pointed local file, and the Remote is used to download the file to the local through HTTP and then update the Local field.

[0118] According to the identification of the multimedia file, the target index file corresponding to the target segment (e.g. the collection of segments in the data packet) is obtained from the index file table. As known from the above, the index file table includes at least one index file, the index file includes the characteristics of the segment (data packet), and the segment is obtained by packeting the multimedia file.

[0119] According to the identification of the multimedia file, the target index file corresponding to the target segment is obtained from the index file table, including: determining the multimedia file according to the identification of the multimedia file; searching the index file of the multimedia file from the index file table; and obtaining the target index file corresponding to the target segment from the index file of the multimedia file according to the time period corresponding to the target segment.

[0120] Suppose the total time of the video is 30 minutes, and the video is marked as X, and every two minutes of the video forms a data packet, then the video includes 15 data packets, corresponding to 15 index files, namely index file 1 to index file 15, then according to the mark X of the multimedia file, the 15 index files are found in the index file table, and then suppose the requested video segment is the segment from the 5th minute to the 9th minute, then the index files corresponding to the video segment are index file 3 to index file 5, namely, index file 3 to index file 5 are target index files, and the total video segment included by index file 3 to index file 4 is the video segment from the 4th minute to the 10th minute.

[0121] It can be understood that the index file table usually includes a plurality of index files of the video and audio, and since the number of the video and audio is huge, the index file table can include a large amount of index files.

[0122] The position information of the target segment in the multimedia file is obtained according to the characteristics of the segments in the target index file;

[0123] The characteristics of the segments in the target index file include the decoding time of the first frame in each data packet, and therefore, the position information of the target segment in the multimedia file can be obtained based on the characteristics. In an embodiment of the present application, the position information of the target segment in the multimedia file is obtained according to the characteristics of the segments in the target index file, and includes: obtaining the start time and the end time of the target segment; and determining the start position and the end position of the target segment in the multimedia file according to the characteristics of the segments in the target index file, the start time and the end time of the target segment.

[0124] The characteristics of the segments are characteristic data of the data packets, and include but are not limited to Idx: channel ID, Key: whether it is a key frame, Time: frame decoding time, Serial: packet serial number, and CompositionTime: relative time.

[0125] Further, the start position and the end position of the target segment in the multimedia file are determined according to the characteristics of the segments in the target index file, the start time and the end time of the target segment, and include: obtaining the start frame of the target segment in the multimedia file according to the characteristics of the segments in the target index file and the start time of the target segment; and obtaining the end frame of the target segment in the multimedia file according to the characteristics of the segments in the target index file and the end time of the target segment.

[0126] Assuming the total time length of the audio-visual is 30 minutes, and every two minutes of the audio-visual segment constitutes a data packet, then the audio-visual includes 15 data packets, corresponding to 15 index files, assuming the requested audio-visual segment is the segment from the 5th minute to the 9th minute, then the index file corresponding to the audio-visual segment is index file 3 to index file 5, that is, index file 3 to index file 5 are the target index files, and the total audio-visual segment included by index file 3 to index file 4 is the audio-visual segment from the 4th minute to the 10th minute, that is, the decoding time corresponding to the first frame at the 4th minute start time in index file 3, and the decoding time corresponding to the last frame at the 9th minute end time in index file 5. And the requested video segment is the segment from the 5th minute to the 9th minute, therefore, knowing the decoding time corresponding to the first frame at the 4th minute start time in index file 3, through time offset, the position of the audio-visual frame corresponding to the 5th minute in index file 3 can be determined, and similarly, the position of the audio-visual frame corresponding to the 9th minute in index file 5 can be determined, that is, knowing the data from which frame (start frame) to which frame (end frame) is needed to be obtained.

[0127] That is, the storage service parses the index file, formats it into a dictionary, an IndexHeader object, a packet time sequence queue, etc., wherein the dictionary: one-to-one mapping between the time of the packet and the feature data, the packet time sequence queue: caching the time sequence object of the packet, the IndexHeader object: pointing to the metadata. The above three structures guarantee the one-to-one mapping and fast search function of the index and the block. That is, the mapping relationship between the time (the decoding time of the first frame) of each data packet and the data packet feature is parsed.

[0128] Streaming from the data of the multimedia file according to the position information. That is, streaming from the data of the multimedia file, that is, the binary block file, according to the start frame and the end frame of the target segment.

[0129] As a specific example, the implementation in the video cloud system is as follows: a user configures a camera (RTSP pull stream protocol) to the video cloud system, the video cloud calls the interface of the streaming media server (add camera), the streaming media server starts the RTSP pull stream service, after successful pull stream, the stream is played out in the form of live broadcast. Configure storage strategy: call the storage strategy interface of the streaming media service, add the storage strategy of the stream, at this time the system will automatically start the storage service of the stream, first the stream is converted into a Packet structure, and then sent to the storage service, the storage service starts a thread to perform serialization and disk storage mechanism. Video playback: after the video playback business program detects the existence of the index file, the deserialization operation is started, and then the on-demand resource message is published to the pull stream end, when the user on-demand the resource from the pull stream end (the request packet will carry a start time and an end time), the deserialized object performs retrieval and packet output according to the input parameters, and the on-demand service is completed. Of course, if it is file export, it is similar to playback, that is, the basic process is consistent with video playback, only that the file format conversion is performed when the packet is output, that is, the complete file is sent to the user after the secondary packaging according to the file format specified by the user.

[0130] According to the multimedia file storage method, when the acquisition request of the target segment is received, the target index file corresponding to the target segment can be quickly queried, and then the position information of the target segment in the multimedia file can be quickly determined according to the characteristics of the segments in the target index file, and the live stream can be accurately pulled from the data of the multimedia file according to the position information. The target segment can be arbitrarily and quickly extracted from the complete file, the use experience of the user is improved, so that the video can be quickly and efficiently downloaded according to the file segment of the user specified time period.

[0131] Figure 7 A block schematic diagram of the multimedia file storage device in an embodiment of the present application.

[0132] As Figure 7 shown, the multimedia file storage device 700 of the embodiment of the present application comprises an acquisition module 710, a conversion module 720 and a writing module 730, wherein:

[0133] The acquisition module 710 is configured to obtain a live stream of a multimedia file.

[0134] The conversion module 720 is configured to convert the live stream into a plurality of block files in a target format, wherein the size of the block files changes with the change of the length of the cache queue and / or the number of writable disks.

[0135] The writing module 730 is configured to sequentially write the plurality of block files into the cache queue, and schedule a plurality of threads in the thread pool to write the block files in the cache queue into the writable disk in parallel.

[0136] According to the storage device of the multimedia file, when the acquisition request of the target segment is received, the target index file corresponding to the target segment can be quickly queried, and then the position information of the target segment in the multimedia file can be quickly determined according to the characteristics of the segments in the target index file, and the streaming can be accurately pulled from the data of the multimedia file according to the position information. The target segment can be arbitrarily and quickly cut from the complete file, the use experience of the user is improved, and therefore, the video can be quickly and efficiently downloaded according to the file segment of the arbitrary time period specified by the user.

[0137] Further, the storage device of the multimedia file further includes a receiving module, a searching module, a positioning module and an obtaining module.

[0138] The receiving module is configured to receive an acquisition request of a target segment, the acquisition request including an identifier of a multimedia file, and the target segment being at least a part of the multimedia file;

[0139] The searching module is configured to obtain a target index file corresponding to the target segment from an index file table according to the identifier, the index file table including at least one index file, and the index file including characteristics of segments, the segments being obtained by packetizing the multimedia file;

[0140] The positioning module is configured to obtain position information of the target segment in the multimedia file according to the characteristics of the segments in the target index file;

[0141] The obtaining module is configured to pull streaming from data of the multimedia file according to the position information.

[0142] In an embodiment of the present application, the searching module is specifically configured to:

[0143] determine the multimedia file according to the identifier;

[0144] search an index file of the multimedia file from the index file table;

[0145] obtain the target index file corresponding to the target segment from the index file of the multimedia file according to a time period corresponding to the target segment.

[0146] In an embodiment of the present application, the positioning module is specifically configured to:

[0147] obtain a start time and an end time of the target segment;

[0148] According to the characteristic of the segment in the target index file, the start time and the end time of the target segment, the start position and the end position of the target segment in the multimedia file are determined.

[0149] In an embodiment of the present application, the positioning module is specifically configured to:

[0150] According to the characteristic of the segment in the target index file, the start time of the target segment, the start frame of the target segment in the multimedia file is obtained;

[0151] According to the characteristic of the segment in the target index file, the end time of the target segment, the end frame of the target segment in the multimedia file is obtained.

[0152] In an embodiment of the present application, the obtaining module is specifically configured to:

[0153] According to the start frame and the end frame of the target segment, the data of the multimedia file is pulled.

[0154] In an embodiment of the present application, before the target index file corresponding to the target segment is obtained from the index file table according to the identification, the method further comprises:

[0155] According to the packet of the multimedia file, the segment of the multimedia file is obtained;

[0156] The characteristic of the segment of the multimedia file is extracted;

[0157] According to the characteristic, the index file is obtained, and the index file is stored in the index file table.

[0158] In an embodiment of the present application, the method further comprises:

[0159] The multimedia file is converted into a block file, and the data of the multimedia file is obtained;

[0160] The data of the multimedia file is stored.

[0161] In summary, the storage device of the multimedia file in the embodiment of the present application can quickly query the target index file corresponding to the target segment when receiving the acquisition request of the target segment, and then the position information of the target segment in the multimedia file can be quickly determined according to the characteristic of the segment in the target index file, and the data of the multimedia file is accurately pulled according to the position information. The target segment can be arbitrarily and quickly extracted from the complete file, the use experience of the user is improved, and thus the video can be quickly and efficiently downloaded according to the file segment of the user specified time period.

[0162] It should be understood that the units or modules described in the apparatus 700 correspond to the units or modules described in the method with reference to Figure 1 The various steps in the described method correspond. Thus, the operations and features described above for the method equally apply to the apparatus 700 and the units contained therein, which will not be described again. The apparatus 700 can be pre- implemented in a browser or other secure application of an electronic device, or can be loaded into the browser or secure application of an electronic device by downloading or the like. The corresponding units in the apparatus 700 can cooperate with the units in the electronic device to implement the solutions of the embodiments of the present application.

[0163] In the foregoing detailed description, several modules or units are mentioned. The division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into a plurality of modules or units.

[0164] In summary, the storage apparatus of the multimedia file proposed in the embodiments of the present application can quickly query the target index file corresponding to the target segment when receiving the acquisition request of the target segment, and then can quickly determine the position information of the target segment in the multimedia file according to the characteristics of the segments in the target index file, and accurately stream from the data of the multimedia file according to the position information. The target segment can be arbitrarily and quickly extracted from the complete file, improving the user experience, so as to ensure that the video can be quickly and efficiently downloaded according to the user-specified time period.

[0165] Reference is made below to Figure 8 , Figure 8 A structural schematic diagram of a computer system of an electronic device or server suitable for implementing the embodiments of the present application is shown,

[0166] As shown in Figure 8 , the computer system includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 1002 or programs loaded into a random access memory (RAM) 1003 from a storage portion 1008. In the RAM 1003, various programs and data required for operation instructions of the system are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other through a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0167] The following components are connected to the I / O interface 1005: an input part 1006 including a keyboard, a mouse, etc.; an output part 1007 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage part 1008 including a hard disk, etc.; and a communication part 1009 including a network interface card such as a LAN card, a modem, etc. The communication part 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as necessary. A removable medium 1011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 1010 as necessary, so that a computer program read out therefrom is installed in the storage part 1008 as necessary.

[0168] In particular, in accordance with embodiments of the present application, the above-referenced flowcharts Figure 2 The processes described can be implemented as computer software programs. For example, embodiments of the present application include a computer program product which includes a computer program carried on a computer-readable medium, the computer program containing program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program contains program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, the above-described functions defined in the system of the present application are executed.

[0169] It should be noted that the computer-readable medium shown in the application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or component. In this application, the computer-readable signal medium can include a data signal carried in a baseband or as a carrier wave part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take many forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium that can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or component. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0170] The flowcharts and block diagrams in the drawings illustrate the possible implementation architectures, functions and operation instructions of the systems, methods and computer program products according to various embodiments of the application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment or a part of code, which contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can also occur in different order from that noted in the drawings. For example, two connected blocks can actually be executed substantially in parallel, and sometimes in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operation instructions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0171] The units or modules described in the embodiments of the present application can be implemented in the form of software or in the form of hardware. The units or modules described can also be arranged in a processor. In some cases, the names of the units or modules do not constitute a limitation on the units or modules themselves.

[0172] As another aspect, the present application also provides a computer readable storage medium, which can be included in the electronic device described in the above embodiments, or can exist separately without being assembled into the electronic device. The computer readable storage medium stores one or more programs, and when the programs are used by one or more processors to execute the multimedia file storage method described in the present application.

[0173] The above description is merely preferred embodiments of the present application and a description of the principles of the technology used. Those skilled in the art should understand that the disclosed range of the present application is not limited to the technical solutions formed by the specific combinations of the above technical features, and should also cover other technical solutions formed by any combinations of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features can be replaced with the technical features disclosed in the present application (but not limited to) having similar functions to form technical solutions.

Claims

1. A storage method of a multimedia file, characterized by, The method comprises the following steps: obtaining a live stream of a multimedia file; converting the live stream into a plurality of chunk files in a target format, wherein the size of the chunk files changes with the length of a cache queue and / or the number of writable disks; the total size of the chunk files determines the amount of data to be written to the disks and whether there is room for improvement in disk performance during thread scheduling; and the number of writable disks determines the concurrent writing capability of the disks; writing the plurality of chunk files to the cache queue in sequence, and scheduling a plurality of threads in a thread pool to write the chunk files in the cache queue to the writable disks in parallel; the length of the cache queue is not less than the number of threads in the thread pool; wherein the converting the live stream into a plurality of chunk files in a target format comprises: reading frame data of the live stream from a cache; converting the frame data into files in the target format; dividing the files into a plurality of chunk files according to the size of the chunk files; the scheduling a plurality of threads in a thread pool to write the chunk files in the cache queue to the writable disks in parallel comprises: randomly scheduling idle threads in the thread pool to write the chunk files in the cache queue to the writable disks in parallel.

2. The storage method of a multimedia file according to claim 1, characterized by, Before the converting the live stream into a plurality of chunk files in a target format, the method further comprises: obtaining the length of the cache queue and the total size of the plurality of chunk files; determining the size of the chunk files according to the length of the cache queue and the total size of the plurality of chunk files; and / or, obtaining the number of writable disks and the writing speed of the writable disks; obtaining the total writing speed of the writable disks according to the number of writable disks and the writing speed of the writable disks; determining the size of the chunk files according to the comparison result between the total writing speed of the plurality of threads in the thread pool and the total writing speed of the writable disks in the case of different sizes of the chunk files.

3. The storage method of a multimedia file according to any one of claims 1-2, characterized in that, Before the scheduling a plurality of threads in a thread pool to write the chunk files in the cache queue to the writable disks in parallel, the method further comprises: determining the number of threads in the thread pool according to the number of writable disks, wherein the number of threads is not less than the number of writable disks; initializing the thread pool according to the number of threads.

4. The storage method of a multimedia file according to claim 1, characterized by, The randomly scheduling idle threads in the thread pool to write the chunk files in the cache queue to the writable disks in parallel comprises: obtaining the storage path of the writable disks; randomly scheduling idle threads in the thread pool to write the chunk files in the cache queue to the writable disks according to the storage path.

5. The storage method of a multimedia file according to claim 1, characterized by, After the writing the plurality of chunk files to the cache queue in sequence and the scheduling a plurality of threads in a thread pool to write the chunk files in the cache queue to the writable disks in parallel, the method further comprises: after uploading the chunk files written to the writable disks to a server, receiving an acquisition request of a target segment, the acquisition request comprising an identifier of a multimedia file, and the target segment being at least a part of the multimedia file; According to the identifier, a target index file corresponding to the target segment is obtained from an index file table, the index file table comprising at least one index file, the index file comprising characteristics of segments, the segments being obtained by packetizing the multimedia file; According to the characteristics of the segments in the target index file, position information of the target segment in the multimedia file is obtained; According to the position information, streaming is pulled from data of the multimedia file.

6. The storage method of a multimedia file according to claim 5, wherein, The obtaining of the target index file corresponding to the target segment from the index file table according to the identifier comprises: The multimedia file is determined according to the identifier; An index file of the multimedia file is retrieved from the index file table; According to a time period corresponding to the target segment, a target index file corresponding to the target segment is obtained from the index file of the multimedia file.

7. The storage method of a multimedia file according to claim 5, wherein, The obtaining of the position information of the target segment in the multimedia file according to the characteristics of the segments in the target index file comprises: The start time and the end time of the target segment are obtained; According to the characteristics of the segments in the target index file, the start time and the end time of the target segment, start and end positions of the target segment in the multimedia file are determined.

8. The storage method of a multimedia file according to claim 7, characterized by, The determination of the start and end positions of the target segment in the multimedia file according to the characteristics of the segments in the target index file, the start time and the end time of the target segment comprises: According to the characteristics of the segments in the target index file and the start time of the target segment, a start frame of the target segment in the multimedia file is obtained; According to the characteristics of the segments in the target index file and the end time of the target segment, an end frame of the target segment in the multimedia file is obtained.

9. The storage method of a multimedia file according to claim 8, characterized by, The streaming pulled from the data of the multimedia file according to the position information comprises: According to the start frame and the end frame of the target segment, streaming is pulled from the data of the multimedia file.

10. The storage method of a multimedia file according to any one of claims 5 to 9, characterized in that, Before the target index file corresponding to the target segment is obtained from the index file table according to the identifier, the method further comprises: According to packetization of the multimedia file, segments of the multimedia file are obtained; Characteristics of the segments of the multimedia file are extracted; According to the characteristics, the index file is obtained and stored in the index file table.

11. A storage device for multimedia files, characterized in that Comprise: An acquisition module is configured to acquire a live stream of a multimedia file; A conversion module is configured to convert the live stream into a plurality of block files in a target format, wherein the size of the block files changes with the length of a cache queue and / or the number of writable disks; the total size of the block files determines the amount of data to be written to the disks and determines whether there is room for improvement in disk performance in the thread scheduling process; and the number of writable disks determines the concurrent writing capability of the disks; A writing module is configured to sequentially write the plurality of block files to the cache queue and schedule a plurality of threads in a thread pool to write the block files in the cache queue to the writable disks in parallel; and the length of the cache queue is not less than the number of threads in the thread pool. The conversion of the live stream into the plurality of block files in the target format comprises: reading frame data of the live stream from the cache; converting the frame data into a file in the target format; segmenting the file into a plurality of chunk files according to sizes of the chunk files; a plurality of threads in the scheduling thread pool write the chunk files in the cache queue to the writable disk in parallel, including: randomly scheduling idle threads in the thread pool to write the chunk files in the cache queue to the writable disk in parallel.

12. The storage method of a multimedia file according to claim 11, wherein, Further comprising: a receiving module configured to receive a request for a target segment after uploading the chunk files to be written to the writable disk to a server, the request including an identification of a multimedia file, the target segment being at least a part of the multimedia file; a searching module configured to obtain a target index file corresponding to the target segment from an index file table according to the identification, the index file table including at least one index file, the index file including characteristics of a segment, the segment being obtained by packetizing the multimedia file; a positioning module configured to obtain location information of the target segment in the multimedia file according to the characteristics of the segment in the target index file; an obtaining module configured to pull stream from data of the multimedia file according to the location information.

13. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the program to implement the multimedia file storage method according to any one of claims 1-10.

14. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the multimedia file storage method according to any one of claims 1-10.

Citation Information

Patent Citations

  • Method and system for merging data in server

    CN103678699A

  • Video playing method and device, equipment and storage medium

    CN114025201A

  • Video source file processing method, video playing method, device and equipment

    CN114584806A

  • Streaming Media Cache for Media Streaming Service

    US20180191857A1