Live video downloading method and related device
By assigning substream rooms to P2P nodes and determining node roles, dynamically planning the download method of P2P nodes, the problem of taking into account both the download speed of live videos and the CDN bandwidth is solved, and efficient live video download and bandwidth saving is achieved.
Patent Information
- Application Number
- CN202411718188.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-02-11
AI Technical Summary
At this stage, it is difficult to take into account the download speed of live videos and the live broadcast bandwidth of CDNs, and it is difficult for the existing technology to effectively solve this problem.
By obtaining the substream configuration of the target live stream, the first substream room is allocated based on the substream configuration to be downloaded, and the node role is determined, the substream configuration is sent to the P2P node, so that it determines the video slice to be downloaded, and the video role is determined. The corresponding second sub-stream room responds to the scheduling request of the P2P node and recommends the best performance download method based on the node role.
It realizes that while ensuring the download speed of live videos, it reduces the live broadcast bandwidth consumption of CDN, maximizes the download speed of live videos and saves CDN bandwidth.
Smart Images

Figure CN119420956A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software technology, and in particular to a live video downloading method and related devices. Background Art
[0002] The rise of live video streaming has put immense pressure on the bandwidth required by CDNs (Content Delivery Networks). To save bandwidth costs, peer-to-peer (P2P) live streaming has emerged.
[0003] In P2P live streaming, end users primarily download live videos from other end users watching the same video, or from idle embedded devices in their homes (such as routers or computers). Alternatively, they can download directly from CDNs. However, balancing live video download speeds with CDN bandwidth remains a pressing issue. Summary of the Invention
[0004] In view of the above problems, this application provides a live video downloading method and related devices to achieve the purpose of taking into account both the download speed of live video and the live broadcast bandwidth of CDN. The specific solution is as follows:
[0005] A first aspect of the present application provides a live video downloading method, which is applied to a P2P scheduling server and includes:
[0006] Obtaining a substream configuration of a target live stream, where the substream configuration is used to describe a substream room corresponding to the target live stream;
[0007] Allocating a first substream room to a P2P node for downloading a video based on the substream configuration, and determining a node role of the P2P node in the first substream room;
[0008] Sending the substream configuration to the P2P node so that the P2P node determines a second substream room corresponding to a video slice to be downloaded, where the video slice is a logical slice divided by the CDN into the video file of the target live stream;
[0009] In response to the scheduling request for the second sub-stream room sent by the P2P node, recommend, based on the node role, a download method with optimal performance corresponding to the second sub-stream room to the P2P node, so that the P2P node downloads the video slices based on the download method and composes the video file.
[0010] In a possible implementation, allocating a first substream room to a P2P node for downloading a video based on the substream configuration includes:
[0011] Obtaining the total number of first P2P nodes in the sub-stream room;
[0012] A room with the smallest total number of first P2P nodes is selected from the sub-stream rooms as the first sub-stream room.
[0013] In a possible implementation, determining the node role of the P2P node in the first sub-stream room includes:
[0014] Obtaining the device type of the P2P node;
[0015] If the device type does not meet the preset seed node generation condition, the P2P node is used as a non-seed node in the first sub-stream room, and the download source corresponding to the non-seed node is other P2P nodes;
[0016] When the device type satisfies the seed node generation condition, the node ratio of seed nodes to non-seed nodes in the first sub-stream room is obtained; if the node ratio is less than a preset ratio threshold, the P2P node is used as the seed node in the first sub-stream room, and the download source corresponding to the seed node is the CDN; if the node ratio is equal to the ratio threshold, the P2P sharing performance value of the seed node in the first sub-stream room is calculated, and a seed node in the first sub-stream room whose P2P sharing performance value is less than the preset performance threshold is adjusted to a non-seed node, and the P2P node is used as the seed node in the first sub-stream room.
[0017] In a possible implementation, calculating the P2P sharing performance value of the seed node in the first sub-stream room includes:
[0018] Obtaining a P2P sharing index value of a seed node in the first sub-stream room;
[0019] A weighted calculation is performed on the P2P sharing index value to obtain a P2P sharing performance value of the seed node in the first sub-stream room.
[0020] In a possible implementation, the live video downloading method further includes:
[0021] Obtaining the total number of second P2P nodes under the target live stream and the total number of slices of the video slice;
[0022] Calculating a P2P sharing ratio corresponding to the target live stream according to the total number of the second P2P nodes, the substream configuration, the total number of slices, and the ratio threshold;
[0023] The ratio threshold is adjusted according to the P2P sharing ratio, and the magnitude of the P2P sharing ratio is negatively correlated with the adjustment direction of the ratio threshold.
[0024] A second aspect of the present application provides a live video downloading device, which is applied to a P2P scheduling server, and includes:
[0025] A configuration acquisition module, configured to acquire a substream configuration of a target live stream, wherein the substream configuration is used to describe a substream room corresponding to the target live stream;
[0026] a role determination module, configured to allocate a first substream room to a P2P node for downloading a video based on the substream configuration, and determine a node role of the P2P node in the first substream room;
[0027] a configuration sending module, configured to send the substream configuration to the P2P node, so that the P2P node determines a second substream room corresponding to a video slice to be downloaded, where the video slice is a logical slice divided by the CDN from the video file of the target live stream;
[0028] A scheduling response module is used to respond to the scheduling request for the second sub-stream room sent by the P2P node, and recommend the download method with the best performance corresponding to the second sub-stream room to the P2P node based on the node role, so that the P2P node downloads the video slices based on the download method and composes the video file.
[0029] A third aspect of the present application provides a P2P scheduling server, comprising at least one processor and a memory connected to the processor, wherein:
[0030] The memory is used to store computer programs;
[0031] The processor is used to execute the computer program so that the electronic device can implement the live video downloading method of the above-mentioned first aspect or any implementation method of the first aspect.
[0032] A fourth aspect of the present application provides a live video download system, which includes: a P2P node, a CDN, and the P2P scheduling server provided by the third aspect above.
[0033] In a fifth aspect, the present application provides a computer program product comprising computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the live video downloading method of the first aspect or any implementation of the first aspect.
[0034] The sixth aspect of the present application provides a computer storage medium, characterized in that the storage medium carries one or more computer programs, which, when executed by an electronic device, enable the electronic device to implement the live video downloading method of the above-mentioned first aspect or any implementation method of the first aspect.
[0035] By means of the above technical solution, a live video downloading method and related devices provided by the present application are applied to a P2P scheduling server to obtain the substream configuration of the target live stream, where the substream configuration is used to describe the substream room corresponding to the target live stream; based on the substream configuration, a first substream room is allocated to the P2P node of the video to be downloaded, and the node role of the P2P node in the first substream room is determined; the substream configuration is sent to the P2P node so that the P2P node determines the second substream room corresponding to the video slice to be downloaded, where the video slice is the logical slice divided by the CDN for the video file of the target live stream; in response to a scheduling request for the second substream room sent by the P2P node, the method recommends the download method with the best performance corresponding to the second substream room to the P2P node based on the node role, so that the P2P node downloads the video slice based on the download method and composes the video file. In this application, video files are logically sliced to ensure that video slices can be quickly transmitted in the P2P network. By configuring sub-stream rooms, the roles of P2P nodes can be dynamically and adaptively divided, so as to dynamically plan the download method with the best performance of P2P nodes and ensure that the download resources of all P2P nodes are as complementary as possible, thereby reducing the bandwidth consumption of CDN services. This can maximize the download speed of live video and save CDN live bandwidth. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.
[0037] Figure 1 A system architecture diagram of a live video downloading system provided in an embodiment of the present application;
[0038] Figure 2 A schematic diagram of the structure of a P2P scheduling server provided in an embodiment of the present application;
[0039] Figure 3 A flowchart of a live video downloading method provided in an embodiment of the present application;
[0040] Figure 4 A partial flow chart of a live video downloading method provided in an embodiment of the present application;
[0041] Figure 5 A schematic diagram of another portion of the flow chart of a live video downloading method provided in an embodiment of the present application;
[0042] Figure 6 A schematic diagram of another portion of the flow chart of a live video downloading method provided in an embodiment of the present application;
[0043] Figure 7 A schematic diagram of slicing a video file provided in an embodiment of the present application;
[0044] Figure 8 A schematic structural diagram of a live video downloading device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] The following describes the embodiments of the present application in conjunction with the accompanying drawings. The terms used in the implementation methods of the present application are only used to explain the specific embodiments of the present application and are not intended to limit the present application.
[0046] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0047] The terms "first", "second" etc. in the specification of the application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, and this is merely a way of distinguishing the objects of the same attributes when describing them in the embodiments of the application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0048] See also Figure 1 , Figure 1 This is a system architecture diagram of a live video download system provided in an embodiment of the present application. Figure 1 As shown, a live video downloading system provided by the embodiment of the present application includes: a P2P node 101, a CDN 102, and a P2P scheduling server 103. The P2P scheduling server 103 may include one or more servers ( Figure 1 (In the example, one server is included for explanation), the P2P scheduling server 103 can provide the live video downloading method provided in the embodiment of the present application for multiple P2P nodes 100.
[0049] It should be noted that, in actual applications, the P2P node can be a user terminal for watching live video, or a PCDN (P2P CDN, P2P content distribution network) device, wherein the PCDN device can be an idle router or computer of the user.
[0050] See also Figure 2 , Figure 2 This is a schematic diagram of the structure of a P2P scheduling server provided in an embodiment of the present application. Figure 2 As shown, a P2P scheduling server 103 provided in an embodiment of the present application includes: a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.
[0051] The bus 201 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 2 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0052] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0053] The memory 204 may include volatile memory, such as random access memory (RAM). The memory 204 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard drive (HDD), or solid state drive (SSD).
[0054] The memory 204 may be used to store software codes related to the live video downloading method, and the processor 202 may execute the steps of the live video downloading method of the chip, and may also schedule other units to implement corresponding functions.
[0055] It should be understood that the above-mentioned P2P scheduling server 103 can be a centralized or distributed device, and the processor 202 in the above-mentioned P2P scheduling server 103 can be a hardware circuit (application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor 202 can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0056] See also Figure 3 , Figure 3 This is a flow chart of a live video downloading method provided in an embodiment of the present application. Figure 3 As shown, a live video downloading method provided by an embodiment of the present application is applied to the P2P scheduling server 103 and may include steps S301 to S304. These steps are described in detail below.
[0057] S301: Obtain the substream configuration of the target live stream. The substream configuration is used to describe the substream room corresponding to the target live stream.
[0058] In the embodiment of the present application, the target live stream can be an HLS (HTTP Live Streaming) live stream to be downloaded. For the target live stream, the P2P scheduling server 103 can obtain its substream configuration, which is used to describe the substream rooms of the target live stream, that is, to divide the video content of the target live stream into different live rooms, so as to plan the video content downloaded by the P2P nodes in different live rooms.
[0059] For example, the target live stream is fixedly divided into N sub-streams, that is, the corresponding sub-stream rooms are N. Accordingly, the sub-stream configuration includes description information of the N sub-stream rooms, specifically including the total number N of sub-stream rooms and the serial number of each sub-stream room.
[0060] S302: Allocate a first substream room to the P2P node to download the video based on the substream configuration, and determine the node role of the P2P node in the first substream room.
[0061] In this embodiment of the present application, a P2P node newly entering the live broadcast room can be used as a P2P node for downloading videos, and a corresponding substream room, i.e., the first substream room, is assigned to it based on the substream configuration. It should be noted that a P2P node is only assigned one substream room under a live broadcast, and each substream room can contain multiple P2P nodes.
[0062] After the first sub-stream room is allocated to the P2P node, its node role in the first sub-stream room may be determined. The node role can indicate the download source of the P2P node.
[0063] In a possible implementation, to ensure a balanced number of nodes in different sub-stream rooms, the P2P node of the video to be downloaded can be assigned to the sub-stream room with the least number of nodes. Figure 4 , Figure 4 This is a partial flow chart of a live video downloading method provided in an embodiment of the present application. Figure 4 As shown, an embodiment of the present application provides a live video downloading method, wherein in step S302, "allocating a first sub-stream room to a P2P node for a video to be downloaded based on the sub-stream configuration" may include steps S401 to S402, and these steps are described in detail below.
[0064] S401: Obtain the total number of first P2P nodes in the sub-stream room.
[0065] In the embodiment of the present application, for each sub-stream room corresponding to the target live stream, the total number of P2P nodes located in the sub-stream room, that is, the total number of first P2P nodes, can be counted.
[0066] S402: Select a room with the smallest total number of first P2P nodes from the sub-stream rooms as the first sub-stream room.
[0067] In an embodiment of the present application, for different sub-stream rooms corresponding to the target live stream, the total number of their respective first P2P nodes is compared, so that the sub-stream room with the smallest total number of first P2P nodes is selected and allocated to the P2P node of the video to be downloaded, that is, as the first sub-stream room.
[0068] In a possible implementation, the P2P nodes in the sub-stream room can be divided into seed nodes and non-seed nodes. The download source of the seed node is the CDN, while the download source of the non-seed node is other P2P nodes. By setting the node ratio of seed nodes to non-seed nodes in the sub-stream room, the node role of the P2P node can be dynamically adjusted. Figure 5 , Figure 5 This is another part of the flow chart of a live video downloading method provided in an embodiment of the present application. Figure 5As shown, an embodiment of the present application provides a live video downloading method, wherein "determining the node role of the P2P node in the first sub-stream room" in step S302 may include steps S501 to S503, and these steps are described in detail below.
[0069] S501: Obtain the device type of the P2P node.
[0070] In the embodiment of the present application, the device type of the P2P node of the video to be downloaded is obtained to determine whether it is a NAT type with high bandwidth and container penetration, mainly including other NAT types except symmetric NAT.
[0071] S502: When the device type does not meet the preset seed node generation condition, the P2P node is used as a non-seed node in the first sub-stream room, and the download source corresponding to the non-seed node is other P2P nodes.
[0072] In an embodiment of the present application, if the P2P node of the video to be downloaded is not a NAT type with high bandwidth and container penetration, it is determined that it does not meet the seed node generation conditions, and the P2P node can be used as a non-seed node in the first sub-stream room. At this time, the download source of the P2P node is other P2P nodes.
[0073] S503: When the device type meets the seed node generation conditions, obtain the node ratio of seed nodes to non-seed nodes in the first sub-stream room; if the node ratio is less than a preset ratio threshold, use the P2P node as the seed node in the first sub-stream room, and the download source corresponding to the seed node is the CDN; if the node ratio is equal to the ratio threshold, calculate the P2P sharing performance value of the seed node in the first sub-stream room, and adjust a seed node in the first sub-stream room whose P2P sharing performance value is less than the preset performance threshold to a non-seed node, and use the P2P node as the seed node in the first sub-stream room.
[0074] In an embodiment of the present application, if the P2P node of the video to be downloaded is a NAT type with high bandwidth and container penetration, it is determined that it meets the seed node generation conditions, and then the node ratio of seed nodes to non-seed nodes in the current first sub-stream room is obtained.
[0075] If the node ratio is less than the preset ratio threshold, it means that the seed node in the first sub-stream room has not reached the limit. At this time, the P2P node is used as the seed node in the first sub-stream room. At this time, the download source of the P2P node is CDN.
[0076] If the node ratio is equal to the preset ratio threshold, it means that the seed nodes in the first sub-stream room have reached the limit. At this time, the P2P sharing performance values of various sub-nodes in the first sub-stream room can be calculated to determine the sharing performance of various sub-nodes in the first sub-stream room in the P2P network.
[0077] If there is a seed node in the first substream room whose P2P sharing performance value is less than a preset performance threshold, one of the seed nodes with the smallest P2P sharing performance value can be adjusted to a non-seed node, and the P2P node to be downloaded from the video is used as the seed node in the first substream room.
[0078] Of course, if there is no seed node in the first substream room whose P2P sharing performance value is less than the preset performance threshold, the P2P node of the video to be downloaded is regarded as a non-seed node in the first substream room.
[0079] In a possible implementation, the P2P sharing performance value can be calculated using the P2P sharing index. Figure 6 , Figure 6 This is another part of the flow chart of a live video downloading method provided in an embodiment of the present application. Figure 6 As shown, an embodiment of the present application provides a live video downloading method, wherein "calculating the P2P sharing performance value of the seed node in the first sub-stream room" in step S503 may include steps S601 to S602, and these steps are described in detail below.
[0080] S601: Obtain the P2P sharing index value of the seed node in the first sub-stream room.
[0081] In the embodiment of the present application, for each seed node in the first sub-stream room, the values of the seed node under different P2P sharing indicators, i.e., P2P sharing indicator values, can be obtained. Specifically, the P2P sharing indicators may include online time, total shared bandwidth, number of P2P connections, etc.
[0082] S602: Perform weighted calculation on the P2P sharing index value to obtain the P2P sharing performance value of the seed node in the first sub-flow room.
[0083] In the embodiment of the present application, for each seed node in the first sub-stream room, a weighted calculation may be performed on its P2P sharing index value to obtain its P2P sharing performance value in the first sub-stream room.
[0084] In one possible implementation, the seed node is a P2P node with good network, easy P2P penetration, and high performance. For the video slices in the sub-stream room to which the seed node belongs, the seed node will download them from the CDN on a fixed basis, and share the downloaded video slices with the P2P nodes in the sub-stream room and other sub-stream rooms of this route. The more seed nodes there are, the more bandwidth will be downloaded from the CDN. If there are too few seed nodes, the download bandwidth required by other non-seed nodes may not be supplied. Therefore, the ratio threshold corresponding to the seed node and the non-seed node needs to be continuously adjusted to save the live broadcast bandwidth to the greatest extent while ensuring the download speed. In this regard, a live video downloading method provided in an embodiment of the present application also includes the following steps:
[0085] Obtain the total number of second P2P nodes and the total number of slices of the video slice under the target live stream; calculate the P2P sharing ratio corresponding to the target live stream based on the total number of second P2P nodes, sub-stream configuration, total number of slices and ratio threshold; adjust the ratio threshold according to the P2P sharing ratio, and the size of the P2P sharing ratio is negatively correlated with the adjustment direction of the ratio threshold.
[0086] In an embodiment of the present application, the total number of P2P nodes under the target live stream (i.e., the total number of second P2P nodes), the total number of video slices into which all video files are divided, the total number of sub-stream rooms in the sub-stream configuration, and the ratio threshold of different sub-stream rooms can be counted.
[0087] Based on the total number of second P2P nodes, the total number of slices, the total number of rooms, and the ratio threshold, the P2P sharing ratio corresponding to the target live stream is calculated. Specifically, P2P sharing ratio = (total number of second P2P nodes × total number of slices - total number of second P2P nodes × total number of slices × ratio threshold / total number of rooms) / (total number of second P2P nodes × total number of slices).
[0088] After obtaining the P2P sharing rate corresponding to the target live stream, the ratio threshold can be adjusted according to the P2P sharing rate. Specifically, the size of the P2P sharing rate is negatively correlated with the adjustment direction of the ratio threshold, that is, the larger the P2P sharing rate, the greater the downward adjustment of the ratio threshold.
[0089] S303: Send the substream configuration to the P2P node, so that the P2P node determines the second substream room corresponding to the video slice to be downloaded. The video slice is a logical slice divided by the CDN for the video file of the target live stream.
[0090] In the embodiment of the present application, the substream configuration of the target live stream is sent to the P2P node of the video to be downloaded. For the P2P node to download the video, it obtains the substream configuration of the target live stream sent by the P2P scheduling server 103, and also obtains the slice configuration of the target video file sent by the CDN. The slice configuration is used to describe the video slices corresponding to the video file of the target live stream. The video slices are the logical slices into which the video file of the target live stream is divided by the CDN.
[0091] See also Figure 7 , Figure 7 A schematic diagram of a video file slice provided in an embodiment of the present application. Figure 7 As shown, the video file of the target live stream is a ts file. CDN can divide it into M video slices according to a fixed segmentation size. Of course, video slices are logical divisions of video files by CDN. Each video slice belongs to only one video file and will not cross video files. Moreover, for the last video slice in the video file, its size will be less than or equal to the fixed segmentation size.
[0092] It should be noted that the video file of the target live stream is composed of multiple consecutive video files. Each video file has a unique serial number in the target live stream, and the serial number of the first video slice in all video files starts from a fixed serial number (such as 0 or 1).
[0093] The P2P node downloading the video can determine the substream room corresponding to the video slice to be downloaded, i.e., the second substream room, based on the substream configuration of the target live stream. Specifically, the sequence number of the substream room to which the video slice belongs = (the sequence number of the video file in the target live stream + the sequence number of the video slice in the video file) % the total number of substream rooms, where % represents the remainder operation. This ensures that the number of P2P nodes and the number of video slices managed by each substream room are as uniform as possible.
[0094] S304: In response to the scheduling request for the second sub-stream room sent by the P2P node, recommend the download method with the best performance corresponding to the second sub-stream room to the P2P node based on the node role, so that the P2P node downloads the video slices based on the download method and composes the video file.
[0095] In the embodiment of the present application, after the P2P node of the video to be downloaded determines the second sub-stream room corresponding to the video slice to be downloaded, it can send a scheduling request for the second sub-stream room to the P2P scheduling server 103. In response to the scheduling request, the P2P scheduling server 103 determines whether the second sub-stream room includes the first sub-stream room.
[0096] If the second sub-stream room contains the first sub-stream room: for the first sub-stream room, the download method with the best performance corresponding to the first sub-stream room is recommended to the P2P node of the video to be downloaded based on the node role in the first sub-stream room. Specifically, if the node role is a seed node, the download method of the P2P node of the video to be downloaded is CDN; if the node role is a non-seed node, the download method of the P2P node of the video to be downloaded is the P2P node with the best performance other than the P2P node of the video to be downloaded in the first sub-stream room (which may be a seed node or a non-seed node); for other sub-stream rooms in the second sub-stream room except the first sub-stream room, the download method of the P2P node of the video to be downloaded is the P2P node with the best performance in the sub-stream room (which may be a seed node or a non-seed node).
[0097] If the second substream room does not include the first substream room, the P2P node to download the video will download the video from the P2P node with the best performance in the second substream room (which may be a seed node or a non-seed node).
[0098] It should be noted that the strategy of the P2P scheduling server 103 to determine the P2P node with the best performance in the sub-stream room can be determined according to the region, network, etc. of the P2P node, and this embodiment of the present application does not limit this.
[0099] After obtaining the optimal download method for the second sub-stream room, the P2P node to be downloaded can download the video slices from the second sub-stream room according to the download method to form a video file. Of course, when downloading the video slices corresponding to the second sub-stream room, the P2P node to be downloaded considers the download method recommended by the P2P scheduling server 103 on the one hand, and the buffer level on the other hand, to determine whether to download from other P2P nodes or from the CDN. If the P2P scheduling server 103 recommends downloading from other P2P nodes, and the buffer level on the local end is low, to ensure smooth video playback, the P2P node to be downloaded will download the video slices from the CDN.
[0100] Through the above description, the embodiment of the present application provides a live video downloading method, which ensures that the video slices can be quickly transmitted in the P2P network by logically slicing the video files. By configuring sub-stream rooms, the roles of P2P nodes can be dynamically and adaptively divided, thereby dynamically planning the download method with the best performance of P2P nodes, ensuring that the download resources of all P2P nodes are as complementary as possible, thereby reducing the bandwidth consumption of CDN services. This can maximize the download speed of live videos and save CDN live bandwidth.
[0101] The above describes a live video downloading method provided by an embodiment of the present application. The following describes an apparatus for executing the live video downloading method.
[0102] See also Figure 8 , Figure 8 This is a structural diagram of a live video downloading device provided in an embodiment of the present application. Figure 8 As shown, an embodiment of the present application provides a live video downloading device, comprising:
[0103] Configuration acquisition module 801, used to obtain the sub-stream configuration of the target live stream, where the sub-stream configuration is used to describe the sub-stream room corresponding to the target live stream;
[0104] a role determination module 802 for allocating a first substream room to a P2P node to download a video based on the substream configuration, and determining a node role of the P2P node in the first substream room;
[0105] Configuration sending module 803, configured to send the substream configuration to the P2P node, so that the P2P node determines the second substream room corresponding to the video slice to be downloaded. The video slice is a logical slice divided by the CDN into the video file of the target live stream;
[0106] The scheduling response module 804 is used to respond to the scheduling request for the second sub-stream room sent by the P2P node, and recommend the download method with the best performance corresponding to the second sub-stream room to the P2P node based on the node role, so that the P2P node downloads the video slices based on the download method and composes the video file.
[0107] In one possible implementation, the role determining module 802 for allocating a first substream room to a P2P node for downloading a video based on the substream configuration is specifically configured to:
[0108] The total number of first P2P nodes in the sub-stream room is obtained; and a room with the smallest total number of first P2P nodes is selected from the sub-stream rooms as the first sub-stream room.
[0109] In a possible implementation, the role determination module 802 for determining the node role of the P2P node in the first sub-stream room is specifically configured to:
[0110] Obtain the device type of the P2P node; if the device type does not meet the preset seed node generation conditions, use the P2P node as a non-seed node in the first sub-stream room, and the download source corresponding to the non-seed node is other P2P nodes; if the device type meets the seed node generation conditions, obtain the node ratio of seed nodes to non-seed nodes in the first sub-stream room; if the node ratio is less than a preset ratio threshold, use the P2P node as a seed node in the first sub-stream room, and the download source corresponding to the seed node is a CDN; if the node ratio is equal to the ratio threshold, calculate the P2P sharing performance value of the seed node in the first sub-stream room, and adjust a seed node in the first sub-stream room whose P2P sharing performance value is less than the preset performance threshold to a non-seed node, and use the P2P node as the seed node in the first sub-stream room.
[0111] In one possible implementation, the role determination module 802 for calculating the P2P sharing performance value of the seed node in the first sub-stream room is specifically configured to:
[0112] Obtain a P2P sharing index value of the seed node in the first sub-stream room; perform weighted calculation on the P2P sharing index value to obtain a P2P sharing performance value of the seed node in the first sub-stream room.
[0113] In a possible implementation, the role determination module 802 is further configured to:
[0114] Obtain the total number of second P2P nodes and the total number of slices of the video slice under the target live stream; calculate the P2P sharing ratio corresponding to the target live stream based on the total number of second P2P nodes, sub-stream configuration, total number of slices and ratio threshold; adjust the ratio threshold according to the P2P sharing ratio, and the size of the P2P sharing ratio is negatively correlated with the adjustment direction of the ratio threshold.
[0115] It should be noted that the detailed functions of each module in the embodiment of the present application can be found in the corresponding public part of the above-mentioned live video downloading method embodiment, and will not be repeated here.
[0116] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any live video downloading method provided in the embodiment of the present application.
[0117] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any live video downloading method provided in the embodiment of the present application.
[0118] It should also be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided in this application, the connection relationship between the modules indicates that there is a communication connection between them, which can be specifically implemented as one or more communication buses or signal lines.
[0119] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course can also be implemented by special hardware including application-specific integrated circuits, special CPUs, special memories, special components, etc. In general, all functions performed by computer programs can be easily implemented with corresponding hardware, and the specific hardware structures used to implement the same function can also be diverse, such as analog circuits, digital circuits or special circuits, etc. However, for the present application, software program implementation is a better implementation method in most cases. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a number of instructions to enable a computer device (which can be a personal computer, training equipment, or network equipment, etc.) to execute the methods described in each embodiment of the present application.
[0120] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0121] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, a computer, a training device or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website, a computer, a training device or a data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
Claims
1. A method for downloading live video, characterized in that: The live video downloading method is applied to a P2P scheduling server, and the live video downloading method comprises: Obtaining a substream configuration of a target live stream, where the substream configuration is used to describe a substream room corresponding to the target live stream; Allocating a first substream room to a P2P node for downloading a video based on the substream configuration, and determining a node role of the P2P node in the first substream room; Sending the substream configuration to the P2P node, so that the P2P node determines a second substream room corresponding to a video slice to be downloaded, where the video slice is a logical slice divided by the CDN for the video file of the target live stream; In response to the scheduling request for the second sub-stream room sent by the P2P node, recommend the download method with the best performance corresponding to the second sub-stream room to the P2P node based on the node role, so that the P2P node downloads the video slices based on the download method and composes the video file.
2. The live video downloading method according to claim 1, characterized in that: The allocating a first substream room to a P2P node for a video to be downloaded based on the substream configuration includes: Obtaining the total number of first P2P nodes in the sub-stream room; A room with the smallest total number of first P2P nodes is selected from the sub-stream rooms as the first sub-stream room.
3. The live video downloading method according to claim 1, characterized in that: The determining the node role of the P2P node in the first sub-stream room includes: Obtaining the device type of the P2P node; In the case that the device type does not meet the preset seed node generation condition, the P2P node is used as a non-seed node in the first sub-stream room, and the download source corresponding to the non-seed node is other P2P nodes; In the case where the device type meets the seed node generation condition, the node ratio of seed nodes to non-seed nodes in the first sub-stream room is obtained; if the node ratio is less than a preset ratio threshold, the P2P node is used as the seed node in the first sub-stream room, and the download source corresponding to the seed node is the CDN; if the node ratio is equal to the ratio threshold, the P2P sharing performance value of the seed node in the first sub-stream room is calculated, and a seed node in the first sub-stream room whose P2P sharing performance value is less than the preset performance threshold is adjusted to a non-seed node, and the P2P node is used as the seed node in the first sub-stream room.
4. The method for downloading live video according to claim 3, characterized in that: The calculating the P2P sharing performance value of the seed node in the first sub-stream room includes: Obtaining a P2P sharing index value of a seed node in the first sub-stream room; The P2P sharing index value is weightedly calculated to obtain the P2P sharing performance value of the seed node in the first sub-stream room.
5. The live video downloading method according to claim 3, characterized in that: The live video downloading method further includes: Obtaining the total number of second P2P nodes under the target live stream and the total number of slices of the video slice; Calculate the P2P sharing rate corresponding to the target live stream according to the total number of the second P2P nodes, the substream configuration, the total number of slices and the ratio threshold; The ratio threshold is adjusted according to the P2P sharing ratio, and the magnitude of the P2P sharing ratio is negatively correlated with the adjustment direction of the ratio threshold.
6. A live video downloading device, characterized in that: The live video downloading device is applied to a P2P scheduling server, and the live video downloading device comprises: A configuration acquisition module, used to acquire a substream configuration of a target live stream, wherein the substream configuration is used to describe a substream room corresponding to the target live stream; a role determination module, configured to allocate a first substream room to a P2P node for downloading a video based on the substream configuration, and determine a node role of the P2P node in the first substream room; A configuration sending module is used to send the substream configuration to the P2P node, so that the P2P node determines the second substream room corresponding to the video slice to be downloaded, where the video slice is a logical slice divided by the CDN for the video file of the target live stream; A scheduling response module is used to respond to the scheduling request for the second sub-stream room sent by the P2P node, and recommend the download method with the best performance corresponding to the second sub-stream room to the P2P node based on the node role, so that the P2P node downloads the video slices based on the download method and composes the video file.
7. A P2P scheduling server, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the live video downloading method as described in any one of claims 1 to 5.
8. A live video downloading system, characterized in that: The live video downloading system comprises: a P2P node, a CDN, and the P2P scheduling server as described in claim 7.
9. A computer program product, characterized in that It includes computer-readable instructions, and when the computer-readable instructions are executed on an electronic device, the electronic device implements the live video downloading method as described in any one of claims 1 to 5.
10. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the live video downloading method as described in any one of claims 1 to 5.