M3u8 format explanation and Practical Application Analysis

Source: Internet
Author: User
Tags rfc

Http://blog.csdn.net/langeldep/article/details/8603045

What are the advantages of m3u8?
After searching online, you may have different opinions. My personal understanding is that you can adapt to multiple bit rates. Based on network bandwidth, the client selects a file suitable for the bit rate for playing, ensuring the smoothness of the video stream.

In iOS device and Mac, HTTP can be used for distribution, where playlist is a standard m3u8 file extended by M3U, and the media file is a MPEG2-TS or AAC file (audio only ).

M3u8 files can be used in two scenarios:

Multi-bit rate adaptive stream,

# 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 stream

# Extm3u

# EXT-X-TARGETDURATION: 5220

# Extinf: 5220,

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

# EXT-X-ENDLIST


The International Standards Organization defines this. rfc doc:
Http://tools.ietf.org/html/draft-pantos-http-live-streaming-06
The m3u8 file is an extension of the M3U File. The RFC defines the extended keywords:
Where:

# EXT-X-TARGETDURATION
Defines the maximum duration of each ts.
# EXT-X-MEDIA-SEQUENCE
Defines the serial number of the first file in the current m3u8 file. Each ts file has a unique serial number in the m3u8 file. This serial number is used to switch the bit rate during MBR for alignment.

# EXT-X-KEY

Defines the encryption method and the URL of the key file for obtaining 16 bytes of the key file to decode the TS file.

Attribute:
Method
URL
# EXT-X-PROGRAM-DATE-TIME

Absolute Time of the first file

# EXT-X-ALLOW-CACHE

Whether to allow cache.
# EXT-X-ENDLIST
Indicates the end of The m3u8 file. Live m3u8 does not have this tag.
# EXT-X-STREAM-INF
Attribute:
Bandwidth specifies the bit rate
Unique id of Program-ID
Codecs specifies the stream encoding type
# EXT-X-DISCONTINUITY
When this tag is encountered, the following attributes are changed:
File Format
Number and type of tracks
Encoding Parameters
Encoding Sequence

Timestamp Sequence

# EXT-X-VERSION this attribute can be used not to use, can not





M3u8 is divided into top-level m3u8 and second-level m3u8. Top-level m3u8 is mainly applicable to multiple bit rates. Second-level m3u8 is the real slicing file,

By default, the client will first select the request with the highest bit rate. If the bit rate cannot be reached, the client will request a stream with a low bit rate.


A top-level m3u8 file in actual 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 defines two level-2 files, 11. m3u8 and 22. m3u8. The client selects one of them to get its content.

The content of level 2 m3u8 files is 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-0000ts
# Extinf: 8,
1-22.ts
# Extinf: 9,
1-24.ts
# Extinf: 3,
1-26.ts
# EXT-X-ENDLIST


After the client obtains the above level 2 m3u8 file, it will continue to request the file in it, and then it can be played.

The above describes the on-demand video and live video. In the m3u8 file, the property tells the live video, and the client regularly requests 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.