(One in the HLS player) m3u8 parsing of HLS Protocol

Source: Internet
Author: User

According to the http://tools.ietf.org/html/draft-pantos-http-live-streaming-08, can have a better understanding of m3u8 than the license system.

Hls (HTTP live streaming) is an HTTP-based streaming media solution developed by Apple for mobile devices such as iPhone, iPod, itouch, and iPad. In HLS technology, web server provides client with near real-time audio and video streams. However, the standard HTTP protocol is used in the process of use. Therefore, you only need to use the HLS technology to directly provide on-demand videos and live videos on common HTTP applications. Video-related applications in App Store are basically applied to this technology. The basic principle of this technology is to split 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 encoding is AAC.

Okay. Let me start talking about me. For example:

# Extm3u # EXT-X-TARGETDURATION: 15 # extinf: 7, http://data.video.qiyi.com/videos/movie/20111225/f9eb21f9247aafb04b39cc5bba13afa1.ts? Start = 0 & End = 658512 & hsize = 5343 & tag = 0 & V = 7620766549 & contentlength = 229360 # extinf: 14, http://data.video.qiyi.com/videos/movie/20111225/f9eb21f9247aafb04b39cc5bba13afa1.ts? Start = 1712 & End = 2720295 & hsize = 5343 & tag = 1 & V = 7620766549 & contentlength = 1544984 # extinf: 10, http://data.video.qiyi.com/videos/movie/20111225/f9eb21f9247aafb04b39cc5bba13afa1.ts? Start = 658512 & End = 3785637 & hsize = 5343 & tag = 1 & V = 7620766549 & contentlength = 1082880 // omitted... # EXT-X-DISCONTINUITY # extinf: 9, http://data.video.qiyi.com/videos/movie/20111225/f2eab9af69495077eea62a17029b0c9b.ts? Start = 0 & End = 836062 & hsize = 14301 & tag = 0 & V = 7620766549 & contentlength = 408148 # extinf: 10, http://data.video.qiyi.com/videos/movie/20111225/f2eab9af69495077eea62a17029b0c9b.ts? Start = 1748 & End = 1489908 & hsize = 14301 & tag = 1 & V = 7620766549 & contentlength = 493500 # extinf: 10, http://data.video.qiyi.com/videos/movie/20111225/f2eab9af69495077eea62a17029b0c9b.ts? Start = 377373 & End = 2159598 & hsize = 14301 & tag = 1 & V = 7620766549 & contentlength = 694660 // omitted... # EXT-X-ENDLIST


This is a simple m3u8 file. Note # extinf: [int/Double], indicating the total length of the segment, this field is very critical we can find through it to see the jump position of TS segment; # EXT-X-DISCONTINUITY, indicates that a new time point starts, that is, the timestamp of the data stream starts from 0 at the moment. You have to change it. Otherwise, the imediaseeking: setpositions will be missing. Of course, some m3u8 do not have this field, most of which are smaller than the film's total length (not absolute ).

The rest is to parse the string. In addition, it is better to separate the time list from the TS address list, which makes it easier to use because most of the time is multi-thread.

 

(One in the HLS player) m3u8 parsing of HLS Protocol

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.