Livepeer Studio
Thursday, January 28, 2021
Product

Livepeer Video Services New Stream Recording & MP4 Download Features

By
Angie Ramirez
Angie Ramirez
4 min read
The latest release of Livepeer Video Services stream recording & MP4 downloads, and much requested features from our comunity.

Our lives, from meaningful life events like birthdays, weddings, and baby showers, to work meetings, fitness classes, shopping, and social media streaming, have moved online this year. With change comes an opportunity to innovate - and that’s what we have done collectively as a world society amidst a global pandemic.

At Livepeer, we understand the increasing importance of capturing these meaningful moments, both for individuals and for companies riding this wave of digital innovation. We are therefore proud to announce the release of Livepeer Video Services stream recording, a feature much requested and anticipated.

This recording feature provides all Livepeer API and dashboard users with a .m3u8 and an MP4 link to an adaptive bitrate streaming (ABR) recording of their completed livestream. Playback is delivered via Livepeer.com's CDN by default.

To take advantage of this newly released feature, check out the guide below. The first section is for Livepeer Video Services users who create streams using the Livepeer Video Services Dashboard directly. The second section is for those who use the Livepeer API.

Please note: If you are using recording and OBS, be sure to change your keyframe interval to 2.

Using the Livepeer Video Services Dashboard to record streams

If you’re using the Livepeer Video Services Dashboard to create streams, enabling recording is as simple as checking the Record ON toggle in your individual stream page. The URL for your individual stream page should look something like this:

https://livepeer.com/dashboard/streams/12345678-ab40-429d-a714-0e0fd4ab0abc.

The Record ON toggle is located immediately below the Stream Key section. You can also change the settings by using the "Actions" button at the top of the page. When Record ON is switched on, future streaming sessions will be recorded and stored by Livepeer Video Services. The session recording playback URL will be available about 5 minutes after the live stream ends and will appear in the session table at the bottom of the stream page.

Using the Livepeer API to record streams

If you do not have a Livepeer Video Services account or an API key follow step 1 in this guide prior to getting started.

Before learning how to make a simple API request to turn recording on for streaming, we need to understand the Livepeer API stream object.

There are two types of stream objects.

  • A child stream object is a single live streaming session.
  • A parent stream object shows the configuration and metadata totals of all its child stream sessions.

On a parent stream object.

  • record: true means that new sessions are recorded
  • record: false means that new sessions are not recorded

On a child-session stream object, the record value is read-only.

  • record: true means that the session is actively being recorded or was recorded.
  • record: false means that the session is not being recorded or was not recorded.

Read more about the stream object here.

To create a new recording-enabled stream:

Send an HTTP POST request to https://livepeer.com/api/stream. In that request, include an authorization header of Bearer <api_key>, a JSON body with a stream name of your choosing, a record field set to true, and details about which video profiles or renditions you’d like to transcode your stream into. See step 3 in this guide for more information on profiles.

Sample post request:

curl -X POST \
-H 'content-type: application/json' \
-H 'authorization: Bearer <api_key>' \
-d '{
  "name": "test_stream_recording_on",
  "record": true
}' \
https://livepeer.com/api/stream

Sample response of stream with recording turned on:

{
  "name":"test_stream_recording_on",
  "record":true,
  "kind":"stream",
  "userId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxx",
  "id":"yyyyyyyy-yyyy-yyyy-yyyy-yyyy",
  "createdAt":1595721600,
  "streamKey":"zzzz-zzzz-zzzz-zzzz",
  "playbackId":"xyz123xyz123",
  "createdByTokenName":"test-api-key",
  <other asset object keys, like profiles>
}

To enable recording for existing streams:

PATCH /stream/<parent_stream_id>/record to modify a parent stream object. The parent record value is inherited by all future child-session stream objects.

curl -X PATCH https://livepeer.com/api/stream/<parent_stream_id>/record \
-H 'content-type: application/json' \
-H 'authorization: Bearer <api_key>' \
-d '{"record":true}'

To check if recording is enabled on an existing stream:

The response to GET /stream/<parent_stream_id> will return the record value.

curl -H 'authorization: Bearer <api_key>' \
"https://livepeer.com/api/stream/<parent_stream_id>"

To request all recorded sessions for a parent stream:

The parentId of a child-session stream object is the same as the id of its parent stream object. A common use case is to request all recorded sessions with the same parentId. For example, a user generated content (UGC) video platform may create a stream object for each UGC live streamer and then want to show an archive of all recorded livestream sessions for each live streamer.

To request all stream sessions with the same parentId with record: true  make the following request:

curl -H 'authorization: Bearer <api_key>' \
"https://livepeer.com/api/stream/<parent_stream_id>/sessions?record=1"

Playback a session recording:

The playback URL for a livestream session recording will not be available until approximately 5 minutes after the livestream has ended.

Once the recording is ready, the session stream object's recordingUrl parameter will return the .m3u8 recording playback URL. Additionally, the session stream object's mp4URL will return an .mp4 recording playback URL.

The recording playback URL will look something like this: https://region-cdn.livepeer.com/recordings/<id-of-stream-session>/index.m3u8. View the live stream with any HLS video player.

For more detailed information on stream recording or to ask any questions, share your thoughts, or make any kind of suggestion, feel free to get in touch at [email protected]. We’d love to hear from you!


Get
Started
Join the next-gen, creator-owned video ecosystem. From “decentralized YouTube” to video NFT marketplaces, Livepeer Studio empowers developers to build video-enabled applications that give creators total control over their content with no middlemen.

Why Livepeer Studio

Livepeer Studio is a powerful suite of web3 tools that make it easy for builders to create new video experiences and access the decentralized Livepeer network. More than a product, Livepeer Studio is a growing community of web3 developers and creators creating the future of web3 video.

Why Livepeer

Livepeer is the world's open video infrastructure. Founded in 2017, Livepeer provides cost efficient, secure, scalable, and reliable infrastructure that can handle today's high demand for video processing. Livepeer's decentralized network includes over 70,000 GPUs and currently processes millions of minutes a week.

Social