Composition

The Composition API is Editframe's core and most powerful offering. You can think of a composition as the blueprint of a video, consisting of an unlimited number of layers. Each element in your eventual video is represented by an individual layer in the composition.

Composition options

  • Name
    backgroundColor
    Type
    Description

    Any solid hexadecimal, rgb, or named color.

  • Name
    dimensions
    Type
    Description

    Required unless instantiating a composition via a videoFile, which will calculate dimensions automatically.

  • Name
    dimensions.height
    Type
    Description

    Video height in pixels.

  • Name
    dimensions.width
    Type
    Description

    Video width in pixels.

  • Name
    duration
    Type
    required
    Description

    Video duration in seconds. Required unless initializing a composition with a videoFile or using composition.addSequence, which will calculate the composition's duration automatically. If provided in supplment to a sequence, the final video will be trimmed to the specified duration.

  • Name
    metadata
    Type
    Description

    Arbitrary metadata for your convenience. Editframe doesn't use this data.

Composition videoFile

If you have an existing video file that you would like to use to automatically set the dimensions and duration attributes for your composition, you can provide it as the second argument.

The videoFile must be either a path to a local file, an URL, or a CompositionFile.

CompositionFile

// ReadableStream
const fs = require('node:fs');
const compositionFile = fs.createReadStream('/path/to/video.mp4');

// or 

// Blob
const frames = []
const compositionFile = new Blob(frames, { type: 'video/webm;codecs=h264' })

Example instantiation

const composition = await editframe.videos.new({
  backgroundColor: "#c400ac",
  dimensions: {
    height: 1080,
    width: 1920,
  },
  duration: 60,
  metadata: {
    myId: "1",
  },
},
"https://editframe.com/docs/video-composition/create-composition/puppy-beach.mp4"
);