English | Korean | Chinese | Japanese

Chapter 5. HLS APIs

Configurations

You can configure several HLS parameters in the configuration.

· HLS List Size: Sets the maximum number of playlist entries. The default value is 3. This setting applies to both live streams and playback streams without a specified duration.

· HLS Time(sec): Sets the target segment length in seconds. The default value is 1. Segments are cut at the next I-frame after this time has elapsed. This applies to live streams and playback streams without a specified duration.

· HLS Time(Playback): Sets the target segment length in seconds for playback streams with a specified duration. The default value is 2. Segments are cut at the next I-frame after this time has elapsed.

Unless necessary, you typically do not need to change these values.

 

Live HLS streaming

 Request
### Primary Stream
http://<address>:<port>/hlsLive/ch[chno]/stream.m3u8
### Sub Stream
http://<address>:<port>/hlsLive/ch[chno]_[sub]/stream.m3u8

· chno: channel number.

· sub: Sub-stream index; 1 for the 1st sub-channel; 2 for the 2nd sub-channel.

· Live streaming must be enabled in the configuration.

 

Request Recording Playback HLS streaming

 Request
### Method 1: Specify time in YYYYMMDDHHMMSS
http://<address>:<port>>/reqPlayback?ch=<channel no>
    [&sub=<sub-stream index, default=0>]
    &time=<YYYYMMDDHHMMSS>&duration=<seconds>
### Method 2: Specify time using Unix Timestamp
http://<address>:<port>/reqPlayback?ch=<channel no>
    [&sub=<sub-stream index, default=0>]
    &timestamp=<Unix Timestamp>&duration=<seconds>

· ch: Channel number.

· sub: Sub-stream index; defaults to 0 (primary stream) if not provided.

· time: Specifies the exact time of the video image, formatted in `YYYYMMDDHHMMSS`.

· timestamp: Specifies the time of the video image in Unix timestamp format.

· duration:

· If the duration is set to zero (`0`), the HLS video will be streamed in live mode, which does not allow navigation in video time (no keep-alive signal needed).

· If the duration is set to a positive value, such as ten seconds (10), you need to send a keep-alive signal every two seconds to prevent the VMS server from deleting the HLS video files.

 Response
{
  "id: "<id.no>",
  "path: "/hlsPlayback/id<id.no>/stream.m3u8"
}

· id: Unique ID used for sending keep-alive signals. This ID should be used in subsequent requests to keep the stream active.

· path: The URL path to access the HLS stream.

 

Request Archived File Playback HLS streaming

 Request
http://<address>:<port>/reqFilePlayback?id=<file id>
    &timestamp=<Unix Timestamp>&duration=<seconds>

· id: Unique file ID.

· timestamp: Specifies the time of the video image in Unix timestamp format.

· duration:

· If the duration is set to zero (`0`), the HLS video will be streamed in live mode, which does not allow navigation in video time (no keep-alive signal needed).

· If the duration is set to a positive value, such as ten seconds (10), you need to send a keep-alive signal every two seconds to prevent the VMS server from deleting the HLS video files.

 Response
{
  "id: "<id.no>",
  "path: "/hlsFilePlayback/id<id.no>/stream.m3u8"
}

· id: Unique ID used for sending keep-alive signals. This ID should be used in subsequent requests to keep the stream active.

· path: The URL path to access the HLS stream.

 

Send Keep Alive Signal for Playback HLS streaming

 Request
### Recording Playback
http://<address>:<port>>/reqPlaybackKeepAlive?id=<id.no>
### Archived File Playback
http://<address>:<port>>/reqFilePlaybackKeepAlive?id=<id.no>

· id_no: The unique identifier you received from the “Request Playback HLS streaming” response. This ID is used to keep the HLS stream active.