简体   繁体   English

在 ios AVPlayer 中切换 HLS stream 的码率

[英]Switching bitrates of HLS stream in ios AVPlayer

I need to switch specific bitrate in HLS stream. To set the bitrate I am using the below property during initialisation.我需要在 HLS stream 中切换特定比特率。要设置比特率,我在初始化期间使用以下属性。

let playerItem = AVPlayerItem(url: streamUrl)
playerItem.preferredPeakBitRate = 240
player = AVPlayer(playerItem: playerItem)

But during the playback, if I am trying to set another bitrate using below code但是在播放过程中,如果我尝试使用以下代码设置另一个比特率

self.playerController?.player?.currentItem?.preferredPeakBitRate = 1500

The stream is not switching to 720p. stream 没有切换到 720p。

Stream contains both the bitrates and works fine with whatever bitrate I provide during initialisation. Stream 包含两种比特率,并且可以与我在初始化期间提供的任何比特率一起正常工作。

If I'm not mistaken, the preferredPeakBitRate is measured in bits per second and not resolution.如果我没记错的话,preferredPeakBitRate 是以比特每秒而不是分辨率来衡量的。 After reviewing an Apple Developer video it seems that it's actually kilobits per second but the documentation states otherwise.在查看 Apple Developer 视频后,它似乎实际上是每秒千比特,但文档中另有说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM