Layer configuration
Trim
The Trim config allows you to specify a smaller subsect of media to be rendered in your composition by specifying start
and end
attributes. For example, if you have a 3 minute song or video and only want to use the portion starting at 15.5
seconds through 20.1
seconds.
Info
As Image Layers have no inherent duration
, they are defaulted to the full duration of your composition. If you only want your image to play for a specific amount of time, you would specify a trim
end
,
Interface
interface Trim {
trim?: {
// number of seconds from
// the beginning of layer to trim off
// defaults to 0
start?: number;
// number of seconds that
// a layer should last
// defaults to original media duration
// or composition duration for media without duration
end?: number;
};
}
Configuring Trim
You can modify a layer's trim-related settings by passing a configuration object or by calling its setters. You can read the layer's trim-related settings by calling its getters
Configuration Object
const video = await composition.addVideo(
"https://editframe.com/docs/layer-configuration/trim/drone-lagoon-short.mp4",
{
trim: {
start: 1.5, // original video is 10 seconds
end: 3.5,
},
}
);
Output
Setters
setTrim
const audio = await composition.addAudio(
"https://editframe.com/docs/layer-configuration/trim/audio-example.mp3"
);
audio.setTrim(2.1, 3);
Output
Getters
audio.trim; // -> { start: 2.2, end: 5.1}