Video slice management method and device, computer equipment, readable storage medium and program product
By designing a shared memory-based channel index structure in the live broadcast server system, the high I/O consumption and delay problems caused by reading and parsing playlist files during the streaming process of the live broadcast server system is solved, and the system's concurrent response capabilities are improved.
Patent Information
- Application Number
- CN202411753672.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-04
AI Technical Summary
In the process of pushing streams to the client, in order to ensure time shift and view playback services at any time period, the live broadcast server system needs to read and parse a large number of playlist files according to the time period, resulting in the system's large disk I/O consumption and large response delay, which reduces the system's concurrent response capability.
A channel shared index structure based on shared memory is designed, including channel index red and black trees and channel index linked lists, which are used to query and traverse video slice files, reducing dependence on playlist files and reducing system storage and disk I/O consumption.
By reducing the reading and parsing of playlist files, the system's storage consumption and disk write I/O consumption are reduced, and the concurrent response capability of the live broadcast server system is improved.
Smart Images

Figure CN119562084A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video live broadcast technology, and in particular to a video slice management method, apparatus, computer equipment, computer-readable storage medium and computer program product. Background Art
[0002] With the continuous development of the Internet, live broadcasting is becoming more and more popular. As an indispensable technology for live broadcasting, HLS (HTTP Live Streaming, Hypertext Transfer Protocol Dynamic Bitrate Adaptation) is used for audio and video services on PCs and mobile terminals.
[0003] The live broadcast server system is widely used in many application scenarios such as mobile TV and live video. It provides decoding, caching, and slicing storage services for the source streams provided by the content provider. At the same time, it provides live broadcast, time-shifting, playback, and double-speed broadcast control services based on protocols such as HLS and RTSP (Real Time Streaming Protocol) to the client.
[0004] The live streaming server system not only needs to handle the streaming service of hundreds of video source streams from content providers in real time, but also needs to undertake the service of pushing streams to clients, that is, responding to clients with sliced content cached or stored by the live streaming server system using protocols such as HLS and RTSP. With the increasing popularity of ultra-high-definition, 4K, and 8K video bit rates, high-performance slice management has gradually become an important factor affecting the performance of live streaming server systems.
[0005] However, in the process of pushing streams to the client, the live broadcast server system in the related technology needs to read the corresponding playlist file by time period and re-parse the slice file content of the requested time period in order to ensure time-shifting and playback services at any time period, resulting in a large amount of system disk read I / O consumption. At the same time, the parsing speed is slow and the response delay is large, which greatly reduces the system's concurrent response capability.
[0006] Therefore, there is a problem in the related art that the concurrent response capability of the live broadcast server system is poor. Summary of the invention
[0007] Based on this, it is necessary to provide a video slice management method, device, computer equipment, computer-readable storage medium and computer program product that can improve the concurrent response capability of the live broadcast server system in response to the above-mentioned technical problems.
[0008] In a first aspect, the present application provides a video slice management method, comprising:
[0009] Receive a video playback request sent by a client; the video playback request is used to request video content within a time range from a first time to a second time of a target video content source channel;
[0010] In the target channel index red-black tree corresponding to the target video content source channel of the channel sharing index structure, querying a first index node matching the first time and a second index node matching the second time; the target channel index red-black tree includes index nodes corresponding to a plurality of video slice files originating from the target video content source channel respectively; each of the index nodes is inserted into the target channel index red-black tree using the timestamp information of the corresponding video slice file as a keyword;
[0011] In the target channel index linked list corresponding to the target video content source channel of the channel shared index structure, the video slice files corresponding to each index node between the first index node and the second index node are traversed and obtained, and returned to the client; the target channel index linked list is used to indicate the time sequence of each index node in the target channel index red-black tree.
[0012] In one of the embodiments, when the video playback request is an HLS request, traversing to obtain the video slice files corresponding to each index node between the first index node and the second index node, and returning the video slice files to the client, includes:
[0013] Traversing and acquiring video slice information stored in each index node between the first index node and the second index node;
[0014] Generate an m3u8 playlist file according to each of the video slice information; the m3u8 playlist file includes a slice download address of the video slice file corresponding to each index node between the first index node and the second index node;
[0015] The m3u8 playlist file is sent to the client; the client is used to send a slice download request to the live broadcast server system based on the slice download address in the m3u8 playlist file;
[0016] In response to the slice download request, the video slice files corresponding to each index node between the first index node and the second index node are sent to the client.
[0017] In one of the embodiments, when the video playback request is an RTSP request, traversing to obtain the video slice files corresponding to each index node between the first index node and the second index node, and returning the video slice files to the client, includes:
[0018] Traverse and obtain video slice files corresponding to each index node between the first index node and the second index node;
[0019] The traversed video slice files are returned to the client in chronological order.
[0020] In one of the embodiments, the timestamp information includes an absolute timestamp of a slice start time corresponding to the video slice file; the querying of a first index node matching the first time and a second index node matching the second time in a target channel index red-black tree corresponding to the target video content source channel in a channel sharing index structure includes:
[0021] Create a first node pointer and a second node pointer; the first node pointer points to the root node of the target channel index red-black tree; the second node pointer is used to store the query result, and the query result is initially set to a null value;
[0022] The target channel index red-black tree is traversed through the first node pointer loop, and for any time between the first time and the second time, it is determined whether the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to any time;
[0023] According to the judgment result, the query result currently stored in the second node pointer is updated; the currently stored query result is used to determine the index node matching the any time.
[0024] In one embodiment, updating the query result currently stored in the second node pointer according to the judgment result includes:
[0025] When the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to any time, the index node currently pointed to by the first node pointer is used as the query result currently stored by the second node pointer, and the loop is terminated; the index node in the query result currently stored by the second node pointer is the index node matching any time.
[0026] In one embodiment, updating the query result currently stored in the second node pointer according to the judgment result includes:
[0027] When the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is less than any of the times, the index node currently pointed to by the first node pointer is used as the query result currently stored by the second node pointer, and the first node pointer is made to point to the right child node of the index node currently pointed to;
[0028] When the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is greater than any of the times, the first node pointer is set to point to the left child node of the index node currently pointed to;
[0029] Return to the step of determining whether the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to any of the times, until they are equal or the next index node pointed to by the first node pointer is empty, and end the loop.
[0030] In one embodiment, the method further comprises:
[0031] Receive and parse the video source stream of the target video content source channel;
[0032] Determine whether the duration of the current slice of the video source stream meets a preset threshold;
[0033] If the conditions are met, the absolute timestamp of the slice start time corresponding to the current slice is used as a keyword and inserted into the target channel index red-black tree and the target channel index linked list.
[0034] In one embodiment, the method further comprises:
[0035] Performing a scheduled cleanup task on the target video content source channel at preset intervals;
[0036] The scheduled cleaning task is used to obtain a first difference between a first timestamp and a second timestamp; the first timestamp is an absolute timestamp of the slice start time corresponding to the first node in the target channel index red-black tree; the second timestamp is an absolute timestamp of the slice start time corresponding to the start node in the target channel index linked list;
[0037] The scheduled cleanup task is also used to delete the video slice file corresponding to the starting node and release the memory resources of the video slice information maintained by the starting node when the first difference is greater than a preset protection duration.
[0038] In one embodiment, the scheduled cleanup task is also used to obtain a second difference between the current timestamp and the first timestamp; the scheduled cleanup task is also used to delete the first node in the target channel index red-black tree when the second difference is greater than a preset maximum playback time.
[0039] In a second aspect, the present application also provides a video slice management device, including:
[0040] A receiving module, configured to receive a video playback request sent by a client; the video playback request is used to request video content within a time range from a first time to a second time of a target video content source channel;
[0041] A query module is used to query a first index node matching the first time and a second index node matching the second time in a target channel index red-black tree corresponding to the target video content source channel of the channel sharing index structure; the target channel index red-black tree includes index nodes corresponding to a plurality of video slice files respectively originating from the target video content source channel; each of the index nodes is inserted into the target channel index red-black tree using the timestamp information of the corresponding video slice file as a keyword;
[0042] A traversal module is used to traverse the target channel index linked list corresponding to the target video content source channel in the channel shared index structure, obtain the video slice files corresponding to each index node between the first index node and the second index node, and return them to the client; the target channel index linked list is used to indicate the time sequence of each index node in the target channel index red-black tree.
[0043] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the steps of the above method are implemented.
[0044] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.
[0045] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0046] The above-mentioned video slice management method, device, computer equipment, computer-readable storage medium and computer program product receive a video playback request sent by a client; the video playback request is used to request the video content within the time range from the first time to the second time of the target video content source channel; in the target channel index red-black tree corresponding to the target video content source channel of the channel shared index structure, query the first index node matching the first time and the second index node matching the second time; the target channel index red-black tree includes index nodes corresponding to multiple video slice files originated from the target video content source channel respectively; each index node is inserted into the target channel index red-black tree with the timestamp information of the corresponding video slice file as a keyword; in the target channel index linked list corresponding to the target video content source channel of the channel shared index structure, traverse and obtain the video slice files corresponding to each index node between the first index node and the second index node, and return them to the client; the target channel index linked list is used to indicate the time sequence of each index node in the target channel index red-black tree.
[0047] In this way, a channel shared index structure based on shared memory is designed, which includes a channel index red-black tree and a channel index linked list. After receiving a video playback request for video content within a time range from a first time to a second time for requesting a target video content source channel, a first index node matching the first time and a second index node matching the second time are queried and located according to the target channel index red-black tree corresponding to the target video content source channel of the channel shared index structure. According to the target channel index linked list corresponding to the target video content source channel of the channel shared index structure, video slice files corresponding to each index node between the first index node and the second index node are traversed to obtain the files, and the files are returned to the client. The live broadcast server only needs to store the base speed video slice files, and does not need to store the forward and reverse slice files and m3u8 playlist files of various speeds. There is no need to read the corresponding time period m3u8 files twice and parse them twice, which reduces the system storage consumption and disk write I / O consumption, and improves the concurrent response capability of the live broadcast server system. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0049] Figure 1 An architecture diagram of a live broadcast server system in one embodiment;
[0050] Figure 2An architectural flow chart of video slice management of a live broadcast server system based on shared memory in one embodiment;
[0051] Figure 3 is a schematic diagram of a channel sharing index structure in one embodiment;
[0052] Figure 4 A schematic diagram of an update process of an index node in an embodiment;
[0053] Figure 5 A schematic diagram of a process of managing video slices in an embodiment;
[0054] Figure 6 A schematic diagram of a process of processing an HLS m3u8 request based on a shared index structure in one embodiment;
[0055] Figure 7 A schematic diagram of a process of deleting an index node in an embodiment;
[0056] Figure 8 is a flow chart of a video slice management method in another embodiment;
[0057] Fig. 9 is a structural block diagram of a video slice management device in one embodiment;
[0058] Fig.10 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0059] 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.
[0060] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0061] The present application provides a video slice management method, and this embodiment uses the method applied to a live broadcast server system as an example for illustration.
[0062] The live broadcast server system is widely used in many application scenarios such as IPTV (Interactive Personality TV), mobile TV, and live video. It provides decoding, caching, and slicing storage services for the source streams provided by the content provider, and provides live broadcast, time shift, playback, and speed control services based on protocols such as HLS and RTSP to the client. Figure 1 As shown, an architecture diagram of a live broadcast server system is provided. The live broadcast server system not only needs to process the pull stream service of hundreds of video source streams from content providers in real time, but also needs to undertake the push stream service to the client, that is, respond to the client with the video slice content cached or stored by the live broadcast server system in the form of HLS, RTSP and other protocols. With the increasing popularity of current video bit rates such as ultra-high definition, 4K, and 8K, high-performance slice management has gradually become an important factor affecting the performance of live broadcast server systems. Although traditional live broadcast servers can meet the above capabilities, they also have the following problems:
[0063] 1) High concurrent disk I / O and storage consumption: In a multi-process architecture, hundreds of live streams are processed in real time, and each live stream has 2, 4, 8, 16, and 32 times the speed of forward and reverse broadcast control slice storage, and m3u8 playlist file storage. The storage duration is often more than 7 days, with high storage consumption and concurrent disk I / O, which significantly reduces the overall system performance.
[0064] 2) High concurrent disk reading I / O consumption and slow parsing of playback content: During the streaming process to the client, in order to ensure time-shifting and playback services for any period of time, it is necessary to read the corresponding m3u8 playlist file by period and re-parse the slice file content of the requested period, resulting in a large amount of system disk reading I / O consumption, slow parsing speed, large response delay, and greatly reducing the system's concurrent response capability.
[0065] The present application proposes a video slice management method for a live broadcast server system based on shared memory. Through shared memory, a high-performance index structure and index method are designed to maintain video slice information of the full playback time without introducing a database, and provide efficient update, search, and deletion methods to effectively reduce the system response time when pushing streams to the client. At the same time, in the slice generation stage, a thread pool is introduced to reduce process blocking caused by disk I / O, thereby improving system performance and concurrent response capabilities.
[0066] Among them, shared memory refers to a large-capacity memory that can be accessed by different central processing units (CPUs) in a multi-process computer system. Shared memory is a communication method between multiple processes under the Unix operating system. This method is usually used for communication between multiple processes of a program. In fact, multiple programs can also transfer information through shared memory.
[0067] Specifically, under the multi-process implementation architecture of the live broadcast server system, the slice index structure is implemented in shared memory with the video content source channel as the granularity, and efficient index update, search, and deletion methods are provided. Without the introduction of a database, it is ensured that a single fixed business process maintains and all business processes share the index information of the full playback time, and then an efficient m3u8 file list generation method is provided, which only needs to store the base speed video slice file, without storing various levels of multiple speed video slice files and m3u8 playlist files, effectively reducing storage resource usage and push stream response delay. At the same time, in order to solve the problem of process blocking caused by disk I / O during the slice recording of video streams from hundreds of content channels, which in turn affects the system responsiveness, a thread pool is introduced in the slice generation stage to reduce process blocking caused by disk I / O. Overall, the system performance and concurrent responsiveness are improved.
[0068] Furthermore, if Figure 2 As shown, an architectural flow chart of video slice management of a live broadcast server system based on shared memory is provided.
[0069] Under the implementation architecture of the live server system with multiple business processes, for the video stream accessed by the content provider (i.e., the video content source channel), the video content source channel is used as the granularity. In a single business process, a shared index structure is established on the shared memory to maintain the index information of the full time-shift and playback slices of the channel, and the business process maintains the index update and data writing of the channel. Only the base speed video slice files need to be stored, and there is no need to store the forward and reverse video slice files and m3u8 file lists of various speeds.
[0070] When writing video slice files to storage, a thread pool is introduced. When the video stream data of the channel is parsed to meet the slice conditions (such as the slice duration), threads are used to asynchronously process index updates and write video slice files to storage blocks to avoid disk I / O blocking the process. At the same time, a timed processing mechanism is started in the process to regularly clear the shared index information and slice data of the channels managed by the process.
[0071] All business processes can handle requests from client groups for live broadcast, time-shift, and video content. Based on the content of the request, the business process queries the shared index structure, indexes the requested content, and returns video slice files, m3u8 playlist files, etc. to the client.
[0072] In the present application, a shared index structure of a channel is implemented based on a red-black tree and a linked list, and a shared index structure based on a shared memory is obtained. The shared index structure includes a channel index red-black tree corresponding to each video content source channel and a corresponding channel index linked list. The channel index red-black tree includes a plurality of index nodes corresponding to video slice files originating from the corresponding video content source channel; the channel index linked list is used to indicate the time sequence of each index node in the corresponding channel index red-black tree.
[0073] The channel index red-black tree corresponding to each video content source channel can be established by a single business process, maintaining the index information of the full time shift and playback slice of the channel, and maintaining the index update and data writing of the channel by the business process. All other business processes can read the channel index red-black tree established by the business process. That is, each business process can access the channel index red-black tree corresponding to each video content source channel in the channel shared index structure.
[0074] like Figure 3 As shown, a schematic diagram of a channel sharing index structure is provided. The channel sharing index structure corresponds to the ch_index_struct member of the "channel structure" in the figure.
[0075] 1) Channel shared index structure (shared index structure):
[0076] Necessary elements:
[0077] rbtree: channel index red-black tree, used to query and maintain index information of full time shift and playback slices.
[0078] lock: read-write lock, used to protect the shared data of rbtree. When updating or deleting the index node in rbtree, a write lock is set; when searching for the index node in rbtree, a read lock is set.
[0079] Node*start_node: Maintains the channel index list. This member is the starting node of the node list.
[0080] Node*end_node: Maintains the channel index list. This member is the end node of the node list.
[0081] path: the file directory where the slices are recorded.
[0082] 2) Channel index red-black tree rbtree:
[0083] The index nodes in the channel index red-black tree use the Unix absolute timestamp as the key (keyword) to insert, query and delete the index nodes.
[0084] Necessary elements:
[0085] insert method: Provides an insert method using Unix absolute timestamp as key.
[0086] find method: Provides a query method using Unix absolute timestamp as key.
[0087] delete method: provides a method to remove the index node from the channel index red-black tree, but does not release the index node resources.
[0088] Root node: The root node of the channel index red-black tree, a necessary parameter of the red-black tree.
[0089] 3)Node index structure:
[0090] Necessary elements:
[0091] 1. key: red-black tree node, using Unix absolute timestamp as key.
[0092] 2. index_struct: stores the index information of ts shard files (including timestamp, seg_size, seg_duration, seg_sequence, gop_num, gop_group, bandwidth, file_name).
[0093] 2.1, timestamp: the start time of the video slice, Unix absolute timestamp.
[0094] 2.2, seg_size: video slice size.
[0095] 2.3, seg_duration: video slice duration.
[0096] 2.4, seg_sequence: video slice sequence number, increasing from 0 to 1.
[0097] 2.5. gop_num: the number of GOPs (Group of Pictures) of the contained video. GOP is a set of pictures in a sequence to assist random access. The first image of GOP must be an I frame (key frame) to ensure that GOP does not need to refer to other images and can be decoded independently).
[0098] 2.6, gop_group[]: GOP group, containing the index information of all GOPs in the slice (including gop_size, i_frame_size, duration, data_off).
[0099] 2.6.1. gop_size: GOP size.
[0100] 2.6.2. i_frame_size: GOP key frame (I frame) size.
[0101] 2.6.3, duration: GOP duration.
[0102] 2.6.4, data_off: the offset position of the GOP start point in the video slice.
[0103] 2.7, bandwidth: the average video bit rate of the video slice.
[0104] 2.8, file_name: the file name of the video slice.
[0105] 3. Node*left: points to the left child node.
[0106] 4. Node*right: points to the right child node.
[0107] 5. Node*prev: Node linked list, pointing to the index node of the next timestamp.
[0108] 6. Node*next: A node linked list pointing to the index node of the previous timestamp.
[0109] Update method for shared index structure:
[0110] Live streaming has the characteristics of time sequence, and adopts the insertion method with Unix absolute timestamp as key. When the video slice meets the conditions for slice formation, the new index node is inserted into the channel index red-black tree and channel index linked list of the shared index structure with the Unix absolute timestamp of the slice start time as the key.
[0111] The update process of the index node is as follows Figure 4 As shown:
[0112] Update steps:
[0113] 1) Receive the source stream from the content provider (video content source channel) and parse it.
[0114] 2) Parse to the key frame (I frame), which is the starting position of the next GOP.
[0115] 3) Whether the current video slice duration has reached the preset value (preset slice duration).
[0116] 4) If yes, create a thread task, start the thread, enter the video slice storage and index node creation and update process, and return to 1); if no, return directly to 1).
[0117] 5) In the child thread:
[0118] a) Write the video slice content into storage.
[0119] b) Create an index node and fill the video slice information into the node.
[0120] c) Add a write lock to the shared index structure.
[0121] d) The index node uses the Unix absolute timestamp of the slice start time as the key and is inserted into the channel index red-black tree of the shared index structure in the method of "smaller value is the left node, larger value is the right node"; the index node is inserted at the end of the channel index linked list and becomes the new tail node.
[0122] e) Unlock the lock on the shared index structure.
[0123] f) End the thread task and return the thread to the thread pool.
[0124] The video slice information may refer to the information contained in the necessary element index_struct of the node index structure.
[0125] In one embodiment, Figure 5 As shown, a video slice management method is provided. This embodiment uses the method applied to a live broadcast server system as an example. The live broadcast server in the live broadcast server system can be implemented by an independent server or a server cluster composed of multiple servers. The method includes the following steps:
[0126] Step S510: receiving a video playback request sent by a client.
[0127] The video playback request may include but is not limited to requests for live broadcast, time shift, and playback content.
[0128] The video play request is used to request the video content of the target video content source channel within a time range from a first time to a second time.
[0129] The first time and the second time may refer to a certain point in time.
[0130] The target video content source channel is the video content source channel requested by the video playback request.
[0131] In a specific implementation, the live broadcast server system can receive a video playback request sent by a client.
[0132] Step S520: In the target channel index red-black tree corresponding to the target video content source channel of the channel sharing index structure, a first index node matching the first time and a second index node matching the second time are searched.
[0133] The target channel index red-black tree is a channel index red-black tree corresponding to the target video content source channel in the channel sharing index structure.
[0134] The target channel index red-black tree includes index nodes corresponding to a plurality of video slice files originating from the target video content source channel.
[0135] Each index node in the target channel index red-black tree is inserted into the target channel index red-black tree using the timestamp information of the corresponding video slice file as a key.
[0136] In a specific implementation, the live broadcast server system can query the target channel index red-black tree with the first time as the key, and use the queried index node that matches the first time as the first index node. Also, query the target channel index red-black tree with the second time as the key, and use the queried index node that matches the second time as the second index node.
[0137] The timestamp information corresponding to the first index node matches the first time; and the timestamp information corresponding to the second index node matches the second time.
[0138] Step S530: traverse and obtain the video slice files corresponding to each index node between the first index node and the second index node in the target channel index linked list corresponding to the target video content source channel of the channel sharing index structure, and return them to the client.
[0139] The target channel index linked list is a channel index linked list corresponding to the target video content source channel.
[0140] The target channel index linked list is used to indicate the time sequence of each index node in the target channel index red-black tree.
[0141] In a specific implementation, the live broadcast server system can traverse each index node between the first index node and the second index node in the target channel index linked list corresponding to the target video content source channel of the channel shared index structure, so as to return the video slice files corresponding to each index node between the first index node and the second index node to the client.
[0142] For example, the video play request is used to request the video content of the target video content source channel N whose starting time is between Unix time X (first time) and Unix time Y (second time).
[0143] In the slice management module, according to the first time X of the video playback request, the target channel index red-black tree is queried with X as the key, and the first index node node_X is queried. According to the second time Y of the video playback request, the target channel index red-black tree is queried with Y as the key, and the second index node node_Y is queried. According to the target channel index linked list, node_X to node_Y are traversed to obtain the video slice files corresponding to each index node between node_X and node_Y.
[0144] In the above-mentioned video slice management method, a video playback request sent by a client is received; the video playback request is used to request the video content within the time range from the first time to the second time of the target video content source channel; in the target channel index red-black tree corresponding to the target video content source channel of the channel shared index structure, a first index node matching the first time and a second index node matching the second time are queried; the target channel index red-black tree includes index nodes corresponding to multiple video slice files originating from the target video content source channel respectively; each index node is inserted into the target channel index red-black tree with the timestamp information of the corresponding video slice file as a keyword; in the target channel index linked list corresponding to the target video content source channel of the channel shared index structure, the video slice files corresponding to each index node between the first index node and the second index node are traversed and returned to the client; the target channel index linked list is used to indicate the time sequence of each index node in the target channel index red-black tree.
[0145] In this way, a channel shared index structure based on shared memory is designed, which includes a channel index red-black tree and a channel index linked list. After receiving a video playback request for video content within a time range from a first time to a second time for requesting a target video content source channel, a first index node matching the first time and a second index node matching the second time are queried and located according to the target channel index red-black tree corresponding to the target video content source channel of the channel shared index structure. According to the target channel index linked list corresponding to the target video content source channel of the channel shared index structure, video slice files corresponding to each index node between the first index node and the second index node are traversed to obtain the files, and the files are returned to the client. The live broadcast server only needs to store the base speed video slice files, and does not need to store the forward and reverse slice files and m3u8 playlist files of various speeds. There is no need to read the corresponding time period m3u8 files twice and parse them twice, which reduces the system storage consumption and disk write I / O consumption, and improves the concurrent response capability of the live broadcast server system.
[0146] In one embodiment, in combination with the update method of the shared index structure described in the above embodiment, for the update of the index node corresponding to the target video content source channel, the live broadcast server system can receive and parse the video source stream of the target video content source channel; determine whether the duration of the current slice of the video source stream meets the preset threshold; if so, use the absolute timestamp of the slice start time corresponding to the current slice as a keyword and insert it into the target channel index red-black tree and the target channel index linked list.
[0147] For the specific update process, please refer to Figure 4 It is understandable that the updating method for the index node corresponding to each video content source channel is the same, and the target video content source channel is used as an example in this embodiment, and the updating method for the index node is not limited to the target video content source channel.
[0148] In one embodiment, when the video playback request is an HLS request, the video slice files corresponding to each index node between the first index node and the second index node are traversed and obtained, and returned to the client, including: traversing and obtaining the video slice information stored in each index node between the first index node and the second index node; generating an m3u8 playlist file according to each video slice information; the m3u8 playlist file includes the slice download address of the video slice file corresponding to each index node between the first index node and the second index node; sending the m3u8 playlist file to the client; the client is used to send a slice download request to the live broadcast server based on the slice download address in the m3u8 playlist file; in response to the slice download request, sending the video slice files corresponding to each index node between the first index node and the second index node to the client.
[0149] The video slice information may refer to the information contained in the necessary element index_struct of the node index structure, including the start time of the slice, the slice size, the slice duration, the slice sequence number and other information.
[0150] In a specific implementation, when the video playback request is an HLS request, the live broadcast server system traverses and obtains the video slice files corresponding to each index node between the first index node and the second index node, and returns them to the client. The live broadcast server system can traverse and obtain the video slice information stored in each index node between the first index node and the second index node, and generate an m3u8 playlist file according to each video slice information; wherein the m3u8 playlist file includes the slice download addresses of the video slice files corresponding to each index node between the first index node and the second index node; the live broadcast server system sends the m3u8 playlist file to the client; the client is used to send a slice download request to the live broadcast server system based on the slice download address in the m3u8 playlist file, and the live broadcast server system responds to the slice download request and sends the video slice files corresponding to each index node between the first index node and the second index node to the client.
[0151] Take the HLS request for the target video content source channel N starting from Unix time X (first time) to Unix time Y (second time) as an example. Generally, the HLS request needs to request the m3u8 playlist file first. The multi-level m3u8 situation is not considered here, and only a general description is given. Figure 6 As shown, a flow chart of processing HLS m3u8 requests based on a shared index structure is provided.
[0152] In the slice management module, according to the first time X of the video playback request, the target channel index red-black tree is queried with X as the key, and the first index node node_X is queried. According to the second time Y of the video playback request, the target channel index red-black tree is queried with Y as the key, and the second index node node_Y is queried. According to the target channel index linked list, node_X to node_Y are traversed to obtain the video slice information corresponding to each index node between node_X and node_Y, and the m3u8 playlist file is generated in real time in the memory. Afterwards, the m3u8 playlist file generated in real time is returned to the user. The user sends a slice download request to the live server system one by one according to the slice download request of the m3u8 playlist file received according to the HLS protocol, and the live server system responds to the slice download request and sends the corresponding video slice file to the client.
[0153] In this way, based on the shared index structure, for the video playback requests of the client group for live broadcast, time-shift, and playback content, the shared index structure is queried according to the time range of the request, and the base speed and multi-speed m3u8 playlist files are generated in real time, and the corresponding video slice files are returned to the client. There is no need to read the corresponding time period m3u8 file twice and parse it twice, which improves the concurrent response capability of the system.
[0154] In other embodiments, when the video playback request is an RTSP request, the video slice files corresponding to each index node between the first index node and the second index node are traversed and obtained, and returned to the client, including: traversing and obtaining the video slice files corresponding to each index node between the first index node and the second index node; returning each traversed video slice file to the client in chronological order.
[0155] In the specific implementation, when the video playback request is an RTSP request, the live broadcast server system traverses and obtains the video slice files corresponding to each index node between the first index node and the second index node, and returns them to the client. There is no m3u8 playlist file generation process. The video slice files obtained by the index are directly returned to the client one by one in chronological order by traversing the first index node to the second index node.
[0156] In this way, when the video playback request is an RTSP request and when the video playback request is an HLS request, the target channel index red-black tree of the shared index structure is used to search for an index node that matches the target time period carried by the request (i.e., the time range from the first time to the second time); the linked list is traversed through the target channel index linked list of the shared index structure, and the traversal process is a lock-free operation. Compared with the related art, the m3u8 playlist file of the target time period is read from the disk again for secondary parsing, which avoids disk I / O consumption, reduces overall process consumption, responds faster, and improves the overall concurrent response capability of the system.
[0157] In one embodiment, the timestamp information includes the absolute timestamp of the slice start time corresponding to the video slice file; in the target channel index red-black tree corresponding to the target video content source channel of the channel shared index structure, querying the first index node matching the first time and the second index node matching the second time, including: creating a first node pointer and a second node pointer; the first node pointer points to the root node of the target channel index red-black tree; the second node pointer is used to store the query result, and the query result is initially set to a null value; the target channel index red-black tree is traversed through the first node pointer, and for any time between the first time and the second time, it is determined whether the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to any time; according to the judgment result, updating the query result currently stored by the second node pointer; the currently stored query result is used to determine the index node matching any time.
[0158] In a specific implementation, the live broadcast server system can create a first node pointer and a second node pointer in the process of querying the first index node matching the first time and the second index node matching the second time in the target channel index red-black tree corresponding to the target video content source channel of the channel shared index structure; the first node pointer points to the root node of the target channel index red-black tree; the second node pointer is used to store the query result, which is initially set to a null value.
[0159] The search method for the first index node matching the first time and the second index node matching the second time is the same, and any of the first time and the second time is used as an example below. The target channel index red-black tree is traversed through the first node pointer loop to determine whether the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to the any time, and based on the judgment result, the query result currently stored by the second node pointer is updated; wherein the currently stored query result is used to determine the index node matching the any time.
[0160] Wherein, when the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to the arbitrary time, the index node currently pointed to by the first node pointer is used as the query result currently stored by the second node pointer, and the loop ends. In this way, the index node in the query result currently stored by the second node pointer is the index node matching the arbitrary time.
[0161] For example, if any time is the first time, when the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to the first time, the index node currently pointed to by the first node pointer is used as the query result currently stored by the second node pointer, and the query result currently stored by the second node pointer is output. The index node in the query result currently stored by the second node pointer is the first index node that matches the first time.
[0162] If any time is the second time, when the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to the second time, the index node currently pointed to by the first node pointer is used as the query result currently stored by the second node pointer, and the query result currently stored by the second node pointer is output. The index node in the query result currently stored by the second node pointer is the second index node matching the second time.
[0163] In this way, after directly finding the index node whose absolute timestamp of the corresponding slice start time is equal to the time to be searched, the loop ends and the queried index node is used as the index node corresponding to the time to be searched, ensuring that the video slice information indexed by the index node is the most matching with the time to be searched, so that the video slice file indexed by the index node is the video content closest to the target time period requested by the video playback request.
[0164] In other embodiments, when the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is less than any time, the index node currently pointed to by the first node pointer is used as the query result currently stored by the second node pointer, and the first node pointer is pointed to the right child node of the index node currently pointed to; when the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is greater than any time, the first node pointer is pointed to the left child node of the index node currently pointed to; return to the step of determining whether the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to any time, until they are equal or the next index node pointed to by the first node pointer is empty, and the loop ends.
[0165] It can be understood that, when the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is less than any time, the next index node pointed to by the first node pointer is the right child node of the index node currently pointed to; when the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is greater than any time, the next index node pointed to by the first node pointer is the left child node of the index node currently pointed to.
[0166] In actual applications, this index node search method can be named "exact and left value matching" search method. The search steps are as follows:
[0167] 1) Assume that the timestamp to be searched is find_timestamp (that is, if any of the above times is find_timestamp).
[0168] 2) The shared index structure adds a read lock to the lock.
[0169] 3) Create node pointers node (first node pointer) and ret (second node pointer), let node point to the root node of the target channel index red-black tree, and let ret equal to null.
[0170] 4) Enter the while loop, and the loop ends when node is equal to null.
[0171] 5) Compare the member key of node (the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer) with find_timestamp:
[0172] a) If find_timestamp is equal to node->key, set ret to be equal to node, that is, ret = node (use the index node currently pointed to by the first node pointer as the query result currently stored by the second node pointer), jump out of the loop and go to step 6).
[0173] b) If find_timestamp is less than node->key, set node to be equal to the left child of node, that is, node = node->left (set the first node pointer to the left child of the currently pointed index node). Return to step 4).
[0174] c) If find_timestamp is greater than node->key, set ret equal to node, set node equal to the right child node of node, that is, ret = node, node = node->right (use the index node currently pointed to by the first node pointer as the query result currently stored by the second node pointer, and set the first node pointer to point to the right child node of the index node currently pointed to). Return to step 4).
[0175] 6) The shared index structure unlocks the lock.
[0176] 7) ret is the query result. If ret is not empty, the query is successful (the index node corresponding to any node is found). If ret is empty, the find_timestamp of the query is not within the valid time range (that is, there is no index node corresponding to any time).
[0177] The above method ensures that the query is searched based on the principle of "precise and left value matching", that is, the index node queried has a key value that is equal to or less than the find_timestamp of the query. It ensures that the indexed video slice information is less than and closest to the query find_timestamp time point, so that when the user searches for video content at a certain time point, he can quickly locate the video slice file closest to the time point, ensuring that the user obtains the content most relevant to his needs, reducing the user's waiting time and improving the accuracy of the returned video slice file. Through precise matching, the system can avoid transmitting irrelevant or future slice data, reducing bandwidth consumption and improving resource utilization efficiency. The returned video slice information matches the user's query time point, avoiding data inconsistency problems caused by timestamp mismatch and improving system reliability. By ensuring that the indexed video slice information is less than and closest to the query time point, not only the user experience and content relevance are improved, but also the system performance and resource utilization are optimized. This query method can effectively meet users' needs for video content in application scenarios such as video on demand and live playback, and enhance the system's intelligent and personalized service capabilities.
[0178] In addition, the present application also provides a method for deleting a shared index structure. For the deletion of index nodes in the channel shared index structure, a timing mechanism is adopted, and every fixed time period, the business process scans all video content source channels managed by this business process. The absolute timestamp of the slice start time corresponding to the index node is compared with the current time point. For index nodes whose duration exceeds the playback duration, they are removed from the channel index red-black tree. Timely cleaning of index nodes that are no longer needed can reduce the number of nodes in the red-black tree, thereby improving the performance of retrieval and insertion operations; for index nodes whose duration exceeds the "playback duration plus protection duration", the memory resources of the index node are released, the memory is returned to the shared memory, and the corresponding video slice file is deleted. Timely cleaning can avoid invalid information occupying too much memory.
[0179] The protection duration is used to determine how long the resources of an index node are kept after it is removed from the channel index red-black tree, to avoid the situation where the index node has reached the maximum playback duration but is still being used by clients.
[0180] Take the target video content source channel as an example for explanation. In one embodiment, the live broadcast server system can perform a scheduled cleanup task for the target video content source channel at preset intervals; the scheduled cleanup task is used to obtain a first difference between a first timestamp and a second timestamp, wherein the first timestamp is an absolute timestamp of the slice start time corresponding to the first node in the target channel index red-black tree; the second timestamp is an absolute timestamp of the slice start time corresponding to the start node (start_node) in the target channel index linked list. The scheduled cleanup task is also used to delete the video slice file corresponding to the start node when the first difference is greater than the preset protection duration, and release the memory resources of the video slice information maintained by the start node.
[0181] In addition, the scheduled cleanup task is also used to obtain a second difference between the current timestamp and the first timestamp; when the second difference is greater than a preset maximum playback time, the first node in the target channel index red-black tree is deleted.
[0182] It is understandable that the method for deleting the index node corresponding to each video content source channel is the same. In this embodiment, the target video content source channel is taken as an example, and the method for deleting the index node is not limited to being applied to the target video content source channel.
[0183] In actual applications, the process of deleting index nodes is as follows: Figure 7 :
[0184] How to delete:
[0185] 1) The channel timing processing mechanism is triggered at every preset time interval (eg, X seconds, where X is greater than 0).
[0186] 2) Circularly scan the status of each channel in the channel pool. If all channels have been scanned, go to step 1) after X seconds, otherwise go to step 3).
[0187] 3) Determine whether the channel is managed by this service process. If so, proceed to step 4), otherwise, return to step 2).
[0188] 4) Get the first node of the channel index red-black tree, that is, the leftmost node, recorded as min_node.
[0189] 5) Determine whether the key value of min_node minus the channel index list start_node->key is greater than the "protection duration". If so, proceed to step 6), otherwise, proceed to step 8).
[0190] 6) Delete the video slice file indexed by start_node and release the memory resources of the video slice information maintained by start_node.
[0191] 7)start_node points to the next node of start_node, that is, it points to start_node->next.
[0192] 8) Add a write lock to the shared index structure.
[0193] 9) Get the current Unix timestamp timestamp, and determine whether the key value of timestamp minus min_node is greater than the maximum playback time. If yes, proceed to step 10), otherwise, proceed to step 12).
[0194] 10) The min_node node is removed from the channel index red-black tree.
[0195] 11)min_node points to the next index node of min_node, that is, points to min_node->next, and returns to step 9).
[0196] 12) Unlock the lock of the shared index structure and return to step 2).
[0197] In another embodiment, Figure 8 As shown, a flow chart of a video slice management method is provided, and the method is applied to a live broadcast server system as an example for explanation, including the following steps:
[0198] Step S802: receiving a video playback request sent by a client.
[0199] Step S804: Create a first node pointer and a second node pointer.
[0200] Step S806, looping through the target channel index red-black tree through the first node pointer, for any time between the first time and the second time, determine whether the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to any time.
[0201] Step S808, when the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to any time, the index node currently pointed to by the first node pointer is used as the query result currently stored by the second node pointer, and the loop ends.
[0202] Step S810, when the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is less than any time, the index node currently pointed to by the first node pointer is used as the query result currently stored by the second node pointer, and the first node pointer is set to point to the right child node of the index node currently pointed to.
[0203] Step S812, when the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is greater than any time, the first node pointer is set to point to the left child node of the index node currently pointed to.
[0204] Step S814, return to the step of determining whether the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to any time, until they are equal or the next index node pointed to by the first node pointer is empty, and end the loop.
[0205] Step S816: In the target channel index linked list corresponding to the target video content source channel in the channel sharing index structure, traverse to obtain the video slice files corresponding to each index node between the first index node and the second index node, and return them to the client.
[0206] It should be noted that the specific limitations of the above steps can refer to the specific limitations of a video slice management method above.
[0207] 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.
[0208] Based on the same inventive concept, the embodiment of the present application also provides a video slice management device for implementing the above-mentioned video slice management method. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above-mentioned method, so the specific limitations in one or more video slice management device embodiments provided below can refer to the above-mentioned limitations on the video slice management method, which will not be repeated here.
[0209] In an exemplary embodiment, Fig. 9 As shown, a video slice management device is provided, including: a receiving module 910, a query module 920 and a traversal module 930, wherein:
[0210] The receiving module 910 is used to receive a video play request sent by a client; the video play request is used to request video content within a time range from a first time to a second time of a target video content source channel.
[0211] The query module 920 is used to query the first index node matching the first time and the second index node matching the second time in the target channel index red-black tree corresponding to the target video content source channel of the channel shared index structure; the target channel index red-black tree includes index nodes corresponding to multiple video slice files originated from the target video content source channel respectively; each of the index nodes is inserted into the target channel index red-black tree using the timestamp information of the corresponding video slice file as a keyword.
[0212] The traversal module 930 is used to traverse and obtain the video slice files corresponding to each index node between the first index node and the second index node in the target channel index linked list corresponding to the target video content source channel in the channel shared index structure, and return them to the client; the target channel index linked list is used to indicate the time sequence of each index node in the target channel index red-black tree.
[0213] In one of the embodiments, when the video playback request is an HLS request, the traversal module 930 is specifically used to traverse and obtain the video slice information stored in each index node between the first index node and the second index node; generate an m3u8 playlist file according to each video slice information; the m3u8 playlist file includes the slice download address of the video slice file corresponding to each index node between the first index node and the second index node; send the m3u8 playlist file to the client; the client is used to send a slice download request to the live broadcast server system based on the slice download address in the m3u8 playlist file; in response to the slice download request, send the video slice files corresponding to each index node between the first index node and the second index node to the client.
[0214] In one of the embodiments, when the video playback request is an RTSP request, the traversal module 930 is specifically used to traverse and obtain the video slice files corresponding to each index node between the first index node and the second index node; and return each of the traversed video slice files to the client in chronological order.
[0215] In one embodiment, the timestamp information includes the absolute timestamp of the slice start time corresponding to the video slice file; the query module 920 is specifically used to create a first node pointer and a second node pointer; the first node pointer points to the root node of the target channel index red-black tree; the second node pointer is used to store the query result, and the query result is initially set to a null value; the target channel index red-black tree is traversed through the first node pointer, and for any time between the first time and the second time, it is determined whether the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to any time; according to the judgment result, the query result currently stored by the second node pointer is updated; the currently stored query result is used to determine the index node matching the any time.
[0216] In one of the embodiments, the query module 920 is specifically used to use the index node currently pointed to by the first node pointer as the query result currently stored by the second node pointer, and end the loop when the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to any time; the index node in the query result currently stored by the second node pointer is the index node matching any time.
[0217] In one embodiment, the query module 920 is specifically used to, when the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is less than the any time, use the index node currently pointed to by the first node pointer as the query result currently stored by the second node pointer, and make the first node pointer point to the right child node of the index node currently pointed to; when the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is greater than the any time, make the first node pointer point to the left child node of the index node currently pointed to; return to the step of determining whether the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to the any time, until they are equal or the next index node pointed to by the first node pointer is empty, and end the loop.
[0218] In one of the embodiments, the device also includes: an update module, used to receive and parse the video source stream of the target video content source channel; determine whether the duration of the current slice of the video source stream meets a preset threshold; if so, use the absolute timestamp of the slice start time corresponding to the current slice as a keyword and insert it into the target channel index red-black tree and the target channel index linked list.
[0219] In one of the embodiments, the device also includes: a deletion module, which is used to perform a scheduled cleanup task for the target video content source channel at every preset time interval; the scheduled cleanup task is used to obtain a first difference between a first timestamp and a second timestamp; the first timestamp is an absolute timestamp of the slice start time corresponding to the first node in the target channel index red-black tree; the second timestamp is an absolute timestamp of the slice start time corresponding to the starting node in the target channel index linked list; the scheduled cleanup task is also used to delete the video slice file corresponding to the starting node when the first difference is greater than a preset protection time, and release the memory resources of the video slice information maintained by the starting node.
[0220] In one embodiment, the scheduled cleanup task is also used to obtain a second difference between the current timestamp and the first timestamp; the scheduled cleanup task is also used to delete the first node in the target channel index red-black tree when the second difference is greater than a preset maximum playback time.
[0221] Each module in the above-mentioned video slice management device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0222] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Fig.10 As shown. The computer device 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 computer device is used to provide computing and control capabilities. The memory of the computer device 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 computer device is used to store video slice file data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a video slice management method is implemented.
[0223] Those skilled in the art will understand that Fig.10The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0224] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0225] 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.
[0226] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0227] 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.
[0228] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods 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.
[0229] 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.
[0230] 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 video slice management method, characterized in that: The method comprises: Receive a video playback request sent by a client; the video playback request is used to request video content within a time range from a first time to a second time of a target video content source channel; In the target channel index red-black tree corresponding to the target video content source channel of the channel sharing index structure, querying a first index node matching the first time and a second index node matching the second time; the target channel index red-black tree includes index nodes corresponding to a plurality of video slice files originating from the target video content source channel respectively; each of the index nodes is inserted into the target channel index red-black tree using the timestamp information of the corresponding video slice file as a keyword; In the target channel index linked list corresponding to the target video content source channel of the channel shared index structure, the video slice files corresponding to each index node between the first index node and the second index node are traversed and obtained, and returned to the client; the target channel index linked list is used to indicate the time sequence of each index node in the target channel index red-black tree.
2. The method according to claim 1, characterized in that In the case where the video playback request is an HLS request, the traversing to obtain the video slice files corresponding to each index node between the first index node and the second index node, and returning the video slice files to the client, includes: Traversing and acquiring video slice information stored in each index node between the first index node and the second index node; Generate an m3u8 playlist file according to each of the video slice information; the m3u8 playlist file includes a slice download address of the video slice file corresponding to each index node between the first index node and the second index node; The m3u8 playlist file is sent to the client; the client is used to send a slice download request to the live broadcast server system based on the slice download address in the m3u8 playlist file; In response to the slice download request, the video slice files corresponding to each index node between the first index node and the second index node are sent to the client.
3. The method according to claim 1, characterized in that: In the case where the video playback request is an RTSP request, the traversing to obtain the video slice files corresponding to each index node between the first index node and the second index node, and returning the video slice files to the client, includes: Traverse and obtain video slice files corresponding to each index node between the first index node and the second index node; The traversed video slice files are returned to the client in chronological order.
4. The method according to claim 1, characterized in that: The timestamp information includes an absolute timestamp of a slice start time corresponding to the video slice file; the querying of a first index node matching the first time and a second index node matching the second time in a target channel index red-black tree corresponding to the target video content source channel in a channel sharing index structure includes: Create a first node pointer and a second node pointer; the first node pointer points to the root node of the target channel index red-black tree; the second node pointer is used to store the query result, and the query result is initially set to a null value; The target channel index red-black tree is traversed through the first node pointer loop, and for any time between the first time and the second time, it is determined whether the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to any time; According to the judgment result, the query result currently stored in the second node pointer is updated; the currently stored query result is used to determine the index node matching the any time.
5. The method according to claim 4, characterized in that The updating, according to the judgment result, of the query result currently stored in the second node pointer includes: When the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to any time, the index node currently pointed to by the first node pointer is used as the query result currently stored by the second node pointer, and the loop is terminated; the index node in the query result currently stored by the second node pointer is the index node matching any time.
6. The method according to claim 5, characterized in that The updating, according to the judgment result, of the query result currently stored in the second node pointer includes: When the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is less than any of the times, the index node currently pointed to by the first node pointer is used as the query result currently stored by the second node pointer, and the first node pointer is made to point to the right child node of the index node currently pointed to; When the judgment result indicates that the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is greater than any of the times, the first node pointer is set to point to the left child node of the index node currently pointed to; Return to the step of determining whether the absolute timestamp of the slice start time corresponding to the index node currently pointed to by the first node pointer is equal to any of the times, until they are equal or the next index node pointed to by the first node pointer is empty, and end the loop.
7. The method according to claim 1, characterized in that The method further comprises: Receive and parse the video source stream of the target video content source channel; Determine whether the duration of the current slice of the video source stream meets a preset threshold; If the conditions are met, the absolute timestamp of the slice start time corresponding to the current slice is used as a keyword and inserted into the target channel index red-black tree and the target channel index linked list.
8. The method according to claim 1, characterized in that The method further comprises: Performing a scheduled cleanup task on the target video content source channel at preset intervals; The scheduled cleaning task is used to obtain a first difference between a first timestamp and a second timestamp; the first timestamp is an absolute timestamp of the slice start time corresponding to the first node in the target channel index red-black tree; the second timestamp is an absolute timestamp of the slice start time corresponding to the start node in the target channel index linked list; The scheduled cleanup task is also used to delete the video slice file corresponding to the starting node and release the memory resources of the video slice information maintained by the starting node when the first difference is greater than a preset protection duration.
9. The method according to claim 8, characterized in that The scheduled cleanup task is also used to obtain a second difference between the current timestamp and the first timestamp; the scheduled cleanup task is also used to delete the first node in the target channel index red-black tree when the second difference is greater than a preset maximum playback time.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
Citation Information
Cited By
Video segment management method and apparatus, computer device, readable storage medium, and program product
WO2026118856A1