直播活动低延迟设置Live Event low latency settings

媒体服务徽标 v3media services logo v3


本文展示了如何在直播活动上设置较低的延迟。This article shows how to set low latency on a Live Event. 它还讨论了在各种播放器中使用低延迟设置时看到的典型结果。It also discusses typical results that you see when using the low latency settings in various players. 结果因网络延迟而异。The results vary based on network latency.

若要使用新的 LowLatency 功能,请在 LiveEvent 上将 StreamOptionsFlag 设置为 LowLatencyTo use the new LowLatency feature, you set the StreamOptionsFlag to LowLatency on the LiveEvent. 为 HLS 播放创建 LiveOutput 时,将 LiveOutput.Hls.fragmentsPerTsSegment 设置为 1。When creating LiveOutput for HLS playback, set LiveOutput.Hls.fragmentsPerTsSegment to 1. 流启动并运行后,可以使用 Azure Media Player(AMP 演示页),并设置播放选项以使用“低延迟启发式配置文件”。Once the stream is up and running, you can use the Azure Media Player (AMP demo page), and set the playback options to use the "Low Latency Heuristics Profile".

备注

目前,Azure Media Player 中的“低延迟启发式配置文件”设计用于在 MPEG-DASH 协议中播放采用 CSF 或 CMAF 格式(例如,format=mdp-time-csfformat=mdp-time-cmaf)的流。Currently, the LowLatency HeuristicProfile in Azure Media Player is designed for playing back streams in MPEG-DASH protocol, with either CSF or CMAF format (for example, format=mdp-time-csf or format=mdp-time-cmaf).

以下 .NET 示例展示了如何在 LiveEvent 上设置 LowLatencyThe following .NET example shows how to set LowLatency on the LiveEvent:

LiveEvent liveEvent = new LiveEvent(
            location: mediaService.Location, 
            description: "Sample LiveEvent for testing",
            vanityUrl: false,
            encoding: new LiveEventEncoding(
                        // Set this to Standard to enable a transcoding LiveEvent, and None to enable a pass-through LiveEvent
                        encodingType:LiveEventEncodingType.None, 
                        presetName:null
                    ),
            input: new LiveEventInput(LiveEventInputProtocol.RTMP,liveEventInputAccess), 
            preview: liveEventPreview,
            streamOptions: new List<StreamOptionsFlag?>()
            {
                // Set this to Default or Low Latency
                // To use low latency optimally, you should tune your encoder settings down to 1 second "Group Of Pictures" (GOP) length instead of 2 seconds.
                StreamOptionsFlag.LowLatency
            }
        );

参阅完整示例:MediaV3LiveAppSee the full example: MediaV3LiveApp.

直播活动延迟Live Events latency

下表显示了媒体服务中的延迟的典型结果(当启用了 LowLatency 标志时),延迟指的是从贡献源到达服务之时到查看者看到播放器上的回放之时之间的时间。The following tables show typical results for latency (when the LowLatency flag is enabled) in Media Services, measured from the time the contribution feed reaches the service to when a viewer sees the playback on the player. 若要以最佳方式使用低延迟,应将编码器设置下调至 1 秒“图片组”(GOP) 长度。To use low latency optimally, you should tune your encoder settings down to 1 second "Group Of Pictures" (GOP) length. 当使用较高的 GOP 长度时,可以在相同帧速率下最小化带宽消耗并降低比特率。When using a higher GOP length, you minimize bandwidth consumption and reduce bitrate under same frame rate. 在动作较少的视频中特别有用。It is especially beneficial in videos with less motion.

直通Pass-through

启用 2 秒 GOP 低延迟2s GOP low latency enabled 启用 1 秒 GOP 低延迟1s GOP low latency enabled
AMP 中的 DASHDASH in AMP 10 秒10s 8 秒8s
本机 iOS 播放器上的 HLSHLS on native iOS player 14 秒14s 10 秒10s

实时编码Live encoding

启用 2 秒 GOP 低延迟2s GOP low latency enabled 启用 1 秒 GOP 低延迟1s GOP low latency enabled
AMP 中的 DASHDASH in AMP 14 秒14s 10 秒10s
本机 iOS 播放器上的 HLSHLS on native iOS player 18 秒18s 13 秒13s

备注

根据本地网络状况,端到端延迟可能有所不同。The end-to-end latency can vary depending on local network conditions. 应当测试你的确切配置。You should test your exact configurations.

后续步骤Next steps