nginx-rtmp-module
nginx-rtmp-module copied to clipboard
"Live" type HLS streams not playable on newer versions of Safari
Somewhere between v13 and v15 of Safari, something changed so that HLS streams coming from nginx-rtmp are no longer playable (it just shows a black screen with a loading bar, no error message on console or anything). After a bunch of investigation I narrowed this down to the #EXT-X-PROGRAM-DATE-TIME:
tag which is apparently required on live streams per the HLS spec.
There's a 7 year old unmerged PR that adds an hls_datetime
directive which solves the problem. I've confirmed that building against a forked branch with this PR solves the problem. It would be awesome to get this merged, and in the meantime I thought it would be valuable to document the workaround. Cheers
https://github.com/arut/nginx-rtmp-module/pull/379
Bumping this - #379 seems to not have been merged properly to release at least unless it was omitted intentionally for some reason that I'm not seeing. This would help me as well as I need the stream's current position exposed which seems doable with hls_datetime timestamp
under this proposal. Is there a reason why this directive isn't supported right now?
For anyone looking for a resolution of this issue, It seems https://github.com/sergey-dryabzhinsky/nginx-rtmp-module is relatively more actively maintained than this repo. Also, I got a similar issue of mine resolved when I used that fork.
@koundinyagoparaju Having issues with playing hls on iOS. Did you have to use the hls_datetime
directive to solve the issue using https://github.com/sergey-dryabzhinsky/nginx-rtmp-module fork?
I believe one quirk with HLS playback on IOS Webkit is that audio is required for some reason. Reading through the nginx-rtmp-module hls handling code, I got the impression that there are some assumptions about the presence of audio in there as well. When audio is absent, fragment boundaries do not seem to get aligned with keyframes.
In my case, adding a silent aac audio track to the rtmp stream sent to nginx-rtmp-module made the hls stream playable in IOS. In cases where the rtmp stream cannot be easily changed, it might be possible to add the audio track via an ffmpeg exec recode in the nginx module.
Separately, not sure if this is strictly required, but I also added an hls_max_fragment 100s
directive, with a value larger than the target HLS fragment size. I tested this using libnginx-mod-rtmp v1.2.2+dfsg-5 from Debian unstable, so no special forks.