如何查找AVPlayer当前比特率 [英] How to find AVPlayer current bitrate

查看:791
本文介绍了如何查找AVPlayer当前比特率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取AVPlayer正在播放视频流的比特率。我尝试使用观察到的比特率属性 AVPlayerItemAccessLogEvent ,但它给出了非常高的价值。在进一步探索<$ c后$ c> Observed-bit-rate 属性我知道这个属性显示段的下载速率的值。我需要知道这个位播放器正在播放流的速率。

I am trying to fetch bit rate at which the AVPlayer is playing the video stream . I tried with observed bit rate property of AVPlayerItemAccessLogEvent , but it gives very high value.After exploring further on Observed-bit-rate property I understood that this property shows the value of download rate of a segment.I need to know the bit rate at which the player is playing the stream.

下图显示了LIVE流的观察位与指示比特率。

The graph below shows Observed bit vs Indicated bit rate for the LIVE stream.

请就此问题提出建议。

我尝试了以下链接,但没有运气:

I tried the following link but no luck :

https: //stackoverflow.com/a/14845997/1730345

MPMoviePlayerController MovieAccessLogEvent - 膨胀的observeBitrate

推荐答案

你是对的 observedBitrate 。这显示了下载速度。

You are right about observedBitrate. That shows the download speed.

shownBitrate 应该告诉你播放当前流所需的广告比特率。我相信价值来自HLS主清单。当播放没有多个比特率变体的流,并且只有一个比特率变体可用时, shownBitrate 的值将为 -1

The indicatedBitrate should tell you the advertised bitrate required to play the current stream. I believe that value comes from the HLS master manifest. When playing a stream that does not have multiple bitrate variants, and there's only one bitrate variant available, the value of indicatedBitrate will be -1.

如果您一直在处理拥有主清单的流,那么 shownBitrate 就是最佳选择。

If you are always dealing with streams that have a master manifest, then indicatedBitrate is the best option.

如果您正在处理没有主清单的流,那么估算比特率的一种方法是获取最后一个 AVPlayerItemAccessLogEvent 条目,并使用以下方法计算:

If you are dealing with streams that don't have a master manifest, then one way to estimate the bitrate is to grab the last AVPlayerItemAccessLogEvent entry, and calculate it using:

numberOfBitsTransferred = (numberOfBytesTransferred * 8)
numberOfBitsTransferred / segmentsDownloadedDuration

从经验上讲,每次玩家切换比特率时,都会发布一个新的访问日志条目。最新的访问日志条目将包含有关最近选择的流的数据。

Empirically speaking, every time the player switches bitrate, it will post a new access log entry. The latest access log entry will contain data about the most recently selected stream.

这篇关于如何查找AVPlayer当前比特率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆