Live channel
Use this guide to create a live channel that ingests a UDP source, transcodes it with a transcoding preset and runs on one of your organization's streamers. For the fields and rules behind each call, see the Playback API.
Before you begin¶
- You have an access token for a user whose role in the workspace has
workspace:channels:manage. See Authentication. - You know the workspace ID (
<WORKSPACE_ID>). - Your source is a UDP stream the streamer can receive, for example multicast
udp://239.0.0.1:5000. - An organization admin has opened at least one streamer with role
ingestto the workspace. A user withorg:distribution:manage(by default the organization owner and admin) does this withPUT /api/v1/distribution/<ORG_ID>/streamers/<STREAMER_ID>/access. See the Distribution API.
In the examples, replace <API_HOST> with the CoreAPI host from API conventions and
<ACCESS_TOKEN> with your token.
Steps¶
-
List the streamers your workspace may use, and note the
idof one with"role": "ingest":curl -s "https://<API_HOST>/api/v1/playback/<WORKSPACE_ID>/streamers" \ -H "Authorization: Bearer <ACCESS_TOKEN>"You get
200 OKwith the streamers:{ "success": true, "data": [ { "id": 4, "name": "streamer-a", "host": "streamer-a.example.com", "publicHost": "tv.example.com", "httpPort": 80, "role": "ingest", "status": "online", "hasGpu": false } ] }An empty
datalist means no streamer is open to the workspace yet: ask an organization admin. -
List the transcoding presets and choose one:
curl -s "https://<API_HOST>/api/v1/playback/<WORKSPACE_ID>/transcoding-presets" \ -H "Authorization: Bearer <ACCESS_TOKEN>"You get
200 OKwith presets like this one (shortened):{ "success": true, "data": [{ "id": 3, "name": "HD ladder 720p", "isSystem": false, "passthroughMode": "", "videoRenditions": [{ "label": "720p", "width": 1280, "height": 720, "codec": "libx264", "bitrate": 3000000, "fps": 25, "gopSize": 50, "preset": "veryfast", "profile": "high", "rc_mode": "vbr" }], "audioCodec": "aac", "audioBitrate": 128000, "chunkDuration": "2s", "fragmentDuration": "1s", "netTimeout": "500ms", "forceClean": true, "dropSecondAudio": false, "inUseCount": 0 }] } -
Create the channel. Copy the preset's tuning values into
ingestConfigand its renditions and audio intotranscodeConfig(the server doesn't expand the preset for you):curl -s -X POST "https://<API_HOST>/api/v1/playback/<WORKSPACE_ID>/channels" \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "sid": <SID>, "name": "News 24", "type": "live", "transcodingPresetId": 3, "primaryGenre": "news", "languages": ["en"], "ingestConfig": { "chunkDuration": "2s", "fragmentDuration": "1s", "netTimeout": "500ms", "forceClean": true, "failoverCount": 1 }, "transcodeConfig": { "*": { "dropVideoSource": true, "dropAudioSource": true, "video": [{ "codec": "libx264", "width": 1280, "height": 720, "bitrate": 3000000, "preset": "veryfast", "profile": "high", "gopSize": 50, "rc_mode": "vbr", "fps": 25 }], "audio": [{ "codec": "aac", "bitrate": 128000 }] } }, "origins": [{ "streamerId": 4, "ingestUrl": "<SOURCE_URL>" }] }'<SID>: a service ID no other channel uses, for example101.<SOURCE_URL>: your UDP source, for exampleudp://239.0.0.1:5000?fifo_size=1000000&overrun_nonfatal=1. The query string is optional: the API only checks that the URL starts withudp://(orpl:///) and passes it to the streamer unchanged. The streamer defines whatfifo_sizeandoverrun_nonfataldo.forceClean:truekeeps the stream clean of DRM even when DRM is configured.failoverCount: consecutive source failures before the streamer switches to another source URL. It applies to DASH pull sources only, so it has no effect on a UDP source; copy the preset's value.- For a preset with
"passthroughMode": "full", send"transcodeConfig": {}instead.
You get
201 Createdwith the channel indraftstatus, its origin, and an emptyfailureslist:{ "success": true, "data": { "id": 42, "sid": 101, "name": "News 24", "type": "live", "status": "draft", "quality": "HD", "origins": [{ "id": 88, "streamerId": 4, "streamId": "news_24.stream", "status": "active", "playbackUrl": "https://tv.example.com/news_24.stream/manifest.mpd", "playbackUrlHls": "https://tv.example.com/news_24.stream/master.m3u8" }] }, "failures": [] }Note the channel
id. Iffailuresisn't empty, that origin's streamer refused the stream: its reply is infailures[].response. The channel still runs on the other origins. -
Mark the channel ready, so it can join channel groups:
curl -s -X PATCH "https://<API_HOST>/api/v1/playback/<WORKSPACE_ID>/channels/42/status" \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "status": "ready" }'You get
200 OK:
Verify¶
Check the channel's health. The call takes up to 6 seconds because it probes the source for up to 4 seconds. Call it once after you create the channel; if you poll, wait for each call to return and poll every 10 seconds or less often (a recommendation: each call opens a temporary probe stream on the streamer):
curl -s "https://<API_HOST>/api/v1/playback/<WORKSPACE_ID>/channels/42/health" \
-H "Authorization: Bearer <ACCESS_TOKEN>"
The channel works when outputRunning is true and status is healthy:
{
"success": true,
"data": {
"channelId": 42, "channelName": "News 24", "sid": 101, "ingestUrl": "udp://239.0.0.1:5000",
"streamerId": 4, "streamerName": "streamer-a", "detected": true, "status": "healthy", "outputRunning": true,
"origins": [{ "streamerId": 4, "streamerName": "streamer-a", "host": "streamer-a.example.com",
"status": "online", "healthy": true }]
}
}
unhealthy means the streamer didn't start receiving your source within the 4-second probe. The API sets no time for a new channel to turn healthy; if the first call isn't healthy, check the source before you call again.
You can also open the origin's playbackUrl (DASH) or playbackUrlHls (HLS) in a player.
Troubleshooting¶
| Symptom | Cause | Fix |
|---|---|---|
403 with "Forbidden - Insufficient permissions" |
Your role lacks workspace:channels:manage in this workspace |
Ask an organization admin for a role that has it. |
400 streamer … not found or not available to this workspace |
The streamer isn't open to the workspace | Use an id from step 1. |
400 ingestUrl must be a udp:// or [pl:///](../../get-started/concepts/glossary.md#media-and-channels) URL |
Another scheme in ingestUrl |
Use a udp:// source. |
502 all origins failed |
Every streamer refused the stream or couldn't be reached; nothing was kept | Check transcodeConfig against the preset and that the streamer is online, then retry. |
A failure says the streamer has role "cproxy" |
UDP sources need an ingest streamer |
Choose a streamer with "role": "ingest". |
500 on create |
The sid is already used |
Choose another sid. |
status is unhealthy, outputRunning is false |
The source isn't reaching the streamer | Check the source address and that the streamer's network receives it. |