使用 Azure 媒体服务执行实时流式处理以创建多比特率流Live streaming using Azure Media Services to create multi-bitrate streams

Note

自 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.

概述Overview

在 Azure 媒体服务 (AMS) 中,频道表示用于处理实时传送视频流内容的管道 。In Azure Media Services (AMS), a Channel represents a pipeline for processing live streaming content. 通道 采用以下两种方式之一接收实时输入流:A Channel receives live input streams in one of two ways:

  • 本地实时编码器采用以下格式之一将单比特率流发送至能够使用媒体服务执行实时编码的频道: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). 然后,频道将对传入的单比特率流执行实时编码,使之转换为多比特率(自适应)视频流。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.

  • 本地实时编码器将多比特率 RTMP 或平滑流式处理(分片 MP4)发送到无法通过 AMS 进行实时编码的频道 。An on-premises live encoder sends a multi-bitrate RTMP or Smooth Streaming (Fragmented MP4) to the Channel that is not enabled to perform live encoding with AMS. 引入流会通过 “通道” ,但不会进行任何进一步处理。The ingested streams pass through Channels without any further processing. 这种方法称为 直通This method is called pass-through. 可以使用以下输出多比特率平滑流的实时编码器: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:Telestream Wirecast、Haivision、Teradek 和 Tricaster 编码器。The following live encoders output RTMP: Telestream Wirecast, Haivision, Teradek and Tricaster encoders. 实时编码器也可将单比特率流发送到并未启用实时编码的通道,但不建议这样做。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.

    Note

    实时传送视频流时,使用直通方法是最经济的。Using a pass-through method is the most economical way to do live streaming.

从媒体服务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 – 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. 有关使用此类型频道的详细信息,请参阅使用创建多比特率流的本地编码器执行实时传送视频流For more detailed information about working with channels of this type, see Live streaming with on-premises encoders that create multi-bitrate streams.
  • 标准 - 如果打算使用媒体服务将单比特率实时流编码为多比特率流,请选择此值。Standard – Choose this value, if you plan to use Media Services to encode your single bitrate live stream to multi-bitrate stream. 请注意,实时编码会影响计费,应记住,将实时编码通道保持为“正在运行”状态会产生费用。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.

Note

本主题讨论为执行实时编码(标准编码类型)启用的频道的属性 。This topic discusses attributes of channels that are enabled to perform live encoding (Standard encoding type). 若要了解如何使用无法执行实时编码的频道,请参阅使用创建多比特率流的本地编码器执行实时传送视频流For information about working with channels that are not enabled to perform live encoding, see Live streaming with on-premises encoders that create multi-bitrate streams.

请务必仔细阅读 注意事项 部分。Make sure to review the Considerations section.

计费影响Billing Implications

一旦通过 API 将实时编码通道的状态转换为“正在运行”,就会开始计费。A live encoding channel begins billing as soon as it's state transitions to "Running" via the API. 也可以在 Azure 门户或 Azure 媒体服务资源管理器工具 (https://aka.ms/amse) 中查看状态。You can also view the state in the Azure portal, or in the Azure Media Services Explorer tool (https://aka.ms/amse).

下表显示了通道状态如何映射到 API 和 Azure 门户中的计费状态。The following table shows how Channel states map to billing states in the API and Azure portal. API 与门户 UX 之间的状态略有不同。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 live encoding channel. 不停止编码通道会导致持续计费。Failure to stop an encoding channel will result in continued billing.

通道状态及其如何映射到计费模式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)
or
流式处理(至少有一个正在运行的节目)Streaming (at least one running program)
YES
正在停止Stopping 正在停止Stopping 否(暂时状态)No (transient state)
已停止Stopped 已停止Stopped No

自动关闭未使用的通道Automatic shut-off for unused Channels

从 2016 年 1 月 25 日开始,媒体服务推出了一项更新,对于长时间以未使用状态运行的通道,它会自动停止该通道(已启用实时编码)。Starting with January 25, 2016, Media Services rolled out an update that automatically stops a Channel (with live encoding enabled) after it has been running in an unused state for a long period. 这适用于没有活动节目且长时间未收到输入贡献源的通道。This applies to Channels that have no active Programs, and which have not received an input contribution feed for an extended period of time.

未使用期限的阈值通常为 12 个小时,但随时会变化。The threshold for an unused period is nominally 12 hours, but is subject to change.

实时编码工作流Live Encoding Workflow

下图呈现了实时流式处理工作流,其中频道通过以下协议之一接收单比特率流:RTMP 或平滑流式处理;然后,将该流编码为多比特率流。The following diagram represents a live streaming workflow where a channel receives a single bitrate stream in one of the following protocols: RTMP or Smooth Streaming; it then encodes the stream to a multi-bitrate stream.

实时工作流

常见的实时流处理方案Common Live Streaming Scenario

以下是创建常见的实时流应用程序时涉及的常规步骤。The following are general steps involved in creating common live streaming applications.

Note

目前,直播活动的最大建议持续时间为 8 小时。Currently, the max recommended duration of a live event is 8 hours.

实时编码会影响计费,应该记住,将实时编码通道保持为“正在运行”状态会产生按小时计算的费用。There is a billing impact for live encoding and you should remember that leaving a live encoding channel in the "Running" state will incur hourly billing charges. 建议在实时流式处理事件完成之后立即停止正在运行的通道,以避免产生额外的小时费用。It is recommended that you immediately stop your running channels after your live streaming event is complete to avoid extra hourly charges.

  1. 将视频摄像机连接到计算机。Connect a video camera to a computer. 启动并配置一个可通过以下协议之一输出 单比特率流的本地实时编码器:RTMP 或平滑流式处理。Launch and configure an on-premises live encoder that can output a single bitrate stream in one of the following protocols: RTMP or Smooth Streaming.

    此步骤也可以在创建频道后执行。This step could also be performed after you create your Channel.

  2. 创建并启动通道。Create and start a Channel.

  3. 检索通道引入 URL。Retrieve the Channel ingest URL.

    实时编码器使用引入 URL 将流发送到频道。The ingest URL is used by the live encoder to send the stream to the Channel.

  4. 检索频道预览 URL。Retrieve the Channel preview URL.

    使用此 URL 来验证频道是否正常接收实时流。Use this URL to verify that your channel is properly receiving the live stream.

  5. 创建节目。Create a program.

    使用 Azure 门户时,创建节目的同时还会创建资产。When using the Azure portal, creating a program also creates an asset.

    使用 .NET SDK 或 REST 时,需要创建一个资源并指定在创建节目时要使用该资源。When using .NET SDK or REST you need to create an asset and specify to use this asset when creating a Program.

  6. 发布与节目关联的资源。Publish the asset associated with the program.

    Note

    创建 AMS 帐户后,会将一个处于“已停止”状态的默认流式处理终结点添加到帐户。 When your AMS account is created a default streaming endpoint is added to your account in the Stopped state. 要从中流式传输内容的流式处理终结点必须处于“正在运行”状态。 The streaming endpoint from which you want to stream content has to be in the Running state.

  7. 准备好开始流式传输和存档后,启动节目。Start the program when you are ready to start streaming and archiving.

  8. (可选)可以向实时编码器发信号,以启动广告。Optionally, the live encoder can be signaled to start an advertisement. 将广告插入到输出流中。The advertisement is inserted in the output stream.

  9. 要停止对事件进行流式传输和存档时,停止节目。Stop the program whenever you want to stop streaming and archiving the event.

  10. 删除节目(并选择性地删除资产)。Delete the Program (and optionally delete the asset).

Note

千万不要忘记停止实时编码通道。It is very important not to forget to Stop a Live Encoding Channel. 请注意,实时编码会影响每小时计费,应记住,将实时编码通道保持为“正在运行”状态会产生费用。Be aware that there is an hourly 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.

频道输入(引入)配置Channel's input (ingest) configurations

引入流式传输协议Ingest streaming protocol

如果“编码器类型”设为“标准”,则有效选项为 :If the Encoder Type is set to Standard, valid options are:

  • 单比特率 RTMPSingle bitrate RTMP
  • 单比特率分片 MP4(平滑流式处理) Single bitrate Fragmented MP4 (Smooth Streaming)

单比特率 RTMPSingle bitrate RTMP

注意事项:Considerations:

  • 传入流不能包含多码率视频The incoming stream cannot contain multi-bitrate video
  • 视频流应具有小于 15 Mbps 的平均比特率The video stream should have an average bitrate below 15 Mbps
  • 音频流应具有小于 1 Mbps 的平均比特率The audio stream should have an average bitrate below 1 Mbps
  • 以下是支持的编解码器:Following are the supported codecs:
  • MPEG-4 AVC/H.264 VideoMPEG-4 AVC / H.264 Video
  • Baseline、Main、High Profile(8 位 4:2:0)Baseline, Main, High Profile (8-bit 4:2:0)
  • High 10 Profile(10 位 4:2:0)High 10 Profile (10-bit 4:2:0)
  • High 422 Profile(10 位 4:2:2)High 422 Profile (10-bit 4:2:2)
  • MPEG-2 AAC-LC AudioMPEG-2 AAC-LC Audio
  • Mono、Stereo、Surround (5.1, 7.1)Mono, Stereo, Surround (5.1, 7.1)
  • 44.1 kHz 采样率44.1 kHz sampling rate
  • MPEG-2 样式 ADTS 打包MPEG-2 style ADTS packaging
  • 推荐的编码器包括:Recommended encoders include:
  • Telestream WirecastTelestream Wirecast
  • Flash 媒体实时编码器Flash Media Live Encoder

单比特率分片 MP4(平滑流式处理)Single bitrate Fragmented MP4 (Smooth Streaming)

典型用例:Typical use case:

使用供应商提供的本地实时编码器(如 Elemental Technologies、Ericsson、Ateme、Envivio)通过开放的 Internet 将输入流发送到附近的 Azure 数据中心。Use on-premises live encoders from vendors like Elemental Technologies, Ericsson, Ateme, Envivio to send the input stream over the open internet to a nearby Azure data center.

注意事项:Considerations:

这同样适用于单比特率 RTMPSame as for single bitrate RTMP.

其他注意事项Other considerations

  • 通道或其关联的节目正在运行时,无法更改输入协议。You cannot change the input protocol while the Channel or its associated programs are running. 如果需要不同的协议,应当针对每个输入协议创建单独的频道。If you require different protocols, you should create separate channels for each input protocol.
  • 传入视频流的最大分辨率为 1920 x 1080,如果隔行扫描,速率最大为 60 个字段/秒,如果渐进式下载,则速度为 30 帧/秒。Maximum resolution for the incoming video stream is 1920x1080, and at most 60 fields/second if interlaced, or 30 frames/second if progressive.

摄取 URL(终结点)Ingest URLs (endpoints)

频道提供用户在实时编码器中指定的输入终结点(引入 URL),因此编码器可以将流推送到用户的频道。A Channel provides an input endpoint (ingest URL) that you specify in the live encoder, so the encoder can push streams to your Channels.

创建通道后,可以获得引入 URL。You can get the ingest URLs once you create a Channel. 若要获取这些 URL,通道不一定要处于“正在运行” 状态。To get these URLs, the Channel does not have to be in the Running state. 准备好开始将数据推送到通道时,通道必须处于“正在运行” 状态。When you are ready to start pushing data into the Channel, it must be in the Running state. 通道开始引入数据后,可通过预览 URL 来预览流。Once the Channel starts ingesting data, you can preview your stream through the preview URL.

可以选择通过 TLS 连接引入分片 MP4(平滑流式处理)实时流。You have an option of ingesting Fragmented MP4 (Smooth Streaming) live stream over an TLS connection. 要通过 TLS 进行引入,请确保将引入 URL 更新为 HTTPS。To ingest over TLS, make sure to update the ingest URL to HTTPS. 目前,AMS 对自定义域不支持 TLS。Currently, AMS doesn’t support TLS with custom domains.

允许的 IP 地址Allowed IP addresses

可以定义允许向此通道发布视频的 IP 地址。You can define the IP addresses that are allowed to publish video to this channel. 允许的 IP 地址可以指定为单个 IP 地址(例如“10.0.0.1”)、使用一个 IP 地址和 CIDR 子网掩码的 IP 范围(例如“10.0.0.1/22”)或使用一个 IP 地址和点分十进制子网掩码的 IP 范围(例如“10.0.0.1(255.255.252.0)”)。Allowed IP addresses can be specified as either a single IP address (for example, '10.0.0.1'), an IP range using an IP address and a CIDR subnet mask (for example, ‘10.0.0.1/22’), or an IP range using an IP address and a dotted decimal subnet mask (for example, '10.0.0.1(255.255.252.0)').

如果未指定 IP 地址并且没有规则定义,则不会允许任何 IP 地址。If no IP addresses are specified and there is no rule definition then no IP address will be allowed. 若要允许任何 IP 地址,请创建规则并设置 0.0.0.0/0。To allow any IP address, create a rule and set 0.0.0.0/0.

通道预览Channel preview

预览 URLPreview URLs

通道还提供了一个预览终结点(预览 URL),可使用它在进一步处理和传递流之前预览流并对其进行验证。Channels provide a preview endpoint (preview URL) that you use to preview and validate your stream before further processing and delivery.

可以在创建频道时获取预览 URL。You can get the preview URL when you create the channel. 若要获取该 URL,通道不一定要处于“正在运行” 状态。To get the URL, the channel does not have to be in the Running state.

通道开始摄取数据后,可以预览流。Once the Channel starts ingesting data, you can preview your stream.

Note

当前,不管指定了哪种输入类型,都只能以分片 MP4(平滑流式处理)格式来传送预览流。Currently the preview stream can only be delivered in Fragmented MP4 (Smooth Streaming) format regardless of the specified input type. 可以使用 Azure 门户中托管的播放器来查看流。You can use a player hosted in the Azure portal to view your stream.

允许的 IP 地址Allowed IP Addresses

可以定义允许连接到预览终结点的 IP 地址。You can define the IP addresses that are allowed to connect to the preview endpoint. 如果未指定 IP 地址,则允许任何 IP 地址。If no IP addresses are specified any IP address will be allowed. 允许的 IP 地址可以指定为单个 IP 地址(例如“10.0.0.1”)、使用一个 IP 地址和 CIDR 子网掩码的 IP 范围(例如“10.0.0.1/22”)或使用一个 IP 地址和点分十进制子网掩码的 IP 范围(例如“10.0.0.1(255.255.252.0)”)。Allowed IP addresses can be specified as either a single IP address (for example, ‘10.0.0.1’), an IP range using an IP address and a CIDR subnet mask (for example, ‘10.0.0.1/22’), or an IP range using an IP address and a dotted decimal subnet mask (for example, ‘10.0.0.1(255.255.252.0)’).

实时编码设置Live encoding settings

本部分介绍当频道的“编码类型”设为“标准”时,如何调整频道内的实时编码器的设置 。This section describes how the settings for the live encoder within the Channel can be adjusted, when the Encoding Type of a Channel is set to Standard.

Note

你的贡献源只能包含单个音频曲目 – 当前不支持引入多个音频曲目。Your contribution feed can only contain a single audio track – ingesting of multiple audio tracks is currently not supported. 使用本地实时编码进行实时编码时,可以通过平滑流式处理协议发送包含多个音频曲目的贡献源。When doing live encoding with on-premises live encodes, you can send a contribution feed in the Smooth Streaming protocol containing multiple audio tracks.

Ad 标记源Ad marker source

可以指定 Ad 标记信号的源。You can specify the source for ad markers signals. 默认值是 Api,它指示频道内的实时编码器应侦听异步 Ad 标记 API 。Default value is Api, which indicates that the live encoder within the Channel should listen to an asynchronous Ad Marker API.

CEA 708 隐藏字幕CEA 708 Closed Captions

可选标志,它指示实时编码器忽略传入视频中嵌入的任何 CEA 708 字幕数据。An optional flag which tells the live encoder to ignore any CEA 708 captions data embedded in the incoming video. 当该标志设为 false(默认值)时,编码器将检测 CEA 708 数据并将该数据重新插入到输出视频流中。When the flag is set to false (default), the encoder will detect and re-insert CEA 708 data into the output video streams.

索引Index

建议在单个节目传输流 (SPTS) 中发送。It is recommended to send in a single program transport stream (SPTS). 如果输入流包含多个节目,频道中的实时编码器将分析输入中的节目映射表 (PMT),标识流类型名称为 MPEG-2 AAC ADTS、AC-3 System-A、AC-3 System-B、MPEG-2 Private PES、MPEG-1 Audio 或 MPEG-2 Audio 的输入并以 PMT 中指定的顺序安排这些输入。If the input stream contains multiple programs, the live encoder within the Channel parses the Program Map Table (PMT) in the input, identifies the inputs that have a stream type name of MPEG-2 AAC ADTS or AC-3 System-A or AC-3 System-B or MPEG-2 Private PES or MPEG-1 Audio or MPEG-2 Audio, and arranges them in the order specified in the PMT. 然后,会使用从零开始的索引选取该安排中的第 n 个条目。The zero-based index is then used to pick up the n-th entry in that arrangement.

语言Language

音频流的语言标识符符合 ISO 639-2 标准,如 ENG。The language identifier of the audio stream, conforming to ISO 639-2, such as ENG. 如果不存在,则默认为 UND(未定义)。If not present, the default is UND (undefined).

系统预设System Preset

指定此通道内的实时编码器要使用的预设。Specifies the preset to be used by the live encoder within this Channel. 目前,唯一允许的值是 Default720p(默认值) 。Currently, the only allowed value is Default720p (default).

Default720p 会将视频编码为以下 6 层。Default720p will encode the video into the following 6 layers.

输出视频流Output Video Stream

比特率BitRate 宽度Width 高度Height MaxFPSMaxFPS 配置文件Profile 输出流名称Output Stream Name
35003500 12801280 720720 3030 High Video_1280x720_3500kbpsVideo_1280x720_3500kbps
22002200 960960 540540 3030 High Video_960x540_2200kbpsVideo_960x540_2200kbps
13501350 704704 396396 3030 High Video_704x396_1350kbpsVideo_704x396_1350kbps
850850 512512 288288 3030 High Video_512x288_850kbpsVideo_512x288_850kbps
550550 384384 216216 3030 High Video_384x216_550kbpsVideo_384x216_550kbps
200200 340340 192192 3030 High Video_340x192_200kbpsVideo_340x192_200kbps

输出音频流Output Audio Stream

音频以 128 kbps 的速率编码为立体声 AAC-LC,采样率为 48 kHz。Audio is encoded to stereo AAC-LC at 128 kbps, sampling rate of 48 kHz.

指示广告Signaling Advertisements

通道启用实时编码后,管道中会有一个正在处理视频的组件,可对其进行操作。When your Channel has Live Encoding enabled, you have a component in your pipeline that is processing video, and can manipulate it. 可以向通道发出信号,以将静态图像和/或广告插入到传出自适应比特率流中。You can signal for the Channel to insert slates and/or advertisements into the outgoing adaptive bitrate stream. 盖板是在某些情况下(例如,在商业广告期间)可用于覆盖输入实时源的静止图像。Slates are still images that you can use to cover up the input live feed in certain cases (for example during a commercial break). 广告信号是嵌入到传出流中的时间同步信号,用于指示视频播放器执行特殊操作(例如,在适当时间切换到广告)。Advertising signals, are time-synchronized signals you embed into the outgoing stream to tell the video player to take special action – such as to switch to an advertisement at the appropriate time. 有关用于此目的的 SCTE-35 信号机制的概述,请参阅此 博客See this blog for an overview of the SCTE-35 signaling mechanism used for this purpose. 下面是可以在直播活动中实现的典型方案。Below is a typical scenario you could implement in your live event.

  1. 事件开始前,让观看者获得事件前图像。Have your viewers get a PRE-EVENT image before the event starts.
  2. 事件结束后,让观看者获得事件后图像。Have your viewers get a POST-EVENT image after the event ends.
  3. 如果在事件期间出现问题(例如,在体育场中出现电源故障),则让观看者收到错误事件图像。Have your viewers get an ERROR-EVENT image if there is a problem during the event (for example, power failure in the stadium).
  4. 在商业广告期间发送广告时间图像以隐藏直播活动源。Send an AD-BREAK image to hide the live event feed during a commercial break.

以下是指示广告时可以设置的属性。The following are the properties you can set when signaling advertisements.

持续时间Duration

商业广告的持续时间(以秒为单位)。The duration, in seconds, of the commercial break. 此持续时间必须是非零正值,才能启动商业广告。This has to be a non-zero positive value in order to start the commercial break. 商业广告正在播放时,将持续时间设为 0,并且 CueId 与正在播放的商业广告匹配,广告会被取消。When a commercial break is in progress, and the duration is set to zero with the CueId matching the on-going commercial break, then that break is canceled.

CueIdCueId

商业广告的唯一 ID,下游应用程序将使用它来执行相应操作。A Unique ID for the commercial break, to be used by downstream application to take appropriate action(s). 必须是一个正整数。Needs to be a positive integer. 可以将此值设为任意随机正整数,或使用上游系统跟踪提示 ID。You can set this value to any random positive integer or use an upstream system to track the Cue Ids. 在通过 API 提交之前,请确保将任何 ID 规范化为正整数。Make certain to normalize any IDs to positive integers before submitting through the API.

显示静态图像Show slate

可选。Optional. 指示实时编码器在商业广告期间切换到默认盖板图像并隐藏传入视频源。Signals the live encoder to switch to the default slate image during a commercial break and hide the incoming video feed. 插入静态图像期间音频也会静音。Audio is also muted during slate. 默认值为 falseDefault is false.

所用图像将是在创建通道时通过默认静态图像资产 ID 属性指定的图像。The image used will be the one specified via the default slate asset Id property at the time of the channel creation. 将对静态图像进行拉伸以适合显示图像大小。The slate will be stretched to fit the display image size.

插入“盖板”图像Insert Slate images

可以向通道中的实时编码器发出信号,以切换到静态图像。The live encoder within the Channel can be signaled to switch to a slate image. 它还可以指示实时编码器结束正在显示的静态图像。It can also be signaled to end an on-going slate.

在某些情况下(例如,在广告期间)可以配置实时编码器以切换到静态图像,并隐藏传入的视频信号。The live encoder can be configured to switch to a slate image and hide the incoming video signal in certain situations – for example, during an ad break. 如果未配置此类静态图像,则在该广告期间不会屏蔽输入视频。If such a slate is not configured, input video is not masked during that ad break.

持续时间Duration

静态图像的持续时间(以秒为单位)。The duration of the slate in seconds. 此持续时间必须是非零正值,才能启动静态图像。This has to be a non-zero positive value in order to start the slate. 如果正在显示静态图像,而指定的持续时间为零,则会终止正在显示的静态图像。If there is an on-going slate, and a duration of zero is specified, then that on-going slate will be terminated.

在 Ad 标记上插入静态图像Insert slate on ad marker

当设为 true 时,此设置会将实时编码器配置为在广告期间插入静态图像。When set to true, this setting configures the live encoder to insert a slate image during an ad break. 默认值为 true。The default value is true.

默认静态图像资产 IDDefault slate Asset Id

可选。Optional. 指定媒体服务资源(包含静态图像)的资源 ID。Specifies the Asset Id of the Media Services Asset which contains the slate image. 默认值为 null。Default is null.

Note

在创建频道之前,具有以下约束的盖板图像应当作为专用资产上传(该资产中不应有其他文件)。Before creating the Channel, the slate image with the following constraints should be uploaded as a dedicated asset (no other files should be in this asset). 只有在广告时间,或已明确收到信号要求插入盖板时,实时编码器才会插入盖板,此时才会使用此图像。This image is used only when the live encoder is inserting a slate due to an ad break, or has been explicitly signaled to insert a slate. 实时编码器进入这种“输入信号丢失”状态时,目前无法使用自定义图像。There is currently no option to use a custom image when the live encoder enters such an 'input signal lost' state.

  • 分辨率最大为 1920x1080。At most 1920x1080 in resolution.
  • 大小最大为 3 MB。At most 3 Mbytes in size.
  • 文件名必须具有 *.jpg 扩展名。The file name must have a *.jpg extension.
  • 必须将该图像作为资产中的唯一 AssetFile 上传到资产,并应将此 AssetFile 标记为主文件。The image must be uploaded into an Asset as the only AssetFile in that Asset and this AssetFile should be marked as the primary file. 资产不能加密存储。The Asset cannot be storage encrypted.

如果未指定“默认盖板资产 Id”,并且“在 ad 标记上插入盖板”设为 true,则将使用默认 Azure 媒体服务图像隐藏输入视频流 。If the default slate Asset Id is not specified, and insert slate on ad marker is set to true, a default Azure Media Services image will be used to hide the input video stream. 插入静态图像期间音频也会静音。Audio is also muted during slate.

通道的节目Channel's programs

通道与节目相关联,使用节目,可以控制实时流中片段的发布和存储。A channel is associated with programs that enable 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.

可以通过设置 存档窗口 长度,指定希望保留节目录制内容的小时数。You can specify the number of hours you want to retain the recorded content for the program by setting the Archive Window length. 此值的设置范围是最短 5 分钟,最长 25 小时。This value can be set from a minimum of 5 minutes to a maximum of 25 hours. 存档时段长度还决定了客户端能够从当前实时位置向后搜索的最长时间。Archive window length also dictates the maximum number 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 which stores the streamed content. 资产会映射到 Azure 存储帐户中的块 blob 容器,资产中的文件则作为 blob 存储在该容器中。An asset is mapped to a block blob container in the Azure Storage account and the files in the asset are stored as blobs in that container. 若要发布节目,以便客户查看该流,必须为关联的资源创建按需定位符。To publish the program so your customers can view the stream you must create an OnDemand 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.

不应当将现有节目重用于新事件。You should not reuse existing programs for new events. 而是应当为每个事件创建并启动一个新节目,如“对实时流式传输应用程序进行编程”部分中所述。Instead, create and start a new program for each event as described in the Programming Live Streaming Applications section.

准备好开始流式传输和存档后,启动节目。Start the program when you are ready to start streaming and archiving. 要停止对事件进行流式传输和存档时,停止节目。Stop the program whenever you want to stop streaming and archiving the event.

如果要删除存档的内容,请停止并删除节目,并删除关联的资产。To delete archived content, stop and delete the program and then delete the associated asset. 如果资产被某个节目使用,则无法将其删除;必须先删除该节目。An asset cannot be deleted if it is used by a program; the program must be deleted first.

即使停止并删除了节目,只要没有删除资产,用户也能够将已存档内容作为点播视频进行流式传输。Even after you stop and delete the program, the users would be able to stream your archived content as a video on demand, for as long as you do not delete the asset.

如果希望保留已存档的内容但不希望其可供流式传输,请删除流式传输定位符。If you do want to retain the archived content, but not have it available for streaming, delete the streaming locator.

获取实时源的缩略图预览Getting a thumbnail preview of a live feed

启用实时编码后,可以在实时源到达通道时获得实时源的预览。When Live Encoding is enabled, you can now get a preview of the live feed as it reaches the Channel. 这是一个很有用的工具,可用于检查实时源是否实际到达通道。This can be a valuable tool to check whether your live feed is actually reaching the Channel.

通道状态,以及状态如何映射到计费模式Channel states and how states 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. 此状态下可以更新通道属性,但不允许进行流式传输。In this state, the Channel properties can be updated but streaming is not allowed.
  • 正在启动Starting. 通道正在启动。The Channel is being started. 此状态下不允许进行更新或流式传输。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.
  • 正在停止Stopping. 通道正在停止。The Channel is being stopped. 此状态下不允许进行更新或流式传输。No updates or streaming is allowed during this state.
  • 正在删除Deleting. 正在删除通道。The Channel is being deleted. 此状态下不允许进行更新或流式传输。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 是否计费?Billed?
正在启动Starting 正在启动Starting 否(暂时状态)No (transient state)
正在运行Running 准备就绪(没有正在运行的节目)Ready (no running programs)
or
流式处理(至少有一个正在运行的节目)Streaming (at least one running program)
Yes
正在停止Stopping 正在停止Stopping 否(暂时状态)No (transient state)
已停止Stopped 已停止Stopped No

Note

目前,启动通道所需的平均时间为大约 2 分钟,最长可能需要 20 多分钟。Currently, the Channel start average is about 2 minutes, but at times could take up to 20+ minutes. 通道重置最长可能需要 5 分钟。Channel resets can take up to 5 minutes.

注意事项Considerations

  • 当某个编码类型为标准的通道出现输入源/贡献源丢失的情况时,该通道会采取相应的补偿措施,将源视频/音频替换为表示错误的静态图像和静音。When a Channel of Standard encoding type experiences a loss of input source/contribution feed, it compensates for it by replacing the source video/audio with an error slate and silence. 该通道会持续发出静态图像,直到输入/贡献源恢复。The Channel will continue to emit a slate until the input/contribution feed resumes. 我们建议不要让实时通道处于此类状态的时间超过 2 小时。We recommend that a live channel not be left in such a state for longer than 2 hours. 如果超出该限制,该通道无法保证输入重新连接时的行为,也无法保证其响应重置命令时的行为。Beyond that point, the behavior of the Channel on input reconnection is not guaranteed, neither is its behavior in response to a Reset command. 这种情况下必须停止通道并将其删除,并创建一个新的。You will have to stop the Channel, delete it and create a new one.
  • 通道或其关联的节目正在运行时,无法更改输入协议。You cannot change the input protocol while the Channel or its associated programs are running. 如果需要不同的协议,应当针对每个输入协议创建单独的频道。If you require different protocols, you should create separate channels for each input protocol.
  • 每次重新配置实时编码器后,请对通道调用 重置 方法。Every time you reconfigure the live encoder, call the Reset method on the channel. 重置通道之前,必须停止节目。Before you reset the channel, you have to stop the program. 在重置频道后,重新启动节目。After you reset the channel, restart the program.
  • 只有当通道处于“正在运行”状态且通道中的所有节目都已停止时才能停止通道。A channel can be stopped only when it is in the Running state, and all programs on the channel have been stopped.
  • 默认情况下,只能向媒体服务帐户添加 5 个通道。By default you can only add 5 channels to your Media Services account. 这是所有新帐户的软配额。This is a soft quota on all new accounts. 有关详细信息,请参阅配额和限制For more information, see Quotas and Limitations.
  • 通道或其关联的节目正在运行时,无法更改输入协议。You cannot change the input protocol while the Channel or its associated programs are running. 如果需要不同的协议,应当针对每个输入协议创建单独的频道。If you require different protocols, you should create separate channels for each input protocol.
  • 仅当通道处于“正在运行” 状态时才会收取费用。You are only billed when your Channel is in the Running state. 有关详细信息,请参阅部分。For more information, refer to this section.
  • 目前,直播活动的最大建议持续时间为 8 小时。Currently, the max recommended duration of a live event is 8 hours.
  • 确保使要从中流式传输内容的流式处理终结点处于“正在运行”状态 。Make sure to have the streaming endpoint from which you want to stream content in the Running state.
  • 编码预设使用“最大帧速率”30 fps 的思路。The encoding preset uses the notion of "max frame rate" of 30 fps. 因此,如果输入为 60fps/59.94i,则输入帧将修剪/反交错为 30/29.97 fps。So if the input is 60fps/59.94i, the input frames are dropped/de-interlaced to 30/29.97 fps. 如果输入为 50fps/50i,则输入帧将修剪/反交错为 25 fps。If the input is 50fps/50i, the input frames are dropped/de-interlaced to 25 fps. 如果输入为 25 fps,则输出将保持为 25 fps。If the input is 25 fps, output remains at 25 fps.
  • 完成后请不要忘记关闭通道。Don't forget to STOP YOUR CHANNELS when done. 否则会继续计费。If you don't, billing will continue.

已知问题Known Issues

  • 通道启动时间已改善为平均 2 分钟,但有时因为需求提高,可能仍然需要长达 20 分钟以上的时间。Channel start up time has been improved to an average of 2 minutes, but at times of increased demand could still take up to 20+ minutes.
  • 盖板图像应符合此处所述的限制。Slate images should conform to restrictions described here. 如果尝试创建默认盖板大于 1920x1080 的频道,请求最终会出错。If you attempt to create a Channel with a default slate that is larger than 1920x1080, the request will eventually error out.
  • 再次强调,完成流式处理后请不要忘记关闭通道。Once again....don't forget to STOP YOUR CHANNELS when you are done streaming. 否则会继续计费。If you don't, billing will continue.

需要帮助?Need help?

可以通过导航到新建支持请求来开具支持票证You can open a support ticket by navigating to New support request

后续步骤Next step

查看媒体服务学习路径。Review Media Services learning paths.

媒体服务 v3(最新版本)Media Services v3 (latest)

查看最新版本的 Azure 媒体服务!Check out the latest version of Azure Media Services!

媒体服务 v2(旧版)Media Services v2 (legacy)

使用 Azure 媒体服务传送实时传送视频流事件Delivering Live Streaming Events with Azure Media Services

创建频道,通过门户执行从单比特率到自适应比特率流的实时编码Create channels that perform live encoding from a singe bitrate to adaptive bitrate stream with Portal

创建频道,通过 NET SDK 执行从单比特率到自适应比特率流的实时编码Create channels that perform live encoding from a singe bitrate to adaptive bitrate stream with .NET SDK

Manage channels with REST APIManage channels with REST API

媒体服务概念Media Services Concepts

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