Create a stream
Live streaming with Livepeer.com is easy. The first step is understanding the
stream
object. It is the core building block of the Livepeer.com platform.
A Livepeer.com stream
is a unique object with configuration data and metadata
about all live stream sessions associated with it.
stream
object with a parentId
represented a single live stream session. This type of "child-session" stream object will be deprecated in an upcoming version of the API in favor of the session
object.There are two ways to create a stream object:
Login to the Livepeer.com Dashboard, and navigate to the Streams page, livepeer.com/dashboard/streams. On this page you can create a new stream and delete streams. When you name your stream, pick a unique name and include URL compatible characters only.
On the Stream page (livepeer.com/dashboard/streams), you can also click on a stream to find out configuration and usage information.
Send a POST
request to https://livepeer.com/api/stream
. This creates a new
Livepeer.com stream
object.
Use a Livepeer.com API key as a part of the authorization header, and use a JSON
body to specify the configuration for the stream. The only parameter you are
required to set is the name
of your stream, but we also highly recommend that
you define the profiles
parameter with 720p, 480p and 360p renditions.
If you do not define transcoding rendition profiles
when creating the
stream
, no transcoding will happen. Your playback video will have the
attributes of the source stream only, will not take advantage of adaptive
bitrate streaming and will likely buffer.
Here is an example request:
curl -X POST \
-H 'content-type: application/json' \
-H 'authorization: Bearer {api_key}' \
-d '{
"name": "test_stream",
"profiles": [
{
"name": "720p",
"bitrate": 2000000,
"fps": 30,
"width": 1280,
"height": 720
},
{
"name": "480p",
"bitrate": 1000000,
"fps": 30,
"width": 854,
"height": 480
},
{
"name": "360p",
"bitrate": 500000,
"fps": 30,
"width": 640,
"height": 360
}
]
}' \
https://livepeer.com/api/stream
This is an example response to the request above. streamKey
, playbackId
, and
id
are unique to the stream
object. You will need the streamKey
to
broadcast live video and the playbackId
to configure the playback URL to watch
the live stream.
{
"name":"test_stream",
"profiles":[
{"name":"720p","bitrate":2000000,"fps":30,"width":1280,"height":720},
{"name":"480p","bitrate":1000000,"fps":30,"width":854,"height":480},
{"name":"360p","bitrate":500000,"fps":30,"width":640,"height":360},
],
"id":"ijkl61f3-95bd-4971-a7b1-4dcb5d39e78a",
"createdAt":1596081229373,
"streamKey":"abcd-uimq-jtgy-x98v",
"playbackId":"efghb2mxupongp5k",
{other asset object keys}
}