NAME

Twilio::Rest::Video::V1::Composition - The Composition resource

SYNOPSIS

my $client = Twilio::Rest::Client->new($account_sid, $auth_token);

my $composition = $client->video->v1->compositions->create($room_sid, \%options);
for my $composition ($client->video->v1->compositions->read({}, 20)) {
  ...
}
my $composition = $client->video->v1->compositions($sid)->fetch;
$client->video->v1->compositions($sid)->delete;

DESCRIPTION

Recording compositions

This file holds CompositionList, CompositionPage, CompositionContext and CompositionInstance. Methods that make a request throw Twilio::Exceptions::RestException on an error response.

CompositionList

Returned by $client->video->v1->compositions. See also Twilio::ListResource.

create

my $composition = $client->video->v1->compositions->create($room_sid, \%options);

Returns a CompositionInstance.

The required values are:

$room_sid

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

The options are:

audio_sources

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 reference.

audio_sources_excluded

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. An array reference.

format

One of mp4 or webm.

resolution

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.

status_callback

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.

status_callback_method

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

trim

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.

video_layout

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 A hash or array reference, or a string of JSON.

read

my @records = $client->video->v1->compositions->read(\%options, $limit, $page_size);

List of all Recording compositions. Returns the records as a list, fetching as many pages as it needs.

The options are:

date_created_after

Read only Composition resources created on or after this ISO 8601 date-time with time zone. A string, or an object with an epoch method. See "iso8601_date_time" in Twilio::Serialize.

date_created_before

Read only Composition resources created before this ISO 8601 date-time with time zone. A string, or an object with an epoch method. See "iso8601_date_time" in Twilio::Serialize.

room_sid

Read only Composition resources with this Room SID.

status

Read only Composition resources with this status. Can be: enqueued, processing, completed, deleted, or failed. One of enqueued, processing, completed, deleted or failed.

stream

my $stream = $client->video->v1->compositions->stream(\%options, $limit, $page_size);

Takes the same arguments as "read", and returns a Twilio::Stream.

page

my $page = $client->video->v1->compositions->page(\%options, $page_size, $page_token, $page_number);

Fetches one page, and returns a Twilio::Page.

get_page

my $page = $client->video->v1->compositions->get_page($url);

Fetches the page at a URL given by Twilio.

get_context

my $context = $client->video->v1->compositions->get_context($sid);

Returns a CompositionContext, and makes no request.

CompositionPage

A Twilio::Page of CompositionInstance objects.

records_key

build_instance

Used by Twilio::Page.

CompositionContext

Returned by $client->video->v1->compositions($sid). It makes no request until one of these methods is called.

fetch

my $composition = $client->video->v1->compositions($sid)->fetch;

Returns a single Composition resource identified by a Composition SID. Returns a CompositionInstance.

delete

$client->video->v1->compositions($sid)->delete;

Delete a Recording Composition resource identified by a Composition SID. Returns true.

CompositionInstance

See also Twilio::InstanceResource.

It has fetch and delete, which work as they do on the context.

Its fields are:

account_sid

The SID of the Account that created the Composition resource.

audio_sources

The array of track names to include in the composition. The composition includes all audio sources specified in audio_sources except those specified in audio_sources_excluded. The track names in this property can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, student* includes tracks named student as well as studentTeam.

audio_sources_excluded

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

bitrate

The average bit rate of the composition's media.

date_completed

The date and time in GMT when the composition's media processing task finished, specified in ISO 8601 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.

date_created

The date and time in GMT when the resource was created specified in ISO 8601 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.

date_deleted

The date and time in GMT when the composition generated media was deleted, specified in ISO 8601 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.

duration

The duration of the composition's media file in seconds.

format

One of mp4 or webm.

The URL of the media file associated with the composition.

media_external_location

The URL of the media file associated with the composition when stored externally. See External S3 Compositions for more details.

resolution

The dimensions of the video image in pixels expressed as columns (width) and rows (height). The string's format is {width}x{height}, such as 640x480.

room_sid

The SID of the Group Room that generated the audio and video tracks used in the composition. All media sources included in a composition must belong to the same Group Room.

sid

The unique string that we created to identify the Composition resource.

size

The size of the composed media file in bytes.

status

One of enqueued, processing, completed, deleted or failed.

status_callback

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

status_callback_method

The HTTP method used to call status_callback. Can be: POST or GET, defaults to POST. One of GET or POST.

trim

Whether to remove intervals with no media, as specified in the POST request that created the composition. 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.

url

The absolute URL of the resource.

video_layout

An object that describes the video layout of the composition in terms of regions. See Specifying Video Layouts for more info.

CONSTRUCTORS

new

Objects here come from the methods above, so there is no need to call new directly.

LICENSE

Copyright (c) 2026 Francisco Zarabozo. Released under the MIT License.