The m3u8 files created by SRS won't play in only iOS safari, but other m3u8 files work in iOS, Android and Web

1.3k Views Asked by At

I've been building live streaming app for all platforms including iOS, Android and web.

Simple Realtime Server is used to publish video streaming for my project, it makes m3u8 files.

The video streaming files made by SRS are playing well for Web and Android, but not for iPhone.

But famous demo m3u8 files are working well on iPhone, too. So I think my srs.conf file has some wrong parameters.

You can check my issues using the following service. https://livepush.io/hls-player/index.html

The following demo file is working very good for both iPhone, android and web with above test service.

https://live-par-1-abr-cdn.livepush.io/live_abr_cdn/emaIqCGoZw-6/index.m3u8

please check how it works well on iPhone.

https://prnt.sc/Ukece_IhPeI0

The following file is made by SRS, it plays well for Android and web, but not working for iPhone. https://live.indiefire.io/PsfYcRZxTP/2023_06_29_12_24_07.m3u8

When I play this file, the following issue is occurred.

"The media playback was aborted due to a corruption problem or because the media used features your browser did not support."

See the Screenshot on iPhone. https://prnt.sc/fF85E7biPnsx

And the following is my srs.conf file.

listen              27017;
max_connections     1000;
daemon              on;
http_api {
    enabled         on;
    listen          1985;
    https {
        enabled on;
        listen 1990;
        key ./conf/server.key;
        cert ./conf/server.crt;
    }   
}
http_server {
    enabled         on;
    listen          80;
    dir             ./objs/nginx/html;
    https {
        enabled on;
        listen 443;
        key ./conf/server.key;
        cert ./conf/server.crt;
    }   
}
stats {
    network         0;
}
rtc_server {
    enabled on;
    listen 8000;
    candidate 45.79.27.216;
}
vhost __defaultVhost__ {
    hls {
        enabled         on;
    hls_fragment    2;
        hls_window      300;
        hls_wait_keyframe       off;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
    rtc {
        enabled     on;
        rtmp_to_rtc on;
        rtc_to_rtmp on;
    }

    tcp_nodelay     on;
    min_latency     on;

    play {
        gop_cache       off;
        queue_length    10;
        mw_latency      100;
    }

    publish {
        mr off;
    }
}

I tried also several public video stream files as the following, all m3u8 files are working well on iPhone, but the m3u8 files made by SRS are not playing for iPHone.

https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8

http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8

https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8

https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8

https://moctobpltc-i.akamaihd.net/hls/live/571329/eight/playlist.m3u8

http://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8

https://diceyk6a7voy4.cloudfront.net/e78752a1-2e83-43fa-85ae-3d508be29366/hls/fitfest-sample-1_Ott_Hls_Ts_Avc_Aac_16x9_1280x720p_30Hz_6.0Mbps_qvbr.m3u8

https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8

I think my srs.conf file has wrong parameters. How can I fix this issue?

1

There are 1 best solutions below

4
On

It seems that the issue might be due to:

  1. The hls_wait_keyframe off; setting results in each ts file not starting with an I frame.
  2. The encoder's GOP is not set to 1s, so the player needs to download several ts files before obtaining an I frame.
  3. Since there are only 3 ts files, if the player starts from a file other than the first one, it won't be able to acquire an I frame.

In simpler terms, you can modify the setting to hls_wait_keyframe on; for the iPhone to function properly. This change will help confirm my assumption.

It appears that you want to reduce the latency of HLS. You can maintain the hls_wait_keyframe off setting, but you'll need to adjust the encoder's GOP to 1s for optimal performance.

If need more discussion, please contact us by discord, you can find the link at the GitHub page.

Other factors can also lead to playback failure:

  1. If the stream has audio, it should contain audio packets. Alternatively, disable the audio to support video-only HLS.
  2. Safari requires a minimum of 3 TS files to initiate playback, so avoid playing the stream if it only has one or two TS files.

Note: To enable pure video HLS support in SRS, use the hls_acodec an; configure.