Principle of time-shifting live streaming

Time-shifting live streaming is based on conventional HTTP Live Streaming (HLS). In live streaming, an ingest stream is segmented into .ts files, which are distributed to playback users through the HLS protocol. The .m3u8 playlist files requested by users contain constantly refreshing .ts file addresses. In conventional HLS, the .ts file addresses and corresponding .ts files are not persistently stored, making it impossible to trace the live streaming video content prior to the current time. In contrast, in HLS with the time shifting feature enabled, the .ts file addresses and corresponding .ts files are persistently stored in the database and OSS bucket independently for up to 15 days. This makes it possible to trace the video content back from the start time of live streaming to the current time.

Time shifting setting

The time shifting feature is now available in open beta. You can open a ticket to try this feature.

Item Description
Enterprise name None
Streaming domain All live streams under the specified streaming domain support time shifting.
Retention period of time-shifting content Time-shifting content is retained for seven days by default.

Request parameters for time shifting

To implement time-shifting live streaming, you need to add time-shifting parameters to a conventional HLS URL such as http://domain/app/stream.m3u8.

Required parameter

Note You must specify this parameter to call a time-shifting operation through CDN.

Time-related parameter

The format of the key is lhs_{type}_{format}_{unit}_{zone}.
Note The parameter name consists of four variables and a fixed prefix lhs_. The variables are separated with underscores (_). The variables are described as follows:
  • type: the type of the time. Valid values:

    • start: the start time of live streaming.

    • end: the end time of live streaming.

    • vodend: the end time of video-on-demand (VOD). If you set this variable to vodend, the video is played back in VOD mode. In this case, all .ts files within a specified duration are returned at a time, including the endlist tags.

    • offset: the forward offset time.

  • format: the format of the time. Valid values:

    • unix: the UNIX timestamp.

    • human: the human-readable time such as 20170809230130.

  • unit: the unit of the time. Valid values:

    • s: second

    • ms: millisecond

    • us: microsecond

    • ns: nanosecond

  • zone: the time zone.

    • Valid values: any integer from 0 to 9. The value indicates the number of hours to add to UTC to get the standard time in the specified time zone. A value of 0 indicates the UTC time. A value of 8 indicates the China Standard Time.


  • lhs_start_unix_s_0=1502280113

  • lhs_offset_unix_ms_8=1502308959375

  • lhs_end_human_s_8=20170809200010

Sample requests"

Timeline query

You can query the periods of time during which time-shifting data was involved within a historical duration along the timeline of a specified stream.

  • URL: http://{$domain}/openapi/timeline/query

  • Method: GET

  • Parameters:

    • app (required): the name of the live streaming application.

    • stream (required): the name of the live stream.

    • format (required): the format of the time-shifting data to be queried, which can be .ts or .flv.

    • lhs_start_unix_s_0 (required): the start timestamp, measured in seconds since 00:00:00 Thursday, 1 January 1970.

    • lhs_end_unix_s_0 (required): the end timestamp, measured in seconds since 00:00:00 Thursday, 1 January 1970.
      Note If you have enabled CDN authentication, you must add the authentication parameters accordingly.
  • Response (JSON format):

    • current: the current system time, with which the time of your player is aligned.

    • timeline: an array. Each element of the array is called a map, which indicates a valid time-shifting period. Each map includes the following fields:

    • timeline[i].start: the start timestamp of a valid .ts file, measured in seconds since 00:00:00 Thursday, 1 January 1970.

    • timeline[i].end: the end timestamp of a valid .ts file, measured in seconds since 00:00:00 Thursday, 1 January 1970.

  • Example

    http://$host/openapi/timeline/query? app=bbb&domain=aaaa&format=ts&lhs_end_unix_s_0=1513334270&lhs_start_unix_s_0=1513334255&stream=cc