Programmable Video Rest API: Recordings
Overview
Twilio Video’s Group Rooms and Recording APIs allow you to record the audio and video shared in a Programmable Video Room. To turn on Recording in a Group Room, set the RecordParticipantsOnConnect
property to true
when creating the Room. Check the Rooms REST API documentation for additional information.
All Recording resources are located beneath the following Base URL.
https://video.twilio.com
Legal implications of call recording
If you choose to record voice or video calls, you need to comply with certain laws and regulations, including those regarding obtaining consent to record (such as California’s Invasion of Privacy Act and similar laws in other jurisdictions). Additional information on the legal implications of call recording can be found in the "Legal Considerations with Recording Voice and Video Communications" Help Center article.
Notice: Twilio recommends that you consult with your legal counsel to make sure that you are complying with all applicable laws in connection with communications you record or store using Twilio.
Contents
- Recording Instance Resource
- Recordings List Resource
- Using the Rooms API to find Recordings
- Examples
- Retrieve a Recording
- Retrieve a Recording's Media
- Delete a Recording
- Get all Recordings from a given Room
- Get all Recordings from a given Participant
- Get the list of deleted Recordings
- Get all Recordings from a given Room using the Rooms API
- Retrieve a Recording using the Rooms API
- Retrieve a Recording's Media using the Rooms API
- Size estimation of a track Recording
- Known limitations
Recording instance resource
Recordings captured by Programmable Video products are single-track, single-media and stored in a single file format.
Recordings are represented through a REST API with the following URI scheme:
/v1/Recordings/{RecordingSid}
Resource properties
A Recording has the following properties:
Resource Properties in REST API format | |
---|---|
account_sid
|
The SID of the Account that created the Recording resource. |
status
|
The status of the recording. Can be: |
date_created
|
The date and time in GMT when the resource was created specified in ISO 8601 format. |
sid
|
The unique string that we created to identify the Recording resource. |
source_sid
|
The SID of the recording source. For a Room Recording, this value is a |
size
|
The size of the recorded track, in bytes. |
url
|
The absolute URL of the resource. |
type
|
The recording's media type. Can be: |
duration
|
The duration of the recording in seconds rounded to the nearest second. Sub-second tracks have a |
container_format
|
The file format for the recording. Can be: |
codec
|
The codec used to encode the track. Can be: |
grouping_sids
|
A list of SIDs related to the recording. Includes the |
track_name
|
The name that was given to the source track of the recording. If no name is given, the |
offset
|
The time in milliseconds elapsed between an arbitrary point in time, common to all group rooms, and the moment when the source room of this track started. This information provides a synchronization mechanism for recordings belonging to the same room. |
media_external_location
|
The URL of the media file associated with the recording when stored externally. See External S3 Recordings for more details. |
status_callback
|
The URL called using the |
status_callback_method
|
The HTTP method used to call |
links
|
The URLs of related resources. |
Note: The duration of media tracks is rounded to the nearest second. Thus, sub-second duration tracks have a Duration
property of 1 second.
HTTP GET
Returns a single Recording Instance resource identified by a RecordingSid
.
Example: Retrieve a Recording
HTTP GET to the /Media
subresource
Retrieves the media file associated to a given Recording Instance resource
identified by a RecordingSid
.
When you make a request to this URL, Twilio will generate a temporary URL for accessing this binary data, and issue an HTTP 302 redirect response to your request. The Recording will be returned in the format as described in the metadata, with the Content-Type
header set according to the codec used to record the media.
Codec | Content-Type value |
---|---|
PCMU |
audio/x-matroska |
H264 |
video/x-matroska |
The URL returned will be available by default for 600 seconds, but this can be configured to a value between 1 and 3600 seconds via the Ttl
request param. If the recording is not yet available, a 404 is returned. If the recording is not available (for example, if its status is processing
or deleted
, or if the track was muted for the duration of the recording), an HTTP 404 response is returned.
The HTTP GET request accepts the following parameters
Name | Description |
---|---|
ContentDisposition | Optional. Sets the Content-Disposition header of the redirect_to URL. Possible values are attachment or inline . Default value attachment%3B%20filename%3D%22RTxxx.mk{a|v} (not PII) |
Ttl | Optional. Duration in seconds for which the redirect_to URL can be used to retrieve the media file. The default Ttl is 600 seconds. The minimum supported Ttl value is 1 second and the maximum supported value is 3600 seconds. (not PII) |
The Content-Disposition
header can be set in this request. By default, the value of this header is attachment%3B%20filename%3D%22RTxxx.mk{a|v}
.
NOTE: You can play these recordings in media players that support the Matroska file format, like the VLC player. You can also use other programs like Chrome, ffplay or ffplayer to play these recordings. However, these files are optimized for compactness and they are not player-friendly. Hence, you may experience different types of problems when playing these files. For generating player-friendly media files, compose your Recordings using Twilio's Recordings Composition API.
Example: Retrieve a Recording's Media
HTTP POST
Not supported.
HTTP DELETE
Deletes the recording media file.
The metadata for the Recording is preserved for a period of 30 days, and its Status
is set to deleted
. After this period, the metadata will not be available. By default, Recordings with deleted
status are not returned when retrieving the Recordings list. To retrieve deleted
Recordings, use the Status=deleted
filter.
Note that the 30 day period starts after the Status
is set to deleted
. After this period expires, the metadata will not be available.
Example: Delete a Recording
To to delete a large set of Video Recordings, you can use the bulk deletion capabilities available in the Twilio Console.
Recordings List Resource
Recordings list is available at the following URI:
/v1/Recordings
HTTP GET
Returns a list of all Track Recordings with paging data.
HTTP GET: List filters
The following GET query string parameters allow you to limit the list returned. Note, parameters are case-sensitive.
Parameters in REST API format | |
---|---|
status
Optional
|
Read only the recordings that have this status. Can be: |
source_sid
Optional
|
Read only the recordings that have this |
grouping_sid
Optional
|
Read only recordings with this |
date_created_after
Optional
|
Read only recordings that started on or after this ISO 8601 date-time with time zone. |
date_created_before
Optional
|
Read only recordings that started before this ISO 8601 date-time with time zone, given as |
media_type
Optional
|
Read only recordings that have this media type. Can be either |
This endpoint does not retrieve deleted recordings by default. To retrieve deleted recordings, use the status filter in your request.
This endpoint does not retrieve deleted recordings by default. To retrieve deleted recordings, use the status filter in your request.
HTTP POST
Not supported.
HTTP DELETE
Not supported.
Using the Rooms API to find Recordings
You can also retrieve the list of recordings for a specific room using the Rooms API endpoint.
Example: Get all recordings from a given Room using the Rooms API
This endpoint does not retrieve deleted recordings by default. To retrieve deleted recordings, use the status filter in your request.
Size estimation of a track Recording
Video track Recording
The size of a video Recording (.mkv) will vary based on resolution, bit rate and duration. The following table shows files size for a single participant with video captured at common resolutions and bitrates:
Capture Size | 1 Hr | 8 Hrs | 24 Hrs |
---|---|---|---|
720 @ 1,500 kbps | 0.7 GB | 5.4 GB | 16.2 GB |
480 @ 700 kbps | 0.3 GB | 2.5 GB | 7.6 GB |
180 @ 200 kbps | 0.1 GB | 0.7 GB | 2.2 GB |
The above table is for heuristic estimation and reference only. There are a lot of other factors influence the actual video file size such as compression ratio, variable bitrate, color depth.
Audio track Recording
The size of an audio Recording (.mka) will vary based on bit rate and duration. The following table shows files size for a single participant with audio captured at common bit rates:
Capture Size | 1 Hr | 8 Hrs | 24 Hrs |
---|---|---|---|
16 kbps | 7.2 MB | 57.6 MB | 172.8 MB |
32 kbps | 14.4 MB | 115.2 MB | 345.6 MB |
40 kbps | 18 MB | 144 MB | 432 MB |
Note that the file size reported by our REST API may vary slightly from that shown due to file allocation methods and/or possible differences in the amount of header information.
Known limitations
- Recording files are generated with a format optimized for reliability and compactness. This format is not player friendly. Hence, many media players may not render Recordings media files appropriately. For generating player-friendly media files, compose your Recordings using Twilio's Recordings Composition API.
- Participants of Group Rooms on the browser
Firefox Mobile
could find Recording gaps due to a Firefox bug when sending temporization. Twilio recommends Video participants to use other mobile browsers.
Need some help?
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.