RTCOutboundRtpStreamStats.qpSum - Web APIs 编辑

The qpSum property of the RTCOutboundRtpStreamStats dictionary is a value generated by adding the Quantization Parameter (QP) values for every frame this sender has produced to date on the video track corresponding to this RTCOutboundRtpStreamStats object. In general, the higher this number is, the more heavily compressed the video data is.

Syntax

var qpSum = RTCOutboundRtpStreamStats.qpSum;

Value

An unsigned 64-bit integer value which indicates the sum of the quantization parameter (QP) value for every frame sent so far on the track described by the RTCOutboundRtpStreamStats object. Since the value of QP is typically larger to indicate higher compression factors, the larger this sum is, the more heavily compressed the stream generally has been.

Note: This value is only available for video media.

Usage notes

Quantization is the process of applying lossy compression to a range of values, resulting in a single quantum value. This value takes the place of the range of values, thereby reducing the number of different values that appear in the overall data set, making the data more compressible. The quantization process and the amount of compression can be controlled using one or more parameters.

It's important to keep in mind that the value of QP can change periodically—even every frame—so it's difficult to know for certain how substantial the compression is. The best you can do is make an estimate. You can use the value of RTCSentRtpStreamStats.framesEncoded to get the number of frames that have been encoded so far, and compute an average from there. See Calculating average quantization below for a function that does this.

Also, the exact meaning of the QP value depends on the codec being used. For example, for the VP8 codec, the QP value can be anywhere from 1 to 127 and is found in the frame header element "y_ac_qi", whose value is defined in RFC 6386: 19.2. H.264 uses a QP which ranges from 0 to 51; in this case, it's an index used to derive a scaling matrix used during the quantization process. Additionally, QP is not likely to be the only parameter the codec uses to adjust the compression. See the individual codec specifications for details.

Example

Calculating average quantization

The calculateAverageQP() function shown below computes the average QP for the given RTCStats object that contains RTP stream statistics, returning 0 if the object doesn't describe an RTP stream.

function calculateAverageQP(stats) {
  let frameCount = 0;

  switch(stats.type) {
    case "inbound-rtp":
    case "remote-inbound-rtp":
      frameCount = stats.framesDecoded;
      break;
    case "outbound-rtp":
    case "remote-outbound-rtp":
      frameCount = stats.framesEncoded;
      break;
    default:
      return 0;
  }

  return status.qpSum / frameCount;
}

Specifications

SpecificationStatusComment
Identifiers for WebRTC's Statistics API
The definition of 'RTCOutboundRtpStreamStats.qpSum' in that specification.
Candidate RecommendationInitial definition.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:135 次

字数:4872

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文