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

Question: How to Seamlessly Update HLS Stream URL in ExoPlayer When Manifest Expires (HTTP 483) Without Interrupting Playback? #1944

Open
mneckoee opened this issue Dec 3, 2024 · 1 comment
Assignees
Labels

Comments

@mneckoee
Copy link

mneckoee commented Dec 3, 2024

I am using ExoPlayer to play an HLS stream in a Kotlin-based Android app. Our media server changes the stream links every minute to avoid video link leakage. If I request .ts chunks based on an expired manifest file (.m3u8), the server responds with an HTTP error code 483, indicating that I need to retrieve the new stream link.

Situation:

At the start of playback, ExoPlayer downloads a valid manifest and then fetches the first 10 .ts chunks (e.g., 001.ts to 010.ts), which represents the first 5 minutes of video.

At minute 4, the player requests another 10 chunks in advance to buffer the next 5 minutes. However, by that time, the manifest file has expired, and the server returns an HTTP 483 error.

I can detect the error using a custom HttpDataSource or a custom LoadErrorHandlingPolicy, but the challenge is how to switch the stream URL seamlessly without interrupting playback. The goal is for the player to retrieve the new manifest and continue playing the video after minute 5, without the user noticing any interruption.

What I've Tried:

I have a custom HttpDataSource to catch the 483 error, but I'm unsure how to update the stream URL in ExoPlayer without resetting the player or causing playback to stop.

Question:

How can I update the HLS manifest URL in ExoPlayer dynamically when an error like HTTP 483 occurs, without interrupting playback or requiring the user to notice any transition?

@marcbaechinger
Copy link
Contributor

marcbaechinger commented Dec 11, 2024

I assume this is for an VOD HLS stream or more technically a HLS playlist that has an #EXT-X-ENDLIST tag, is this correct?

In any case, from the HLS spec I don't think that such a modification is valid.

https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-16#section-6.2.1

The server responsibilty section declares this IMO when saying:

An EXT-X-PLAYLIST-TYPE tag with a value of VOD indicates that the Playlist file MUST NOT change.

It further defines the changes allowed to a playlist (6.2.1 as well) which is for live stream, but changing the URI is not included and I think this is for good reasons:

Append lines to it ([Section 6.2.1](https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-16#section-6.2.1)).

      Remove Media Segment URIs from the Playlist in the order that they
      appear, along with any tags that apply only to those segments
      ([Section 6.2.2](https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-16#section-6.2.2)).

      Remove Media Metadata tags that no longer apply to the
      presentation ([Section 6.2.1](https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-16#section-6.2.1)).

      Remove EXT-X-PART tags no longer at the live edge ([Section 6.2.2](https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-16#section-6.2.2)).

      Increment the value of the EXT-X-MEDIA-SEQUENCE or EXT-X-
      DISCONTINUITY-SEQUENCE tags ([Section 6.2.2](https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-16#section-6.2.2)).

      Add an EXT-X-ENDLIST tag to the Playlist ([Section 6.2.1](https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-16#section-6.2.1)).

From this I think changing the URI of a segment is not a valid change. For VOD a playlist is loaded only once for these reasons. For live segments can be removed, but the URI of the segment can not change according to allowed changes quoted above.

Please let me know if you think I misinterpret the spec. Happy to follow up on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants