I have an AVQueuePlayer
that is supposed to play sequentially an array of AVURLAsset
representing consecutive fragments of one continuous video.
Whenever a fragment ends and another starts, there is a small glitch that can be well noticed (frame hold for approx 0.2sec and sound gets muted)
I tried researching how to get around that issue but haven't found anything. I tried solving it by having 2 AVQueuePlayer
's and switch between both around 0.2sec before the end of every fragment. Issue not solved.
Any idea on how to solve that?
Note: When joining the mp4 fragments together using an mp4 joiner software, the output is a single smooth video without any glitch.
Been through this exactly. You will experience that glitch no matter what you do. Reason being how AVQueuePlayer
works. It loads the next item when the previous ends. So if your videos are big, you may also see that blank screen for 2-3 seconds. One solution is what you mentioned, i.e. using two AVQueuePlayer
. But as you said its not working for you, and even if you make it work, it will be clumsy.
A better and clean solution is AVMutableComposition
. It may look complex at first but its fast and one time task. You create a composition of all of your videos and play it in a simple AVPlayer
. And in your case, I assume you just have to play it, so you don't even have to export it.
To know how to use AVMutableComposition
, go through this link. It will explain with exact code you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With