How to find AVPlayer current bitrate

自闭症网瘾萝莉.ら 提交于 2019-12-20 10:57:17

问题


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.

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

Kindly give your suggestion on this issue.

I tried the following link but no luck :

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

MPMoviePlayerController MovieAccessLogEvent - Inflated observedBitrate.


回答1:


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

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.

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

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.



来源:https://stackoverflow.com/questions/32406838/how-to-find-avplayer-current-bitrate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!