I am using HLS streaming in my application and I am using AVPlayer. Now I want to get bitrate of the video track using AVAsset. Although I have added observer and other stuff I am getting tracks array as empty always.Am I on right track or missing anything?
HLS is adaptive, therefore, bitrate can vary across the duration of the stream based on various conditions. You are on completely the wrong track, unlike playing a file, either local or from a network URL, currentItem.asset.tracks will always be nil.
You'll need to query the AVPlayer's currentItem's accessLog and inspect the appropriate "events".
The following from the documentation should give you the information you need;
Look at ;
AVPlayerItemAccessLog
and
AVPlayerItemAccessLogEvent
EDIT:
You might benefit from reading apple's Live streaming overview this will give you a better understanding of the .m3u8 index files, specifically that the media file can be encoded for various bit rates to accommodate different network throughput/congestion. The client is responsible for switching between segments encoded at different bit rates.
The observedMinBitrate and observedMaxBitrate are likely to be the properties you'll find most useful, however withought knowing your intended use, it's hart to say if any will suffice. Keep in mind also, as per the Docs, these are Per Segment (refer to the overview for a better understanding of segment).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With