IOS - audio sync and delay for AVPlayer and AVPlayerItem, how to determine startup delay

I play one file and record another. Ideally, later, I want to play both of them backwards, with the same sync as the user when they watched the first clip. That is, the sound reproduced in clip 1, which was recorded by clip 2, must match (not echo) when both clips are played simultaneously. I know this will never happen, so I will mutate clip 1, but play back its video. I want clip 1 video to match the audio in clip 2 ... This is the goal.

So much easier: let's say I interrupted AVPlayer (Item) ... When I press play, how can I programmatically tell how long the clip will take to get to the screen and speaker? Is it due to the audio buffering latency in AVPlayer (Item)? or is it also determined by something in the kernel? audio driver? Anyway: is there a way that I can measure? This will bring me closer to my goal, now the two clips are off by about 250ms.

Someone told me to use addBoundaryTimeObserverForTimes and see when it crosses zero time. This does not work. But if I cast a clip and put a border at 1 second, I get a call after about 1050m.I don't know if there was a 50ms delay due to lack of time in the callback system or because there is actually a 50ms startup delay , or if it is something else.

+3


source to share





All Articles