在 Azure 门户中使用本地编码器实时传送流Perform live streaming with on-premises encoders using Azure portal

备注

不会向媒体服务 v2 添加任何新特性或新功能。No new features or functionality are being added to Media Services v2.
查看最新版本:媒体服务 v3Check out the latest version, Media Services v3. 另请参阅从 v2 到 v3 的迁移指南Also, see migration guidance from v2 to v3

本教程指导你完成相关步骤,使用 Azure 门户创建经配置后可直通传递的“通道” 。This tutorial walks you through the steps of using the Azure portal to create a Channel that is configured for a pass-through delivery.

先决条件Prerequisites

以下是完成本教程所需具备的条件:The following are required to complete the tutorial:

强烈建议阅读以下文章:It is highly recommended to review the following articles:

常见实时流式处理方案Common live streaming scenario

以下步骤说明了在创建常用的实时传送视频流应用程序时涉及的任务,这些应用程序使用的通道经配置后可以进行直通传递。The following steps describe tasks involved in creating common live streaming applications that use channels that are configured for pass-through delivery. 本教程说明了如何创建和管理直通通道和直播活动。This tutorial shows how to create and manage a pass-through channel and live events.

备注

确保要从中流式传输内容的流式处理终结点处于“正在运行”状态 。Make sure the streaming endpoint from which you want to stream content is in the Running state.

  1. 将视频摄像机连接到计算机。Connect a video camera to a computer.
    有关设置建议,请查看简单且可移植的事件视频设备设置For setup ideas, check out Simple and portable event video gear setup.

  2. 启动并配置输出多比特率 RTMP 或分段 MP4 流的本地实时编码器接收实时输入流。Launch and configure an on-premises live encoder that outputs a multi-bitrate RTMP or Fragmented MP4 stream. 有关详细信息,请参阅 Azure 媒体服务 RTMP 支持和实时编码器For more information, see Azure Media Services RTMP Support and Live Encoders.
    另外,请查看以下博客:采用 OBS 的实时传送视频流生产Also, check out this blog: Live streaming production with OBS.

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

  3. 创建并启动直通通道。Create and start a pass-through Channel.

  4. 检索频道引入 URL。Retrieve the Channel ingest URL.

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

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

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

  6. 创建直播活动/节目。Create a live event/program.

    使用 Azure 门户时,创建直播活动的同时还会创建资产。When using the Azure portal, creating a live event also creates an asset.

  7. 在准备好开始流式传输和存档时,启动事件/节目。Start the event/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 event/program whenever you want to stop streaming and archiving the event.

  10. 删除事件/节目(并选择性地删除资产)。Delete the event/program (and optionally delete the asset).

重要

请参阅使用可创建多比特率流的本地编码器实时传送视频流,了解与实时传送视频流(使用本地编码器和直通频道)相关的概念和注意事项。Please review Live streaming with on-premises encoders that create multi-bitrate streams to learn about concepts and considerations related to live streaming with on-premises encoders and pass-through channels.

查看通知和错误To view notifications and errors

若要查看 Azure 门户生成的通知和错误,请单击“通知”图标。If you want to view notifications and errors produced by the Azure portal, click on the Notification icon.

通知

创建并启动直通通道和事件Create and start pass-through channels and events

通道与事件/节目相关联,使用事件/节目,可控制实时流中的段的发布和存储。A channel is associated with events/programs that enable you to control the publishing and storage of segments in a live stream. 通道管理事件。Channels manage events.

可以通过设置 存档窗口 长度,指定希望保留节目录制内容的小时数。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 amount of time clients can seek back in time from the current live position. 超出指定时间长度后,事件也能够运行,但落在时间窗口长度后面的内容将不断被丢弃。Events 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 event is associated with an asset. 若要发布事件,必须为关联的资产创建按需定位符。To publish the event, you must create an OnDemand locator for the associated asset. 此定位符可用于生成提供给客户端的流 URL。Having this locator enables you to build a streaming URL that you can provide to your clients.

一个通道最多支持三个并发运行的事件,因此可为同一传入流创建多个存档。A channel supports up to three concurrently running events 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 live events. 与之相反,应针对每个事件创建并启动新事件。Instead, create and start a new event for each event.

在准备好开始流式传输和存档时,启动事件。Start the event 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 event and then delete the associated asset. 如果资产被某个事件使用,则无法将其删除,必须先删除该事件。An asset cannot be deleted if it is used by an event; the event must be deleted first.

即使你停止并删除了事件,只要没有删除资产,用户也能够按需将已存档内容作为视频进行流式传输。Even after you stop and delete the event, 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.

使用门户来创建通道To use the portal to create a channel

本部分演示如何使用“快速创建” 选项来创建直通通道。This section shows how to use the Quick Create option to create a pass-through channel.

有关直通通道的详细信息,请参阅使用可创建多比特率流的本地编码器实时传送视频流For more details about pass-through channels, see Live streaming with on-premises encoders that create multi-bitrate streams.

  1. Azure 门户中,选择 Azure 媒体服务帐户。In the Azure portal, select your Azure Media Services account.

  2. 在“设置” 窗口中,单击“实时传送视频流” 。In the Settings window, click Live streaming.

    入门

    此时会显示“实时传送视频流” 窗口。The Live streaming window appears.

  3. 单击“快速创建” ,使用 RTMP 引入协议创建直通通道。Click Quick Create to create a pass-through channel with the RTMP ingest protocol.

    此时会显示“创建新通道” 窗口。The CREATE A NEW CHANNEL window appears.

  4. 为新通道命名,并单击“创建” 。Give the new channel a name and click Create.

    此时会使用 RTMP 引入协议创建直通通道。This creates a pass-through channel with the RTMP ingest protocol.

创建事件Create events

  1. 选择要对其添加事件的通道。Select a channel to which you want to add an event.
  2. 按“直播活动” 按钮。Press Live Event button.

事件

获取引入 URLGet ingest URLs

创建通道后,可以获得要提供给实时编码器的引入 URL。Once the channel is created, you can get ingest URLs that you will provide to the live encoder. 编码器使用这些 URL 来输入实时流。The encoder uses these URLs to input a live stream.

已创建

观看事件Watch the event

如果要观看事件,请在 Azure 门户中单击“观看” ,或者先复制流式处理 URL,然后使用所选播放器进行播放。To watch the event, click Watch in the Azure portal or copy the streaming URL and use a player of your choice.

已创建

停止时,直播活动会自动转换为点播内容。Live event automatically get converted to on-demand content when stopped.

清理Clean up

有关直通通道的详细信息,请参阅使用可创建多比特率流的本地编码器实时传送视频流For more details about pass-through channels, see Live streaming with on-premises encoders that create multi-bitrate streams.

  • 只有当频道中的所有事件/节目都已停止时,才能停止频道。A channel can be stopped only when all events/programs on the channel have been stopped. 停止通道后,不会产生任何费用。Once the Channel is stopped, it does not incur any charges. 需要重新启动它时,它会采用相同的引入 URL,因此无需重新配置编码器。When you need to start it again, it will have the same ingest URL so you won't need to reconfigure your encoder.
  • 只有当频道中的所有直播活动都已删除时,才能删除频道。A channel can be deleted only when all live events on the channel have been deleted.

查看存档的内容View archived content

即使你停止并删除了事件,只要没有删除资产,用户也能够按需将已存档内容作为视频进行流式传输。Even after you stop and delete the event, 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. 如果资产被某个事件使用,则无法将其删除,必须先删除该事件。An asset cannot be deleted if it is used by an event; the event must be deleted first.

若要管理资产,请选择“设置”,再单击“资产” 。To manage your assets, select Setting and click Assets.

资产

后续步骤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)