Introduction to HLS 1 HLS and m3u8

Source: Internet
Author: User
Tags auth

HLS (HTTP Live streaming) is a streaming media solution developed by Apple based on the HTTP protocol for mobile devices such as the iphone, IPod, itouch and ipad. In HLS technology, the WEB server provides near-real-time audio and video streaming to clients. However, the use of the standard HTTP protocol is used, so at this time, as long as the use of HLS technology, can be used in ordinary HTTP applications directly on demand and live. Video-related applications in the App Store are basically applications of this technology. The rationale for this technique is to cut a video file or video stream into small pieces (TS) and create an index file (m3u8). The supported video stream encoding is H.264, and the audio stream code is AAC.

Apple's dynamic bit rate adaptive technology. Mainly used for PC and Apple terminal audio and video services. Includes an M3U (8) index file, a TS media fragment file, and a key encryption string file.
Commonly used streaming media protocols are mainly HTTP progressive download and real-time streaming media protocol based on RTSP/RTP, these two kinds of basic things are completely different, now more convenient and easy to use is the HTTP progressive download method. In this regard, Apple's HTTP Live streaming is representative of this aspect. It was originally a stream that Apple developed for mobile devices such as iphones, ipods, itouch, and ipads. Now there are many applications on the desktop, and HTML5 is directly supporting this.
However, small slices of the HLS protocol generate a large number of files that can be wasted by storing or processing these files. If you want to implement a few days of time shift, the index will be a huge number, and significantly affect the request speed. Therefore, the HLS protocol is very demanding for storage I/O requirements. In this respect, there are also companies to put forward a very good solution.
New on-Demand server system, the original memory cache data real-time slicing technology, subversion of this traditional implementation method, fundamentally solve a large number of slices of fragmentation, making a single server slicing and packaging capacity is no longer a bottleneck. The basic principles are as follows:
Not to save the TS slice file to disk, but the existence of memory, this technology makes the server's disk no longer have "tons of" file fragmentation, greatly reducing the disk I/O times, extended the service life of the server disk, greatly improve the stability of the server operation. At the same time, because the use of this technology, so that the terminal request data directly from the server's memory to obtain, greatly improve the terminal data request response speed, optimize the video viewing experience.

simply summed up is: first of all, a complete video into a number of TS video files, users download m3u8 files, through the m3u8 file's index address to play specific each small video

1. m3u8 Document Concept
The m3u8 file refers to the m3u file in the UTF-8 encoded format. M3U file is a record of an indexed plain text file, open it when the playback software does not play it, but according to its index to find the corresponding audio and video files of the network address to play online.

2. Examples of m3u8 documents
For example, when using cloud Chart TV on-demand Live program, send a request:
Http://121.199.63.236:7613/m3u8/cckw1/szws.m3u8?from=bab&fun=yes&chk=y&chunk=xax&ppw=yuntutv &auth=yuntutvyuntutvyuntutv&auth=yuntutvyuntutvyuntutv&nwtime=1406515232&sign= 033d5483609e6bc87987fc7d2f30a024
Returns the m3u8 file with the following file contents

#EXTM3U
#EXT-x-media-sequence:140651513
#EXT-x-targetduration:10
#EXTINF: 8,
http:// Vapp1.fw.live.cntv.cn/cache/289_/seg0/index140651513[140651513].ts
#EXTINF: 9,
http:// Vapp1.fw.live.cntv.cn/cache/289_/seg0/index140651514[140651514].ts
#EXTINF:
http:// Vapp1.fw.live.cntv.cn/cache/289_/seg0/index140651515[140651515].ts
#EXTINF:
http:// Vapp1.fw.live.cntv.cn/cache/289_/seg0/index140651516[140651516].ts
#EXTINF:
http:// Vapp1.fw.live.cntv.cn/cache/289_/seg0/index140651517[140651517].ts
#EXTINF: 8,
http:// Vapp1.fw.live.cntv.cn/cache/289_/seg0/index140651518[140651518].ts
#EXTINF:
http:// Vapp1.fw.live.cntv.cn/cache/289_/seg0/index140651519[140651519].ts
#EXTINF: 8,
http:// Vapp1.fw.live.cntv.cn/cache/289_/seg0/index140651520[140651520].ts
#EXTINF: 9,
http:// Vapp1.fw.live.cntv.cn/cache/289_/seg0/index140651521[140651521].ts
#EXTINF:
http:// Vapp1.fw.live.cntv.cn/cache/289_/seg0/index140651522[140651522].ts
Then download the audio and video and play it according to the link in the index

3. m3u file label and attribute description
The m3u file can contain more than one tag, and each tag's function and properties are as follows:
#EXTM3U
The first line of each m3u file must be this tag, please indicate the function
#EXT-x-media-sequence:140651513
Each media URI has only a unique ordinal number in playlist, adjacent to ordinal +1, and a media URI is not necessarily included, if not, the default is 0
#EXTINF:
Duration Specifies the duration (in seconds) for each media segment (TS), only valid for the URI that follows it, and title is the URL of the download resource
#EXT-x-targetduration
Specifies the maximum media segment length (in seconds). So the length of time specified in the #extinf must be less than or equal to the maximum value. This tag can only occur once in the entire playlist file (in the case of nesting, a m3u8 with a true TS URL will appear in the tag)
#EXT-x-key
Indicates how to decode media segments. Its scope is the next time the tag appears all media URIs, the property is None or AES-128. None indicates that the URI and the IV (initialization Vector) attribute must not exist, and AES-128 (Advanced encryptionstandard) indicates that the URI must exist and IV may not exist.
For AES-128, the Keytag and URI attributes together represent a key file, which can be obtained by URI, and if there is no IV (initialization Vector), the sequence number is encoded as IV. Assigns the high order of the serial number to 16 bytes of buffer, the left complement 0, and if there is IV, the change is treated as a 16-byte 16-number.
#EXT-x-program-date-time
Associate an absolute time or date with the first sample in a media segment, only valid for the next Meida URI, formatted like #ext-x-program-date-time:
For example: #EXT-x-program-date-time:2010-02-19t14:54:23.031+08:00
#EXT-x-allow-cache
Whether to allow cache, this can appear anywhere in the playlist file, and appear at most once, the effect is all media segments. The format is as follows: #EXT-x-allow-cache:
#EXT-x-playlist-type
Provides information about the variability of the PLAYLIST, which is valid for the entire PLAYLIST file and is optional, in the following format: #EXT-x-playlist-type: If it is VOD, the server cannot change PLAYLIST file; if it is an event, The server cannot change or delete any part of the playlist file, but you can add a new line to the file.
#EXT-x-endlist
Represents the end of the playlist, which can appear anywhere in the playlist, but only one can appear, in the following format: #EXT-x-endlist
#EXT-x-media
A version that is used to represent the same content in playlist, for example, by using 3 of these tags to represent 3 audio without voice, or 2 of this tag to represent different angles of the video in the playlists. The label exists independently, and the attribute contains:
URI: If not, it means that the selectable version of this tag description exists in the Ext-x-stream-inf of the main playlist;
Type:audio and video;
Group-id: A mediatag with the same ID, consisting of a set of styles;
LANGUAGE: Determine the main language used
NAME: Translation of human-readable language
Default:yes or no, the default is no, and if yes, the client will play with this option unless the user chooses it himself.
Autoselect:yes or no, the default is no, and if yes, the client chooses according to the current playback environment (the user does not choose according to their preferences).
#EXT-x-stream-inf
Specifies a media URI that contains multimedia information as a playlist, which is typically nested using m3u8, which is valid only for URIs immediately following: #EXT-x-stream-inf: The following properties are available:
Bandwidth: bandwidth, must have.
Program-id: This value is a decimal integer that uniquely identifies a specific description within the scope of the playlist file. A playlist file may contain more than one tag with the same ID.
CODECS: It's not necessary.
Resolution: Resolution.
AUDIO: This value must match the "Group-id" attribute value in the "Ext-x-media" tab of the AUDIO category.
Video: Ditto

HLS history

The first version of the HLS draft was enacted in 2009

The latest version of 18:https://tools.ietf.org/html/draft-pantos-http-live-streaming-18#userconsent# expires in May 2016 and updates new versions

Reference article: m3u8 File Introduction http://blog.sina.com.cn/s/blog_6cf7acdf0102v0xv.html

--HLS--M3U8 analysis of streaming media development (1) http://blog.csdn.net/jwzhangjie/article/details/9743971

--HLS--M3U8 analysis of streaming media development (2): HLS draft http://blog.csdn.net/jwzhangjie/article/details/9744027

m3u8 Analysis of Network live TV (Part One) http://blog.csdn.net/matthew_fan/article/details/8365401

m3u8 Analysis of Network live TV (http://blog.csdn.net/matthew_fan/article/details/8438384)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.