About HTTP Live Streaming官方文档翻译 [iOS]

新博客文章地址:About HTTP Live Streaming官方文档翻译 [iOS]
CSDN文章地址:About HTTP Live Streaming官方文档翻译 [iOS]

版权声明:本文为博主原创翻译,如需转载请注明出处。

苹果源文档地址 - 点击这里

About HTTP Live Streaming - HTTP实时流

HTTP Live Streaming (HLS) is Apple’s technology for streaming live and on-demand audio/video content to iPhone, iPad, iPod touch, Apple TV, and Mac. Central to HLS is the delivery of content using the HTTP protocol—the same protocol that powers the web. HTTP lets you easily deploy media content in streams using commonplace web servers rather than specialized streaming servers. HLS streams behave like regular web traffic. They work with preexisting caching infrastructure, such as Content Delivery Networks (CDNs), and reliably pass through typical firewalls and routers. HLS adapts to variable network conditions, dynamically adjusting playback to match the available speed of wired and wireless connections.

HTTP Live Streaming (HLS) 是苹果公司的技术,有关流媒体直播和点播音频/视频内容,支持iPhone, iPad, iPod touch, Apple TV, 和 Mac。内部 对 HLS 内容的传递 使用与HTTP协议相同的协议来处理网络服务。 HTTP可以轻松地使用普通的Web服务器,而不是专门的流媒体服务器 来部署流媒体内容。HLS流行为像常规的网络流量。工作方式为预先缓存基础结构,比如内容分发网络(CDN),以及可靠地通过典型的防火墙和路由器。HLS适应可变的网络状况,动态地调整播放以匹配有线和无线连接的可用速度。

In addition to reliability and ease of deployment, HLS supports important features for the delivery of commercial content: closed captions, fast forward and reverse playback, alternate audio and video, fallback alternatives, timed metadata, ad insertion, and content protection.

除了可靠性和易于部署,HLS支持广告内容投递的重要特征:字幕,快进和快退播放,备用音频和视频,后备方案,定时元数据,广告插播,和内容保护。

This document describes key aspects of HLS including the features mentioned above. The full HTTP Live Streaming specification is available as an IETF Internet-Draft at http://tools.ietf.org/html/draft-pantos-http-live-streaming.

此文件描述的HLS的主要方面包括上述特征。 完整的HTTP实时流规范可以作为一个IETF互联网草案 http://tools.ietf.org/html/draft-pantos-http-live-streaming

HLS Workflow - HLS 工作流

In a typical HLS workflow, a video encoder solution that supports HLS receives a live video feed or distribution-ready media file. The encoder creates multiple versions (known as variants) of the audio/video at different bit rates, resolutions, and quality levels. The encoder then segments the variants into a series of small files, called media segments. At the same time, the encoder creates a media playlist file for each variant containing a list of URLs pointing to the variant’s media segments. The encoder also creates a master playlist file, containing a list of the URLs to variant media playlists, and descriptive tags to control the playback behavior of the stream. While producing playlists and segments, the encoder or automated scripts upload the files to a web server or CDN.

支持HLS视频编码的解决案,接收实时视频流或分发就绪媒体文件。该编码器根据不同的比特率,分辨率和质量水平,创建多个版本(被称为variants)的音频/视频。编码器然后将这些变量段细分成一系列的小文件,称为媒体片段。编码器为每个变体创建一个媒体播放列表文件,包含URL的列表,这些URL指向的媒体片段。编码器还创建了一个主播放列表文件,其中包含的URL列表,指向变种媒体播放列表,并描述性标签来控制流的播放行为。当产生播放列表和段,码器或自动化脚本将文件上传到Web服务器或CDN。

You provide access to the content by embedding a link to the master playlist file in a web page, or by creating your own custom application that downloads the master playlist file.

通过在网页嵌入一个链接,指向主播放列表文件,来提供内容的入口。或者创建自己的自定义应用程序,下载主播放列表文件。

Media Segments - 媒体片段

An encoder creates media segments by dividing the event data into short MPEG-2 transport stream files (.ts). Typically, the files contain H.264 video or AAC audio with a duration of 5 to 10 seconds each. The encoder lets you set the encoding and duration of the media segments.

编码器通过将所述事件数据划分为短 MPEG-2 传输流文件(.ts)。通常情况下,该文件包含 H.264 视频和 AAC 音频,每个持续5到10秒。

Media Playlist Files - 媒体播放列表文件

The encoder creates the media playlists as text files saved in the M3U format (.m3u8). The media playlists contain URLs to the media segments and other information needed for playback. The playlist type—live, event, or video on demand (VOD)—determines how the stream can be navigated.

编码器创建媒体播放列表,作为文本文件保存在M3U格式(.m3u8 )。媒体播放列表包含指向媒体片段的 URL,以及其他需要播放的信息。播放列表式的直播,事件,或视频点播(VOD),确定该如何导流。

Live playlists let viewers perform fast forward and reverse playback within a limited time range. The range advances along the program until the end of the live presentation. Event playlists let a viewer rewind to the beginning of the stream even as it continues to stream live. VOD playlists represent a previously completed program that can be fully navigated from beginning to end.

实时播放列表,可以让观众进行快速前进,以及在有限的时间内后退。范围沿程序前进,直到直播演示结束。事件播放列表,可以让观众倒带到流的开始,即使它还继续直播。VOD播放列表是先前完成的程序,从开始到结束全都能随时播放。

Live and Event Media Playlists - 实时和事件媒体播放列表

Both the live and event types of programs require updates to the media playlists as newly created media segments become available on the server. The encoder adds new media segment references to the end of the playlist and uploads the updated playlist to the server.

实时类型和事件类型,都需要将媒体播放列表更新为最新创建的媒体片段,变为服务器上可用的。编码器在播放列表的末尾添加了新的媒体片段引用,并上传到服务器的更新列表。

In a live playlist, as shown in Listing 1, references to older media segments can be removed from the media playlist and discarded, providing a sliding window into a continuous stream.

在一个播放列表,如清单1所示,旧媒体段的引用可被从媒体播放清单中移除并丢弃,为连续流提供一个滑动窗口。

Listing 1 A simple live media playlist

清单1一个简单的媒体直播的播放列表

1
2
3
4
5
6
7
8
9
10
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:26
#EXTINF:9.901,
http://media.example.com/wifi/segment26.ts
#EXTINF:9.901,
http://media.example.com/wifi/segment27.ts
#EXTINF:9.501,
http://media.example.com/wifi/segment28.ts

An event playlist, shown in Listing 2, has the same format as the live media playlist above, with the exception of an extra line: #EXT-X-PLAYLIST-TYPE:EVENT. That designation alerts media player that this playlist will behave differently than a live media playlist. Event playlists maintain the references to older media while gaining new references. This process results in an expanding media playlist. This type of playlist allows the players to navigate freely (backward and forward) from the beginning of the program. Because references to all media segments remain in the playlist when the live event ends, event playlists are easily converted to VOD playlists.

事件的播放列表, 如清单2所示,与上面的直播媒体播放列表具有相同的格式,一行除外:#EXT-X-PLAYLIST-TYPE:EVENT。这标志提醒媒体播放器,该播放列表的行为不同于实时的媒体播放列表。获得新的引用时, 事件的播放列表维持旧的媒体引用。这个过程导致媒体播放列表的不断扩大。这种类型的播放列表的允许用户从节目的开始自由(向前和向后)导航。因为实时事件结束后,所有的媒体段引用保持在播放列表中,事件的播放列表很容易转换成VOD播放列表。

Listing 2 A simple event media playlist

清单2一个简单的事件媒体播放列表

1
2
3
4
5
6
7
8
9
10
11
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:EVENT
#EXTINF:9.9001,
http://media.example.com/wifi/segment0.ts
#EXTINF:9.9001,
http://media.example.com/wifi/segment1.ts
#EXTINF:9.9001,
http://media.example.com/wifi/segment2.ts

VOD Media Playlists - VOD媒体播放列表

A VOD playlist, shown in Listing 3, contains references to all available media segments for the complete presentation, beginning to end. This kind of playlist allows the player to navigate the entire program. A VOD #EXT-X-ENDLIST tag marks the end of downloadable media segments.

VOD播放列表,显示在清单3,包含了从开始到结束 完整的呈现所有可用的媒体片段的引用。 这种列表允许用户浏览整个程序。 VOD #EXT-X-ENDLIST 标签标志着下载的媒体段的结束。

Listing 3 A simple VOD media playlist

清单3简单的VOD媒体播放列表

1
2
3
4
5
6
7
8
9
10
11
12
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:9.9001,
http://media.example.com/wifi/segment0.ts
#EXTINF:9.9001,
http://media.example.com/wifi/segment1.ts
#EXTINF:9.9001,
http://media.example.com/wifi/segment2.ts
#EXT-X-ENDLIST

Master Playlists - 主播放列表

The master playlist provides an address for each individual media playlist in the stream. Figure 1 shows this relationship. The master playlist also provides important details such as bandwidth, resolution, and codec. The player uses that information to decide the most appropriate variant for the device and the currently measured, available bandwidth.

主播放列表为每个单独的媒体播放列表提供了一个地址流。 图1显示了这种关系。主播放列表也提供了重要的细节,如带宽,分辨率和编解码器。 播放器使用该信息来决定设备的最合适的变体和当前测量的,可用的带宽。


图1播放列表的关系

The sample master playlist in Listing 4 shows four variants. The order of the media playlists in the master playlists does not matter, except when you start the stream. The player begins downloading the first variant it can play. If conditions warrant, the player switches to another media playlist midstream.

清单4中的样本主播放列表显示四个变种。 媒体播放列表在主播放列表的顺序并不重要,当你启动流时除外。 播放器在开始下载第一个变种,它就可以播放了。如果条件允许,播放器切换到另一个媒体播放列表的中游。

Listing 4 A master playlist file with four available variants

清单4 有四个变体的一种主播放列表文件

1
2
3
4
5
6
7
8
9
10
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2855600,CODECS="avc1.4d001f,mp4a.40.2",RESOLUTION=960x540
live/medium.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=5605600,CODECS="avc1.640028,mp4a.40.2",RESOLUTION=1280x720
live/high.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1755600,CODECS="avc1.42001f,mp4a.40.2",RESOLUTION=640x360
live/low.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=545600,CODECS="avc1.42001e,mp4a.40.2",RESOLUTION=416x234
live/cellular.m3u8

A player downloads a master playlist only once. However, the number of media playlist downloads vary with the playlist type. For live and event broadcasts, the player downloads the media playlist files after each segment duration because the the playlist may update with new segments or lose older segments as the stream progresses. For VOD, players download media playlists only once.

播放器只下载主列表一次。 然而,媒体播放列表的下载数随着播放列表类型而变化。对于实时和事件广播,播放器在每个片段时间之后,下载媒体播放文件,因为播放列表可以用新的片段更新或随着流进展丢弃老片段。对于 VOD 下载播放器的播放列表媒体只有一次。

Publishing Your HLS Streams - 发布HLS流

You provide access to your streams by adding a link to the master playlist file in a web page, or by creating your own custom application built with the AV Foundation or Media Player frameworks. See AVFoundation Programming Guide or Media Player Framework Reference.

给流提供入口的方式有,通过网页中的主文件列表添加一个链接,或用 AV Foundation 或媒体播放器的框架构建自己的自定义应用程序。见 AVFoundation Programming Guide 或者 Media Player Framework Reference

Key Features - 主要特征

The HLS technology lets you stream your content through HTTP and enables automatic switching between streams as network conditions change. Those attributes alone make HLS a great solution for media distribution. Additionally, the technology includes features for usability, availability, advertising, and security. You can build the quality with the following extensible solutions.

该HLS技术,让您通过HTTP流形式传输您的内容,使流在网络条件的变化之间自动切换。这些特性使得HLS媒体分发成为一个很好的解决方案。此外,该技术还包括针对易用性,可用性,广告,安全等特点。你可以用以下的可扩展的解决方案,建立高质量的程序。

Closed Captions and Subtitles - 隐藏式字幕和字幕

HLS supports CEA-608 closed captions embedded in the MPEG-2 transport stream as specified in ATSC A/72. Most encoders automatically include the closed captioning in the media segments as the encoder processes the incoming video. Some encoders also insert closed captioning from a separate closed caption file or segmented QuickTime files that contain closed caption tracks (cclp).

HLS支持 CEA-608 字幕,嵌入在 MPEG-2 传输流中,在 ATSC A/72中指定。大多数编码器自动包括在媒体段中的字幕 作为编码器处理传入的视频。一些编码器也从一个独立的隐藏式字幕文件,或分段的、包含隐藏式字幕音轨(cclp)的QuickTime文件 插入隐藏式字幕。

HLS also supports multiple subtitles in WebVTT format. For more information on implementation of WebVTT, see WWDC 2012: What’s New in HLS and WebVTT: The Web Video Text Tracks Format specification.

HLS还支持 WebVTT 格式的多种字幕。有关 WebVTT 实现的更多信息,请参见 WWDC 2012: What’s New in HLSWebVTT: The Web Video Text Tracks Format specification

Fast Forward and Reverse Playback - 快进和快退播放

HLS supports fast forward and reverse playback through the use of an I-frame playlist. The I-frame playlist points to a byte range within already existing media segments. Fast forward and reverse playback do not need special media segments.

HLS快进支持并通过使用一个I-frame的播放列表 实现快退播放。I-frame 播放列表指向现有媒体段内的字节范围。快进和快退播放不需要特殊的媒体片段。

For in-depth information on I-frame playlists, watch WWDC 2012: Effective HLS.

有关 I-frame 的播放列表的详细信息,看 WWDC 2012: Effective HLS

Alternate Audio and Video Renditions - 备用音频和视频副本

HLS master playlists offer multiple audio renditions, a valuable trait for localization. For example, your master playlist may include multiple language soundtracks such as French, German, Spanish, and English. The audio tracks contain unmuxed (signals have not been combined) audio segments. The master playlist file controls the playback.

HLS主播放列表提供多种音频格式副本,对于本地化非常有用。例如,你的主播放列表可能包括多语言音轨,如法语,德语,西班牙语和英语。 音轨包含 unmuxed(信号未被组合)的音频段。主播放列表文件控制播放。

HLS also supports multiple video streams; for example, multiple video angles for a sporting event. Again, the master playlist file controls the playback.

HLS还支持多个视频流; 例如,体育赛事的多角度视频。再次,主播放列表文件控制播放。

For more information on alternate media renditions, watch WWDC 2012: Effective HLS.

有关备用媒体备份的更多信息,请观看 WWDC 2012: Effective HLS

Fallback with Stream Alternates - 流交替回退

Not only do alternate media playlists in your master playlist operate as bandwidth or device alternatives, the alternates also serve as failure fallbacks. If the player cannot reload the media playlist file—due to issues such as 404 errors, server crashing, or a content distributor node problem—the player attempts to switch to another compatible media playlist provided on a different server. Offering multiple media playlists with the same bandwidth, the player switches to an identical playlist, providing consistent stream performance.

不仅在您的主列表 做交替媒体播放列表操作带宽或设备替换,候补也可作为故障回退。 如果玩家不能重新加载媒体播放列表文件 - 由于比如 404 errors 问题,服务器崩溃或内容分发节点问题 - 播放器试图切换到不同的服务器上的另一个兼容的媒体播放列表。使用相同的带宽提供多个媒体播放列表,播放器切换到相同播放列表,提供一致的数据流性能。

Timed Metadata - 定时的元数据

You can add various kinds of metadata to media stream segments. The data offers applications additional information during playback. For example, add the album art, artist’s name, and song title to an audio stream, or add the current batter’s name and statistics to video of a baseball game.

你可以将各种元数据添加到媒体流段。在播放过程中,数据为应用程序提供更多的信息。例如,专辑封面,艺术家的名字和歌曲标题添加到音频流,或者添加当前击球手的名字和统计棒球比赛的视频。

You insert the additional data, known as timed metadata, into a media stream at a given time offset. (Optionally, insert timed metadata into all segments after a given time.)

插入附加的数据,被称为定时元数据,变成了媒体流在给定的时间偏移。(任选地,插入定时元数据到给定的时间之后的所有段)

For more information on timed metadata, read Timed Metadata for HTTP Live Streaming.

有关定时元数据的详细信息,请阅读 Timed Metadata for HTTP Live Streaming

Ad Insertion - 广告插入

HLS facilitates ad insertion through discontinuity markers. The markers within playlists smooth transitions between disparate content.

HLS通过不连续的标记有利于广告插播。 播放列表中的标记不同的平滑内容之间的转换。

For more on discontinuities, read Example Playlist Files for use with HTTP Live Streaming.

欲了解更多有关不连续性的信息,阅读 Example Playlist Files for use with HTTP Live Streaming

Content Protection - 内容保护

Media segments can be individually encrypted using sample-level encryption. References to the corresponding key files appear in the playlist file so that the player can retrieve the keys for decryption.

媒体片段可以用样品级加密进行单独加密。到相应的密钥文件的引用出现在播放列表文件,使得播放器可以检索密钥用于解密。

HLS supports key exchange with the method of your choice. Static keys, encoder generated keys, and frequently updated keys are just a few of the possibilities.

HLS支持与您所选择方法的密钥交换。 静态密钥,编码器生成密钥,并且经常更新的密钥只有少数可能性。

For detail on the sample-level encryption specified for use with HLS, read MPEG-2 Stream Encryption Format for HTTP Live Streaming.

有关与HLS使用指定的样品级加密的细节,读 MPEG-2 Stream Encryption Format for HTTP Live Streaming

For details on serving keys, see How to securely serve Key files for HTTP Live Streaming with HTTPS.

有关服务密钥的详细信息,请参阅 How to securely serve Key files for HTTP Live Streaming with HTTPS

Requirements for iOS Apps - 对于iOS应用需求

The following requirements apply to iOS apps submitted for distribution in the App Store for use on Apple products. Noncompliant apps may be rejected or removed, at the discretion of Apple.

  • If your app delivers video over cellular networks, and the video exceeds either 10 minutes or 5 MB of data in a five-minute period, you must use HLS. You can use - progressive download for smaller clips.
  • If your app uses HLS over cellular networks, you must provide at least one stream at 192 Kbps or lower bandwidth. The low-bandwidth stream may be audio-only or audio with a still image.

以下要求适用于在App Store提交分发上使用苹果产品的iOS应用。苹果公司的决定,不符合要求的应用程序可能会被拒绝或删除。

  • 如果您的应用程序提供蜂窝网络视频,超过10分钟的视频或者在5分钟以内的 5MB 数据,必须使用HLS。你可以使用渐进式下载更小的片段。
  • 如果应用程序使用HLS蜂窝网络,则必须在192 Kbps或更低的带宽提供至少一个流。低带宽流可以是仅音频或音频与静止图像。

Sample Streams - 样品流

A series of HTTP streams are available for testing on Apple’s developer site. These examples show proper formatting of HTML to embed streams, .m3u8 playlists to index the streams, and .ts media segment files. See the HTTP Live Streaming page.

一系列的HTTP流可用于苹果的开发者网站的测试。 这些例子显示HTML嵌入数据流格式,.m3u8 播放列表索引流,.ts 媒体段文件。见 HTTP Live Streaming page

Apple provides simplified command-line tools, such as the Media File Segmenter and Media Stream Segmenter, to divide presentations and produce playlist files. Sign in with your developer ID and visit the HTTP Live Streaming page, under “Downloads.”

苹果提供了简化的命令行工具,如Media File SegmenterMedia Stream Segmenter ,拆分演示和产生的播放列表文件。使用您的开发者ID,访问 HTTP Live Streaming page 在“下载”。

Use the Apple-provided media stream validator found in these downloaded tools prior to serving your streams, to ensure that they are fully compliant with HLS.

使用苹果提供的媒体流验证器在这些下载工具发现为你流之前,确保他们完全符合HLS。

Getting Started with HLS - 开始使用HLS

To get started with your own HLS streams, the HTTP Live Streaming Content Guide provides a simple walkthrough of basic stream creation. The guide also explains complex HLS concepts, how to implement advanced features, and requirements for streaming to iOS devices.

要开始使用自己的HLS流,HTTP Live Streaming Content Guide 提供基本流创建的一个简单演练。该指南还说明了复杂的HLS的概念,如何实现先进的功能,并要求分流到iOS设备。

Read the HTTP Live Streaming specification for current and definitive technical information.

阅读 HTTP Live Streaming specification 这是当前权威的技术资料。

HLS Feature Release History - HLS功能发布历史



文章目录
  1. 1. About HTTP Live Streaming - HTTP实时流
    1. 1.1. HLS Workflow - HLS 工作流
    2. 1.2. Media Segments - 媒体片段
    3. 1.3. Media Playlist Files - 媒体播放列表文件
    4. 1.4. Live and Event Media Playlists - 实时和事件媒体播放列表
    5. 1.5. VOD Media Playlists - VOD媒体播放列表
    6. 1.6. Master Playlists - 主播放列表
    7. 1.7. Publishing Your HLS Streams - 发布HLS流
    8. 1.8. Key Features - 主要特征
      1. 1.8.1. Closed Captions and Subtitles - 隐藏式字幕和字幕
      2. 1.8.2. Fast Forward and Reverse Playback - 快进和快退播放
      3. 1.8.3. Alternate Audio and Video Renditions - 备用音频和视频副本
      4. 1.8.4. Fallback with Stream Alternates - 流交替回退
      5. 1.8.5. Timed Metadata - 定时的元数据
      6. 1.8.6. Ad Insertion - 广告插入
      7. 1.8.7. Content Protection - 内容保护
    9. 1.9. Requirements for iOS Apps - 对于iOS应用需求
    10. 1.10. Sample Streams - 样品流
    11. 1.11. Getting Started with HLS - 开始使用HLS
    12. 1.12. HLS Feature Release History - HLS功能发布历史