You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AVPlayerViewController播放.m3u8视频前5秒分辨率过低问题求助

HLS流播放前5秒分辨率异常问题

流式播放.m3u8视频时,AVPlayerViewController播放的前5秒分辨率远低于视频其余部分,即便视频已完全缓冲,再次回退到前5秒时问题依旧存在。

已尝试以下解决策略:

  • 将AVPlayerItem的canUseNetworkResourcesForLiveStreamingWhilePaused属性设为true;
  • 将AVPlayerItem的preferredForwardBufferDuration属性设为30秒;
  • 使用AVAsset的loadValuesAsynchronously(forKeys:completionHandler:)方法,确保加载所有必要数据后再创建AVPlayerItem;
  • 对AVPlayerItem.status使用KVO,当状态为.readyToPlay时调用AVPlayer的prerollAtRate方法。

当前代码实现:

let url = URL(string: "https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8")!
let asset = AVURLAsset(url: url)
let item = AVPlayerItem(asset: asset)
let playerViewController = AVPlayerViewController()
playerViewController.player = AVPlayer(playerItem: item)
self.present(playerViewController, animated: true)

前5秒效果

前5秒效果

5秒后效果

5秒后效果

内容的提问来源于stack exchange,提问作者Objective D

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 11:57:37