why AVPlayer sends range

Hi,

I am writing my own HTTP web service server that supports iOS devices to view video files. On iOS I am using `AVPlayer` and on the server side it is simply `.mp4` files. But it seems like AVPlayer buffers for a long time (10+ seconds) before starting playing a video.


After a bit debugging, it seems that AVPlayer send weird range values in its HTTP request for the video, for example:


1st request headers send range 0-1: (this is OK)


X-Playback-Session-Id: B1F3B5AE-B49A-40B1-8F2E-A501E1BC24AF
Range: bytes=0-1
Accept: */*
User-Agent: AppleCoreMedia/1.0.0.17A860 (iPhone; U; CPU OS 13_1_2 like Mac OS X; en_us)
Accept-Language: en-us
Accept-Encoding: identity
Connection: keep-alive


2nd request headers send range 0-37724087, which is full length of the video.

This is weird, why doesn't AVPlayer take advantage of range header and ask for only a small range?


X-Playback-Session-Id: B1F3B5AE-B49A-40B1-8F2E-A501E1BC24AF
Range: bytes=0-37724087
Accept: */*
User-Agent: AppleCoreMedia/1.0.0.17A860 (iPhone; U; CPU OS 13_1_2 like Mac OS X; en_us)
Accept-Language: en-us
Accept-Encoding: identity
Connection: keep-alive


3rd request headers send range of 37683200-37724087, which is the last chunk of the video.

Again very weird, why does AVPlayer ask for the range that was already covered by the previous request?


X-Playback-Session-Id: B1F3B5AE-B49A-40B1-8F2E-A501E1BC24AF
Range: bytes=37683200-37724087
Accept: */*
User-Agent: AppleCoreMedia/1.0.0.17A860 (iPhone; U; CPU OS 13_1_2 like Mac OS X; en_us)
Accept-Language: en-us
Accept-Encoding: identity
Connection: keep-alive


Any ideas? Any comments or pointers are appreciated.

Post not yet marked as solved Up vote post of keepsimple Down vote post of keepsimple
2.4k views

Replies

I know this was asked 2 years ago, but I have the same question. Any answers on that? That behaviour is especially bad when you proxy videos from an AWS S3 instance.