Explanation of "HLS" m3u8 format and practical application analysis

Source: Internet
Author: User
Tags rfc unique id
What good is m3u8. Transfer from http://blog.csdn.net/langeldep/article/details/8603045
Online Search, we have divergent opinions, personal understanding is mainly can be multi-bitrate adaptation, according to network bandwidth, the client will choose a suitable for their own bitrate files to play, to ensure the smooth flow of video.

The iOS device and Mac can be distributed in HTTP, where the playlist standard is the m3u8 file extended by M3U, the media file is mpeg2-ts or AAC file (audio only).

There are two application scenarios for m3u8 files:

multi-bit rate adaptation flow,

#EXTM3U

#EXT-x-stream-inf:program-id=1,bandwidth=1280000

Http://example.com/low.m3u8

#EXT-x-stream-inf:program-id=1,bandwidth=2560000

Http://example.com/mid.m3u8

#EXT-x-stream-inf:program-id=1,bandwidth=7680000

Http://example.com/hi.m3u8

#EXT-x-stream-inf:program-id=1,bandwidth=65000,codecs= "mp4a.40.5"

HTTP://EXAMPLE.COM/AUDIO-ONLY.M3U8 single-bit rate adaptive flow

#EXTM3U

#EXT-x-targetduration:5220

#EXTINF: 5220,

Http://media.example.com/entire.ts

#EXT-x-endlist


The International Standards Organization defines this as RFC doc:
http://tools.ietf.org/html/draft-pantos-http-live-streaming-06
m3u8 file is an extension of m3u file. Extended keywords are defined in this RfC:
which
#EXT-x-targetduration defines the maximum duration for each TS. #EXT-x-media-sequence defines the sequence number of the first file in the current m3u8 file, each TS file has a fixed, unique sequence number in the m3u8 file that is used to align the switching bitrate during MBR.

#EXT-x-key

Defines the encryption method and the URL of the key file for obtaining a 16bytes key file to decode the TS file. Properties: METHOD URL #EXT-x-program-date-time

Absolute time of first file

#EXT-x-allow-cache Whether the CACHE is allowed. #EXT-x-endlist Indicates the end of the m3u8 file. Live m3u8 does not have the tag. #EXT-x-stream-inf Property: BANDWIDTH Specify the bitrate
Program-id Unique ID
CODECS Specifies the encoding type of the stream #EXT-x-discontinuity when the tag is encountered, the following properties are changed: file format number and type of tracks Enco Ding parameters encoding sequence

Timestamp sequence

#EXT-x-version This property with no need to, can not

m3u8 Sub-top m3u8 and two-level m3u8, the top m3u8 is mainly multi-bitrate adaptation, two-level m3u8 is the real slice file,

By default, the client will first select the highest bitrate request, and if it finds that the bitrate is not reached, it will request a low -bitrate stream


A top-level m3u8 file that is actually in use is as follows:

#EXTM3U
#EXT-x-stream-inf:program-id=201273221265,bandwidth=358400
11.m3u8
#EXT-x-stream-inf:program-id=201273221265,bandwidth=972800
22.m3u8


The above top-level m3u8 file also defines the 11.m3u8 and 22.m3u8 two level two files, and the client chooses one to get its contents.

Level Two m3u8 file contents are as follows:


#EXTM3U
#EXT-x-version:1
#EXT-x-targetduration:10
#EXT-x-media-sequence:0
#EXTINF: 3,
1-4.ts
#EXTINF: 8,
1-6.ts
#EXTINF: 8,
1-8.ts
#EXTINF: 8,
1-10.ts
#EXTINF: 8,
1-12.ts
#EXTINF: 8,
1-14.ts
#EXTINF: 8,
1-16.ts
#EXTINF: 9,
1-18.ts
#EXTINF: 6,
1-20.ts
#EXTINF: 8,
1-22.ts
#EXTINF: 9,
1-24.ts
#EXTINF: 3,
1-26.ts
#EXT-x-endlist


After the client gets to the above level two m3u8 file, it will continue to request the files inside, then it can play.

Explained above is the situation of on-demand, live, the m3u8 file will have a property to tell is live, the client will be timed to request a new m3u8 file.

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.