Live video stream playing method and device, storage medium and electronic equipment
By segmenting the live video stream and matching the playback method with the network status, the problem of high live broadcast latency is solved and the interactive effect of live broadcast is improved. In particular, in the case of network fluctuations, it can quickly adapt to the network status and reduce latency.
Patent Information
- Application Number
- CN202410245722.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-04
- Publication Date
- 2025-09-05
AI Technical Summary
In existing live broadcast solutions, due to fluctuations in the network environment and limitations of the push protocol, the playback delay of live video streams is high, resulting in poor interactive effects.
By fragmenting the live video stream, multiple video fragments sorted by playback time are obtained, and the receiving end flexibly switches to obtain the matching live video stream according to the network status, and skips the first N-1 video fragments for playback to reduce latency.
It significantly reduces the delay between the live broadcast end and the audience end, improves the effect of live broadcast interaction, and can quickly adapt to the network status and improve the quality of live broadcast, especially in the case of network fluctuations.
Smart Images

Figure CN120602737A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a method and device for playing a live video stream, a storage medium, and an electronic device. Background Art
[0002] With the development of Internet technology, user groups are participating in live broadcast interactions on live broadcast-related platforms more and more frequently.
[0003] During live broadcasts, the host often needs to interact with the audience. High latency can lead to poor interaction. Existing live broadcast solutions are prone to high latency issues due to network fluctuations and limitations of push protocols.
[0004] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention
[0005] Embodiments of the present invention provide a method and apparatus for playing a live video stream, a storage medium, and an electronic device, to at least solve the technical problem of high playback delay of a live video stream in the related field.
[0006] According to one aspect of an embodiment of the present invention, a method for playing a live video stream is provided, comprising: in response to a video playback request, obtaining a first fragment sequence matching a first video segment, wherein the first video segment is a video segment in the live video stream, and the first fragment sequence includes M video segments obtained by performing a fragmentation operation on the first video segment and sorted according to the playback time, wherein M is an integer greater than 1; taking the Nth video segment in the first fragment sequence as the first video segment, and playing the first video segment based on the first video segment and the video segments located after the first video segment in the first fragment sequence. A live video stream, wherein N is an integer greater than 1 and less than M; determining a second video segment from a second segment sequence that matches the second video segment, and playing the live video stream based on the second video segment and the video segment following the second video segment in the second segment sequence after the video segment in the first segment sequence has been played, wherein the second video segment is a video segment following the first video segment in the live video stream, and the second segment sequence includes M video segments obtained by segmenting the second video segment and sorted by playback time.
[0007] According to another aspect of an embodiment of the present invention, a device for playing a live video stream is further provided, comprising: an acquisition unit for acquiring, in response to a video playback request, a first fragment sequence matching a first video segment, wherein the first video segment is a video segment in a live video stream, and the first fragment sequence comprises M video segments obtained by performing a fragmentation operation on the first video segment and sorted according to the playback time, wherein M is an integer greater than 1; a first playback unit for taking the Nth video segment in the first fragment sequence as the first video segment, and based on the first video segment, and the video segment located after the first video segment in the first fragment sequence Play the above-mentioned live video stream, wherein the above-mentioned N is an integer greater than 1 and less than the above-mentioned M; a second playback unit is used to determine the second video fragment from the second fragment sequence matching the second video segment, and when the above-mentioned video fragment in the above-mentioned first fragment sequence is played, play the above-mentioned live video stream according to the above-mentioned second video fragment and the above-mentioned video fragment located after the above-mentioned second video fragment in the above-mentioned second fragment sequence, wherein the above-mentioned second video segment is the video segment located after the above-mentioned first video segment in the above-mentioned live video stream, and the above-mentioned second fragment sequence includes M video fragments obtained by fragmenting the above-mentioned second video segment and sorted by playback time.
[0008] Optionally, the playback device of the above-mentioned live video stream also includes: an acquisition module, used to obtain a fragment sequence file matching the above-mentioned second fragment sequence, wherein the above-mentioned fragment sequence file includes a fragment link of each of the above-mentioned video fragments in the above-mentioned second fragment sequence; according to multiple fragment links respectively used to indicate the above-mentioned second video fragment and the above-mentioned video fragment located after the above-mentioned second video fragment in the above-mentioned second fragment sequence, the above-mentioned second video fragment and the above-mentioned video fragment located after the above-mentioned second video fragment in the above-mentioned second fragment sequence are sequentially acquired.
[0009] Optionally, the acquisition module is used to: determine the link type of the current fragment link corresponding to the current video fragment to be acquired, wherein the link type includes a fragmented type and a pre-fragmented type, the video fragment indicated by the fragment link of the fragmented type is in a fragmentation completed state at the target time, and the video fragment indicated by the fragment link of the pre-fragmented type is in a fragmentation uncompleted state at the target time, and the target time is the time indicated by the generation timestamp of the fragment sequence file; in the case that the link type of the current fragment link is the fragmented type, the current video fragment is acquired according to the current fragment link; in the case that the link type of the current fragment link is the pre-fragmented type and it is confirmed that the current video fragment is in the fragmentation completed state, the current video fragment is acquired according to the current fragment link.
[0010] Optionally, the above-mentioned acquisition module is used to: obtain the remaining cache space of the cache queue, wherein the queue tail of the above-mentioned cache queue is used to store the video data obtained by decapsulating the above-mentioned video fragments, and the queue head of the above-mentioned cache queue is used to take out the above-mentioned video data for decoding and playback; when the above-mentioned remaining cache space is greater than or equal to the target data amount, obtain the current video data obtained by decapsulating the current video fragment, and according to the above-mentioned remaining cache space, add the target video data in the above-mentioned current video data to the above-mentioned cache queue.
[0011] Optionally, the above-mentioned acquisition module is also used to: obtain the first duration corresponding to the above-mentioned video segment, wherein the above-mentioned first duration is the duration of the video segment corresponding to the above-mentioned video segment; obtain the second duration corresponding to the above-mentioned video segment, wherein the above-mentioned second duration is the duration required to obtain the above-mentioned video segment; determine the target duration based on the above-mentioned first duration and the above-mentioned second duration; determine the space size of the above-mentioned cache queue based on the data volume of the above-mentioned video data matching the above-mentioned target duration.
[0012] Optionally, the second playback unit is configured to: when the current live broadcast delay is greater than or equal to a target threshold, use the Lth video fragment in the second fragment sequence as the second video fragment, wherein L is an integer greater than 1 and less than M; and when the current live broadcast delay is less than a target threshold, use the first video fragment in the second fragment sequence as the second video fragment.
[0013] Optionally, the above-mentioned first playback unit is also used to: obtain a target bandwidth parameter, wherein the above-mentioned target bandwidth parameter is used to estimate the transmission rate corresponding to the current terminal when obtaining the above-mentioned video fragment; when the above-mentioned target bandwidth parameter does not match the video resolution corresponding to the current video fragment, determine the target resolution according to the above-mentioned target bandwidth parameter; obtain a target fragment sequence file that matches the target resolution, wherein the above-mentioned target fragment sequence file includes a fragment link of each of the above-mentioned video fragments in the third fragment sequence, the third video segment corresponding to the above-mentioned third fragment sequence matches the above-mentioned second video segment corresponding to the above-mentioned second fragment sequence, and the video resolution of the above-mentioned third video segment corresponding to the above-mentioned third fragment sequence is the above-mentioned target resolution; obtain the next above-mentioned video fragment according to the above-mentioned fragment link in the above-mentioned target fragment sequence file.
[0014] Optionally, the above-mentioned first playback unit is used to: obtain the bandwidth measurement parameter corresponding to the current video fragment, wherein the bandwidth measurement parameter is used to instruct the above-mentioned current terminal to obtain the above-mentioned transmission rate corresponding to the current video fragment; use the previous above-mentioned target bandwidth parameter as a reference bandwidth parameter, wherein the previous above-mentioned target bandwidth parameter is the previous bandwidth estimation result of the above-mentioned current terminal; determine the above-mentioned target bandwidth parameter based on the above-mentioned bandwidth measurement parameter and the above-mentioned reference bandwidth parameter.
[0015] Optionally, the first playback unit is further configured to: determine that the target bandwidth parameter does not match the video resolution corresponding to the current video fragment when the reference resolution corresponding to the target bandwidth parameter is smaller than the video resolution; and determine that the target bandwidth parameter does not match the video resolution corresponding to the current video fragment when the reference resolution corresponding to the target bandwidth parameter is greater than or equal to the video resolution, and the reference resolution corresponding to the previous target bandwidth parameter is greater than or equal to the video resolution.
[0016] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the above-mentioned method for playing a live video stream when running.
[0017] According to another aspect of the embodiments of the present application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the above-described method for playing a live video stream.
[0018] According to another aspect of an embodiment of the present invention, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the live video stream playback method through the computer program.
[0019] In an embodiment of the present invention, in response to a video playback request, a first fragment sequence matching a first video segment is obtained, wherein the first video segment is a video segment in a live video stream, and the first fragment sequence includes M video segments obtained by performing a fragmentation operation on the first video segment and sorted by playback time, where M is an integer greater than 1; the Nth video segment in the first fragment sequence is used as the first video segment, and the live video stream is played based on the first video segment and the video segments located after the first video segment in the first fragment sequence, where N is an integer greater than 1 and less than M. integer; determining a second video segment from a second segment sequence that matches the second video segment, and, when the video segment in the first segment sequence is played, playing the live video stream according to the second video segment and the video segment following the second video segment in the second segment sequence, wherein the second video segment is a video segment following the first video segment in the live video stream, and the second segment sequence includes M video segments obtained by performing a segmentation operation on the second video segment and sorted by playback time, thereby realizing playback of the live video stream through the segment sequence.
[0020] In the above-mentioned method for playing live video streams, multiple video fragments are obtained after fragmenting the live video stream, rather than directly receiving the complete live video stream. Therefore, when the network at the receiving end fluctuates, the live video stream matching the network status can be obtained flexibly and quickly according to the network status switch. In addition, in the above-mentioned embodiment, when a video playback request is received, N video fragments can be selected as the starting fragments in the fragment sequence obtained for the first time for playback, that is, the first N-1 video fragments are skipped for playback, which can significantly reduce the delay between the live end and the audience end, and solve the technical problem of high playback delay of live video streams in related technologies. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0022] Figure 1 is a schematic diagram of a hardware environment for an optional method for playing a live video stream according to an embodiment of the present invention;
[0023] Figure 2 is a flowchart of an optional method for playing a live video stream according to an embodiment of the present invention;
[0024] Figure 3is a schematic diagram of an optional method for playing a live video stream according to an embodiment of the present invention;
[0025] Figure 4 is a schematic diagram of another optional method for playing a live video stream according to an embodiment of the present invention;
[0026] Figure 5 is a schematic diagram of another optional method for playing a live video stream according to an embodiment of the present invention;
[0027] Figure 6 is a schematic diagram of another optional method for playing a live video stream according to an embodiment of the present invention;
[0028] Figure 7 is a schematic diagram of another optional method for playing a live video stream according to an embodiment of the present invention;
[0029] Figure 8 is a schematic diagram of an optional fragment sequence file according to an embodiment of the present invention;
[0030] Figure 9 is a schematic diagram of another optional method for playing a live video stream according to an embodiment of the present invention;
[0031] Figure 10 is a schematic diagram of another optional method for playing a live video stream according to an embodiment of the present invention;
[0032] Figure 11 is a schematic diagram of another optional method for playing a live video stream according to an embodiment of the present invention;
[0033] Figure 12 is a flowchart of another optional method for playing a live video stream according to an embodiment of the present invention;
[0034] Figure 13 A schematic structural diagram of an optional device for playing a live video stream according to an embodiment of the present invention;
[0035] Figure 14 FIG. 4 is a schematic structural diagram of an optional electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0036] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0037] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention 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 numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0038] It should be noted that the relevant information and data involved in the relevant implementation methods of this application are all pre-acquired through methods specified in relevant normative legal documents, and before obtaining the above-mentioned relevant information and data, it is necessary to obtain authorization from the corresponding account subject.
[0039] According to one aspect of an embodiment of the present invention, a method for playing a live video stream is provided. As an optional implementation, the method for playing a live video stream can be applied to, but is not limited to, Figure 1 The live video streaming playback system shown in FIG. 1 is composed of a terminal device 102, a server 104, a terminal device 106 and a network 110. Figure 1 As shown, terminal device 102 and terminal device 106 are connected and communicate with server 104 via network 110. The aforementioned network may include, but is not limited to, wired networks and wireless networks. Wired networks include local area networks, metropolitan area networks, and wide area networks, and wireless networks include Bluetooth, Wi-Fi, and other networks that enable wireless communication. The aforementioned terminal devices may include, but are not limited to, at least one of the following: mobile phones (such as Android phones, iOS phones, etc.), laptops, tablets, PDAs, MIDs (Mobile Internet Devices), PADs, desktop computers, smart TVs, and in-vehicle devices. The aforementioned terminal device 102 may be installed with a live broadcast client for providing live interactive operations between target accounts, and the aforementioned terminal device 106 may be installed with a host client for providing live interactive operations between target accounts. It is understood that terminal device 106 is used to collect live data streams and upload them to server 104. After being processed by server 104, the live data streams can be forwarded to multiple terminal devices 102 for playback of the live video streams.
[0040] The terminal device 102 and the terminal device 106 are also provided with a display, a processor and a memory. The display can be used to display the program interface of the client, and the processor can process and convert the operation information generated by the object operation based on the client; the memory is used to store the operation information generated by the object account in historical operations.
[0041] The server 104 may be a single server, a server cluster consisting of multiple servers, or a cloud server. The server includes a database and a processing engine. The processing engine is used to collect, segment, transcode, repackage, and distribute the live video stream obtained during the live broadcast operation.
[0042] According to one aspect of an embodiment of the present invention, the live video stream playback system may further perform the following steps: first, the terminal device 102 performs step S102 to detect a playback request, wherein the playback request is for playing a live video stream generated by the anchor account; then performs step S104 to send a video segment acquisition request to the server 104 via the network 110;
[0043] Next, in the server 104, steps S106 to S110 are executed to slice the acquired live data; a slice sequence file is sent according to the slice processing result; and then, the slice sequence file is sent to the terminal device 102 via the network 110;
[0044] Then, steps S112-S116 are executed in the terminal device 102 to obtain a first fragment sequence matching the first video segment, wherein the first video segment is a video segment in a live video stream, and the first fragment sequence includes M video segments obtained by fragmenting the first video segment and sorted by playback time, where M is an integer greater than 1; the Nth video segment in the first fragment sequence is used as the first video segment, and the live video stream is played based on the first video segment and the video segments following the first video segment in the first fragment sequence, wherein N is an integer greater than 1 and less than M; the second video segment is determined from the second fragment sequence matching the second video segment, and when the video segments in the first fragment sequence are played, the live video stream is played based on the second video segment and the video segments following the second video segment in the second fragment sequence, wherein the second video segment is a video segment in the live video stream following the first video segment, and the second fragment sequence includes M video segments obtained by fragmenting the second video segment and sorted by playback time.
[0045] In the above embodiment of the present invention, in response to a video playback request, a first fragment sequence matching the first video segment is obtained, wherein the first video segment is a video segment in a live video stream, and the first fragment sequence includes M video segments obtained by performing a fragmentation operation on the first video segment and sorted by playback time, and the above M is an integer greater than 1; the Nth video segment in the above first fragment sequence is used as the first video segment, and the live video stream is played based on the first video segment and the video segments located after the first video segment in the above first fragment sequence, wherein the above N is an integer greater than 1 and less than the above An integer of M; determining a second video fragment from a second fragment sequence that matches the second video segment, and playing the live video stream according to the second video fragment and the video fragment following the second video fragment in the second fragment sequence after the video fragment in the first fragment sequence is completed, wherein the second video fragment is a video fragment following the first video fragment in the live video stream, and the second fragment sequence includes M video fragments obtained by fragmenting the second video fragment and sorted according to the playback time, thereby realizing the playback of the live video stream through the fragment sequence.
[0046] In the above-mentioned method for playing live video streams, multiple video fragments are obtained after fragmenting the live video stream, rather than directly receiving the complete live video stream. Therefore, when the network at the receiving end fluctuates, the live video stream matching the network status can be obtained flexibly and quickly according to the network status switch. In addition, in the above-mentioned embodiment, when a video playback request is received, N video fragments can be selected as the starting fragments in the fragment sequence obtained for the first time for playback, that is, the first N-1 video fragments are skipped for playback, which can significantly reduce the delay between the live end and the audience end, and solve the technical problem of high playback delay of live video streams in related technologies.
[0047] The above is only an example and is not limited in this embodiment.
[0048] As an optional implementation, Figure 2 As shown, the above-mentioned method for playing the live video stream may include the following steps:
[0049] S202: In response to a video playback request, obtain a first fragment sequence matching a first video segment, wherein the first video segment is a video segment in a live video stream, and the first fragment sequence includes M video segments obtained by fragmenting the first video segment and ordered by playback time, where M is an integer greater than 1.
[0050] S204: Use the Nth video segment in the first segment sequence as a first video segment, and play the live video stream based on the first video segment and the video segments following the first video segment in the first segment sequence, where N is an integer greater than 1 and less than M.
[0051] S206, determining a second video segment from a second segment sequence that matches the second video segment, and when the video segments in the first segment sequence are played, playing the live video stream according to the second video segment and the video segment that follows the second video segment in the second segment sequence, wherein the second video segment is a video segment that follows the first video segment in the live video stream, and the second segment sequence includes M video segments obtained by performing a segmentation operation on the second video segment and sorted by playback time.
[0052] It should be noted that the above embodiments of the present application can be applied to Figure 3 The live interactive system shown in FIG3 is located at the viewer terminal 304. Specifically, the live interactive system may include a host terminal 301, a cloud server 302, a streaming server 303, and a viewer terminal 304. Furthermore, the host terminal is used to log in to the host account, collect live data streams, and perform local data operations to obtain live data encoded streams. Subsequently, the cloud server 302 receives the live data encoded streams uploaded by the host terminal 301 and performs operations such as decoding and transcoding. Then, the live data encoding stream is transpacked through the streaming server 303, for example, the live data encoding stream in flv format is transpacked into a live data encoding stream in mp4 format; optionally, the live data encoding stream can be segmented during the transpackaging process, that is, the live data encoding stream is divided into multiple video segments of equal length; then, when the audience end 304 initiates a request for the live video of the anchor end 301, the video segments can be obtained from the streaming server 303, and the depackaging and decoding operations are performed in sequence, and then the rendering and playback of the live video stream is realized in the audience end 304.
[0053] Optionally, the specific interactive content involved in the live interactive system may include, but is not limited to, live interactive performances, live interactive promotions, and live interactive games. In the case where the live interactive type involved in the live interactive system is a game, the host end and the audience end may be a live client or a game application client that can provide live interactive access to game content. This embodiment does not limit the specific live interactive content involved in the live interactive system.
[0054] In the above step S202, the above first video segment can be used to indicate the first video segment obtained in response to the video playback request detected by the current terminal. It can be understood that in the interactive scenario of live video, the audience end usually needs to obtain and display the latest live video stream, and does not need to obtain or display the live video stream before the current live request. For example, when the time when the anchor end starts the live broadcast is 19:00, and the time when the audience end initiates the live video playback request is 20:00, the requested video segment usually does not include the live video between 19:00 and 20:00, but directly requests the live video stream with 20:00 as the starting point. In the above embodiment, the above first video segment can be a video segment with 20:00 as the starting point.
[0055] Correspondingly, the first video segment can be obtained by a segmentation operation to obtain a first segment sequence. Figure 4 As shown in FIG, assuming that the length of the first video segment is 25 seconds, five video segments each having a length of less than 5 seconds can be obtained through the segmentation operation.
[0056] It should be noted that, obtaining the first fragment sequence matching the first video clip in the above step S202 may include two obtaining methods. In the first obtaining method, the M video fragments in the first fragment sequence may be directly obtained from the server; in the other obtaining method, a fragment sequence file indicating the first fragment sequence may be obtained first. The above fragment sequence file may include the fragment identifiers of the above M video fragments, and may also include fragment link addresses indicating the above M video fragments.
[0057] Furthermore, in the above step S204, the Nth video segment can be determined from the above first segment sequence as the first video segment, and the first video segment is used as the starting video segment to be played on the current terminal to start playing the live video stream.
[0058] In one optional manner, when the above-mentioned M video fragments are obtained, the Nth video fragment can be directly played as the first video fragment; in another optional embodiment, when a fragment sequence file indicating the above-mentioned first fragment sequence is obtained, the Nth video fragment can be directly requested based on the fragment link address in the above-mentioned fragment sequence file, and the Nth video fragment can be played as the first video fragment.
[0059] The following combination Figure 5The above-mentioned playback method is further explained. Assume that the host end generates the first video segment at 19:00:00, and the length of the first video segment is 25 seconds; after the server performs a segmentation operation on the first video segment, the first segment sequence is obtained, and the length of each video segment is 5 seconds. For the audience end, the delay of the obtained first video segment includes the push delay and the segmentation delay of the server. Assuming that the sum of the above-mentioned push delay and the segmentation delay of the server is 2 seconds, it can be determined that the earliest time for the audience end to obtain the above-mentioned first video segment is 19:00:27. It can be seen that if the playback starts from the first video segment in the regular playback order, the delay of the live stream is specifically 27 seconds; if Figure 5 As shown in this embodiment, by directly skipping the first two video segments and starting playback directly from the third video segment, the live broadcast delay can be significantly reduced to 17 seconds. Since the changes in the live broadcast image are usually not significant in live broadcast scenarios, skipping some of the starting video segments has little impact on the live broadcast effect and can significantly reduce the live broadcast delay.
[0060] In a preferred embodiment, the live broadcast delay can be reduced by increasing the fragmentation density in the server, that is, shortening the fragmentation time. Figure 6 As shown, when the segment length is further shortened from 5s to 2s, and the first video segment to be played is determined to be the third video segment, it is assumed that the host end generates the first video segment at 19:00:00, and the length of the first video segment is 10s; after the server segments the first video segment, the first segment sequence is obtained, and each video segment is 2s long. For the audience end, the delay of the obtained first video segment includes the push delay and the segment delay of the server. Assuming that the sum of the above push delay and the segment delay of the server is 2s, it can be determined that the earliest time for the audience end to obtain the above first video segment is 19:00:12. It can be seen that if the playback starts from the first video segment in the regular playback order, the delay of the live stream is specifically 12s, as shown in FIG. Figure 6 As shown, in this embodiment, by directly skipping the first two video segments and starting to play directly from the third video segment, the live broadcast delay can be further significantly reduced to 8s.
[0061] Through the above-mentioned implementation of the present application, when a video playback request is received, N video segments can be selected as the starting segments for playback in the segment sequence obtained for the first time, that is, the first N-1 video segments are skipped for playback. This can significantly reduce the delay between the live broadcast end and the audience end, and solve the technical problem of high playback delay of live video streams in related technologies.
[0062] In the case where the live video is specifically generated in a gaming scenario, the live video may specifically include the host's screen captured by the host's terminal and the game screen captured by the game server, or the game screen obtained by recording the host's terminal. It is understood that in a gaming live broadcast scenario, the virtual operations performed by the host by controlling the virtual character in the game and the host's reactions in the real screen must match. Otherwise, if network fluctuations cause delays in screen matching, the live broadcast effect in the gaming business scenario will be seriously affected.
[0063] Through the above-mentioned implementation mode of the present application, when a game live video stream is obtained, the game live video stream can be segmented to obtain game video segments; on the audience side, when the game video segment sequence is obtained for the first time, the first N-1 segments are skipped for playback, thereby significantly reducing the live broadcast delay in the game live broadcast scenario; in addition, since in the game live broadcast scenario, the network bandwidth can be detected for each game video segment, and the game live video resolution that matches the current bandwidth can be quickly determined based on the detection result, when the network on the audience side fluctuates, the live video stream that matches the network status can be flexibly and quickly switched according to the network status, thereby improving the live broadcast quality in the game live broadcast scenario.
[0064] Furthermore, in the above step S206, when the video segments in the first segment sequence are played, the second segment sequence may be received and the video segments in the second video sequence may be played, thereby achieving continuous playback of the live video stream.
[0065] It can be understood that in this embodiment, the live video stream can be continuously segmented for the continuously generated video fragments on the server side, and the operation results of each segmentation operation are sent to the current terminal. When the current terminal continuously receives the video fragments returned by the server, it plays the live video stream by continuously playing the video fragments.
[0066] It should be noted that the first video segment and the second video segment may be two adjacent video segments. For example, if the timestamps corresponding to the first video segment are 19:00:00-19:00:10, the timestamps corresponding to the second video segment may be 19:00:10-19:00:20. In another optional embodiment, there may be an overlapping time period between the first video segment and the second video segment. For example, if the timestamps corresponding to the first video segment are 19:00:00-19:00:10, the timestamps corresponding to the second video segment may be 19:00:06-19:00:16. In this embodiment, the specific relationship between the first video segment and the second video segment is not limited.
[0067] Furthermore, before playing the video segments in the second segment sequence corresponding to the second video clip, it is necessary to first determine the second video segment to be played, and then use the second video segment as the first video segment to be played in the second segment sequence, and then continue to play subsequent video segments.
[0068] In an optional implementation, the second video segment may be determined from the second segment sequence according to the live broadcast delay detected in real time:
[0069] When the current live broadcast delay is greater than or equal to the target threshold, the Lth video segment in the second segment sequence is used as the second video segment, where L is an integer greater than 1 and less than M;
[0070] When the current live broadcast delay is less than the target threshold, the first video segment in the second segment sequence is used as the second video segment.
[0071] It is understood that in this embodiment, when the current live broadcast delay is obtained, it can be determined whether to skip the first L-1 video segments in the second segment sequence and play them according to the live broadcast delay status. If the current live broadcast delay is less than the target threshold, the video segments in the second segment sequence can be played sequentially.
[0072] It should be noted that the above-mentioned live broadcast delay can be determined based on the difference between the first timestamp of the live video data played at the viewer end and the second timestamp generated by the above-mentioned live video data at the anchor end.
[0073] In the above-mentioned embodiment of the present application, the current live broadcast delay can be detected in real time before switching between playback of every two fragment sequences, and then, based on the delay status, it is determined whether to skip several video fragments for playback during the playback of the next fragment sequence to reduce the live broadcast delay.
[0074] In an optional embodiment, when the current live broadcast delay is greater than or equal to the target threshold, before using the Lth video segment in the second segment sequence as the second video segment, the second segment features of each video segment in the second segment sequence can be obtained respectively, and compared with the first segment features of the last video segment in the above-mentioned first segment sequence, and the video segment with the highest similarity indicated by the comparison result is determined as the second video segment in the above-mentioned second segment sequence. The above-mentioned segment feature extraction method may include but is not limited to the principal component analysis algorithm, the linear discriminant analysis algorithm, the directional gradient histogram algorithm, etc. In this embodiment, the specific method of extracting the above-mentioned video segment features is not limited.
[0075] Through the above-mentioned implementation mode of the present application, the video segment can be skipped for playback while the video segment closest to the last played video segment is determined as the second video segment to be played, thereby reducing the sense of video fragmentation caused by skipping playback and improving the playback effect of the live video stream.
[0076] In another optional implementation, the second video segment to be played may be determined based on the number of pre-segments included in the segment sequence.
[0077] In this embodiment, each fragment sequence information received by the current terminal may include the same number of pre-fragment information, wherein each pre-fragment information is used to indicate a link address of a video fragment that has not yet been fragmented.
[0078] For example Figure 7 As shown, in the process of the server segmenting the live streaming data of the anchor end, the 6s live streaming data can be segmented first to obtain video segments with serial numbers 1, 2, and 3 in the first segment sequence. Then, in response to the live video request of the current terminal, the server can send 5 segmentation information (for example, the link address of the video segment) to the current terminal, which are used to indicate 1, 2, 3, 4, and 5 respectively, among which segments 4 and 5 are the serial numbers of the video segments that have not yet been segmented, and their corresponding segmentation information (pre-assigned link address) is the pre-segmentation information. Furthermore, while the terminal is downloading video segments according to segment information No. 1, 2, and 3, the server can continue to perform segmentation operations on video segments No. 4 and 5. When the terminal obtains three video segments in sequence according to segment information No. 1, 2, and 3, the server's segmentation operations on video segments No. 4 and 5 have also been completed. The server can then continue to respond to the terminal's segmentation information based on segment information No. 4 and 5 and send video segments No. 4 and 5 to the terminal, thereby utilizing the transmission gaps of the video segments to asynchronously execute segmentation operations on the server, shortening the operation time of the server's video segmentation operations and further reducing the live broadcast delay.
[0079] Furthermore, in the second fragmentation sequence, fragmentation information of fragments 4, 5, and 6, which have completed the fragmentation operation, can be sent to the terminal, and pre-fragmentation information of fragments 7 and 8 can be sent to the terminal. Since the terminal has completed the acquisition operation of fragments 4 and 5 using the pre-fragmentation information in the first fragmentation sequence, fragment 6, that is, the third fragment in the second fragmentation sequence, can be determined as the second video fragment in the second fragmentation sequence.
[0080] In an optional embodiment, before playing the live video stream based on the second video segment and the video segments following the second video segment in the second segment sequence, the method further includes:
[0081] S1, obtaining a fragment sequence file matching the second fragment sequence, wherein the fragment sequence file includes a fragment link of each video fragment in the second fragment sequence;
[0082] S2. According to a plurality of segment links respectively used to indicate the second video segment and the video segment following the second video segment in the second segment sequence, sequentially obtain the second video segment and the video segment following the second video segment in the second segment sequence.
[0083] It is understandable that, in this embodiment, the fragment information corresponding to each video segment can be obtained through the above-mentioned fragment sequence file. Figure 8 As shown, the above-mentioned fragment sequence file may include but is not limited to the file number of the current fragment sequence file (used to indicate the corresponding video segment), and may also include the fragment sequence number, fragment duration and link address of each video fragment.
[0084] Furthermore, in the case that the fragment sequence file includes pre-fragmentation fragment information, the link address in the pre-fragmentation fragment information is used to indicate the link address pre-allocated for the pre-fragmentation.
[0085] In an optional embodiment, the step of sequentially acquiring the second video segment and the video segment following the second video segment in the second segment sequence according to the plurality of segment links respectively indicating the second video segment and the video segment following the second video segment in the second segment sequence includes:
[0086] S1, determining the link type of the current fragment link corresponding to the current video fragment to be obtained, wherein the link type includes a fragmented type and a pre-fragmented type. The video fragment indicated by the fragmented type fragment link is in a fragmentation-completed state at a target time, and the video fragment indicated by the pre-fragmented type fragment link is in a fragmentation-incomplete state at a target time, where the target time is the time indicated by the generation timestamp of the fragment sequence file;
[0087] S2-1, when the link type of the current segment link is a segmented type, obtain the current video segment according to the current segment link;
[0088] S2-2: When the link type of the current segment link is a pre-segment type and it is confirmed that the current video segment is in a segmentation complete state, the current video segment is obtained according to the current segment link.
[0089] Furthermore, in the above embodiment, based on Figure 8 In the process of obtaining video segments in sequence according to the link addresses in the segment sequence file shown, if it is determined that the video segment to be obtained is a video segment that has been completed, the corresponding video segment can be directly requested from the server based on the above link address; if it is determined that the video segment to be obtained is a pre-segmented segment, it is necessary to further confirm whether the segment has completed the segmentation operation in the server. If it is confirmed that it has been completed, the corresponding video segment is requested from the server based on the above link address.
[0090] It should be noted that the terminal can confirm that the current video segment is in the segmentation completed state in the following two ways:
[0091] In the first mode, the terminal directly initiates a request based on the link address, and when receiving a fragmented video response, determines that the current video fragment is in a fragmentation-completed state; when not receiving a fragmented video response, determines that the current video fragment is not in a fragmentation-completed state;
[0092] In another embodiment, the server may send a fragmentation completion confirmation message to the terminal when the fragmentation operation of the pre-fragmentation is completed. When the terminal receives the fragmentation completion confirmation message, it determines that the current video fragment is in a fragmentation completion state.
[0093] The following combination Figure 7The above implementation is further explained. Assuming that in the first fragmentation method, the server completes the fragmentation of each video segment before sending it to the terminal, then for the first video segment with a timestamp corresponding to 19:00:00-19:00:10, assuming that the operation time of the fragmentation operation is 1s for each video segment, then the first video segment of 19:00:00-19:00:10 is obtained into 5 fragments through the fragmentation operation, and the fragmentation information is sent to the terminal through the fragmentation sequence file at the earliest 19:00:15; and through the above implementation of the present application, the last two fragments can be determined as pre-fragments, that is, a storage location is reserved for them and a corresponding link address is generated, and only after completing the fragmentation operation of 3 fragments, the fragmentation sequence file including the above fragmentation information can be sent to the terminal. In other words, through the above implementation, the terminal can obtain the fragmentation sequence file at the earliest 19:00:13, thereby reducing the live broadcast delay caused by the fragmentation operation on the server side.
[0094] In an optional embodiment, playing the live video stream according to the second video segment and the video segments following the second video segment in the second segment sequence includes:
[0095] S1, obtaining the remaining cache space of the cache queue, wherein the tail of the cache queue is used to store the video data obtained by decapsulating the video fragments, and the head of the cache queue is used to retrieve the video data for decoding and playback;
[0096] S2: When the remaining cache space is greater than or equal to the target data amount, the current video data obtained by decapsulating the current video segment is obtained, and the target video data in the current video data is added to the cache queue according to the remaining cache space.
[0097] In this embodiment, after the terminal obtains the video fragments based on the above-mentioned fragment sequence file, the video fragments can be decapsulated and the video data obtained by the encapsulation process can be added to the tail of the cache queue; and at the head of the cache queue, the operation of asynchronously taking out the decapsulated video data for decoding, rendering and playback is executed.
[0098] In this embodiment, before adding the decapsulated video data to the cache queue, the size of the remaining cache space of the cache queue may be determined, and the amount of video data to be added may be determined based on the remaining space.
[0099] It is understandable that in this embodiment, the asynchronous reading and adding operations performed at both ends of the above-mentioned cache queue can be used to alleviate the stuck situation of terminal playback caused by network fluctuations. Since a certain amount of data (i.e., a certain duration) of video data can be cached in the cache space, normal playback of a certain duration can be ensured when the video fragments sent by the server are not obtained in time. For example, assuming that the cache queue can cache 3s of video data, then starting from the current moment, even if there is a 3s duration that fails to normally obtain the fragment data of the next video fragment, the terminal can still play normally based on the 3s video data in the cache queue, thereby avoiding the stuck phenomenon of the terminal being unable to play the live video for 3s.
[0100] In an optional implementation, before obtaining the remaining cache space of the cache queue, the method further includes:
[0101] S1, obtaining a first duration corresponding to the video segment, wherein the first duration is the duration of the video segment corresponding to the video segment;
[0102] S2, obtaining a second duration corresponding to the video segment, wherein the second duration is the duration required to obtain the video segment;
[0103] S3, determining a target duration based on the first duration and the second duration;
[0104] S4, determining the space size of the cache queue according to the data volume of the video data matching the target duration.
[0105] It can be understood that in this embodiment, the space size of the cache queue can be pre-configured. Specifically, the target duration can be determined based on the video duration corresponding to a video segment and the acquisition duration of a video segment by the terminal, and the data volume of the video data of the target duration can be determined as the queue size of the above-mentioned cache queue.
[0106] For example, assuming that the video duration of a video segment is 2 seconds and the terminal takes 1 second to obtain a video segment, the queue size of the cache queue may be specifically the storage space corresponding to 3 seconds of video data.
[0107] It should be noted that the second duration can be determined based on the average acquisition duration of video segments within a period, and then a fixed target duration is determined based on the first duration, and then a fixed-size cache queue can be pre-configured;
[0108] In another optional embodiment, when it is detected that the current terminal network environment fluctuates significantly, the second duration can be determined based on the average acquisition duration of the video segments in the previous segment sequence, and the corresponding target duration can be determined in real time based on the network environment, thereby dynamically configuring the size of the cache queue. For example, in the case of a poor network environment (e.g., low bandwidth and high latency), a relatively large cache queue can be configured to ensure smooth playback of live video and solve the problem of live video playback being stuck.
[0109] In an optional embodiment, the method of determining the second video segment from the second segment sequence that matches the second video clip, and playing the live video stream based on the second video segment and the video segments following the second video segment in the second segment sequence when the video segments in the first segment sequence are played, further includes:
[0110] S1, obtaining a target bandwidth parameter, wherein the target bandwidth parameter is used to estimate the corresponding transmission rate when the current terminal obtains the video fragment;
[0111] S2, when the target bandwidth parameter does not match the video resolution corresponding to the current video segment, determining the target resolution according to the target bandwidth parameter;
[0112] S3, obtaining a target slice sequence file that matches the target resolution, wherein the target slice sequence file includes a slice link for each video slice in the third slice sequence, a third video segment corresponding to the third slice sequence matches the second video segment corresponding to the second slice sequence, and a video resolution of the third video segment corresponding to the third slice sequence is the target resolution;
[0113] S4, obtain the next video segment according to the segment link in the target segment sequence file.
[0114] It is understood that in this embodiment, the target bandwidth parameter corresponding to each video segment can be used to determine whether the resolution of the current video segment matches the current terminal bandwidth. In the event that the bandwidth does not match the resolution of the live video stream, the playback resolution can be quickly switched.
[0115] Specifically, when the bandwidth does not match the resolution of the live video stream, a third segment sequence that matches the target resolution can be obtained, and then the live video stream can be played back according to the video segments in the third segment sequence.
[0116] In this embodiment, since the terminal does not obtain a complete video stream, but multiple video fragments obtained by fragmenting the video stream, the current bandwidth parameters can be accurately detected based on each video fragment, and the video fragment of the corresponding resolution can be obtained according to the detection result, thereby realizing flexible switching of the live video resolution.
[0117] The following combination Figure 9 The above-mentioned embodiment is described. Figure 9 As shown, assuming that the current network bandwidth is detected as the first parameter based on the first fragment 1.ts in the second fragment sequence, and the resolution corresponding to the first parameter is 720P, which does not match the 1080P of the current second fragment sequence, then the second fragment 2.ts in the third fragment sequence can be obtained as the next video fragment to be played; and the current network bandwidth is detected as the second parameter based on the second fragment 2.ts, and the resolution corresponding to the second parameter is 480P, which does not match the 720P of the current third fragment sequence, then the third fragment 3.ts in the fourth fragment sequence can be obtained as the next video fragment to be played;
[0118] When the network condition improves, Figure 9 As shown, the resolution of the next video segment to be played can be adjusted by further using the bandwidth parameter detected in real time.
[0119] It should be noted that Figure 9 The switching method shown is only an illustrative method. In a specific method, it usually takes a certain amount of time to obtain the segment sequence files corresponding to the segment sequences of different resolutions. Therefore, the process of switching video segments of different resolutions can also be implemented as follows:
[0120] Assume that the current network bandwidth is detected as the first parameter based on the first fragment 1.ts in the second fragment sequence, and the resolution corresponding to the first parameter is 720P, which does not match the 1080P of the current second fragment sequence. Then, the fragment sequence file for indicating the third fragment sequence can be obtained first (assuming it takes 1s), and the third fragment 3.ts is requested based on the fragment sequence file for indicating the third fragment sequence. In the process of requesting the third fragment 3.ts, the second fragment 2.ts in the cached second fragment sequence can be continued as the next video fragment to be played. When the third fragment 3.ts in the third fragment sequence is obtained, the third fragment 3.ts in the third fragment sequence is played.
[0121] Through the above-mentioned implementation mode of the present application, since multiple video fragments are obtained after fragmenting the live video stream instead of directly receiving the complete live video stream, it is possible to flexibly and quickly switch to obtain a live video stream that matches the network status when the network at the receiving end fluctuates.
[0122] In an optional implementation manner, the obtaining of the target bandwidth parameter includes:
[0123] S1, obtaining a bandwidth measurement parameter corresponding to the current video segment, wherein the bandwidth measurement parameter is used to instruct the current terminal to obtain a transmission rate corresponding to the current video segment;
[0124] S2: Using the previous target bandwidth parameter as a reference bandwidth parameter, where the previous target bandwidth parameter is the previous bandwidth estimation result of the current terminal;
[0125] S3: Determine a target bandwidth parameter according to the bandwidth measurement parameter and the reference bandwidth parameter.
[0126] In this embodiment, since the bandwidth parameter measured in real time may fluctuate greatly, if only the bandwidth parameter measured in real time is used as the target bandwidth parameter, it may cause the fragment sequence files of different resolutions to be read too frequently, resulting in low data transmission efficiency.
[0127] In this embodiment, the bandwidth measurement parameters of each measurement need to be smoothed with the reference bandwidth parameters estimated last time to obtain the current estimation result, and then the target bandwidth parameters are determined based on the current estimation result. Figure 10 As shown, for each downloaded video segment, the operations of "calculating network speed - smoothing network speed - obtaining predicted value - switching resolution" can be performed in sequence. The smoothing process may include, but is not limited to, weighted averaging, linear interpolation, etc. In this embodiment, the specific implementation method of the smoothing process is not limited.
[0128] Specifically, the current bandwidth measurement can be calculated based on the data size and download time of the downloaded TS segments. The bandwidth prediction value is then smoothed based on the previous prediction result and the current network speed. The corresponding resolution can then be switched. Specifically, the corresponding method can be: 1080P video stream corresponds to a bit rate of 4000-6000kbps (i.e., the target bandwidth parameter), 720P corresponds to a bit rate of 2000-4000bps, 480p corresponds to a bit rate of 1000-2000bps, and 360p corresponds to a bit rate of 600bps.
[0129] The following combination Figure 11 The method of obtaining the above bandwidth measurement parameters is described below. Figure 11As shown, different bandwidth measurement methods can be used in different situations. Specifically, it can be divided into whether the current video segment to be obtained has completed segmentation. If the video segment has been generated, regardless of whether the bandwidth is sufficient, the bandwidth measurement parameters are calculated in the form of Size / Time; if the current segment to be obtained is being generated (i.e., pre-segmentation, and no segmentation completion indication is received from the server), if the bandwidth is insufficient, the timeout of the live video is obtained. If the timeout is serious (for example, greater than the first threshold), it is calculated based on the previous video segment and still uses Size / Time. If the timeout is slight, the sliding maximum window method is used to obtain the bandwidth measurement parameters. When using the above-mentioned sliding maximum window method, it is necessary to select a suitable window size and sliding distance based on conditions such as download delay and bit rate, continuously slide the window, calculate the bandwidth value within the window, and take the maximum bandwidth value as the bandwidth measurement result.
[0130] In an optional implementation, when the target bandwidth parameter does not match the video resolution corresponding to the current video segment, before determining the target resolution according to the target bandwidth parameter, the method further includes:
[0131] Method 1: When the reference resolution corresponding to the target bandwidth parameter is smaller than the video resolution, determining that the target bandwidth parameter does not match the video resolution corresponding to the current video segment;
[0132] Method 2: When the reference resolution corresponding to the target bandwidth parameter is greater than or equal to the video resolution and the reference resolution corresponding to the previous target bandwidth parameter is greater than or equal to the video resolution, it is determined that the target bandwidth parameter does not match the video resolution corresponding to the current video segment.
[0133] It is understandable that in this embodiment, the above two different situations can be used to determine whether the bandwidth matching conditions are met, and the bandwidth can be adjusted accordingly, thereby improving the playback quality of the live video stream.
[0134] Specifically, when playback begins, the starting bitrate is the lowest resolution corresponding to the lowest bitrate. The bitrate upgrade logic is that each time a bitrate change is detected based on a video segment, if a bitrate upgrade is required, it will wait for at least N = 2 segment speed measurements to complete. That is, if the bandwidth bitrate of two consecutive video segments is increased, then the corresponding video segment with the increased resolution will be rendered and played.
[0135] The logic of reducing the bitrate is that every time a change in the bandwidth bitrate is detected, and if the bandwidth is detected to be reduced, the bitrate is directly reduced without waiting and the corresponding video fragments with reduced resolution are rendered and played;
[0136] Through the above-mentioned implementation of the present application, it can be ensured to the greatest extent that users can watch relatively clear pictures while reducing picture freezes.
[0137] The following is a complete description of an implementation of the present application in combination with 12.
[0138] Specifically, on the audience side used for live video streaming playback, in response to the current account entering the live broadcast room on the whitelist, the resolution of the current live broadcast room is adjusted to the auto gear by default; if the current audience side has not logged in to the target account, a login prompt can be given after the live video has been played for a period of time, and the live broadcast room resolution can be adjusted to the auto gear after the target account logs in; after determining that the current live broadcast room has selected the auto gear, the web side can first pull the m3u8 information, and then parse the corresponding ts segment information and download and play it. The specific implementation steps are as follows: Figure 12 As shown:
[0139] S1202, requesting and loading a playlist file;
[0140] S1204, parsing the playlist file;
[0141] It should be noted that the operations of S1202 and S1204 can be specifically implemented through event functions such as MANIFEST_LOADING (list file download instruction), MANIFEST_LOADED (list file confirmed to have been downloaded), and MANIFEST_PARSED (list file confirmed to have been parsed) executed on the viewer end. The above playlist file can be specifically a playlist.m3u8 file, which is used to indicate different link addresses corresponding to video segments of different resolutions.
[0142] Then execute S1206 to start the main process of shard stream loading;
[0143] It should be noted that the above step S1206 may further include two parallel steps S1206-1, loading the m3u8 file of a specific bit rate, and S1206-3, starting the video stream timer;
[0144] It should be noted that the above m3u8 file is a specific fragment sequence file, which includes the link addresses of multiple sequentially sorted fragmented video fragments and the link addresses of pre-fragmented video fragments;
[0145] In S1206-1, a bit rate is selected based on the bandwidth, and the m3u8 file of the corresponding bit rate is loaded and parsed. Assuming that the video resolution corresponding to the current bit rate is 1080p, 1080p.m3u8 can be obtained to obtain 1080p video fragments. Specifically, the different download states of the m3u8 file can be indicated by the LEVEL_LOADING (m3u8 downloading) and LEVEL_LOADED (m3u8 downloaded) events.
[0146] S1206-2, update the specific bitrate ts file list according to the loading result;
[0147] It is understandable that when the m3u8 file can be obtained through the above steps, the fragment sequence number and link address corresponding to each of the video fragments included in the current fragment sequence can be determined;
[0148] Next, based on the updated specific bitrate ts file list and the video stream timer, step S1208 is executed, status polling;
[0149] Then execute S1210, cache management, ts shard selection;
[0150] Specifically, when the m3u8 file indicating the first fragment sequence is obtained for the first time, based on the fragment link address in the m3u8 file, the Nth video fragment is directly requested, and the Nth video fragment is played as the first video fragment;
[0151] When the m3u8 file of the fragment sequence is not obtained for the first time, the first video fragment to be played can be determined from the fragment sequence according to the live broadcast delay detected in real time; the first video fragment to be played can also be determined according to the number of pre-fragments included in the fragment sequence.
[0152] In the process of playing based on the cache queue, asynchronous reading and adding operations are performed at both ends of the cache queue to alleviate the jamming of terminal playback caused by network fluctuations. Since a certain amount of video data (i.e., a certain duration) can be cached in the cache space, normal playback for a certain duration can be ensured even if the video segments sent by the server are not obtained in time. For example, assuming that the cache queue can cache 3s of video data, then starting from the current moment, even if there is a 3s duration in which the segment data of the next video segment cannot be obtained normally, the terminal can still play normally based on the 3s video data in the cache queue, thereby avoiding the jamming phenomenon of the terminal being unable to play the live video for 3s.
[0153] Then, S1212 is executed according to the video data in the cache queue to load the ts segment;
[0154] After executing the above S1212, the bit rate adaptation methods S1214-1 to S1214-3 can be asynchronously executed, and S1216-1 can play the video according to the segmented stream.
[0155] The bit rate adaptation method specifically includes: S1214-1, running the bit rate adaptation strategy; S1214-2, sampling and estimating the network bandwidth; S1214-3, determining the bit rate to be switched; and then returning to step S1206-2.
[0156] In this embodiment, the bandwidth measurement parameters of each measurement need to be smoothed with the reference bandwidth parameters estimated last time to obtain the current estimation result, and then the target bandwidth parameters are determined based on the current estimation result. Figure 10 As shown, for each downloaded video segment, the operations of "calculating network speed - smoothing network speed - obtaining predicted value - switching resolution" can be performed in sequence. When the playback just starts, the starting bit rate is to start playing from the lowest resolution corresponding to the lowest bit rate. The logic of increasing the bit rate is that each time a bit rate change is detected based on the video segment, if the bit rate needs to be increased, wait for at least N = 2 segments to complete the speed test, that is, when the bandwidth bit rate is increased for two consecutive video segments, the corresponding video segment with the increased resolution is rendered and played; the logic of reducing the bit rate is that each time a bandwidth bit rate change is detected and the bandwidth is reduced, there is no need to wait, and the bit rate is directly reduced and the corresponding video segment with the reduced resolution is rendered and played.
[0157] Furthermore, an effectiveness evaluation method can be deployed on the server side. Specifically, this can be achieved by using technical reporting of account operations on the web to detect the effectiveness of live streaming. The evaluation criteria used are average bitrate and average number of freezes per hour. The effectiveness of the above method deployed on the terminal is determined based on the average bitrate of the live streaming and the average number of freezes per hour. Furthermore, based on the effectiveness of the deployment, parameters or methods such as the number of segments skipped in the segment sequence, the segment length of each video segment, the queue size of the cache queue, and the bandwidth measurement method can be dynamically adjusted.
[0158] Furthermore, in the above live broadcast client, video segments can be obtained based on the HLS (HTTP Live Streaming) protocol.
[0159] Through the above-mentioned implementation mode of the present application, multiple video fragments are obtained after fragmentation processing of the live video stream, rather than directly receiving the complete live video stream. Therefore, when the network at the receiving end fluctuates, the live video stream matching the network status can be obtained flexibly and quickly according to the network status switch; in addition, in the above-mentioned implementation mode, when a video playback request is received, N video fragments can be selected as the starting fragments in the fragment sequence obtained for the first time for playback, that is, the method of skipping the first N-1 video fragments for playback is adopted, which can significantly reduce the delay between the live end and the audience end, and solve the technical problem of high playback delay of the live video stream in the related technology.
[0160] In addition, through real-time bandwidth measurement and prediction, the playback bit rate can be dynamically adjusted, thereby improving the user's average bit rate. Users can watch the clearest picture supported by the current network speed in their environment; reduce the freeze rate during viewing. In the live broadcast scene of AUTO gear, live broadcast TS segments of different clarity can be automatically switched. Due to the small segment granularity, the user account is not aware of it, which improves the live broadcast effect.
[0161] It should be noted that for the aforementioned method embodiments, for simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should be aware that the present invention is not limited by the order of the actions described, because according to the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0162] According to another aspect of the embodiment of the present invention, a device for playing live video streams for implementing the above-mentioned method for playing live video streams is also provided. Figure 13 As shown, the device includes:
[0163] An acquiring unit 1302 is configured to acquire, in response to a video playback request, a first fragment sequence matching a first video segment, wherein the first video segment is a video segment in a live video stream, and the first fragment sequence includes M video segments obtained by fragmenting the first video segment and ordered by playback time, where M is an integer greater than 1;
[0164] The first playback unit 1304 is configured to use the Nth video fragment in the first fragment sequence as a first video fragment, and to play the live video stream based on the first video fragment and the video fragments following the first video fragment in the first fragment sequence, where N is an integer greater than 1 and less than M.
[0165] The second playback unit 1306 is used to determine the second video segment from the second segment sequence matching the second video segment, and play the live video stream according to the second video segment and the video segment after the second video segment in the second segment sequence after the video segment in the first segment sequence has been played, wherein the second video segment is the video segment after the first video segment in the live video stream, and the second segment sequence includes M video segments obtained by the segmentation operation on the second video segment and sorted according to the playback time.
[0166] Optionally, the playback device of the above-mentioned live video stream also includes: an acquisition module, used to obtain a fragment sequence file matching the above-mentioned second fragment sequence, wherein the above-mentioned fragment sequence file includes a fragment link of each of the above-mentioned video fragments in the above-mentioned second fragment sequence; according to multiple fragment links respectively used to indicate the above-mentioned second video fragment and the above-mentioned video fragment located after the above-mentioned second video fragment in the above-mentioned second fragment sequence, the above-mentioned second video fragment and the above-mentioned video fragment located after the above-mentioned second video fragment in the above-mentioned second fragment sequence are sequentially acquired.
[0167] Optionally, the acquisition module is used to: determine the link type of the current fragment link corresponding to the current video fragment to be acquired, wherein the link type includes a fragmented type and a pre-fragmented type, the video fragment indicated by the fragment link of the fragmented type is in a fragmentation completed state at the target time, and the video fragment indicated by the fragment link of the pre-fragmented type is in a fragmentation uncompleted state at the target time, and the target time is the time indicated by the generation timestamp of the fragment sequence file; in the case that the link type of the current fragment link is the fragmented type, the current video fragment is acquired according to the current fragment link; in the case that the link type of the current fragment link is the pre-fragmented type and it is confirmed that the current video fragment is in the fragmentation completed state, the current video fragment is acquired according to the current fragment link.
[0168] Optionally, the above-mentioned acquisition module is used to: obtain the remaining cache space of the cache queue, wherein the queue tail of the above-mentioned cache queue is used to store the video data obtained by decapsulating the above-mentioned video fragments, and the queue head of the above-mentioned cache queue is used to take out the above-mentioned video data for decoding and playback; when the above-mentioned remaining cache space is greater than or equal to the target data amount, obtain the current video data obtained by decapsulating the current video fragment, and according to the above-mentioned remaining cache space, add the target video data in the above-mentioned current video data to the above-mentioned cache queue.
[0169] Optionally, the above-mentioned acquisition module is also used to: obtain the first duration corresponding to the above-mentioned video segment, wherein the above-mentioned first duration is the duration of the video segment corresponding to the above-mentioned video segment; obtain the second duration corresponding to the above-mentioned video segment, wherein the above-mentioned second duration is the duration required to obtain the above-mentioned video segment; determine the target duration based on the above-mentioned first duration and the above-mentioned second duration; determine the space size of the above-mentioned cache queue based on the data volume of the above-mentioned video data matching the above-mentioned target duration.
[0170] Optionally, the second playback unit 1306 is configured to: when the current live broadcast delay is greater than or equal to a target threshold, use the Lth video fragment in the second fragment sequence as the second video fragment, where L is an integer greater than 1 and less than M; and when the current live broadcast delay is less than a target threshold, use the first video fragment in the second fragment sequence as the second video fragment.
[0171] Optionally, the first playback unit 1304 is further used to: obtain a target bandwidth parameter, wherein the target bandwidth parameter is used to estimate the transmission rate corresponding to the current terminal when obtaining the video fragment; when the target bandwidth parameter does not match the video resolution corresponding to the current video fragment, determine the target resolution according to the target bandwidth parameter; obtain a target fragment sequence file that matches the target resolution, wherein the target fragment sequence file includes a fragment link of each of the video fragments in the third fragment sequence, the third video segment corresponding to the third fragment sequence matches the second video segment corresponding to the second fragment sequence, and the video resolution of the third video segment corresponding to the third fragment sequence is the target resolution; obtain the next video fragment according to the fragment link in the target fragment sequence file.
[0172] Optionally, the first playback unit 1304 is configured to: obtain a bandwidth measurement parameter corresponding to the current video segment, wherein the bandwidth measurement parameter is used to instruct the current terminal to obtain the transmission rate corresponding to the current video segment; use the previous target bandwidth parameter as a reference bandwidth parameter, wherein the previous target bandwidth parameter is the previous bandwidth estimation result of the current terminal; and determine the target bandwidth parameter based on the bandwidth measurement parameter and the reference bandwidth parameter.
[0173] Optionally, the first playback unit 1304 is further configured to: determine that the target bandwidth parameter does not match the video resolution corresponding to the current video fragment when the reference resolution corresponding to the target bandwidth parameter is smaller than the video resolution; and determine that the target bandwidth parameter does not match the video resolution corresponding to the current video fragment when the reference resolution corresponding to the target bandwidth parameter is greater than or equal to the video resolution, and the reference resolution corresponding to the previous target bandwidth parameter is greater than or equal to the video resolution.
[0174] Optionally, in this embodiment, the embodiments to be implemented by the above-mentioned various unit modules can refer to the above-mentioned various method embodiments, which will not be repeated here.
[0175] According to another aspect of the embodiment of the present invention, an electronic device for implementing the above-mentioned live video stream playback method is also provided. The electronic device may be Figure 14 The terminal device or server shown in FIG. This embodiment is described by taking the electronic device as a terminal device as an example. Figure 14 As shown, the electronic device includes a memory 1402 and a processor 1404. The memory 1402 stores a computer program, and the processor 1404 is configured to execute the steps in any of the above method embodiments through the computer program.
[0176] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0177] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:
[0178] S1. In response to a video playback request, obtain a first fragment sequence matching a first video segment, wherein the first video segment is a video segment in a live video stream, and the first fragment sequence includes M video segments obtained by fragmenting the first video segment and ordered by playback time, where M is an integer greater than 1.
[0179] S2: Use the Nth video segment in the first segment sequence as a first video segment, and play the live video stream based on the first video segment and the video segments following the first video segment in the first segment sequence, where N is an integer greater than 1 and less than M.
[0180] S3, determining the second video segment from the second segment sequence that matches the second video segment, and when the video segment in the first segment sequence is played, playing the live video stream according to the second video segment and the video segment after the second video segment in the second segment sequence, wherein the second video segment is the video segment after the first video segment in the live video stream, and the second segment sequence includes M video segments obtained by the segmentation operation on the second video segment and sorted by the playback time.
[0181] Alternatively, those skilled in the art will appreciate that Figure 14 The structure shown is for illustration only, and the electronic device may also be a vehicle-mounted terminal, a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, or other terminal devices. Figure 14 It does not limit the structure of the above electronic device. For example, the electronic device may also include Figure 14 More or fewer components (such as network interfaces, etc.) as shown in, or with Figure 14 Different configurations shown.
[0182] Among them, the memory 1402 can be used to store software programs and modules, such as the program instructions / modules corresponding to the method and device for playing live video streams in the embodiments of the present invention. The processor 1404 executes various functional applications and data processing by running the software programs and modules stored in the memory 1402, that is, realizing the above-mentioned method for playing live video streams. The memory 1402 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1402 may further include a memory remotely located relative to the processor 1404, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 1402 can be used specifically, but not limited to, to store file information such as target logical files. As an example, such as Figure 14 As shown, the memory 1402 may include, but is not limited to, the acquisition unit 1302, the first playback unit 1304, and the second playback unit 1306 in the live video stream playback device. In addition, it may also include, but is not limited to, other module units in the live video stream playback device, which will not be repeated in this example.
[0183] Optionally, the transmission device 1406 is configured to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one embodiment, the transmission device 1406 includes a network interface controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In one embodiment, the transmission device 1406 is a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0184] In addition, the electronic device further includes: a display 1408 and a connection bus 1410 for connecting various module components in the electronic device.
[0185] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting multiple nodes through network communication. The nodes may form a peer-to-peer network, and any computing device, such as a server, terminal, or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.
[0186] According to one aspect of the present application, a computer program product is provided, comprising a computer program / instructions containing program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication component and / or installed from a removable medium. When the computer program is executed by a central processing unit, the various functions provided in the embodiments of the present application are performed.
[0187] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.
[0188] According to one aspect of the present application, a computer-readable storage medium is provided, and a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned live video stream playback method.
[0189] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0190] S1. In response to a video playback request, obtain a first fragment sequence matching a first video segment, wherein the first video segment is a video segment in a live video stream, and the first fragment sequence includes M video segments obtained by fragmenting the first video segment and ordered by playback time, where M is an integer greater than 1.
[0191] S2: Use the Nth video segment in the first segment sequence as a first video segment, and play the live video stream based on the first video segment and the video segments following the first video segment in the first segment sequence, where N is an integer greater than 1 and less than M.
[0192] S3, determining the second video segment from the second segment sequence that matches the second video segment, and when the video segment in the first segment sequence is played, playing the live video stream according to the second video segment and the video segment after the second video segment in the second segment sequence, wherein the second video segment is the video segment after the first video segment in the live video stream, and the second segment sequence includes M video segments obtained by the segmentation operation on the second video segment and sorted by the playback time.
[0193] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing the hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0194] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above-mentioned computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes a number of instructions for causing one or more computer devices (such as personal computers, servers, or network devices) to execute all or part of the steps of the above-mentioned methods in various embodiments of the present invention.
[0195] In the above embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0196] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0197] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0198] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0199] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.
Claims
1. A method for playing a live video stream, characterized in that: include: In response to a video playback request, obtaining a first fragment sequence matching a first video segment, wherein the first video segment is a video segment in a live video stream, and the first fragment sequence includes M video segments obtained by fragmenting the first video segment and ordered by playback time, where M is an integer greater than 1; Using the Nth video fragment in the first fragment sequence as a first video fragment, and playing the live video stream based on the first video fragment and the video fragments following the first video fragment in the first fragment sequence, where N is an integer greater than 1 and less than M; A second video segment is determined from a second segment sequence that matches the second video segment, and when the video segment in the first segment sequence is played, the live video stream is played according to the second video segment and the video segment that follows the second video segment in the second segment sequence, wherein the second video segment is a video segment that follows the first video segment in the live video stream, and the second segment sequence includes M video segments obtained by performing a segmentation operation on the second video segment and sorted according to the playback time.
2. The method according to claim 1, characterized in that Before playing the live video stream according to the second video segment and the video segment following the second video segment in the second segment sequence, the method further includes: Acquire a fragment sequence file that matches the second fragment sequence, wherein the fragment sequence file includes a fragment link of each of the video fragments in the second fragment sequence; The second video segment and the video segment following the second video segment in the second segment sequence are obtained in sequence according to a plurality of segment links respectively used to indicate the second video segment and the video segment following the second video segment in the second segment sequence.
3. The method according to claim 2, characterized in that The acquiring, in sequence, the second video segment and the video segment following the second video segment in the second segment sequence according to the plurality of segment links respectively indicating the second video segment and the video segment following the second video segment in the second segment sequence comprises: Determine a link type of a current fragment link corresponding to a current video fragment to be obtained, wherein the link type includes a fragmented type and a pre-fragmented type, the video fragment indicated by the fragment link of the fragmented type is in a fragmentation-completed state at a target time, and the video fragment indicated by the fragment link of the pre-fragmented type is in a fragmentation-incomplete state at a target time, and the target time is a time indicated by a generation timestamp of the fragment sequence file; When the link type of the current segment link is the segmented type, obtaining the current video segment according to the current segment link; When the link type of the current segment link is the pre-segment type and it is confirmed that the current video segment is in the segmentation completion state, the current video segment is obtained according to the current segment link.
4. The method according to claim 2, characterized in that Playing the live video stream according to the second video segment and the video segment following the second video segment in the second segment sequence includes: Obtaining remaining cache space of a cache queue, wherein the tail of the cache queue is used to store video data obtained by decapsulating the video fragments, and the head of the cache queue is used to retrieve the video data for decoding and playback; When the remaining cache space is greater than or equal to the target data amount, the current video data obtained by decapsulating the current video fragment is obtained, and the target video data in the current video data is added to the cache queue according to the remaining cache space.
5. The method according to claim 4, characterized in that Before obtaining the remaining cache space of the cache queue, the method further includes: Obtaining a first duration corresponding to the video segment, wherein the first duration is the duration of the video segment corresponding to the video segment; Obtaining a second duration corresponding to the video segment, wherein the second duration is the duration required to obtain the video segment; Determine a target duration according to the first duration and the second duration; The space size of the cache queue is determined according to the data volume of the video data matching the target duration.
6. The method according to claim 2, characterized in that The determining the second video segment from the second segment sequence matching the second video clip includes: When the current live broadcast delay is greater than or equal to the target threshold, use the Lth video fragment in the second fragment sequence as the second video fragment, where L is an integer greater than 1 and less than M; When the current live broadcast delay is less than the target threshold, the first video segment in the second segment sequence is used as the second video segment.
7. The method according to claim 1, characterized in that The method further includes: determining a second video segment from a second segment sequence matching the second video clip, and playing the live video stream according to the second video segment and the video segment following the second video segment in the second segment sequence when the video segment in the first segment sequence is finished playing. Obtaining a target bandwidth parameter, wherein the target bandwidth parameter is used to estimate a transmission rate corresponding to when the current terminal obtains the video fragment; In a case where the target bandwidth parameter does not match the video resolution corresponding to the current video slice, determining the target resolution according to the target bandwidth parameter; Obtaining a target slice sequence file that matches the target resolution, wherein the target slice sequence file includes a slice link for each of the video slices in the third slice sequence, a third video segment corresponding to the third slice sequence matches the second video segment corresponding to the second slice sequence, and a video resolution of the third video segment corresponding to the third slice sequence is the target resolution; The next video segment is obtained according to the segment link in the target segment sequence file.
8. The method according to claim 7, characterized in that The acquiring of the target bandwidth parameter includes: Obtaining a bandwidth measurement parameter corresponding to the current video segment, wherein the bandwidth measurement parameter is used to instruct the current terminal to obtain the transmission rate corresponding to the current video segment; Using the previous target bandwidth parameter as a reference bandwidth parameter, wherein the previous target bandwidth parameter is a previous bandwidth estimation result of the current terminal; The target bandwidth parameter is determined according to the bandwidth measurement parameter and the reference bandwidth parameter.
9. The method according to claim 7, characterized in that When the target bandwidth parameter does not match the video resolution corresponding to the current video segment, before determining the target resolution according to the target bandwidth parameter, the method further includes: When the reference resolution corresponding to the target bandwidth parameter is smaller than the video resolution, determining that the target bandwidth parameter does not match the video resolution corresponding to the current video slice; When the reference resolution corresponding to the target bandwidth parameter is greater than or equal to the video resolution, and the reference resolution corresponding to the previous target bandwidth parameter is greater than or equal to the video resolution, it is determined that the target bandwidth parameter does not match the video resolution corresponding to the current video fragment.
10. A device for playing live video stream, characterized in that: include: an acquiring unit, configured to acquire, in response to a video playback request, a first fragment sequence matching a first video segment, wherein the first video segment is a video segment in a live video stream, and the first fragment sequence includes M video segments obtained by fragmenting the first video segment and sorted by playback time, where M is an integer greater than 1; a first playback unit, configured to use the Nth video fragment in the first fragment sequence as a first video fragment, and play the live video stream based on the first video fragment and the video fragments following the first video fragment in the first fragment sequence, where N is an integer greater than 1 and less than M; A second playback unit is used to determine a second video segment from a second segment sequence matching the second video segment, and play the live video stream based on the second video segment and the video segment following the second video segment in the second segment sequence after the video segment in the first segment sequence has been played, wherein the second video segment is a video segment following the first video segment in the live video stream, and the second segment sequence includes M video segments obtained by segmenting the second video segment and sorted by playback time.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the method according to any one of claims 1 to 9 is executed when the program is executed.
12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
13. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 9 through the computer program.