(stream )
Operations related to livestream api
The only parameter you are required to set is the name of your stream,
but we also highly recommend that you define transcoding profiles
parameter that suits your specific broadcasting configuration.
If you do not define transcoding rendition profiles when creating the
stream, a default set of profiles will be used. These profiles include
240p, 360p, 480p and 720p.
The playback policy is set to public by default for new streams. It can
also be added upon the creation of a new stream by adding
"playbackPolicy": {"type": "jwt"}
from livepeer import Livepeer
from livepeer .models import components
s = Livepeer (
api_key = "<YOUR_BEARER_TOKEN_HERE>" ,
)
res = s .stream .create (request = {
"name" : "test_stream" ,
"pull" : {
"source" : "https://myservice.com/live/stream.flv" ,
"headers" : {
"Authorization" : "Bearer 123" ,
},
"location" : {
"lat" : 39.739 ,
"lon" : - 104.988 ,
},
},
"playback_policy" : {
"type" : components .Type .WEBHOOK ,
"webhook_id" : "1bde4o2i6xycudoy" ,
"webhook_context" : {
"streamerId" : "my-custom-id" ,
},
"refresh_interval" : 600 ,
},
"profiles" : [
{
"width" : 1280 ,
"name" : "720p" ,
"height" : 720 ,
"bitrate" : 3000000 ,
"fps" : 30 ,
"fps_den" : 1 ,
"quality" : 23 ,
"gop" : "2" ,
"profile" : components .Profile .H264_BASELINE ,
},
],
"record" : False ,
"recording_spec" : {
"profiles" : [
{
"bitrate" : 3000000 ,
"width" : 1280 ,
"name" : "720p" ,
"height" : 720 ,
"quality" : 23 ,
"fps" : 30 ,
"fps_den" : 1 ,
"gop" : "2" ,
"profile" : components .TranscodeProfileProfile .H264_BASELINE ,
"encoder" : components .TranscodeProfileEncoder .H_264 ,
},
],
},
"multistream" : {
"targets" : [
{
"profile" : "720p" ,
"video_only" : False ,
"id" : "PUSH123" ,
"spec" : {
"url" : "rtmps://live.my-service.tv/channel/secretKey" ,
"name" : "My target" ,
},
},
],
},
})
if res .stream is not None :
# handle response
pass
operations.CreateStreamResponse
Error Object
Status Code
Content Type
errors.SDKError
4xx-5xx
/
Retrieve streams
from livepeer import Livepeer
s = Livepeer (
api_key = "<YOUR_BEARER_TOKEN_HERE>" ,
)
res = s .stream .get_all ()
if res .data is not None :
# handle response
pass
Parameter
Type
Required
Description
streamsonly
Optional[str]
➖
N/A
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
operations.GetStreamsResponse
Error Object
Status Code
Content Type
errors.SDKError
4xx-5xx
/
Retrieve a stream
from livepeer import Livepeer
s = Livepeer (
api_key = "<YOUR_BEARER_TOKEN_HERE>" ,
)
res = s .stream .get (id = "<id>" )
if res .stream is not None :
# handle response
pass
Parameter
Type
Required
Description
id
str
✔️
ID of the stream
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
operations.GetStreamResponse
Error Object
Status Code
Content Type
errors.SDKError
4xx-5xx
/
Update a stream
from livepeer import Livepeer
from livepeer .models import components
s = Livepeer (
api_key = "<YOUR_BEARER_TOKEN_HERE>" ,
)
res = s .stream .update (id = "<id>" , stream_patch_payload = {
"record" : False ,
"multistream" : {
"targets" : [
{
"profile" : "720p" ,
"video_only" : False ,
"id" : "PUSH123" ,
"spec" : {
"url" : "rtmps://live.my-service.tv/channel/secretKey" ,
"name" : "My target" ,
},
},
],
},
"playback_policy" : {
"type" : components .Type .WEBHOOK ,
"webhook_id" : "1bde4o2i6xycudoy" ,
"webhook_context" : {
"streamerId" : "my-custom-id" ,
},
"refresh_interval" : 600 ,
},
"profiles" : [
{
"width" : 1280 ,
"name" : "720p" ,
"height" : 720 ,
"bitrate" : 3000000 ,
"fps" : 30 ,
"fps_den" : 1 ,
"quality" : 23 ,
"gop" : "2" ,
"profile" : components .Profile .H264_BASELINE ,
},
],
"recording_spec" : {
"profiles" : [
{
"bitrate" : 3000000 ,
"width" : 1280 ,
"name" : "720p" ,
"height" : 720 ,
"quality" : 23 ,
"fps" : 30 ,
"fps_den" : 1 ,
"gop" : "2" ,
"profile" : components .TranscodeProfileProfile .H264_BASELINE ,
"encoder" : components .TranscodeProfileEncoder .H_264 ,
},
],
},
})
if res is not None :
# handle response
pass
operations.UpdateStreamResponse
Error Object
Status Code
Content Type
errors.SDKError
4xx-5xx
/
This will also suspend any active stream sessions, so make sure to wait
until the stream has finished. To explicitly interrupt an active
session, consider instead updating the suspended field in the stream
using the PATCH stream API.
from livepeer import Livepeer
s = Livepeer (
api_key = "<YOUR_BEARER_TOKEN_HERE>" ,
)
res = s .stream .delete (id = "<id>" )
if res is not None :
# handle response
pass
Parameter
Type
Required
Description
id
str
✔️
ID of the stream
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
operations.DeleteStreamResponse
Error Object
Status Code
Content Type
errors.SDKError
4xx-5xx
/
DELETE /stream/{id}/terminate
can be used to terminate an ongoing
session on a live stream. Unlike suspending the stream, it allows the
streamer to restart streaming even immediately, but it will force
terminate the current session and stop the recording.
A 204 No Content status response indicates the stream was successfully
terminated.
from livepeer import Livepeer
s = Livepeer (
api_key = "<YOUR_BEARER_TOKEN_HERE>" ,
)
res = s .stream .terminate (id = "<id>" )
if res is not None :
# handle response
pass
Parameter
Type
Required
Description
id
str
✔️
ID of the stream
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
operations.TerminateStreamResponse
Error Object
Status Code
Content Type
errors.SDKError
4xx-5xx
/
POST /stream/{id}/start-pull
can be used to start ingest for a stream
configured with a pull source. If the stream has recording configured,
it will also start recording.
A 204 No Content status response indicates the stream was successfully
started.
from livepeer import Livepeer
s = Livepeer (
api_key = "<YOUR_BEARER_TOKEN_HERE>" ,
)
res = s .stream .start_pull (id = "<id>" )
if res is not None :
# handle response
pass
Parameter
Type
Required
Description
id
str
✔️
ID of the stream
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
operations.StartPullStreamResponse
Error Object
Status Code
Content Type
errors.SDKError
4xx-5xx
/
Create a clip
from livepeer import Livepeer
s = Livepeer (
api_key = "<YOUR_BEARER_TOKEN_HERE>" ,
)
res = s .stream .create_clip (request = {
"playback_id" : "eaw4nk06ts2d0mzb" ,
"start_time" : 1587667174725 ,
"end_time" : 1587667174725 ,
"name" : "My Clip" ,
"session_id" : "de7818e7-610a-4057-8f6f-b785dc1e6f88" ,
})
if res .data is not None :
# handle response
pass
operations.CreateClipResponse
Error Object
Status Code
Content Type
errors.SDKError
4xx-5xx
/
Retrieve clips of a livestream
from livepeer import Livepeer
s = Livepeer (
api_key = "<YOUR_BEARER_TOKEN_HERE>" ,
)
res = s .stream .get_clips (id = "<id>" )
if res .data is not None :
# handle response
pass
Parameter
Type
Required
Description
id
str
✔️
ID of the parent stream or playbackId of parent stream
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
operations.GetClipsResponse
Error Object
Status Code
Content Type
errors.SDKError
4xx-5xx
/
Add a multistream target
from livepeer import Livepeer
s = Livepeer (
api_key = "<YOUR_BEARER_TOKEN_HERE>" ,
)
res = s .stream .add_multistream_target (id = "<id>" , target_add_payload = {
"profile" : "720p0" ,
"video_only" : False ,
"id" : "PUSH123" ,
"spec" : {
"url" : "rtmps://live.my-service.tv/channel/secretKey" ,
"name" : "My target" ,
},
})
if res is not None :
# handle response
pass
operations.AddMultistreamTargetResponse
Error Object
Status Code
Content Type
errors.SDKError
4xx-5xx
/
remove_multistream_target
Remove a multistream target
from livepeer import Livepeer
s = Livepeer (
api_key = "<YOUR_BEARER_TOKEN_HERE>" ,
)
res = s .stream .remove_multistream_target (id = "<id>" , target_id = "<value>" )
if res is not None :
# handle response
pass
Parameter
Type
Required
Description
id
str
✔️
ID of the parent stream
target_id
str
✔️
ID of the multistream target
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
operations.RemoveMultistreamTargetResponse
Error Object
Status Code
Content Type
errors.SDKError
4xx-5xx
/