New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix initial audio video desync for fMP4 #2832
Conversation
Hi, @robwalch suggested that only the video track should establish initPTS, to avoid different code paths. |
9e5812a
to
0ffbe3d
Compare
I checked this AV desync issue on the v0.14.5 release, and it seems to be still there. I updated the PR. Here's a sample playlist I reproduced the issue with: https://jungdaniel.github.io/hls.js/sample/playlist.m3u8 With the current version what I see is that both the video and audio tracks are shifted to 0. Here I pushed the demo page with the fix if someone would take a look. I think this is the correct timeline: For sanity check here's a little test code for playing the same sample with MSE. No magic or timeline shifting, but the tracks are in sync: https://jungdaniel.github.io/hls.js/sample/index.html As a side note, sometimes the current version also produces the correct timeline. I still believe that it happens when the audio arrives later then the video and the video's initPTS can be used during audio demuxing. I know that removing |
Hi @jungdaniel, The v0.14.5 fixes were for .ts file AVC remuxing, so it makes sense it didn't help here. I love how simple the fix is! Thank you for these additional details.
I don't think it is a problem to defer handling of the initial audio payload. Audio loads and decodes faster so deferring the parsing>buffering is OK. It used to be the audio playlist loading that was deferred, which was bad, but prevented this issue. Always basing the timeline offset on the main stream will provide more stable results. :) I'd like to do some testing and debugging before giving review feedback, and merging the change. Hold tight! I'll get this in soon. |
Doesn't solve #2545 but I don't see any issue with the change. If it prevents an edge case resulting in different buffered ranges it's a great improvement. |
This PR will...
Solves initial AV desync for fMP4.
Why is this Pull Request needed?
It seems that there are cases when initPTS handling is faulty and it results in misaligned offsets for A/V.
I suspect that audio demuxing can start here without knowing the video's initPTS: https://github.com/video-dev/hls.js/blob/master/src/controller/audio-stream-controller.js#L526
Resolves issues:
Might be the same issue: #2545
Checklist