Create and schedule a live event
Overview
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.
Implementation steps
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 four mandatory parameters:
mode=live
published=true
channel=<CHANNEL>
(for example, channel=videogames)is_created_for_kids=<true|false>
curl --request POST \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--form 'mode=live' \
--form 'published=true' \
--form 'channel=<CHANNEL>' \
--form 'is_created_for_kids=false'\
"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. Note: applying a recurrence can be performed together with start and end times in a single HTTP request.
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}"
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 to manage live streams
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.