使用媒体服务实时传送视频流概述Overview of Live Streaming using Media Services


使用 Azure 媒体服务传递实时流式处理事件时,通常涉及以下组件:When delivering live streaming events with Azure Media Services the following components are commonly involved:

  • 一个用于广播事件的相机。A camera that is used to broadcast an event.

  • 一个将信号从相机转换为发送至实时流式处理服务的流的实时视频编码器。A live video encoder that converts signals from the camera to streams that are sent to a live streaming service.

    (可选)多个实时同步编码器。Optionally, multiple live time synchronized encoders. 对于某些需要高可用性与优质体验的重要实时事件,建议使用带时间同步功能的主动-主动冗余编码器,以实现无缝故障转移,且不会丢失数据。For certain critical live events that demand very high availability and quality of experience, it is recommended to employ active-active redundant encoders with time synchronization to achieve seamless failover with no data loss.

  • 实时流式处理服务允许执行以下操作:A live streaming service that enables you to do the following:

    • 使用多种实时传送视频流协议(例如 RTMP 或平滑流式处理)引入实时内容ingest live content using various live streaming protocols (for example RTMP or Smooth Streaming),
    • (可选)将流编码为自适应比特率流(optionally) encode your stream into adaptive bitrate stream
    • 预览实时流,preview your live stream,
    • 记录和存储引入的内容,以便稍后进行流式处理(视频点播)record and store the ingested content in order to be streamed later (Video-on-Demand)
    • 直接通过常用流式处理协议(例如 MPEG DASH、Smooth、HLS)将内容传递给客户,或传递到内容分发网络 (CDN) 以供进一步分发。deliver the content through common streaming protocols (for example, MPEG DASH, Smooth, HLS) directly to your customers, or to a Content Delivery Network (CDN) for further distribution.

Azure 媒体服务 (AMS) 提供了引入、编码、预览、存储和实时传送视频流内容的功能 。Azure Media Services (AMS) provides the ability to ingest, encode, preview, store, and deliver your live streaming content.

借助媒体服务,可以利用动态打包,以便广播正在发送到服务的贡献源中采用 MPEG DASH、HLS 和平滑流式处理格式的实时传送流。With Media Services, you can take advantage of dynamic packaging, which allows you to broadcast your live streams in MPEG DASH, HLS, and Smooth Streaming formats from the contribution feed that is being sent to the service. 观看者可以使用任何与 HLS、DASH 或平滑流式处理兼容的播放器播放实时流。Your viewers can play back the live stream with any HLS, DASH, or Smooth Streaming compatible players. 可以使用 Web 应用程序或移动应用程序中的 Azure Media Player 传送采用上述任何协议的流。You can use Azure Media Player in your web or mobile applications to deliver your stream in any of these protocols.


自 2018 年 5 月 12 日起,实时频道将不再支持 RTP/MPEG-2 传输流引入协议。Starting May 12, 2018, live channels will no longer support the RTP/MPEG-2 transport stream ingest protocol. 请从 RTP/MPEG-2 迁移到 RTMP 或分段 MP4(平滑流式处理)引入协议。Please migrate from RTP/MPEG-2 to RTMP or fragmented MP4 (Smooth Streaming) ingest protocols.

流式处理终结点、频道、节目Streaming Endpoints, Channels, Programs

在 Azure 媒体服务中,“频道”、“程序”和“流式处理终结点”处理所有实时传送视频流功能,包括引入、格式化、DVR、安全性、可伸缩性和冗余 。In Azure Media Services, Channels, Programs, and StreamingEndpoints handle all the live streaming functionalities including ingest, formatting, DVR, security, scalability and redundancy.

通道 表示用于处理实时流内容的管道。A Channel represents a pipeline for processing live streaming content. 通道可以通过以下方式接收实时输入流:A Channel can receive a live input streams in the following ways:

  • 本地实时编码器将多比特率 RTMP 或平滑流式处理(零碎的 MP4)发送到经配置可以进行直通传送的频道 。An on-premises live encoder sends multi-bitrate RTMP or Smooth Streaming (fragmented MP4) to the Channel that is configured for pass-through delivery. 直通传送是指引入的流将会直接通过频道,而不会经过任何进一步的处理 。The pass-through delivery is when the ingested streams pass through Channels without any further processing. 可以使用以下输出多比特率平滑流的实时编码器:MediaExcel、Ateme、Imagine Communications、Envivio、Cisco 和 Elemental。You can use the following live encoders that output multi-bitrate Smooth Streaming: MediaExcel, Ateme, Imagine Communications, Envivio, Cisco and Elemental. 以下实时编码器输出 RTMP:Adobe Flash Media Live Encoder (FMLE)、Telestream Wirecast、Haivision、Teradek 和 Tricaster 转码器。The following live encoders output RTMP: Adobe Flash Media Live Encoder (FMLE), Telestream Wirecast, Haivision, Teradek and Tricaster transcoders. 实时编码器也可将单比特率流发送到并未启用实时编码的通道,但不建议这样做。A live encoder can also send a single bitrate stream to a channel that is not enabled for live encoding, but that is not recommended. 收到请求时,媒体服务会将该流传送给客户。When requested, Media Services delivers the stream to customers.


    需要长时间处理多个事件,并且已经在本地编码器上进行了投入时,可以使用直通这种最经济的方法来实时传送视频流。Using a pass-through method is the most economical way to do live streaming when you are doing multiple events over a long period of time, and you have already invested in on-premises encoders. 请参阅定价详细信息。See pricing details.

  • 本地实时编码器采用以下格式之一将单比特率流发送至能够使用媒体服务执行实时编码的频道:RTMP 或平滑流式处理(分片 MP4)。An on-premises live encoder sends a single-bitrate stream to the Channel that is enabled to perform live encoding with Media Services in one of the following formats: RTMP or Smooth Streaming (fragmented MP4). 已知下列具有 RTMP 输出的实时编码器可使用此类型的通道:Telestream Wirecast、FMLE。The following live encoders with RTMP output are known to work with channels of this type: Telestream Wirecast, FMLE. 然后,频道将对传入的单比特率流执行实时编码,使之转换为多比特率(自适应)视频流。The Channel then performs live encoding of the incoming single bitrate stream to a multi-bitrate (adaptive) video stream. 收到请求时,媒体服务会将该流传送给客户。When requested, Media Services delivers the stream to customers.

从媒体服务2.10 发行版开始,创建通道时,可以指定希望通道接收输入流的方式,以及是否希望通道对流执行实时编码。Starting with the Media Services 2.10 release, when you create a Channel, you can specify in which way you want for your channel to receive the input stream and whether or not you want for the channel to perform live encoding of your stream. 可以使用两个选项:You have two options:

  • 无(直通) - 如果打算使用输出多比特率流(直通流)的本地实时编码器,请指定此值 。None (pass-through) – Specify this value, if you plan to use an on-premises live encoder which will output multi-bitrate stream (a pass-through stream). 在这种情况下,传入流将传递到输出,而不会进行任何编码。In this case, the incoming stream passed through to the output without any encoding. 这是 2.10 发行版以前的通道行为。This is the behavior of a Channel prior to 2.10 release.
  • 标准 - 如果打算使用媒体服务将单比特率实时流编码为多比特率流,请选择此值。Standard – Choose this value, if you plan to use Media Services to encode your single bitrate live stream to multi-bitrate stream. 若要针对不频繁发生的事件快速地向上缩放,此方法可以节省资金。This method is more economical for scaling up quickly for infrequent events. 请注意,实时编码会影响计费,应记住,将实时编码频道保持为“正在运行”状态会产生费用。Be aware that there is a billing impact for live encoding and you should remember that leaving a live encoding channel in the "Running" state will incur billing charges. 建议在实时流式处理事件完成之后立即停止正在运行的通道,以避免产生额外的小时费用。It is recommended that you immediately stop your running channels after your live streaming event is complete to avoid extra hourly charges.

通道类型的比较Comparison of Channel Types

可通过下表来了解媒体服务中支持的两种通道类型的比较情况Following table provides a guide to comparing the two Channel types supported in Media Services

功能Feature 直通通道Pass-through Channel 标准通道Standard Channel
单比特率输入在云中被编码为多比特率Single bitrate input is encoded into multiple bitrates in the cloud No Yes
最大分辨率,层数Maximum resolution, number of layers 1080p,8 层,60+fps1080p, 8 layers, 60+fps 720p,6 层,30 fps720p, 6 layers, 30 fps
输入协议Input protocols RTMP、平滑流RTMP, Smooth Streaming RTMP、平滑流RTMP, Smooth Streaming
价格Price 请参阅定价页并单击“实时视频”选项卡See the pricing page and click on "Live Video" tab 请参阅定价页See the pricing page
最长运行时间Maximum run time 全天候运行24x7 8 小时8 hours
支持插入静态图像Support for inserting slates No Yes
支持发出广告指示Support for ad signaling No Yes
直通 CEA 608/708 字幕Pass-through CEA 608/708 captions Yes Yes
支持非一致性输入 GOPSupport for non-uniform input GOPs Yes 否 - 输入必须是固定的 2 秒 GOPNo – input must be fixed 2sec GOPs
支持可变帧率输入Support for variable frame rate input Yes 否 - 输入必须是固定的帧速率。No – input must be fixed frame rate.
轻微的帧率变化是容许的,例如在高速运动情况下出现的轻微帧率变化。Minor variations are tolerated, for example, during high motion scenes. 但是,编码器不能掉到 10 帧/秒的帧率。But encoder cannot drop to 10 frames/sec.
输入源丢失时,自动关闭通道Auto-shutoff of Channels when input feed is lost No 12 小时后,如果没有运行的程序After 12 hours, if there is no Program running

使用从本地编码器(直通)接收多比特率实时流的频道Working with Channels that receive multi-bitrate live stream from on-premises encoders (pass-through)

下图显示的是直通工作流中涉及的 AMS 平台的主要组成部分。The following diagram shows the major parts of the AMS platform that are involved in the pass-through workflow.


有关详细信息,请参阅 使用从本地编码器接收多比特率实时流的频道For more information, see Working with Channels that Receive Multi-bitrate Live Stream from On-premises Encoders.

使用能够通过 Azure 媒体服务执行实时编码的通道Working with Channels that are enabled to perform live encoding with Azure Media Services

下图显示的是实时流式处理工作流中涉及的 AMS 平台的主要组成部分,该工作流中的频道能够通过媒体服务执行实时编码。The following diagram shows the major parts of the AMS platform that are involved in Live Streaming workflow where a Channel is enabled to perform live encoding with Media Services.


有关详细信息,请参阅使用能够通过 Azure 媒体服务执行实时编码的频道For more information, see Working with Channels that are Enabled to Perform Live Encoding with Azure Media Services.


在媒体服务中,频道负责处理实时传送视频流内容。In Media Services, Channels are responsible for processing live streaming content. 通道提供输入终结点(引入 URL),并将该终结点提供给实时转码器。A Channel provides an input endpoint (ingest URL) that you then provide to a live transcoder. 频道从实时转码器接收实时输入流,并通过一个或多个 StreamingEndpoints 使其可用于流式处理。The channel receives live input streams from the live transcoder and makes it available for streaming through one or more StreamingEndpoints. 频道还提供可用于预览的预览终结点(预览 URL),并在进一步处理和传递流之前对流进行验证。Channels also provide a preview endpoint (preview URL) that you use to preview and validate your stream before further processing and delivery.

可以在创建频道时获取引入 URL 和预览 URL。You can get the ingest URL and the preview URL when you create the channel. 若要获取这些 URL,频道不一定要处于已启动状态。To get these URLs, the channel does not have to be in the started state. 准备好开始将数据从实时转码器推送到频道时,频道必须已启动。When you are ready to start pushing data from a live transcoder into the channel, the channel must be started. 实时转码器开始引入数据后,可以预览流。Once the live transcoder starts ingesting data, you can preview your stream.

每个媒体服务帐户均可包含多个频道、多个节目以及多个 StreamingEndpoint。Each Media Services account can contain multiple Channels, multiple Programs, and multiple StreamingEndpoints. 根据带宽和安全性需求,StreamingEndpoint 服务可专用于一个或多个频道。Depending on the bandwidth and security needs, StreamingEndpoint services can be dedicated to one or more channels. 任何 StreamingEndpoint 都可以从任何通道拉取。Any StreamingEndpoint can pull from any Channel.

创建通道时,可以使用以下格式之一指定允许的 IP 地址:具有 4 个数字、CIDR 地址范围的 IpV4 地址。When creating a Channel, you can specify allowed IP addresses in one of the following formats: IpV4 address with 4 numbers, CIDR address range.


节目 用于控制实时流中片段的发布和存储。A Program enables you to control the publishing and storage of segments in a live stream. 频道管理节目。Channels manage Programs. 频道和节目的关系非常类似于传统媒体,频道具有恒定的内容流,而节目的范围限定为该频道上的一些定时事件。The Channel and Program relationship is very similar to traditional media where a channel has a constant stream of content and a program is scoped to some timed event on that channel. 可以通过设置 ArchiveWindowLength 属性,指定希望保留多少小时的节目录制内容。You can specify the number of hours you want to retain the recorded content for the program by setting the ArchiveWindowLength property. 此值的设置范围是最短 5 分钟,最长 25 小时。This value can be set from a minimum of 5 minutes to a maximum of 25 hours.

ArchiveWindowLength 还决定了客户端能够从当前实时位置按时间向后搜索的最长时间。ArchiveWindowLength also dictates the maximum amount of time clients can seek back in time from the current live position. 超出指定时间长度后,节目也能够运行,但落在时段长度后面的内容会全部被丢弃。Programs can run over the specified amount of time, but content that falls behind the window length is continuously discarded. 此属性的这个值还决定了客户端清单能够增加多长时间。This value of this property also determines how long the client manifests can grow.

每个节目都与资产关联。Each program is associated with an Asset. 若要发布节目,必须为关联的资产创建定位符。To publish the program you must create a locator for the associated asset. 创建此定位符后,可以生成提供给客户端的流式处理 URL。Having this locator will enable you to build a streaming URL that you can provide to your clients.

一个频道最多支持三个同时运行的节目,因此可为同一传入流创建多个存档。A channel supports up to three concurrently running programs so you can create multiple archives of the same incoming stream. 这样,便可以根据需要发布和存档事件的不同部分。This allows you to publish and archive different parts of an event as needed. 例如,业务要求是存档 6 小时的节目,但只广播过去 10 分钟的内容。For example, your business requirement is to archive 6 hours of a program, but to broadcast only last 10 minutes. 为了实现此目的,需要创建两个同时运行的节目。To accomplish this, you need to create two concurrently running programs. 一个节目设置为存档 6 小时的事件但不发布该节目。One program is set to archive 6 hours of the event but the program is not published. 另一个节目设置为存档 10 分钟的事件,并且要发布该节目。The other program is set to archive for 10 minutes and this program is published.

计费影响Billing Implications

一旦通过 API 将频道的状态转换为“正在运行”,就会开始计费。A channel begins billing as soon as it's state transitions to "Running" via the API.

下表显示了频道状态如何映射到 API 和 Azure 门户中的计费状态。The following table shows how Channel states map to billing states in the API and Azure portal. 请注意,API 与门户 UX 之间的状态略有不同。Note that the states are slightly different between the API and Portal UX. 一旦通过 API 将频道置于“正在运行”状态,或者在 Azure 门户中将其设置为“就绪”或“正在流式处理”状态,就会开始计费。As soon as a channel is in the "Running" state via the API, or in the "Ready" or "Streaming" state in the Azure portal, billing will be active.

若要阻止通道进一步计费,必须通过 API 或 Azure 门户停止通道。To stop the Channel from billing you further, you have to Stop the Channel via the API or in the Azure portal. 使用完通道后,需要亲自停止通道。You are responsible for stopping your channels when you are done with the channel. 不停止通道会导致持续计费。Failure to stop the channel will result in continued billing.


使用“标准”通道时,AMS 会自动关闭输入源丢失 12 小时后仍处于“正在运行”状态但没有程序运行的任何通道。When working with Standard channels, AMS will auto shutoff any Channel that is still in “Running” state 12 hours after the input feed is lost, and there are no Programs running. 但是,在频道处于“正在运行”状态的时间段内,仍会向你收费。However, you will still be billed for the time the Channel was in “Running” state.

通道状态及其如何映射到计费模式Channel states and how they map to the billing mode

通道的当前状态。The current state of a Channel. 可能的值包括:Possible values include:

  • 已停止Stopped. 这是通道在创建后的初始状态(除非在门户中选择了自动启动)。此状态下不会发生计费。This is the initial state of the Channel after its creation (unless autostart was selected in the portal.) No billing occurs in this state. 此状态下可以更新通道属性,但不允许进行流式传输。In this state, the Channel properties can be updated but streaming is not allowed.
  • 正在启动Starting. 通道正在启动。The Channel is being started. 此状态下不会发生计费。No billing occurs in this state. 此状态下不允许进行更新或流式传输。No updates or streaming is allowed during this state. 如果发生错误,通道会返回到“已停止”状态。If an error occurs, the Channel returns to the Stopped state.
  • 正在运行Running. 通道能够处理实时流。The Channel is capable of processing live streams. 现在会计收使用费。It is now billing usage. 必须停止通道以防止进一步计费。You must stop the channel to prevent further billing.
  • 正在停止Stopping. 通道正在停止。The Channel is being stopped. 此暂时性状态下不会发生计费。No billing occurs in this transient state. 此状态下不允许进行更新或流式传输。No updates or streaming is allowed during this state.
  • 正在删除Deleting. 频道正被删除。The Channel is being deleted. 此暂时性状态下不会发生计费。No billing occurs in this transient state. 此状态下不允许进行更新或流式传输。No updates or streaming is allowed during this state.

下表显示通道状态如何映射到计费模式。The following table shows how Channel states map to the billing mode.

通道状态Channel state 门户 UI 指示器Portal UI Indicators 是否计费?Is it Billing?
正在启动Starting 正在启动Starting 否(暂时状态)No (transient state)
正在运行Running 准备就绪(没有正在运行的节目)Ready (no running programs)
流式处理(至少有一个正在运行的节目)Streaming (at least one running program)
正在停止Stopping 正在停止Stopping 否(暂时状态)No (transient state)
已停止Stopped 已停止Stopped No

Azure 媒体服务分片 MP4 实时引入规范Azure Media Services Fragmented MP4 Live Ingest Specification

使用能够通过 Azure 媒体服务执行实时编码的频道Working with Channels that are Enabled to Perform Live Encoding with Azure Media Services

使用从本地编码器接收多比特率实时流的频道Working with Channels that Receive Multi-bitrate Live Stream from On-premises Encoders

配额和限制Quotas and limitations.

媒体服务概念Media Services Concepts