Video composition
Adding Layers
Layer Types
Editframe currently supports the following layer types:
Interface
You can add any of these layer types to a composition by calling it's associated add<LayerType>
method. Each one of these methods interfaces adhere to the same rules:
file
If the layer type involves a file, the first argument will be a file
, which must be a CompositionFile
.
options
If the layer type has layer-specific options, the next argument will be options
, an object containing those attributes.
layerConfig
If the layer type allows you to set layer configuration options, the next argument will be an optional layerConfig
object containing those attributes.
Layer Classes
Every add<LayerType>
method returns an instantiated class representing the type of layer you've added. This class has getter and chainable setter methods for all of the attributes that you can provide in the options
and layerConfig
arguments. For example, a call to composition.addAudio
will return an instance of the Audio
class.
Configuring a layer
These two examples are equivalent:
const audio = await composition.addAudio(
"path/to/audio.mp3",
{ volume: 0.5 },
{
timeline: { start: 3 },
trim: { start: 2, end: 6 },
}
);
const audio = await composition.addAudio("path/to/audio.mp3");
audio.setVolume(0.5).setStart(3).setTrim(2, 6);
Reading layer option and configuration attributes
audio.volume; // 0.5
audio.start; // 3
audio.trim; // { start: 2, end: 6 }