Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 974
MartinMoizard Avatar asked Dec 21 '11 15:12

MartinMoizard


1 Answers

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. Each of those is divided into smaller MPEG transport stream chunks.

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.

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.

like image 165
Till Avatar answered Sep 28 '22 10:09

Till