Create composition

POST /v1/Compositions

Recording compositions

application/x-www-form-urlencoded

Body

  • AudioSources array[string]

    An array of track names from the same group room to merge into the new composition. Can include zero or more track names. The new composition includes all audio sources specified in audio_sources except for those specified in audio_sources_excluded. The track names in this parameter can include an asterisk as a wild card character, which will match zero or more characters in a track name. For example, student* includes student as well as studentTeam. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request

  • An array of track names to exclude. The new composition includes all audio sources specified in audio_sources except for those specified in audio_sources_excluded. The track names in this parameter can include an asterisk as a wild card character, which will match zero or more characters in a track name. For example, student* excludes student as well as studentTeam. This parameter can also be empty.

  • Format string

    The container format of the composition's media files. Can be: mp4 or webm and the default is webm. If you specify mp4 or webm, you must also specify one or more audio_sources and/or a video_layout element that contains a valid video_sources list, otherwise an error occurs.

    Values are mp4 or webm.

  • A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to 640x480. The string's format is {width}x{height} where:

    • 16 <= {width} <= 1280
    • 16 <= {height} <= 1280
    • {width} * {height} <= 921,600

    Typical values are:

    • HD = 1280x720
    • PAL = 1024x576
    • VGA = 640x480
    • CIF = 320x240

    Note that the resolution imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See Specifying Video Layouts for more info.

  • RoomSid string Required

    The SID of the Group Room with the media tracks to be used as composition sources.

    Minimum length is 34, maximum length is 34. Format should match the following pattern: ^RM[0-9a-fA-F]{32}$.

  • StatusCallback string(uri)

    The URL we should call using the status_callback_method to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.

  • StatusCallbackMethod string(http-method)

    The HTTP method we should use to call status_callback. Can be: POST or GET and the default is POST.

    Values are HEAD, GET, POST, PATCH, PUT, or DELETE.

  • Trim boolean

    Whether to clip the intervals where there is no active media in the composition. The default is true. Compositions with trim enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See Specifying Video Layouts for more info.

  • An object that describes the video layout of the composition in terms of regions. See Specifying Video Layouts for more info. Please, be aware that either video_layout or audio_sources have to be provided to get a valid creation request

Responses

  • 201

    Created

    Hide response attributes Show response attributes object
    • account_sid string | null

      The SID of the Account that created the resource

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^AC[0-9a-fA-F]{32}$.

    • audio_sources array[string] | null

      The array of track names to include in the composition

    • audio_sources_excluded array[string] | null

      The array of track names to exclude from the composition

    • bitrate integer | null

      The average bit rate of the composition's media

    • date_completed string(date-time) | null

      Date when the media processing task finished

    • date_created string(date-time) | null

      The ISO 8601 date and time in GMT when the resource was created

    • date_deleted string(date-time) | null

      The ISO 8601 date and time in GMT when the composition generated media was deleted

    • duration integer | null

      The duration of the composition's media file in seconds

    • format string | null

      The container format of the composition's media files as specified in the POST request that created the Composition resource

      Values are mp4 or webm.

    • media_external_location string(uri) | null

      The URL of the media file associated with the composition when stored externally

    • resolution string | null

      The dimensions of the video image in pixels expressed as columns (width) and rows (height)

    • room_sid string | null

      The SID of the Group Room that generated the audio and video tracks used in the composition

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^RM[0-9a-fA-F]{32}$.

    • sid string | null

      The unique string that identifies the resource

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^CJ[0-9a-fA-F]{32}$.

    • size integer | null

      The size of the composed media file in bytes

    • status string | null

      The status of the composition

      Values are enqueued, processing, completed, deleted, or failed.

    • status_callback string(uri) | null

      The URL called to send status information on every composition event.

    • status_callback_method string(http-method) | null

      The HTTP method used to call status_callback

      Values are HEAD, GET, POST, PATCH, PUT, or DELETE.

    • trim boolean | null

      Whether to remove intervals with no media

    • url string(uri) | null

      The absolute URL of the resource

    • An object that describes the video layout of the composition

POST /v1/Compositions
curl \
 -X POST https://video.twilio.com/v1/Compositions \
 --user "username:password" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -d 'AudioSources=string&AudioSourcesExcluded=string&Format=mp4&Resolution=string&RoomSid=string&StatusCallback=https%3A%2F%2Fexample.com&StatusCallbackMethod=HEAD&Trim=true'
Request example
{
  "AudioSources": [
    "string"
  ],
  "AudioSourcesExcluded": [
    "string"
  ],
  "Format": "mp4",
  "Resolution": "string",
  "RoomSid": "string",
  "StatusCallback": "https://example.com",
  "StatusCallbackMethod": "HEAD",
  "Trim": true
}
Response examples (201)
{
  "account_sid": "string",
  "audio_sources": [
    "string"
  ],
  "audio_sources_excluded": [
    "string"
  ],
  "bitrate": 42,
  "date_completed": "2023-05-04T09:42:00+00:00",
  "date_created": "2023-05-04T09:42:00+00:00",
  "date_deleted": "2023-05-04T09:42:00+00:00",
  "duration": 42,
  "format": "mp4",
  "links": {},
  "media_external_location": "https://example.com",
  "resolution": "string",
  "room_sid": "string",
  "sid": "string",
  "size": 42,
  "status": "enqueued",
  "status_callback": "https://example.com",
  "status_callback_method": "HEAD",
  "trim": true,
  "url": "https://example.com"
}