您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

使用时移和实时输出创建点播视频Use time-shifting and Live Outputs to create on-demand video playback

媒体服务徽标 v3media services logo v3

在 Azure 媒体服务中,实时输出对象类似于数字视频录制器,它会捕获实时流并将其记录到媒体服务帐户中的某个资产内。In Azure Media Services, a Live Output object is like a digital video recorder that will catch and record your live stream into an asset in your Media Services account. 记录的内容将保存到资产资源定义的容器中(该容器位于附加到你的帐户的 Azure 存储帐户中)。The recorded content is persisted into the container defined by the Asset resource (the container is in the Azure Storage account attached to your account). 使用实时输出还可以控制传出实时流的某些属性,例如,存档记录中保存的流的量(如云 DVR 的容量),以及观看者何时可以开始观看实时流。The Live Output also allows you to control some properties of the outgoing live stream, like how much of the stream is kept in the archive recording (for example, the capacity of the cloud DVR) or when viewers can start watching the live stream. 磁盘上的存档是一个环形存档“窗口”,仅保存实时输出的 archiveWindowLength 属性中指定的内容量。The archive on disk is a circular archive "window" that only holds the amount of content that's specified in the archiveWindowLength property of the Live Output. 超出此窗口的内容将自动从存储容器中丢弃,且不可恢复。Content that falls outside of this window is automatically discarded from the storage container and isn't recoverable. archiveWindowLength 值表示一个 ISO-8601 时间跨度持续时间(例如 PTHH:MM:SS),指定 DVR 的容量。The archiveWindowLength value represents an ISO-8601 timespan duration (for example, PTHH:MM:SS), which specifies the capacity of the DVR. 此值的设置范围是最短 1 分钟,最长 25 小时。The value can be set from a minimum of one minute to a maximum of 25 hours.

实时事件与其实时输出之间的关系类似于传统的电视广播,其中的频道(实时事件)表示恒定的视频流,录制(实时输出)限定为特定的时间段(例如,下午 6:30 到 7:00 的晚间新闻)。The relationship between a Live Event and its Live Outputs is similar to traditional TV broadcast, in that a channel (Live Event) represents a constant stream of video and a recording (Live Output) is scoped to a specific time segment (for example, evening news from 6:30PM to 7:00PM). 将流传输到实时事件后,可以通过创建资产、实时输出和流定位符来启动流事件。Once you have the stream flowing into the Live Event, you can begin the streaming event by creating an asset, Live Output, and streaming locator. 实时输出会存档流,并使观看者可通过流式处理终结点使用该流。Live Output will archive the stream and make it available to viewers through the Streaming Endpoint. 可以使用不同的存档长度和设置针对实时事件创建多个实时输出(最多三个)。You can create multiple Live Outputs (up to three maximum) on a Live Event with different archive lengths and settings. 有关实时传送视频流工作流的信息,请参阅常规步骤部分。For information about the live streaming workflow, see the general steps section.

在发生事件期间使用 DVRUsing a DVR during an event

本部分介绍在发生事件期间如何使用 DVR 来控制可“后退”的流部分。This section discusses how to use a DVR during an event to control what portions of the stream is available for ‘rewind’.

archiveWindowLength 值确定观看者可在当前直播位置中向后的多长时间继续播放。The archiveWindowLength value determines how far back in time a viewer can go from the current live position. archiveWindowLength 值还确定了客户端清单能够增加多长时间。The archiveWindowLength value also determines how long the client manifests can grow.

假设你正在流式传输一场足球比赛,其 ArchiveWindowLength 仅为 30 分钟。Suppose you're streaming a football game, and it has an ArchiveWindowLength of only 30 minutes. 开赛后 45 分钟才开始观看赛事的观看者最多可以寻轨到前 15 分钟的标记处。A viewer who starts watching your event 45 minutes after the game started can seek back to at most the 15-minute mark. 比赛的实时输出会持续到实时事件停止为止。Your Live Outputs for the game will continue until the Live Event is stopped. 超出 archiveWindowLength 的内容将持续从存储中丢弃,且不可恢复。Content that falls outside of archiveWindowLength is continuously discarded from storage and is non-recoverable. 在此示例中,赛事起始位置与 15 分钟标记之间的视频将从 DVR 中清除,并且会从资产 Blob 存储中的容器内清除。In this example, the video between the start of the event and the 15-minute mark would have been purged from your DVR and from the container in blob storage for the asset. 存档是不可恢复,将从 Azure Blob 存储中的容器内删除。The archive isn't recoverable and is removed from the container in Azure blob storage.

一个实时事件最多支持三个并发运行的实时输出(可从一个实时流最多同时创建 3 个录制文件/存档)。A Live Event supports up to three concurrently running Live Outputs (you can create at most 3 recordings/archives from one live stream at the same time). 此项支持可让你根据需要发布和存档事件的不同部分。This support allows you to publish and archive different parts of an event as needed. 假设你需要广播全天候的直播线性源,并需要全天创建不同节目的“录制内容”,以便将其作为点播内容提供给客户,供其抽时间观看。Suppose you need to broadcast a 24x7 live linear feed, and create "recordings" of the different programs throughout the day to offer to customers as on-demand content for catch-up viewing. 对于这种情况,请先创建一个主要实时输出,其存档窗口较短,为 1 小时或更短 - 这是供观看者欣赏的主要实时流。For this scenario, you first create a primary Live Output with a short archive window of 1 hour or less–this is the primary live stream that your viewers would tune into. 可以为此实时输出创建一个流定位符,然后将其作为“实时”源发布到应用或网站。You would create a Streaming Locator for this Live Output and publish it to your app or web site as the "Live" feed. 当实时事件处于运行状态时,可以在节目开始时通过编程方式创建另一个并发实时输出(也可提前 5 分钟这样做,以便提供一些可供以后剪裁的控点)。While the Live Event is running, you can programmatically create a second concurrent Live Output at the beginning of a program (or 5 minutes early to provide some handles to trim later). 在结束节目 5 分钟之后,可以删除第二个实时输出。This second Live Output can be deleted 5 minutes after the program ends. 使用第二个资产可以创建新的流定位符,以便在应用的目录中将此节目发布为点播资产。With this second asset, you can create a new Streaming Locator to publish this program as an on-demand asset in your app's catalog. 可以针对需要作为点播视频共享的其他节目边界或突出显示内容多次重复此过程,同时第一个实时输出提供的“实时”源可以继续广播线性源。You can repeat this process multiple times for other program boundaries or highlights that you wish to share as on-demand videos, all while the "Live" feed from the first Live Output continues to broadcast the linear feed.

为点播创建存档Creating an archive for on-demand playback

实时输出要存档到的资产,在删除实时输出时,会自动成为点播资产。The asset that the Live Output is archiving to automatically becomes an on-demand asset when the Live Output is deleted. 必须先删除所有实时输出,然后才能停止实时事件。You must delete all Live Outputs before a Live Event can be stopped. 在停止时,可以使用可选标志 removeOutputsOnStop 自动删除实时输出。You can use an optional flag removeOutputsOnStop to automatically remove Live Outputs on stop.

即使你停止并删除了事件,只要没有删除资产,用户也能够将已存档内容作为点播视频进行流式传输。Even after you stop and delete the event, users can stream your archived content as a video on-demand, for as long as you don't delete the asset. 如果资产被某个事件使用,则不应将其删除,必须先删除该事件。An asset shouldn't be deleted if it's used by an event; the event must be deleted first.

如果已使用流定位符发布了实时输出的资产,则实时事件(最长为 DVR 窗口长度)将继续可见,直到流定位符过期或被删除(以先发生者为准)。If you've published the asset of your Live Output using a streaming locator, the Live Event (up to the DVR window length) will continue to be viewable until the streaming locator’s expiry or deletion, whichever comes first.

有关详细信息,请参阅:For more information, see:


删除实时输出不会删除基础资产和该资产中的内容。When you delete the Live Output, you're not deleting the underlying asset and content in the asset.

后续步骤Next steps