简体   繁体   English

从HTTP Live Streaming播放视频时访问AVPlayer的数据

[英]Access the data of AVPlayer when playing video from HTTP Live Streaming

I am playing a HTTP Live Streaming video with an AVPlayer. 我正在使用AVPlayer播放HTTP直播视频。

Is there any way to access the cached data by the player to save it locally? 有没有办法让播放器访问缓存的数据以在本地保存?

TLDR; TLDR; That is not impossible but the results would most likely not be that great. 这并非不可能,但结果很可能不那么好。

Keep in mind that a HTTP Video Stream actually consists of multiple bandwidth streams. 请记住,HTTP视频流实际上由多个带宽流组成。 Each of those is divided into smaller MPEG transport stream chunks. 其中每一个都被分成较小的MPEG传输流块。

For playing those streams, AVPlayer usually selects one of the available bandwidth streams, starts preloading and soon also playing. 为了播放这些流,AVPlayer通常选择一个可用的带宽流,开始预加载并很快播放。 Now AVPlayer starts raising the bar and starts downloading chunks from a higher bandwidth stream. 现在,AVPlayer开始提高标准并开始从更高带宽的流中下载块。 The AVPlayer will raise the bar again until it arrived at the highest available bandwidth. AVPlayer将再次提高标准,直到达到最高可用带宽。 This process will be inverted once the AVPlayer identifies problems with keeping a certain playable length preloaded in its queue. 一旦AVPlayer识别出在其队列中预加载某个可播放长度的问题,该过程将被反转。 So in case the network throughput is reduced, a lower bandwidth stream is selected. 因此,在网络吞吐量降低的情况下,选择较低带宽流。 The exact implementation details are not specified but that is roughly how this works. 没有指定确切的实现细节,但这大致是如何工作的。

Now imagine you would locally store/cache that data. 现在假设您将在本地存储/缓存该数据。 You would get a mix of various bandwidth TS chunks - not anything you could playback out of the box. 您可以获得各种带宽TS块的混合 - 而不是任何您可以开箱即用的东西。 Also you would put additional load on this process as filesystem access is rather expensive on mobile devices these days. 此外,如果文件系统访问在移动设备上相当昂贵 ,那么您将在此过程中增加额外负担。

Overall, I think it is not entirely impossible but would not be trivial at all. 总的来说,我认为这并非完全不可能,但根本不是微不足道的。 I have read about people experimenting with filesystem piping on this issue but they never got it to work. 我已经读过关于在这个问题上试验文件系统管道的人,但他们从来没有让它工作。

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

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