zlplayer icon indicating copy to clipboard operation
zlplayer copied to clipboard

Audio gets delayed after some time

Open davidslaby opened this issue 2 years ago • 3 comments

During testing phase, we've found out one essential issue. In case stream is playing for a long time, approx. 1 and half hour, you can observe audio is getting delayed 3-4 seconds. There is 1 sec. delay by default. We are using pass through buffering strategy.

@monyone Do you have any hint, from where it comes from? What should we focus on within the investigation?

Thanks in advance :)

davidslaby avatar Oct 18 '22 13:10 davidslaby

@davidslaby Can you show entire arrived Time and PTS/DTS for Video/Audio PES? If it is wrong or delayed, PassThrought is just send to player, so delayed.

if using ffmpeg, Video/Audio PES is not aligned default. (Video first comes, Audio is delayed) so specify -max_delay 0 sync Video/Audio PES insertion algorithm. (I recommend add more flags -fflags +nobuffer -flags +low_delay for low delay streaming)

In other case, If video is dropframe, PassThrough may be unreliable. Audio is always non drop and video is dropped. I not recommended.

monyone avatar Oct 19 '22 02:10 monyone

Hi @monyone, we are using ffmpeg and all the settings seems to be okay. Based on next round of investigation, It looks sometimes audio frames stuck in decoder queue and audio gets delayed, basically it's not synced to video.

Is there any mechanism to prevent this? Should we change buffering strategy?

Thanks in advance! :)

davidslaby avatar Nov 01 '22 17:11 davidslaby

I've added logs here for testing purpose and built it locally. Screenshot 2022-11-01 v 18 03 37

davidslaby avatar Nov 01 '22 17:11 davidslaby