Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVPlayer - get the list of available bandwidth/bitrate streams and force one of them

I'm trying to change the playback bitrate while the video is playing dynamically on iOS AVFoundation.
In this stream: https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8, there are 5 video bitrates and now the AV chooses the bitrate automatically.

I want to allow the user to select HD quality, so I need a way to force the player to choose the highest bitrate without replacing the source.

like image 310
Itay Kinnrot Avatar asked May 17 '16 07:05

Itay Kinnrot


1 Answers

The Apple's documentation for [AVPlayerItem] (see docs) has the preferredPeakBitRate: method described as:

The desired limit, in bits per second, of network bandwidth consumption for this item.

If network bandwidth consumption cannot be lowered to meet the preferredPeakBitRate, it will be reduced as much as possible while continuing to play the item.


AVPlayerItem: Configuring Network Behaviour [online]. [cit. 2017-02-14]. Available from: https://developer.apple.com/reference/avfoundation/avplayeritem

It isn't hard-limit per say, but if the connection can support the bitrate (as deemed by the iOS) then it tries to meet the expectations.

As for the list of available bitrates you would need to manually parse the m3u8 file or just create the levels yourself.

like image 117
jr.root.cs Avatar answered Oct 05 '22 15:10

jr.root.cs