Skip to content
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

av desync on server restart #6823

Closed
5 tasks done
hard7 opened this issue Nov 1, 2024 · 5 comments · Fixed by #6857
Closed
5 tasks done

av desync on server restart #6823

hard7 opened this issue Nov 1, 2024 · 5 comments · Fixed by #6857

Comments

@hard7
Copy link

hard7 commented Nov 1, 2024

What version of Hls.js are you using?

latest c723ce3

What browser (including version) are you using?

Chrome 130.0.6723.92

What OS (including version) are you using?

Windows 11

Test stream

No response

Configuration

{
   debug: true,
   enableWorker: true,
   emeEnabled: true
}

Additional player setup steps

No response

Checklist

Steps to reproduce

  1. download a live dump: av_desync.tar.gz
  2. tar xf av_desync.tar.gz
  3. cd av_desync
  4. python3 server.py
  5. open http://localhost:8000/demo.html in browser
  6. press play

alternatively you can run the player (npm run dev) and paste the link http://localhost:8000/demo_master.m3u8

Expected behaviour

Audio and Video tracks are in sync during all playtime.

What actually happened?

Audio and Video tracks lose synchronization in a middle (audio is shifted forward to 2s)

If you restart the web page after playback has finished, synchronization will be restored.

Before the next commit the player works fine 2b1e1aa

Chrome logs: logs.txt

Console output

it's attached in the "What actually happened?" section

Chrome media internals output

No response

@hard7 hard7 added Bug Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Nov 1, 2024
@robwalch robwalch added Need sample stream cannot reproduce Stream Issue and removed Bug Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Nov 15, 2024
@robwalch
Copy link
Collaborator

robwalch commented Nov 15, 2024

Sounds like a stream issue. We cannot verify with the information provided. Adding program date time to your live stream would be one way to ensure sync. If the media timestamps are contiguous this should not happen. If your playlist has DISCONTINUITY tags and this happens you are likely missing a properly set DISCONTINUITY-SEQUENCE.

@hard7
Copy link
Author

hard7 commented Nov 20, 2024

Hello, thank you for your response.

When the HLS server is turned off, the audio playlist sometimes retains one segment more than the video playlist. Then the segments are aligned with timestamps and program datetime upon restart time, the player, however, ignores this and results in a desynchronization. This issue wasn't present before commit 2b1e1aa.

Also, when the server restarts, there's a noticeable skip of several segments which leads to timestamp jumps in fmp4. It seems we've deviated from the standard here as we didn't update the discontinuity sequence.

Upon revisiting the behavior with an increment in discontinuity sequence, it's observed that the player spins for some time and then gets stuck. See chrome logs chrome_logs.txt, hls.js was built from 7db2f52

Also please have a look at playlists audio_playlists.txt, video_playlists.txt. Identical X-DISCONTINUITY-SEQUENCE values before and after the server restart should not be an issue, since an additional X-DISCONTINUITY tag is inserted at the beginning.

@robwalch
Copy link
Collaborator

robwalch commented Nov 20, 2024

When the HLS server is turned off, the audio playlist sometimes retains one segment more than the video playlist.

It doesn't look like that happened in the sample playlist txt.

Also please have a look at playlists audio_playlists.txt, video_playlists.txt. Identical X-DISCONTINUITY-SEQUENCE values before and after the server restart should not be an issue, since an additional X-DISCONTINUITY tag is inserted at the beginning.

When matched up to the previous playlists, those discontinuities and segments are aligned as they each start where their last respective playlist ended. The accumulated duration of both audio and video playlists should be maintained by inserting segments with GAP tags prior to the discontinuity to make up for the additional audio that was packaged previously (if there is indeed an additional segment in one which I don't see - both initial versions are ~14 seconds long).

@robwalch
Copy link
Collaborator

Let me know if #6857 resolves or improves the issue for you.

robwalch added a commit that referenced this issue Nov 21, 2024
@robwalch robwalch added this to the 1.6.0 milestone Nov 21, 2024
@hard7
Copy link
Author

hard7 commented Nov 22, 2024

Thanks for #6857, after checking everything looks great. It fixes desync due to extra audio segment. It also fixes player freezing when discontinuity counter increments.

robwalch added a commit that referenced this issue Nov 22, 2024
…dio playlist updates (#6857)

* Attempt to realign audio with main when `alignPlaylists` finds no overlap in playlist updates
#6823
* Cache audio playlist responses until main playlist is alignable
* Align on starting discontinuity tag with discontinuity-sequence (startCC is discontinuity-sequence)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants