Best practices for setting ios-media-file-duration
What is ios-media-file-duration :
We all know unlike RTMP, HTTP is request response model. HTTP delivers data in response to some request. So even if client is playing the livestream, it requires to send some request for data to receive. While in RTMP, you once say to play, and server keeps pushing data to the client as soon as its available to him from publisher. So if server has 1000 min of data, you may choose to send 1000 request to the server and get 1 min of data as response to one request.. or you may choose to send 100 request to the server and get 10 min of data as response to each request.
So ios-media-file-duration is nothing but “amount of data you want to receive in response to one request“.
Implications of ios-media-file-duration:
1. In case you choose to have ios-media-file-duration to be too low, then you are asking client to generate too many request and server to handle them.. This may not be good for your network. Server may clog handling so many request. Sending and handling each request has some overheads at client, server, network, router every point..
2. In case you choose to have high ios-media-file-duration, you are welcoming a huge latency in playback. Reason is that client will have to wait at least for that much amount of data to be available to him, before it can play it.. HLS specification says in its case, client will require 3 such chunks information before it could play..
3. Other than this, in order to achieve better seeking capabilities, you may want each segment starting with a keyframe. So, it is recommended to have ios-media-file-duration be a multiple of key frame interval.
Conclusion – Best practice:
Choose it intelligently depending upon how may concurrent clients will subscribe to your stream and how much latency is acceptable to you. FMS by default configures it to be 8 sec, considering by default publisher configures the keyframe interval to be 4 second.