google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.7k stars 6.02k forks source link

Live HLS playback does not start with different #EXT-X-DISCONTINUITY-SEQUENCE tags #9510

Closed inv3rse closed 2 years ago

inv3rse commented 2 years ago

An audio m3u8 playlist with a different #EXT-X-DISCONTINUITY-SEQUENCE number than the video playlist causes the player to be stuck loading forever.

Internally the HlsMediaChunk for the audio playlist stays forever in timestampAdjuster.sharedInitializeOrWait(isMasterTimestampSource, startTimeUs); because isMasterTimestampSource is false and it expects another thread to initialize the timestampAdjuster.

This appears to never happen, as the other HlsMediaChunk instances aquired different TimestampAdjuster instances via

int discontinuitySequenceNumber =
        mediaPlaylist.discontinuitySequence + mediaSegment.relativeDiscontinuitySequence;
timestampAdjusterProvider.getAdjuster(discontinuitySequenceNumber)

Tested with exoplayer version 14.1 and 15.1. Happens on https://zdf-hls-16.akamaized.net/hls/live/2016499/de/high/master.m3u8 which is unfortionately geo locked to germany.

master.m3u8

#EXTM3U

#EXT-X-INDEPENDENT-SEGMENTS

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="A1.1+A2.1+A3.1-2200042844",NAME="TV Ton",LANGUAGE="deu",DEFAULT=YES,URI="https://zdf-hls-16.akamaized.net/hls/live/2016499/de/d9aea4455a687fac4d3b06d52e285ad2/5/5.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="A1.1+A2.1+A3.1-2200042844",NAME="Originalton",LANGUAGE="mul",URI="https://zdf-hls-16.akamaized.net/hls/live/2016499/de/d9aea4455a687fac4d3b06d52e285ad2/6/6.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="A1.1+A2.1+A3.1-2200042844",NAME="Audio-Deskription",LANGUAGE="deu",URI="https://zdf-hls-16.akamaized.net/hls/live/2016499/de/d9aea4455a687fac4d3b06d52e285ad2/7/7.m3u8"

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="A1.1+A2.1+A3.1-599552640",NAME="TV Ton",LANGUAGE="deu",DEFAULT=YES,URI="https://zdf-hls-16.akamaized.net/hls/live/2016499-b/de/d9aea4455a687fac4d3b06d52e285ad2/5/5.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="A1.1+A2.1+A3.1-599552640",NAME="Originalton",LANGUAGE="mul",URI="https://zdf-hls-16.akamaized.net/hls/live/2016499-b/de/d9aea4455a687fac4d3b06d52e285ad2/6/6.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="A1.1+A2.1+A3.1-599552640",NAME="Audio-Deskription",LANGUAGE="deu",URI="https://zdf-hls-16.akamaized.net/hls/live/2016499-b/de/d9aea4455a687fac4d3b06d52e285ad2/7/7.m3u8"

#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="T1-2200042844",NAME="Untertitel deutsch",CODECS="wvtt",LANGUAGE="deu",DEFAULT=YES,AUTOSELECT=YES,URI="https://zdf-hls-16.akamaized.net/hls/live/2016499/de/d9aea4455a687fac4d3b06d52e285ad2/8/8.m3u8"

#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="T1-599552640",NAME="Untertitel deutsch",CODECS="wvtt",LANGUAGE="deu",DEFAULT=YES,AUTOSELECT=YES,URI="https://zdf-hls-16.akamaized.net/hls/live/2016499-b/de/d9aea4455a687fac4d3b06d52e285ad2/8/8.m3u8"

#EXT-X-STREAM-INF:CODECS="avc1.4d401f,mp4a.40.2",BANDWIDTH=671111,AVERAGE-BANDWIDTH=581111,AUDIO="A1.1+A2.1+A3.1-2200042844",SUBTITLES="T1-2200042844",FRAME-RATE=25.000,RESOLUTION=480x270
https://zdf-hls-16.akamaized.net/hls/live/2016499/de/d9aea4455a687fac4d3b06d52e285ad2/1/1.m3u8
#EXT-X-STREAM-INF:CODECS="avc1.4d401f,mp4a.40.2",BANDWIDTH=671111,AVERAGE-BANDWIDTH=581111,AUDIO="A1.1+A2.1+A3.1-599552640",SUBTITLES="T1-599552640",FRAME-RATE=25.000,RESOLUTION=480x270
https://zdf-hls-16.akamaized.net/hls/live/2016499-b/de/d9aea4455a687fac4d3b06d52e285ad2/1/1.m3u8
#EXT-X-STREAM-INF:CODECS="avc1.4d401f,mp4a.40.2",BANDWIDTH=1173371,AVERAGE-BANDWIDTH=969371,AUDIO="A1.1+A2.1+A3.1-2200042844",SUBTITLES="T1-2200042844",FRAME-RATE=25.000,RESOLUTION=640x360
https://zdf-hls-16.akamaized.net/hls/live/2016499/de/d9aea4455a687fac4d3b06d52e285ad2/2/2.m3u8
#EXT-X-STREAM-INF:CODECS="avc1.4d401f,mp4a.40.2",BANDWIDTH=1173371,AVERAGE-BANDWIDTH=969371,AUDIO="A1.1+A2.1+A3.1-599552640",SUBTITLES="T1-599552640",FRAME-RATE=25.000,RESOLUTION=640x360
https://zdf-hls-16.akamaized.net/hls/live/2016499-b/de/d9aea4455a687fac4d3b06d52e285ad2/2/2.m3u8
#EXT-X-STREAM-INF:CODECS="avc1.4d401f,mp4a.40.2",BANDWIDTH=2257198,AVERAGE-BANDWIDTH=1807198,AUDIO="A1.1+A2.1+A3.1-2200042844",SUBTITLES="T1-2200042844",FRAME-RATE=25.000,RESOLUTION=960x540
https://zdf-hls-16.akamaized.net/hls/live/2016499/de/d9aea4455a687fac4d3b06d52e285ad2/3/3.m3u8
#EXT-X-STREAM-INF:CODECS="avc1.4d401f,mp4a.40.2",BANDWIDTH=2257198,AVERAGE-BANDWIDTH=1807198,AUDIO="A1.1+A2.1+A3.1-599552640",SUBTITLES="T1-599552640",FRAME-RATE=25.000,RESOLUTION=960x540
https://zdf-hls-16.akamaized.net/hls/live/2016499-b/de/d9aea4455a687fac4d3b06d52e285ad2/3/3.m3u8
#EXT-X-STREAM-INF:CODECS="avc1.640028,mp4a.40.2",BANDWIDTH=4504154,AVERAGE-BANDWIDTH=3544154,AUDIO="A1.1+A2.1+A3.1-2200042844",SUBTITLES="T1-2200042844",FRAME-RATE=50.000,RESOLUTION=1280x720
https://zdf-hls-16.akamaized.net/hls/live/2016499/de/d9aea4455a687fac4d3b06d52e285ad2/4/4.m3u8
#EXT-X-STREAM-INF:CODECS="avc1.640028,mp4a.40.2",BANDWIDTH=4504154,AVERAGE-BANDWIDTH=3544154,AUDIO="A1.1+A2.1+A3.1-599552640",SUBTITLES="T1-599552640",FRAME-RATE=50.000,RESOLUTION=1280x720
https://zdf-hls-16.akamaized.net/hls/live/2016499-b/de/d9aea4455a687fac4d3b06d52e285ad2/4/4.m3u8

1.m3u8 (video)

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:576445
#EXT-X-DISCONTINUITY-SEQUENCE:26

#EXT-X-PROGRAM-DATE-TIME:2021-09-29T14:45:30Z
#EXTINF:2.000,
576445.ts

#EXT-X-PROGRAM-DATE-TIME:2021-09-29T14:45:32Z
#EXTINF:2.000,
576446.ts
...

7.m3u8 (audio)

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:576419
#EXT-X-DISCONTINUITY-SEQUENCE:27

#EXT-X-PROGRAM-DATE-TIME:2021-09-29T14:44:38Z
#EXTINF:1.984,
576419.aac

#EXT-X-PROGRAM-DATE-TIME:2021-09-29T14:44:40Z
#EXTINF:2.005,
576420.aac
...

This probably relates to https://github.com/google/ExoPlayer/issues/9203

EDIT: The EXT-X-DISCONTINUITY-SEQUENCE for the problematic content is back in sync again after a restart of the stream encoder.

christosts commented 2 years ago

EDIT: The EXT-X-DISCONTINUITY-SEQUENCE for the problematic content is back in sync again after a restart of the stream encoder.

May I assume that the issue is not occurring any more? And therefore we can close this issue?

inv3rse commented 2 years ago

Correct, the issue is not occurring anymore. But that is the result of a server side change.
I did not find any direct documentation whether such an EXT-X-DISCONTINUITY-SEQUENCE difference would be valid according to the HLS spec or not.

But since other players on iOS, web and desktop (vlc) did play the content correctly I guess that a sequence offset is at least not completely invalid.
Unless confirmed that this is invalid according to HLS spec, I think this still an issue.

christosts commented 2 years ago

Internally the HlsMediaChunk for the audio playlist stays forever in timestampAdjuster.sharedInitializeOrWait(isMasterTimestampSource, startTimeUs); because isMasterTimestampSource is false and it expects another thread to initialize the timestampAdjuster.

As of 2.15.0, the concept of isMasterTimestampSource has been removed so that audio playlists with a different #EXT-X-DISCONTINUITY-SEQUENCE are not stuck. In your report you say that the issue was observed in 2.14.1 and 2.15.1, but it shouldn't happen in 2.15.1. I wonder if it's another bug, or 2.15.1 did not fully addressed the problem.

However, since the issue is not reproducible at the moment, I'm inclined to close this. Please free to re-open if the problem returns/persists.