9

Several people have tried to cache pre-loaded video data using AVPlayer or MPMoviePlayerController, for example

The most straightforward approach would seem to be using AVExportSession on player's currentItem, but nobody seems to be able to get it to work.

My question is: is it is possible to transparently proxy the video requests on the device, with an embedded HTTP server backed by a disk-based cache?

I can run an embedded web server (GCDWebServer), so my question is

  1. Will caching screw up AVPlayer's bandwidth-optimization code that tries to select the highest-bandwidth stream possible? If this is an issue, I can control the stream so it only provides one option.

  2. Is disk performance sufficient to provide an improvement over the network? It would seem like it obviously would be, but I've seen a variety of articles around the web talking about how slow disk I/O is on iOS.

Thanks!

Community
  • 1
  • 1
bcattle
  • 12,115
  • 6
  • 62
  • 82
  • it's unclear from your question and the questions you refer to as to just what your objective is here. Are you trying to save a copy of the played video locally (your ref to AVExportSession) or are you attempting to implement your own cache to improve playback? – MDB983 May 16 '14 at 14:56
  • I don't see the distinction you're trying to draw. What's the difference between "saving a copy of the played video locally" and "implementing a cache to improve playback"? Aren't these the same thing? I'm not aware of caching methods that wouldn't save the video locally. – bcattle May 16 '14 at 18:40
  • The distinction is in the implementation. As you pointed out, you can either use a proxy mechanism to capture what is in the process of being downloaded (from the "players" standpoint), or an AVExportSession which essentially captures data already downloaded/being played. – MDB983 May 16 '14 at 18:58
  • Right. So the purpose of this question is to ask the community if either of those implementations are feasible. The first question [linked above](http://stackoverflow.com/questions/6259095/caching-with-avplayer-and-avassetexportsession) shows the doubt surrounding the `AVExportSession` approach. As I mention in the question body, there are reasons why transparently proxying an `AVPlayer` also may not work. – bcattle May 16 '14 at 21:58
  • Hi @bcattle - I'm working on exactly the same issue - I want to cache my videos on iOS, but so far all my attempts have failed with `NSURLProtocol` and a custom `resourceLoader`. I'm going to implement a transparent proxy now, so wanted to ask if you made any progress with this? – ndbroadbent May 31 '15 at 23:59

1 Answers1

0

For HTTP Live Streaming:

If the embedded web server is to host the media segment files that comprise the HTTP live stream feed, then the files would need to be downloaded to the device already, unless you reconfigure the webserver to act as a proxy.

In either case, it seems that a simpler way would be to download and parse the index file (typically prog_index.m3u8) to get the list of the media segment files and then just initiate download of each one.

augustzf
  • 2,385
  • 1
  • 16
  • 22
  • 1
    Thanks for the insight. I had been imagining a transparent proxy. So you're saying open and read the `.m3u8` file, then transparently proxy each stream therein? – bcattle May 19 '14 at 19:48