Live Slicer

The Live Slicer API allows you to:

  • Mark ads, replacement content, or content boundaries.
  • Set metadata on an asset.
  • Retrieve detailed Live Slicer status information.

The API is exposed via an internal web server in the Live Slicer and can be called from any programming language with an HTTP client interface.

Choosing Between Live Slicer API and Slicer API

APIUse Case
Live Slicer APIUse when you need to control stream behavior (e.g., marking ads, setting metadata, retrieving slicer status).
Slicer APIUse when retrieving the last known status of one or more Live Slicers or updating slicing schedules.

API Conventions

  • Uses POST or GET HTTP methods.
  • Most endpoints do not require query string parameters.
  • Request body must be a serialized JSON object.
  • Responses include a JSON object with an error field:
    • 0 indicates success.
    • Non-zero values indicate errors, often accompanied by a msg field.

Authentication

Authentication is required for Live Slicer version 15091000 or higher. By default, authentication is disabled but can be enabled via the authenticated_api_port configuration parameter. Requests over this port are unencrypted.

Authentication Parameters

ParameterDescription
timestamp10-second authentication window (Unix time).
cnonceUnique integer value.
sigBase-64-encoded SHA-1 hash of Endpoint:Timestamp:cnonce:Authentication Token.

Finding Your API Key

  1. Navigate to Integration Keys.
  2. API keys are listed under the API Keys section.

Authentication Example

Sample Request (HTTP)

POST /content_start HTTP/1.1
Content-Type: application/json
Host: localhost:65009
Content-Length: 108

{
  "timestamp": 1438101883,
  "cnonce": 123,
  "sig": "49bQGXKTRYPQ5b22m89zKe1zcKk=",
  "start_timecode": "11:22:33;04"
}

Sample Request (Python)

import urllib2, hashlib, time, json, base64

secret = hashlib.sha1('XH7HtD8tR3993IxfbcqX0uhKnc-mYksmPxqM2z1a').hexdigest()
timestamp = int(time.time())
endpoint = '/content_start'
cnonce = 123
sig_input = f"{endpoint}:{timestamp}:{cnonce}:{secret}"
sig = base64.b64encode(hashlib.sha1(sig_input).digest())
body = json.dumps({"timestamp": timestamp, "cnonce": cnonce, "sig": sig })
request = urllib2.urlopen('http://localhost:65009/' + endpoint, body)
response = json.loads(request.read())

assert response['error'] == 0

Port Configuration

By default, the Live Slicer listens for API requests on port 65009. You can modify this by updating the api_port configuration setting.


Scheduling Actions

You can schedule when an API request takes effect using one of the following parameters:

ParameterDescription
start_timecodeIdentifies the video frame when an operation will take effect.
offset_time_msIdentifies a time relative to now (local system time), in milliseconds.
offset_from_now_msIdentifies a time relative to the start of the current asset, in milliseconds.

Most Live Slicer API endpoints accept these parameters.

Timecode

start_timecode specifies the exact video frame where an action should occur. The format follows:

  • Drop frame: hh:mm:ss;vf
  • Non-drop frame: hh:mm:ss:vf

Example: 00:15:02;01 marks the second frame at 15 minutes and two seconds after midnight.

For UDP and RTMP sources, enable the useSystemClockAsTimecode setting.

Resolving Timecodes

  • If the requested timecode exists in the capture delay buffer, the Live Slicer applies the action at that frame's presentation timestamp (PTS).
  • If not, the Live Slicer applies the action at the oldest frame in the buffer.
  • Configure the buffer duration via capture_delay.

Future Timecodes

Enable future_timecodes to schedule actions up to 12 hours in the future.

ConditionBehavior
Timecode exists in bufferAction occurs at the specified frame.
Future timecode (<12 hours)API returns an id response; action occurs at the specified time.
Future timecode (>12 hours) or missing frameAction takes effect immediately.
Past timecodeSDI: Action occurs immediately. UDP/RTMP: Action occurs 24 hours later.

Scheduled Break Expiration

Configure the expiration of future breaks using future_break_expiration_minutes.

drop_expired_breaks SettingBehavior
OnExpired API requests are ignored.
Off or missingExpired requests are processed regardless of timecode expiration.

View or delete scheduled breaks via remove_break and list_breaks.


Relative Time Scheduling

An alternative to start_timecode is specifying relative time using:

ParameterDescription
offset_from_now_msTime relative to now, in milliseconds.
offset_time_msTime relative to the start of the current asset, in milliseconds.

Precedence Order: offset_time_ms > offset_from_now_ms > start_timecode

If none of these parameters are included, the action takes effect immediately.


Examples

Sample Request (HTTP)

POST /blackout HTTP/1.1
Content-Type: application/json
Host: localhost:65009
Content-Length: 33

{
  "start_timecode": "11:22:33;04"
}

Sample Response (HTTP)

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 12

{
  "error": 0
}

Sample Request (Python)

import urllib2, json

body = json.dumps({"start_timecode": "11:22:33;04"})
request = urllib2.urlopen('http://localhost:65009/blackout', body)
response = json.loads(request.read())

assert response['error'] == 0

Sample Request (cURL)

curl --data '{"start_timecode":"11:22:33;04"}' http://localhost:65009/blackout

Endpoints

EndpointDescription
/add_cc608Injects EIA/CEA-608/708 captions into the stream.
/add_imagebugSchedules an image overlay.
/add_metaAdds metadata to the currently sliced asset.
/blackoutEnds the current asset and stops capturing until further notice. Resume with /content_start.
/boundaryCreates and defines a content boundary.
/content_startEnds the current asset and starts a new one or resumes from blackout.
/ignore_scheduleEnables/disables ignore state for slicing schedules.
/list_breaksReturns a list of scheduled breaks.
/list_imagebugLists scheduled image overlays.
/pod_endEnds an ad pod and resumes capture.
/pod_startMarks an ad pod for replacement with an unknown duration.
/remove_breakRemoves a break from the schedule.
/remove_imagebugRemoves an image overlay.
/replace_contentReplaces a live stream section with pre-encoded content.
/replace_podMarks an ad pod for replacement with a specific duration.
/restart_laterRestarts the Live Slicer at the next ad break, blackout, or /content_start.
/server_timeReturns the current time for the Live Slicer and CMS.
/stateReturns the Live Slicer's operating state.
/statusProvides Live Slicer status details.
/timedmetaInserts a timed metadata key/value pair into the stream.