使用内容感知编码预设来查找给定分辨率的最佳比特率值Use the content-aware encoding preset to find the optimal bitrate value for a given resolution

媒体服务徽标 v3media services logo v3


若要准备通过自适应比特率流式处理传送的内容,需以多个比特率(从高到低)编码视频。In order to prepare content for delivery by adaptive bitrate streaming, video needs to be encoded at multiple bit-rates (high to low). 这可以确保质量的平稳降级,因为比特率会降低,而视频的分辨率也会降低。This ensures graceful degradation of quality, as the bitrate is lowered so is the resolution of the video. 此类多比特率编码利用所谓的编码梯度 – 分辨率和比特率的表;请参阅媒体服务的内置编码预设Such multiple bit-rate encoding makes use of a so-called encoding ladder – a table of resolutions and bitrates, see the Media Services built-in encoding presets.

应该了解自己正在处理的内容,并根据单个视频的复杂性自定义/优化编码梯度。You should be aware of the content you are processing, and customize/tune the encoding ladder to the complexity of the individual video. 在每种分辨率下有一个比特率,超过该比特率会感知不到任何质量提升 – 编码器将以此最佳比特率运行。At each resolution, there is a bitrate beyond which any increase in quality is not perceptive – the encoder operates at this optimal bitrate value. 下一级优化是基于内容选择分辨率 – 例如,降到 720p 以下不会使 PowerPoint 演示文稿的视频受益。The next level of optimization is to select the resolutions based on the content – for example, a video of a PowerPoint presentation does not benefit from going below 720p. 接下来,可以进一步在编码器中优化视频中每个拍摄画面的设置。Going further, the encoder can be tasked to optimize the settings for each shot within the video.

Azure 的自适应流式处理预设可以部分解决源视频的质量和分辨率可变性的问题。Azure's Adaptive Streaming preset partially addresses the problem of the variability in the quality and resolution of the source videos. 我们的客户混合使用不同的内容,其中某些内容的分辨率为 1080p,有些为 720p,还有少部分为标清或更低分辨率。Our customers have a varying mix of content, some at 1080p, others at 720p, and a few at SD and lower resolutions. 此外,并非所有源内容都是电影或电视演播室提供的高质量夹层文件。Furthermore, not all source content is high-quality mezzanines from film or TV studios. 自适应流式处理预设解决了这些问题,它可以确保比特率梯度永不超过输入夹层文件的分辨率或平均比特率。The Adaptive Streaming preset addresses these problems by ensuring that the bitrate ladder never exceeds the resolution or the average bitrate of the input mezzanine. 但是,此预设不会检查除分辨率和比特率以外的源属性。However, this preset does not examine source properties other than resolution and bitrate.

内容感知编码The content-aware encoding

内容感知编码预设扩展了“自适应比特率流式处理”机制,它可以整合自定义逻辑,使编码器能够查找给定分辨率的最佳比特率值,但不需要进行大量的计算分析。The content-aware encoding preset extends the "adaptive bitrate streaming" mechanism, by incorporating custom logic that lets the encoder seek the optimal bitrate value for a given resolution, but without requiring extensive computational analysis. 此预设将生成一组 GOP 对齐的 MP4 文件。This preset produces a set of GOP-aligned MP4s. 在提供任何输入内容的情况下,服务将对输入内容执行初始的轻量分析,并使用结果来确定最佳层数,以及自适应流式处理适合传送的比特率和分辨率设置。Given any input content, the service performs an initial lightweight analysis of the input content, and uses the results to determine the optimal number of layers, appropriate bitrate and resolution settings for delivery by adaptive streaming. 此预设特别适用于中低复杂性的视频,其中的输出文件的比特率低于自适应流式处理预设,但其质量仍会为观众提供良好的体验。This preset is particularly effective for low and medium complexity videos, where the output files will be at lower bitrates than the Adaptive Streaming preset but at a quality that still delivers a good experience to viewers. 输出将包含带有交错式视频和音频的 MP4 文件The output will contain MP4 files with video and audio interleaved

以下示例图形显示了使用 PSNRVMAF 等质量指标做出的比较。The following sample graphs show the comparison using quality metrics like PSNR and VMAF. 源的创建方式是将电影和电视节目中的高复杂性拍摄画面的简短剪辑相连接,旨在给编码器提供压力。The source was created by concatenating short clips of high complexity shots from movies and TV shows, intended to stress the encoder. 按照定义,此预设产生的结果因内容而异 – 这也意味着,对于某些内容,比特率可能不会显著降低,或者质量不会显著提高。By definition, this preset produces results that vary from content to content – it also means that for some content, there may not be significant reduction in bitrate or improvement in quality.

使用 PSNR 的速率失真 (RD) 曲线

图 1:使用高复杂性源的 PSNR 指标的速率失真 (RD) 曲线Figure 1: Rate-distortion (RD) curve using PSNR metric for high complexity source

使用 VMAF 的速率失真 (RD) 曲线

图 2:使用高复杂性源的 VMAF 指标的速率失真 (RD) 曲线Figure 2: Rate-distortion (RD) curve using VMAF metric for high complexity source

下面是另一个源内容类别的结果,其中,编码器可以确定输入质量较差(由于比特率较低,因此生成了很多压缩项目)。Below are the results for another category of source content, where the encoder was able to determine that the input was of poor quality (many compression artifacts because of the low bitrate). 请注意,使用内容感知预设时,编码器确定只生成一个输出层 – 该层的比特率足够低,使大多数客户端能够播放流,而不会出现停顿。Note that with the content-aware preset, the encoder decided to produce just one output layer – at a low enough bitrate so that most clients would be able to play the stream without stalling.

使用 PSNR 的 RD 曲线

图 3:使用低质量输入的 PSNR 的 RD 曲线(分辨率为 1080p)Figure 3: RD curve using PSNR for low-quality input (at 1080p)

使用 VMAF 的 RD 曲线

图 4:使用低质量输入的 VMAF 的 RD 曲线(分辨率为 1080p)Figure 4: RD curve using VMAF for low-quality input (at 1080p)

如何使用内容感知编码预设How to use the content-aware encoding preset

可按如下所示创建使用此预设的转换。You can create transforms that use this preset as follows.

有关使用转换输出的教程,请参阅后续步骤部分。See the Next steps section for tutorials that use tranform outputs. 可以在 MPEG-DASH 和 HLS 等协议中通过媒体服务流式处理终结点传送输出资产(如教程中所述)。The output asset can be delivered from Media Services streaming endpoints in protocols such as MPEG-DASH and HLS (as shown in the tutorials).

备注

请确保使用预设的 ContentAwareEncoding 而不使用 ContentAwareEncodingExperimental。Make sure to use the ContentAwareEncoding preset not ContentAwareEncodingExperimental.

TransformOutput[] output = new TransformOutput[]
{
   new TransformOutput
   {
      // The preset for the Transform is set to one of Media Services built-in sample presets.
      // You can customize the encoding settings by changing this to use "StandardEncoderPreset" class.
      Preset = new BuiltInStandardEncoderPreset()
      {
         // This sample uses the new preset for content-aware encoding
         PresetName = EncoderNamedPreset.ContentAwareEncoding
      }
   }
};

备注

使用 ContentAwareEncoding 预设的编码作业按输出分钟数计费。Encoding jobs using the ContentAwareEncoding preset are being billed based on the output minutes.

后续步骤Next steps