Skip to content

HLS: media playlist path is absolute, should be relative #4338

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

Open
benelgiac opened this issue May 2, 2025 · 0 comments
Open

HLS: media playlist path is absolute, should be relative #4338

benelgiac opened this issue May 2, 2025 · 0 comments
Labels
EnglishNative This issue is conveyed exclusively in English.

Comments

@benelgiac
Copy link

Describe the bug
When looking at a multi-variant or "master" playlist, path to the media playlist are absolute. I.e.

curl https://myserver/live/livestream.m3u8

#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=1,AVERAGE-BANDWIDTH=1
/live/livestream.m3u8?hls_ctx=g518h58s

The presence of the trailing slash makes the path absolute. This causes errors if there is any redirect to a different path.

EXAMPLE: viewer access content through a reverse proxy or CDN that performs URL rewrite from a publicly available path to an internal address and path where srs is available, e.g.

http://my-public-server/srs ---> http://srs-origin

When a viewer requests the content, what happens is

  1. Player performs GET http://my-public-server/srs/live/livestream.m3u8
  2. Reverse proxy matches the request and remaps to GET http://srs-origin/live/livestream.m3u8
  3. SRS receives request GET http://srs-origin/live/livestream.m3u8 and returns master playlist.
  4. Player receives the multi-variant "master" playlist containing path of media playlist as /live/livestream.m3u8?hls_ctx=g518h58s path
  5. Player now compose hostname+absolute path and performs GET http://my-public-server/live/livestream.m3u8?hls_ctx=g518h58s
  6. Reverse proxy receives a request that does not match the rewrite rules. It returns 404 and SRS never receives a request. This happens because the "srs" part has been dropped.

The correct request would have been GET http://my-public-server/**srs**/live/livestream.m3u8?hls_ctx=g518h58s. The player did the right thing and followed the rules, the problem is that the path in the master playlist is absolute (/live/livestream.m3u8?hls_ctx=g518h58s instead of live/livestream.m3u8?hls_ctx=g518h58s1).

I have read the docs and noticed hls_entry_prefix but I'm not sure this is useful in this case.

Version
Version 5 from ossrs/srs:5

To Reproduce
Steps to reproduce the behavior:

  1. Run srs docker and stream some content
  2. Use NGINX or other reverse proxy and perform path rewrite from public address to internal srs address involving dropping a path (e.g. remap external address 'http://public-srs-origin/path' to 'http://private-srs-origin"
  3. Try and play HLS (player included in srs docker image or HLS.js)
  4. Observe master playlist is downloaded correctly but playback fails as media playlist cannot be downloaded

Expected behavior
The master playlist should not use absolute path. I would expect a playlist like this

#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=1,AVERAGE-BANDWIDTH=1
live/livestream.m3u8?hls_ctx=g518h58s

Additional context
Notice that media segments path in media playlist are correct, they are relative, e.g.

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:48
#EXT-X-TARGETDURATION:12
#EXTINF:10.080, no desc
livestream-48.ts?hls_ctx=r91cqob8  <---- RELATIVE, CORRECT!

Thank you very much

@winlinvip winlinvip added the EnglishNative This issue is conveyed exclusively in English. label May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EnglishNative This issue is conveyed exclusively in English.
Projects
None yet
Development

No branches or pull requests

2 participants