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.
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.