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

ios and mac safari native mode does not support llhls very well #2317

Closed
2 of 14 tasks
fastfading opened this issue Sep 8, 2023 · 2 comments · Fixed by bluenviron/gohlslib#107
Closed
2 of 14 tasks
Labels
bug Something isn't working hls

Comments

@fastfading
Copy link

Related Topic #2288

Which version are you using?

v1.0.3

Which operating system are you using?

  • Linux amd64 standard
  • Linux amd64 Docker
  • Linux arm64 standard
  • Linux arm64 Docker
  • Linux arm7 standard
  • Linux arm7 Docker
  • Linux arm6 standard
  • Linux arm6 Docker
  • Windows amd64 standard
  • Windows amd64 Docker (WSL backend)
  • macOS amd64 standard
  • macOS amd64 Docker
  • macOS arm64 standard (M1 chips)
  • Other (please describe)

Describe the issue

ios and mac safari native mode does not support llhls very well.
there will be a long latency 10s+ delay on ios device and mac safari native mode
sometimes the video freezed and did not recover

Describe how to replicate the issue

  1. build mtx

  2. follow https://github.com/bluenviron/mediamtx#compatibility-with-apple-devices to generate hlsServerKey and hlsServerCert
    openssl genrsa -out server.key 2048
    openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650

  3. start mtx with following configuration. set
    hlsEncryption: yes
    hlsServerKey: server.key
    hlsServerCert: server.crt
    hlsVariant: lowLatency
    hlsSegmentCount: 7
    hlsSegmentDuration: 6s
    hlsPartDuration: 1000ms
    mediamtx.yml.zip

  4. use obs to send rtmp stream , configuration as follow.
    GOP: 6s
    tune:zerolatency
    url: rtmp://localhost:1935/live/abc

image
  1. use mac chrome to play https://localhost:8888/live/abc/ , latency is about 3.5s
    use ios safari to play https://localhost:8888/live/abc/ , we will see a very long latency 10s+
    use mac safari play stream.m3u8 directly https://localhost:8888/live/abc/index.m3u8 we will see a very long latency 10s+
    both ios and mac safari will get freezed sometimes.
    we have seen the network through web console that small segement part.mp4 are downloaded.

we have dig into the issue and find something:
Screenshot 2023-09-06 at 15 27 44 (2)
Screenshot 2023-09-06 at 15 24 22 (2)
Screenshot 2023-09-06 at 15 23 03 (2)
Screenshot 2023-09-06 at 15 22 57 (2)
check the images above

part2856.mp4 is preload in the first m3u8
but in the second m3u8 it is gone.
and browser report part2856.mp4 404 error
this may cause the video freeze on ios or native safari.

ios or native safari always download several seg.mp4 before part.mp4 and push it into play buffer, that cause latency very long.

how to resolve above 2 issues?

Did you attach the server logs?

no, it is easy to replicate

Did you attach a network dump?

no, it is easy to replicate

@aler9 aler9 added bug Something isn't working hls labels Nov 10, 2023
aler9 added a commit to bluenviron/gohlslib that referenced this issue Nov 10, 2023
(bluenviron/mediamtx#2317)

this prevented Low-Latency HLS from running smoothly on Safari
@aler9
Copy link
Member

aler9 commented Nov 10, 2023

Hello, thank you very much for reporting and debugging this bug, i found out that when hlsSegmentDuration is an exact multiple of hlsPartDuration, and IDR frames are sent out at an interval equal to hlsSegmentDuration, there are gaps in parts IDs that causes the URL in EXT-X-PRELOAD-HINT to return 404.

In your case, the setup was

hlsSegmentDuration: 6s
hlsPartDuration: 1s
IDR interval = 6s

This is fixed by bluenviron/gohlslib#107

aler9 added a commit to bluenviron/gohlslib that referenced this issue Nov 10, 2023
(bluenviron/mediamtx#2317)

this prevented Low-Latency HLS from running smoothly on Safari
Copy link
Contributor

This issue is being locked automatically because it has been closed for more than 6 months.
Please open a new issue in case you encounter a similar problem.

@github-actions github-actions bot locked and limited conversation to collaborators May 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working hls
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants