HLS low latency method based on network camera

By performing TS slicing and I-frame identification processing on the video stream in units of set duration, the problem of high latency in HLS technology is solved, and low-latency playback of the HLS player is realized, which is suitable for delay-sensitive live broadcast scenarios.

CN115550746BActive Publication Date: 2024-09-10HANGZHOU VISION INSIGHT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211238434.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-11
Publication Date
2024-09-10
Estimated Expiration
2042-10-11

AI Technical Summary

Technical Problem

The existing HLS technology has a high video stream delay in the live broadcast industry, making it unsuitable for delay-sensitive live broadcast scenarios.

Method used

By slicing the video stream into TS slices with a set duration, and forcing slicing in advance when encountering an I frame, adding a flag indicating whether the TS slice has an I frame, it determines whether the HLS player is playing the first screen, and waits asynchronously to ensure The first TS slice has an I frame to enable normal initialization and playback of the HLS player.

Benefits of technology

The HLS playback delay time is significantly reduced, for example from 12 seconds to 1.2 seconds, ensuring that the HLS player can start playing at the I frame and ensuring normal initialization and playback.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115550746B
    Figure CN115550746B
Patent Text Reader

Abstract

The present invention provides an HLS low-latency method and a media distribution service system based on a network camera, aiming to solve the problem of long HLS playback delay time in the prior art. The present invention provides an HLS low-latency method based on a network camera, comprising: TS slicing a video stream in units of a set duration t; when slicing, if an I frame is encountered but the set duration t is not reached, TS slicing is forced in advance at the I frame; the set duration t is less than the gop duration; a scrolling M3U8 list is provided according to the TS slice, and an identification of whether the TS slice has an I frame is added; an HLS player playback request is received, and it is determined whether the playback of the HLS player belongs to the first screen: if not, it is played in the order of the M3U8 list; if so, the HLS player obtains the M3U8 list for asynchronous waiting and waits until the first TS slice has an I frame, and then the HLS player ends the asynchronous waiting and plays in the order of the M3U8 list. The present invention performs TS slicing by setting the duration t, and the delay time is significantly shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of streaming media, and in particular relates to an HLS low-latency method based on a network camera and a media distribution service system. Background Art

[0002] Currently, in the live broadcast industry, video streams obtained by network cameras need to be watched conveniently and quickly on mobile phones, web and other scenarios. HLS (HTTP Live Streaming, an adaptive bitrate streaming media transmission protocol based on HTTP) has good compatibility, but the delay is relatively high. When playing, mainstream HLS players generally cache 3 TS (Transport Stream, transport stream layer) slices, each slice is a gop (Group of Pictures, a set of pictures between two I frames), and the delay is 3 gop durations. Taking a gop duration of 4 seconds as an example, the conventional HLS playback delay will be as high as 12 seconds, which means that HLS can only be used in slow live broadcast scenarios that are not sensitive to delays. Summary of the invention

[0003] The present invention provides an HLS low-latency method and a media distribution service system based on a network camera, aiming to solve the problem of long HLS playback delay time in the prior art.

[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0005] In a first aspect, the present invention provides an HLS low-latency method based on a network camera, comprising the following steps:

[0006] S100, TS slicing is performed on the video stream in units of a set duration t; during slicing, if an I frame is encountered but the set duration t is not reached, TS slicing is forced in advance at the I frame; the set duration t is less than the gop duration;

[0007] S200, providing a scrolling M3U8 list according to the TS slice, and adding an identification of whether the TS slice has an I frame;

[0008] S300: Receive a HLS player playback request and determine whether the playback of the HLS player belongs to the first screen:

[0009] S310, if not, play in the order of the M3U8 list;

[0010] S320, if yes, the HLS player obtains the M3U8 list and waits asynchronously; based on the flag of whether the TS slice carries an I frame, it is determined whether the first TS slice in the M3U8 list carries an I frame:

[0011] S321. If the first TS slice in the M3U8 list has an I frame, the HLS player ends the asynchronous waiting and plays in the order of the M3U8 list.

[0012] S322. If the first TS slice of the obtained M3U8 list does not have an I frame, the HLS player continues to wait asynchronously until the first TS slice has an I frame, and then the HLS player ends the asynchronous waiting and plays in the order of the M3U8 list.

[0013] Further improved technical solution: The basis for judging whether the playback of the HLS player belongs to the first screen is:

[0014] The judgment is made based on the HLS player playback request record; if the latest playback request of the HLS player is the first playback request; or if the latest playback request of the HLS player is more than the set time from the last playback request; it is determined to be the first screen.

[0015] Based on the above scheme, by making a playback request for the first time; or, if the latest playback request of the HLS player exceeds the set time from the last playback request; it can be convenient to determine whether it belongs to the first screen, so that the HLS player can initialize the playback normally.

[0016] A further improved technical solution: determine whether the playback of the HLS player belongs to the first screen based on the HLS player playback request record saved in the session and the latest cookie of the HLS player; and distinguish the cookies through the playback URL.

[0017] Based on the above solution, the cookie-based session dialogue can easily determine whether it belongs to the first screen, and different cookies can be distinguished by playing the URL.

[0018] A further improved technical solution: the set time length t is 0.3-1 second.

[0019] Based on the above solution, this duration is significantly lower than the slice duration in gop units, which can significantly reduce the delay time.

[0020] A further improved technical solution: the set time length t is 0.4 seconds, 0.5 seconds, 0.6 seconds or 0.8 seconds.

[0021] Based on the above solution, the shorter the set time length t is, the shorter the delay time is.

[0022] A further improved technical solution: There are always 3 TS slices in the M3U8 list, and after the first TS slice in the M3U8 list is played, a new TS slice is added to the end of the M3U8 list.

[0023] Further improved technical solution: During asynchronous waiting, if multiple HLS players perform asynchronous waiting; when the first TS slice carries an I frame, all HLS players end the asynchronous waiting and play in the order of the M3U8 list.

[0024] Based on the above solution, by making multiple different HLS players all wait asynchronously, when the first TS slice carries an I frame, all HLS players end the asynchronous waiting, which is convenient to control and highly efficient.

[0025] In a second aspect, the present invention provides a media distribution service system for executing a network camera-based HLS low-latency method as described in any of the above schemes.

[0026] A further improved solution: the media distribution service system is a cmds http(s) service system that can provide http(s) services.

[0027] The beneficial effects of the present invention are:

[0028] The present invention performs TS slicing by setting a duration t, and compared with the existing slicing in units of gop, the duration t of each TS slice is shorter, thereby reducing the delay time. For example, when 3 TS slices are cached in the M3U8 list, the delay time of the video is 3t. If the duration t is set to 0.4 seconds, the delay is 1.2 seconds. Compared with the delay of 12-16 seconds in the prior art, the delay time of the present invention is significantly shortened.

[0029] In addition, after TS slicing is performed by setting the duration t, in order to avoid the first TS slice played by the HLS player without an I frame, resulting in the HLS player initialization failure and inability to play normally; when slicing, if the present invention encounters an I frame but does not reach the set duration t, the TS slicing is forced in advance at the I frame, and according to the identification of whether the TS slice has an I frame; the HLS player performs asynchronous waiting to ensure that the first TS slice in the M3U8 list has an I frame and the starting point of the TS slice with an I frame is at the I frame, and the HLS player starts playing at the I frame, thereby ensuring that the HLS player initializes normally and can play normally. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying creative work.

[0031] Figure 1 It is a flow chart of the HLS low-latency method based on a network camera of the present invention.

[0032] Figure 2 It is a schematic diagram of the logical framework for implementing the HLS low-latency method of the present invention. DETAILED DESCRIPTION

[0033] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work belong to the protection scope of the present invention.

[0034] In the present invention, the I frame is the first frame of each gop, and serves as a reference point for random access. Only when the HLS player starts playing at the I frame can the HLS player be initialized normally and play normally.

[0035] Embodiment 1:

[0036] See also Figure 1 and Figure 2 , an HLS low-latency method based on a network camera, comprising the following steps:

[0037] S100, TS slicing is performed on the video stream in units of a set duration t; during slicing, if an I frame is encountered but the set duration t is not reached, TS slicing is forced in advance at the I frame; the set duration t is less than the gop duration.

[0038] Among them, the set time length can be set according to actual needs. The shorter the set time length, the shorter the delay time; preferably, the set time length t is 0.3-1 second; specifically, the set time length t can be 0.4 seconds, 0.5 seconds, 0.6 or 0.8 seconds, etc.

[0039] Among them, if an I frame is encountered but the set duration t is not reached, TS slicing is forced in advance at the I frame; the following is a specific explanation with a case: if the duration between the first I frame and the second I frame is 4 seconds, slicing is performed according to the set duration of 0.6 seconds, starting from the first I frame, slicing is performed every 0.6 seconds. When the 7th TS slice is cut, an I frame will be encountered. At this time, slicing needs to be performed in advance at the I frame without skipping the I frame slice.

[0040] S200: Provide a scrolling M3U8 list according to the TS slice, and add an identification of whether the TS slice contains an I frame.

[0041] The M3U8 list refers to an M3U file in UTF-8 encoding format. An M3U file is a plain text file that records an index. The playback software finds the network address of the corresponding audio and video file based on the index of the M3U file for online playback.

[0042] Among them, an identification of whether the TS slice has an I frame is added to facilitate the subsequent steps to determine whether the TS slice has an I frame; the identification of the I frame can be identified in an encoded manner, for example: if it has an identification, it is 1, and if it does not have an identification, it is 0.

[0043] S300, receiving a playback request from an HLS player, and determining whether the playback of the HLS player belongs to the first screen;

[0044] The basis for judging whether the playback of the HLS player belongs to the first screen is as follows:

[0045] The judgment is made based on the HLS player's playback request records; if the HLS player's latest playback request is the first playback request; or if the HLS player's latest playback request is more than the set time from the last playback request; it is determined to be the first screen; the first screen means: if the HLS player has never played it before, or it has been more than the set time from the last playback request, that is, the HLS player playback has been interrupted and then played again; the interruption here can be caused by network delays or by shutting down the HLS player.

[0046] Specifically, the HLS player playback request record saved in the session (implemented based on cookies) and the latest cookie of the HLS player (data stored on the user's local terminal, i.e., the HLS player) are used to determine whether the HLS player's playback belongs to the first screen; and the cookies are distinguished by the playback url (Uniform Resource Locator, used to identify different cookies).

[0047] When clicking on a play link, the HLS player will send a play request and generate the latest cookie, and the HLS player will send a play request every time it plays a TS slice; if the HLS player plays according to the M3U8 list for a period of time, the HLS player will continue to play according to the M3U8 list based on the latest cookie information (identity and other information) saved in the session and the HLS player play request record. If there is an interruption or the play request is the first play request, the session will be judged as the first screen based on the latest cookie information and the HLS player play request record.

[0048] Among them, the server (i.e., the media distribution service system that executes the process steps of the present invention) distinguishes cookies by playing URLs, and the server session stores the playback request records of the HLS player. The HLS player communicates with the server session through the latest cookie to determine whether the playback of the HLS player belongs to the first screen.

[0049] S310, if not, play in the order of the M3U8 list;

[0050] Among them, the M3U8 list generally has 3 or 4 TS slice lists, and plays from early to late according to the TS slice generation time; a specific solution: there are always 3 TS slices in the M3U8 list, and after the first TS slice in the M3U8 list is played, a new TS slice is added to the end of the M3U8 list.

[0051] S320, if yes, the HLS player obtains the M3U8 list and waits asynchronously; based on the flag of whether the TS slice carries an I frame, it is determined whether the first TS slice in the M3U8 list carries an I frame:

[0052] S321. If the first TS slice in the M3U8 list has an I frame, the HLS player ends the asynchronous waiting and plays in the order of the M3U8 list.

[0053] S322. If the first TS slice of the obtained M3U8 list does not have an I frame, the HLS player continues to wait asynchronously until the first TS slice has an I frame, and then the HLS player ends the asynchronous waiting and plays in the order of the M3U8 list.

[0054] In addition, during asynchronous waiting, if multiple HLS players perform asynchronous waiting; when the first TS slice contains an I frame, all HLS players end the asynchronous waiting and play in the order of the M3U8 list.

[0055] Embodiment 2:

[0056] A media distribution service system is used to execute an HLS low-latency method based on a network camera as described in any scheme of Embodiment 1.

[0057] Specifically, the media distribution service system is preferably a cmds http(s) service system that can provide http(s) service. The http(s) service includes cookies, supports sessions based on cookies, and supports asynchronous waiting and asynchronous waiting end; the media distribution service system and the HLS player interact with each other through the http(s) protocol. Cmds (common media distribute server) is a common streaming media distribution service, and HLS is one of the protocols distributed by cmds; http(s) is a (Hyper Text Transfer Protocol) hypertext transfer protocol, which supports asynchronous waiting and asynchronous waiting end.

[0058] The present invention is not limited to the above-mentioned optional implementation modes. Anyone can derive other various forms of products under the inspiration of the present invention. However, no matter what changes are made in the shape or structure, all technical solutions that fall within the scope defined by the claims of the present invention fall within the protection scope of the present invention.

Claims

1. A low-latency HLS method based on network cameras, It is characterized in that The following steps are involved: S100, TS slicing is performed on the video stream in units of a set duration t; when slicing, if an I frame is encountered but the set duration t is not reached, TS slicing is forced in advance at the I frame; the set duration t is less than the gop duration; S200, providing a scrolling M3U8 list according to the TS slice, and adding an identification of whether the TS slice has an I frame; S300, receiving a HLS player playback request, and determining whether the HLS player playback belongs to the first screen: S310, if not, play in the order of the M3U8 list; S320: If yes, the HLS player obtains the M3U8 list and waits asynchronously; based on the flag indicating whether the TS slice carries an I frame, it determines whether the first TS slice in the M3U8 list carries an I frame: S321. If the first TS slice in the M3U8 list has an I frame, the HLS player ends the asynchronous waiting and plays in the order of the M3U8 list; S322. If the first TS slice of the obtained M3U8 list does not have an I frame, the HLS player continues to wait asynchronously until the first TS slice has an I frame, and then the HLS player ends the asynchronous waiting and plays in the order of the M3U8 list; The basis for judging whether the playback of the HLS player belongs to the first screen is: The judgment is made based on the HLS player playback request record; if the latest playback request of the HLS player is the first playback request; or if the latest playback request of the HLS player is more than the set time from the last playback request; It is judged to be On the first screen; Determine whether the HLS player's playback belongs to the first screen based on the HLS player's playback request record saved in the session and the HLS player's latest cookie; and distinguish cookies based on the playback URL.

2. A HLS low-latency method based on a network camera according to claim 1, It is characterized in that The set time length t is 0.3-1 second.

3. A HLS low-latency method based on a network camera according to claim 2, It is characterized in that The set time length t is 0.4 seconds, 0.5 seconds, 0.6 seconds or 0.8 seconds.

4. The HLS low-latency method based on a network camera according to claim 1, It is characterized in that There are always 3 TS slices in the M3U8 list, and after the first TS slice in the M3U8 list is played, a new TS slice is added to the end of the M3U8 list.

5. The HLS low-latency method based on a network camera according to claim 1, It is characterized in that During asynchronous waiting, if multiple HLS players are performing asynchronous waiting; when the first TS slice contains an I frame, all HLS players end the asynchronous waiting and play in the order of the M3U8 list.