Use the Python SCTE plugin to process your SCTE 35/104 signal with a custom Python file. Your code should contain specific functions that hook into SCTE processing and control the state of the Live Slicer.
Python and its libraries must be installed to your system's shared library path. By default, the Live Slicer uses Python 2.7, which is included with Mac OS X and Ubuntu versions 14.04 LTS or lower. However, you may configure the Live Slicer (version 20031300 or higher) to use Python 3.6 by including the following configuration in your Live Slicer configuration file:
Syntax (Python 3.6):
Syntax (Python 3.6 installed with pymalloc support):
Set up a Live Slicer to use your Python SCTE plugin by adding the following settings to your Live Slicer configuration file:
scte_type: python
scte_module: my_scte_plugin
scte_python_version: 3.6m
If you have not installed Python 3.6 with pymalloc support, then you should update the scte_python_version setting with the correct version.
Copy your Python plugin to the plugins subfolder of your Live Slicer's installation directory and then replace my_scte_plugin with your Python plugin's file name.
Plugins may be either be plaintext or encrypted. The configuration for both plaintext and encrypted plugins is the same with the exception of file name. The file name for an encrypted plugin is the SHA-1 hash of the plaintext plugin's file name. Although the file name will be encrypted, the scte_module parameter should still be set to the plaintext file name.
If both an encrypted and plaintext version of your plugin are found, then the plaintext version will take precedence.
Sample Scenario
In this sample scenario:
You have encrypted the above plugin. The encrypted file name is:
Set the scte_module parameter to the following value:
If you would like to use the encrypted version of this plugin, please verify that the plaintext version of the plugin is not present in the Live Slicer's plugins folder.
The most basic plugin, which does nothing, must appear as:
import slicer def Initialize(): return slicer.Initialize()
This function is necessary to establish proper communication between the plugin and the slicer. The second, optional, function is where you perform SCTE logic:
def Process35(slice_info): slicer.Blackout(long(0)) return long(0)
This function receives the SCTE35 packets and inside you may inspect the slice_info object containing the SCTE packet or call slicer module functions to control the slicer. SCTE104 packets are converted to SCTE35 and passed to this function for unified handling of SCTE.
The slicer module provides a way for your plugin to call functions and manipulate slicer state.
The available functions are:
Function | Description |
---|---|
Explicitly ends an ad break. |
|
Adds metadata to an ad break. |
|
Starts an ad break. |
|
Initiates blackout mode. |
|
Starts a new asset. |
|
Ends an ad boundary. |
|
Defines the presentation timestamp (PTS) at which the metadata defined via the MetaMetadata function will be applied. |
|
Indicates the current Live Slicer state. |
|
Returns Live Slicer status and configuration information. |
|
Initializes the slicer module. |
|
Adds metadata to the asset currently being sliced. |
|
Adds metadata to the asset associated with the next segment. |
|
Logs error conditions, informational messages, and debug messages. |
|
Starts an ad boundary. |
|
Adds metadata as an ID3 tag at the presentation timestamp (PTS). |
Initializes the slicer module. Call this function via the Initialize() function as shown above.
Returns a string that indicates the current Live Slicer state.
Valid values are:
Sample request:
print slicer.GetState()
Returns Live Slicer status and configuration information. The response for this function may contain the following parameters:
Parameter |
Type |
Description |
---|---|---|
status |
Object |
Contains Live Slicer status information. This object is similar to the status object returned by the status endpoint from the Live Slicer API. |
config |
Object |
Contains Live Slicer configuration file settings. |
slicerID |
String |
Identifies the Live Slicer's ID as defined in the Live Slicer configuration file. |
externalID |
String |
Indicates the external ID that will be assigned to the CMS asset created from the live stream. |
Sample request:
print slicer.GetStatus()
Initiates blackout mode.
Sample request:
print slicer.Blackout(long(pts))
Starts a new asset. Description and External ID are optional.
Sample request:
print slicer.ContentStart(long(pts), "Description", "External ID")
Starts an ad break. Duration is optional. If omitted, you must call AdEnd() to end the ad break.
Sample request:
print slicer.AdStart(long(pts), long(duration))
Explicitly ends an ad break.
Sample request:
print slicer.AdEnd(long(pts))
Adds metadata to a specific ad break. Call AdMeta before starting an ad break.
This function only adds metadata to a specific ad break. It is not applied globally across all ad breaks.
Sample request:
print slicer.AdMeta("key", "value")
Defines the presentation timestamp (PTS) at which the metadata defined via the MetaMetadata function will be applied.
Sample request:
print slicer.FlushBreakMeta(long(pts))
Adds metadata to the asset currently being sliced as determined by the next video frame.
Metadata may be incorrectly applied to an asset under certain conditions. For example, metatadata may be applied to the previous asset when this function is called directly after a content_start. The recommended method for setting metadata is via the MetaMetadata and FlushBreakMeta functions.
View the metadata associated with an asset from within the CMS.
Sample request:
print slicer.Metadata("key", "value")
Adds metadata to the asset associated with the next segment as determined by content start, ad start, etc.
The recommended method for associating metadata with an asset is to set it via the MetaMetadata function and then setting the presentation timestamp (PTS) at which it will be applied to an asset via the FlushBreakMeta function.
View the metadata associated with an asset from within the CMS.
Sample request:
print slicer.MetaMetadata("key", "value")
Logs error conditions, informational messages, and debug messages to the terminal and syslog.
Valid log levels are:
Syntax:
Sample request:
print slicer.SlicerLogger("info", "Started an asset boundary.")
Starts an asset boundary. If a boundary is already active, this is ignored. Duration is optional. If omitted, call EndBoundary() to explicitly end an asset boundary.
Sample request:
print slicer.StartBoundary(long(pts), name, long(duration))
Ends an asset boundary. This function is ignored when there isn't an active boundary.
Sample request:
print slicer.EndBoundary(long(pts))
Adds metadata as an ID3 tag at the presentation timestamp (PTS).
Syntax:
Sample request:
print slicer.TimedMeta(long(pts), "key", "value")