Recording your live video stream with DVR

1
Enabling DVR Recording

You can call /v1/live-streams/<stream_id> method to enable DVR recording the following way:

curl -H "Authorization: Bearer $ACCESS_TOKEN" 
 -X PUT https://api-live.qencode.com/v1/live-streams/$STREAM_ID
 --data-raw '{ 
 "dvr": {
   "enabled": 1,
   "destination": {
     "url": "s3://us-west.s3.qencode.com/bucketname/path/to/dvr_output",
     "key": "ABCDE12345",
     "secret": "ABCDEFGH12345678",
     "permissions": "public-read"
   }
 }
}'

You should at least specify DVR enabled state and destination object params where recorded videos will be saved. You also can specify the following params:

  • stream_source - specifies the stream to be recorded. Possible values: 'original', 'transcoded' or 'auto' (default).
    • original - system tries to record the original ingested stream
    • transcoded - records the highest available transcoded resolution
    • auto - in this mode system will try to record original stream but will switch to transcoded in case of any incompatibility of incoming stream and recording container
  • resolution - specifies the resolution to be recorded in case stream_source param is set to 'transcoded'. Only applies to to transcoded stream source. Ignored in case stream_source param is set to 'original'.
    Possible values: 'highest', 'lowest', '240p', '480p', '720p', '1080p', '1440p', '4k'. By default the highest transcoded resolution is recorded. In case the highest transcoded resolution is lower than the specified one, system tries to record the closest one.
  • format - specifies the output format for DVR recordings. Possible values: 'mp4' (default) or 'ts'. Use 'ts' for better compatibility if you want to record the original ingested stream instead of transcoded one.
  • max_file_duration - Specifies maximum duration of a recorded video file. In case the stream lasts longer than max_file_duration seconds, system creates another video file and starts transfer of the recorded one to destination specified. Max value - 21600 seconds (6 hrs). Defaults to 14400 (4 hrs).

You can enable or disable stream recording any time, even when your stream is live.

2
Setting recording destination

You should provide at least three params for destination object:

  • url - the folder URL, including protocol, where the recorded output files should be stored. Currently we only support S3 destinations for DVR recordings.

Here's an example of correct value for destination url:

s3://your-s3-sevrer-hostname.com/bucket-name/path/to/dvr-recordings
  • key - S3 storage Access Key ID.
  • secret - S3 storage Secret Access Key.

You optionally can specify permissions for files saved to your storage. Possible values are 'private' (default) and 'public-read'.

3
Setting output format and stream source for recording

You can either record original ingested stream or transcoded stream. Setting stream_source param to 'original' will instruct the system to record original stream. Since MP4 output format for DVR recordings may be not compatible with some video and audio codecs, it's recommended setting output format to 'ts' in this case.

When stream_source param is set to 'transcoded' system select transcoded stream with the highest resolution to be recorded. By default, stream_source param is set to 'auto'. In this mode system checks compatibility of the output format and ingested stream codecs. Original stream is recorded in case they are compatible and transcoded stream is recorded in case of any potential compatibility issues.

4
Setting maximum duration of recorded video files

By default maximum duration of recorded files is set to 4 hours (14400 seconds). You can increase it up to 6 hours by setting max_file_duration param to 21600 seconds. The limitation is applied to a continuous recorded file length, so when it reaches max_file_duration seconds, system starts another video file and recorded one is transferred to the destination specified.