Live Streaming
Our API allows you to create and manage live events on the Dailymotion platform as well as run advertisements and recordings on the content you are broadcasting.
Please note that you need to be a Dailymotion Partner to access this feature.
Publish a live stream
On Dailymotion, a video is considered as a live stream when its mode
is set to live
.
For all operations regarding live streaming (and in general, video) management, you need to request an access token with the manage_videos
scope. Check out the authentication guide for details on how you can request an access token with this scope from your user during the authentication step.
The following steps will get you started with streaming live content.
1. Create a live stream
Since a live stream is based on a video, you can either create a new video with mode
set to live
, or use an existing one.
To create a new video, make a POST HTTP request on https://api.dailymotion.com/videos
containing at least the following three mandatory parameters:
curl --request POST \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--form 'mode=live' \
--form 'published=true' \
--form 'channel=<CHANNEL>' \
"https://api.dailymotion.com/videos"
Note that you can fill in the title, description and any other field just as you would do for any kind of video.
Otherwise, you can use an existing video as a placeholder and transform this video into a live stream by setting the mode
field to live
.
curl --request POST \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--form 'mode=live' \
"https://api.dailymotion.com/video/${VIDEO_ID}"
2. Schedule your live event
Schedule your live event by using either the start_time
and end_time
fields, or start_time
combined with duration
. You can also plan to stream your live event on a regular basis by using the recurrence
field. Note that a recurrence can only be applied if the live stream has both a start date and a duration.
curl --request POST \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--form 'start_time=${START_TIME}' \
--form 'end_time=${END_TIME}' \
"https://api.dailymotion.com/video/${VIDEO_ID}"
Note: this step can be performed together with step 2, in a single HTTP request.
3. Start streaming
Everything is now ready, you can start streaming your content to our servers. Perform a GET HTTP request on your video asking for the live_publish_url
field to retrieve the RTMP URL to feed your encoder.
curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
--form 'fields=live_publish_url' \
"https://api.dailymotion.com/video/${VIDEO_ID}"
This field returns an RTMP url containing both stream url and stream key divided as below:
RTMP URL example | rtmp://publish.dailymotion.com/publish-dm/x1a2b3c?auth=x1cg_588354a7718b9bc1eccfbf9ce62a675714149291 |
---|---|
Stream URL part | rtmp://publish.dailymotion.com/publish-dm |
Stream Key part | x1a2b3c?auth=x1cg_588354a7718b9bc1eccfbf9ce62a675714149291 |
Useful fields and filters for managing a live stream
The following list details some fields and filters of the video object that you may want to use when broadcasting your event and managing your live stream. For more information about those fields, filters and others, please check the API Reference or click on any of these fields.
Fields:
start_time
end_time
recurrence
mode
onair
broadcasting
live_frag_publish_url
live_ingests
live_publish_url
audience
delay
Filters:
Launch a commercial break
During a live event, a broadcaster can launch a commercial break with up to 10 commercials. When the commercial break is triggered, all viewers will simultaneously receive mid-roll advertising in their player, composed of one or several ads depending on the input number.
To launch a commercial break, you need to authenticate and request an access token with the manage_videos
scope. Then, issue a POST HTTP request to https://api.dailymotion.com/video/<VIDEO_ID>
with the live_ad_break_launch
field set to the number of advertisments you want to display.
curl --request POST \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--form 'live_ad_break_launch=1' \
"https://api.dailymotion.com/video/${VIDEO_ID}"
You may be interested in the live_ad_break_end_time
field that lets you know the estimated time of the end of the commercial break.)
Recordings
Dailymotion also enables you to record a live stream and create a video out of it. The recorded video will be available at the end of the live event as a VoD on Dailymotion.
You can set up a manual record (start/stop record) or activate an auto-record option. The recorded video inherits metadata from the live event it is recorded from.
Start/Stop a manual recording
To set up or stop a recording, you have to use the record_status
field on the video object. Make a POST HTTP
request on https://api.dailymotion.com/video/<LIVE_VIDEO_ID>
using record_status=started
or record_status=stopped
depending on if you what to start or stop recording this live event.
curl --request POST \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--form 'record_status=started' \
"https://api.dailymotion.com/video/<LIVE_VIDEO_ID>?fields=id,record_status"
This call returns:
{
"id": <LIVE_VIDEO_ID>,
"record_status": "starting"
}
Activate the auto-record feature
If you want your live event to be automatically recorded, you can toggle the live_auto_record
field to true. Make a POST HTTP
request on https://api.dailymotion.com/video/<LIVE_VIDEO_ID>
setting live_auto_record=true
(or to false if you want to unset the auto-recording feature).
curl --request POST \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--form 'live_auto_record=true' \
"https://api.dailymotion.com/video/<LIVE_VIDEO_ID>?fields=id,live_auto_record"
This call returns:
{
"id": <LIVE_VIDEO_ID>,
"live_auto_record": "true"
}
Useful fields when managing your recordings
To retrieve the list of videos recorded from a live event with id <LIVE_VIDEO_ID>
, make a GET HTTP
request on https://api.dailymotion.com/video/<LIVE_VIDEO_ID>/recordings
Here is a list of fields that you may want to use to know more about your recorded videos:
id
: id of the recorded videorecord_status
: status of the recordinglive_auto_record
: boolean field to be queried on the live video to know if the auto-record feature is onrecord_start_time
: start time of the recordingrecord_end_time
: end time of the recordingrecorded_from
: if you want to know which live event this video is recorded fromrecordings
: the connection on the video object that enables you to list the video recorded from a live event