Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

When first HLS subscribes connects to a stream on WCS server, especilally to CDN stream, it may take a time to split a stream to HLS segmets and to form a playlist. As a result, Safari browser on iOS devices may not be able to play HLS stream on the first attempt. To successfully play HLS stream in this case, the HLS preloader was added since build 5.2.371. The default preloader looks like this:

Since build 5.2.408 preloaders are divided by stream aspect ratio: 16:9, 4:3, 2:1

Default preloader segments are placed to /usr/local/FlashphonerWebCallserver/hls/.preloader folder when server is started

Code Block
themeRDark
lstree /usr/local/FlashphonerWebCallserverFlashphonerWebCallServer/hls/.preloader
/usr/local/FlashphonerWebCallServer/hls/.preloader
-rw-r--r-- 1 root root 51888 Oct 13 04:47 ├── 16x9
│   ├── index0.ts
-rw-r--r-- 1 root root 52828 Oct 13 04:47 index10.ts
-rw-r--r-- 1 root root 54332 Oct 13 04:47 index11.ts
-rw-r--r-- 1 root root 53392 Oct 13 04:47 index12.ts
-rw-r--r-- 1 root root 52828 Oct 13 04:47 index13.ts
-rw-r--r-- 1 root root 52828 Oct 13 04:47 index14.ts
-rw-r--r-- 1 root root 53956 Oct 13 04:47 index15.ts
-rw-r--r-- 1 root root 54144 Oct 13 04:47 index16.ts
-rw-r--r-- 1 root root 52828 Oct 13 04:47 index17.ts
-rw-r--r-- 1 root root 52640 Oct 13 04:47 index18.ts
-rw-r--r-- 1 root root 53580 Oct 13 04:47 index19.ts
-rw-r--r-- 1 root root 52828 Oct 13 04:47 index1.ts
-rw-r--r-- 1 root root 53580 Oct 13 04:47 index2.ts
-rw-r--r-- 1 root root 54520 Oct 13 04:47 index3.ts
-rw-r--r-- 1 root root 52452 Oct 13 04:47 index4.ts
-rw-r--r-- 1 root root 52640 Oct 13 04:47 index5.ts
-rw-r--r-- 1 root root 53204 Oct 13 04:47 index6.ts
-rw-r--r-- 1 root root 54708 Oct 13 04:47 index7.ts
-rw-r--r-- 1 root root 52828 Oct 13 04:47 index8.ts
-rw-r--r-- 1 root root 52828 Oct 13 04:47 index9.ts

...

│   ├── index10.ts
│   ├── index11.ts
│   ├── index12.ts
│   ├── index13.ts
│   ├── index14.ts
│   ├── index15.ts
│   ├── index16.ts
│   ├── index17.ts
│   ├── index18.ts
│   ├── index19.ts
│   ├── index1.ts
│   ├── index2.ts
│   ├── index3.ts
│   ├── index4.ts
│   ├── index5.ts
│   ├── index6.ts
│   ├── index7.ts
│   ├── index8.ts
│   └── index9.ts
├── 2x1
│   ├── index0.ts
│   ├── index10.ts
│   ├── index11.ts
│   ├── index12.ts
│   ├── index13.ts
│   ├── index14.ts
│   ├── index15.ts
│   ├── index16.ts
│   ├── index17.ts
│   ├── index18.ts
│   ├── index19.ts
│   ├── index1.ts
│   ├── index2.ts
│   ├── index3.ts
│   ├── index4.ts
│   ├── index5.ts
│   ├── index6.ts
│   ├── index7.ts
│   ├── index8.ts
│   └── index9.ts
└── 4x3
    ├── index0.ts
    ├── index10.ts
    ├── index11.ts
    ├── index12.ts
    ├── index13.ts
    ├── index14.ts
    ├── index15.ts
    ├── index16.ts
    ├── index17.ts
    ├── index18.ts
    ├── index19.ts
    ├── index1.ts
    ├── index2.ts
    ├── index3.ts
    ├── index4.ts
    ├── index5.ts
    ├── index6.ts
    ├── index7.ts
    ├── index8.ts
    └── index9.ts

The minimal preloader segment duration is 2 seconds by default, and can be set in milliseconds with the following parameter

Code Block
themeRDark
hls_preloader_time_min=2000

Disabling HLS preloader

HLS preloader can be disabled if necessary, this feature is available since build 5.2.396. To disable HLS preloader, the following parameter is used

Code Block
themeRDark
hls_preloader_enabled=false

...

1. Choose video clip (logo for example) 2in three aspect ratios: 16:9, 4:3, 2:1

2. Encode video to H264, add audio track to the clip, set GOP and remove B-frames using ffmpeg

Code Block
languagebash
themeRDark
Code Block
languagebash
themeRDark
ffmpeg -i clip16x9.mp4 -f lavfi -i anullsrc=channel_layout=mono:sample_rate=44100 -c:v h264 -g 30 -bf 0 -shortest 16x9/preloader16x9.mp4
ffmpeg -i clip4x3.mp4 -f lavfi -i anullsrc=channel_layout=mono:sample_rate=44100 -c:v h264 -g 30 -bf 0 -shortest 4x3/preloader4x3.mp4
ffmpeg -i clipclip2x1.mp4 -f lavfi -i anullsrc=channel_layout=mono:sample_rate=44100 -c:v h264 -g 30 -bf 0 -shortest preloader2x1/preloader2x1.mp4

3. Download and install HLS tools from Apple site

...

Code Block
languagebash
themeRDark
cd 16x9
mediafilesegmenter -t 2 -B index -start-segments-with-iframe preloaderpreloader16x9.mp4
tar -cvzf preloader.tar.gz index*.ts

This step should be repeated for all aspect ratios.

5. Make a folder for custom preloader

Code Block
languagebash
themeRDark
themeRDark
mkdir /opt/custom_preloader
mkdir /opt/custom_preloader/16x9
mkdir /opt/custom_preloader/4x3
mkdir /opt/custom_preloader/2x1

6. Unpack preloader segments from archive prepared on step 4

Code Block
languagebash
themeRDark
cd /opt/custom_preloader/16x9
tar -xvzf ~/preloaderpreloader16x9.tar.gz

This step should also be repeated for all aspect ratios.

7. Set custom preloader folder and duration in server settings

Code Block
themeRDark
hls_preloader_time_min=2000
hls_preloader_dir=/opt/custom_preloader

Known limits

...

HLS subscription management using REST API

...