ios - 播放 m3u8 播放列表时 AVPlayer 会自动调整吗?

标签 ios swift avplayer http-live-streaming m3u8

在 AWS 上花了一些时间设置转码过程后,我发现视频的加载时间并没有像 HLS (m3u8) 预期的那样降低。

似乎如果我直接使用 AVPlayer,没有 AVPlayerViewController,我可能需要自己管理视频流质量?我的理解是,如果我有一个 m3u8,事情会自动完成,并且会根据网络条件/设备/等使用最佳质量?

到目前为止,如果按原样使用 AVPlayer,加载时间似乎与没有 m3u8 的加载时间相同,如果不是稍微差的话。

为了更好地理解正在发生的事情,我一直在尝试一些事情。

1) 虽然这样做可以减少加载时间,但我宁愿多做一点,而不是在不使用 wfifi 时一直降低加载时​​间:

self.player?.currentItem?.preferredPeakBitRate = 1

这似乎给我一个质量很低的视频,但加载速度很快。我还没有弄清楚如何检测实际使用的比特率(因为设置这个值可以显着缩短加载时间,我假设 AVPlayer 不会自行处理调整?)。

2) 此外,没有任何运气(导致无限微调器,即使将 preferredPeakBitRate 设置为 1):

self.player.automaticallyWaitsToMinimizeStalling = false

3) 我愿意使用可能处理此问题的第三方库,是否发现了一个名为 VKVideoPlayer 的东西可能会执行其中的一些操作?

谢谢

最佳答案

现在在 iOS8 及更高版本中是可能的。

以下复制自 Apple 的 documentation :

The desired limit, in bits per second, of network bandwidth consumption for this item. SWIFT: var preferredPeakBitRate: Double OBJECTIVE-C: @property(nonatomic) double preferredPeakBitRate

Set preferredPeakBitRate to non-zero to indicate that the player should attempt to limit item playback to that bit rate, expressed in bits per second.

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.

关于ios - 播放 m3u8 播放列表时 AVPlayer 会自动调整吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46434250/

相关文章:

objective-c - 有谁知道如何检测用户是否取消了 "In App"尝试安装另一个 App 版本

iphone - 如何为 iPhone 应用程序循环播放声音?

Swift var 没有改变

ios - 如何让 AVPlayer 检索受 SSL 保护的播放列表?

ios - slider 擦洗不太顺畅

ios - 从服务器缓存 mp4 视频以与 avplayer 一起使用

ios - 保持 NSDates 时区独立

ios - 更改单元格高度后 UITableView 在滚动时跳动

ios - 为什么 iOS CLLocation 显示不正确的值?

ios - 只能通过wifi连接到CloudKit的公共(public)容器,但不能通过蜂窝连接