2

I'm using AVAssetDownloadTask to download some FairPlay-encrypted audio. As per guidelines, the audio is split up into small chunks to allow switching between bitrates during streaming. Our chunks are about 6 seconds each, which means less than 100 kb in size.

The download speed of this process is pretty bad. I've seen speeds between 85 KB/s and 250 KB/s. This is on a connection where when I download a new Xcode beta, I get several megabytes per second.

I'm guessing that the slow speed is due to having to make a separate request for each segment, which is a lot of overhead. I've tried inspecting the download traffic using Charles, and even though it shows one HTTPS connection per download task, the request body size continually ticks upward over the lifetime of the download. I tried downloading a 100MB test file from the same server where the audio files live and it came down at a few megabytes per second.

My question: what are best practices for getting good download performance using AVAssetDownloadTask? Should the segments be larger? Should there be a separate file that is one large chunk for downloading? Or is this behavior weird, suggesting I've got something configured wrong?

Tom Hamming
  • 10,577
  • 11
  • 71
  • 145
  • Did you find a response for your question or did you do some testing with a single file, larger chunks at your end? I'm asking because I have exactly the same issue – user2990759 Apr 24 '19 at 12:23
  • @user2990759 I tried changing my DRM system to output single audio files with segment markers, and the download system still makes HTTP range requests for each individual segment. Because my audio is split up into separate chapter files (I'm downloading audio books), I was able to work around it by keeping 15 or 20 AVAssetDownloadTasks in flight at once. This doesn't work well on iOS 10, though. – Tom Hamming Apr 24 '19 at 15:20
  • Ahhh, iOS 10, don't even mention it :D. We had a lot of issues around the download session. Backing to the main topic, I can have dozens of small video segment files where one segment is ~15MB and the whole downloaded video is up to 4GB. Users are complaining about the download speed and we are looking for a good solution to tweak this as much as we can. – user2990759 Apr 24 '19 at 17:39
  • @user2990759 yeah, my issue was because I'm downloading audio, so even longer segments of 30 seconds or so are small files, which means the ratio of round-trip time to streaming time is higher. Video might be better. – Tom Hamming Apr 25 '19 at 00:01
  • Hey @TomHamming, did you find a solution to your issue? I am encountering the exact same problem here. – trupin May 29 '19 at 22:25
  • @trupin my resources are split up into many tracks, so I start 20 download tasks at a time, one per track, and keep starting new ones as they finish. – Tom Hamming May 30 '19 at 17:16
  • Thanks, @TomHamming. I wrote a downloader from scratch which does exactly that, but I had to shortcircuit `AVURLAssetURLSession`'s entirely. Ideally, I'd like to get `AVURLAssetURLSession` to do that for me, is it possible? – trupin May 31 '19 at 21:18

0 Answers0