How to reduce initial buffering time of AVPlayer to play video?

1.1k views Asked by At

Hello Friends, I am working on OTT platform app, I need to play video very smoothly without any delay like Snapchat and instagram as reference. I am using Cloudinary for uploading videos and everything is working good but at first time, AVPlayer takes time of 1-2 second to start video, which is bad thing for Me. Once video play, next time I come on same video it plays smoothly with less delay of max Half second.

As far as I tried to learn through different blogs and stack over flow answers, I get rid this is default AVPlayer Buffering time and it depends of video durations and its fetching video information like title, metadata etc. But I don't have to use these information anywhere.

I tried to set false this property of AVPlayer .automaticallyWaitsToMinimizeStalling = false, but still no luck.

I tried few solutions from StackOverflow posts, but didn't get success

How to reduce iOS AVPlayer start delay

This is demo video Link Which you can try http://res.cloudinary.com/dtzhnffrp/video/upload/v1621013678/1on1/bgasthklqvixukocv6xy.mov

If you can suggest, what I can use for OTT platforms to play video smoothly really grateful to everyone...

Thanks In Advance

2

There are 2 answers

0
Mick On

Most streaming services use ABR, which creates multiple resolution copies of the video and beaks each into 2-10 second, typicaLLY, chunks.

One benefit of ABR is that to speed up playback start up, the video can start on a lower resolution bit rate and then 'step up' to higher bit rates as it proceeds.

You can often see this on popular streaming services where you will see the video quality is lower when the video starts and improves after a short time.

See here for more on ABRs: https://stackoverflow.com/a/42365034/334402

This requires you to do work on the server side to prepare the video for HLS and DASH streaming, the two most common ABR streaming protocols.

Typically dedicated streaming servers, or a combination of encoders and packagers, are use to prepare and serve the ABR streams. There are also cloud services, for example AWS Media Services or Azure Media Services, which allow on demand streaming models.

0
Doug Sillars On

You can make the videos smaller either by reducing the dimensions or by compressing it more. Both of these have the effect of lowering startup time - but will sacrifice quality in exchange.

Cloudinary will create ABR versions for you, but the last I checked, you pay for each version created.