我正在尝试使用这里提到的苹果文档将HLS流下载到我的iPhone上- https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/MediaPlaybackGuide/Contents/Resources/en.lproj/HTTPLiveStreaming/HTTPLiveStreaming.html
即使是2分钟的小视频下载需要3-4分钟,我有一个快速的互联网连接,所以这不是一个问题。
我想知道的是有什么特定的流需要我下载或在下载时指定吗?我的m3u8中的流是320p、720p、1080p。是不是下载了所有的文件,所以要花那么多时间?
这就是我如何设置代码来下载hls -
let urlConfiguration = URLSessionConfiguration.background(withIdentifier: downloadIdentifier)
// Create a new AVAssetDownloadURLSession with background configuration, delegate, and queue
let assetDownloadSession = AVAssetDownloadURLSession(configuration: urlConfiguration,
assetDownloadDelegate: self,
delegateQueue: OperationQueue.main)
let asset = AVURLAsset(url: URL(string: assetUrl)!)
// Create new AVAssetDownloadTask for the desired asset
let avAssetDownloadTask = assetDownloadSession?.makeAssetDownloadTask(asset: asset,
assetTitle: title,
assetArtworkData: nil,
options: nil)
// Start task and begin download
avAssetDownloadTask?.resume()发布于 2020-06-09 07:49:36
您可以考虑使用Charles Proxy或Wireshark等工具来确定底层网络请求的吞吐量。你可能有一个很慢的服务器。
https://stackoverflow.com/questions/61535340
复制相似问题