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

问题描述:

我正在使用AVPlayer播放HTTP直播视频。

I am playing a HTTP Live Streaming video with an AVPlayer.

播放器是否有办法访问缓存数据以将其保存在本地?

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.

请记住,HTTP视频流实际上由多个带宽流组成。其中每一个都被分成较小的MPEG传输流块。

Keep in mind that a HTTP Video Stream actually consists of multiple bandwidth streams. Each of those is divided into smaller MPEG transport stream chunks.

为了播放这些流,AVPlayer通常选择一个可用的带宽流,开始预加载并很快播放。现在,AVPlayer开始提高标准并开始从更高带宽的流中下载块。 AVPlayer将再次提高标准,直到达到最高可用带宽。一旦AVPlayer识别出在其队列中预加载某个可播放长度的问题,该过程将被反转。因此,在网络吞吐量降低的情况下,选择较低带宽的流。确切的实现细节没有指定,但大致是如何工作的。

For playing those streams, AVPlayer usually selects one of the available bandwidth streams, starts preloading and soon also playing. Now AVPlayer starts raising the bar and starts downloading chunks from a higher bandwidth stream. The AVPlayer will raise the bar again until it arrived at the highest available bandwidth. This process will be inverted once the AVPlayer identifies problems with keeping a certain playable length preloaded in its queue. 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.

现在想象一下,你会在本地存储/缓存这些数据。你会得到各种带宽TS块的混合 - 而不是任何你可以开箱即用的东西。此外,由于文件系统访问现在在移动设备上非常昂贵,因此您将在此过程中增加额外负担。

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. 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.