vidmake v0.2.1
Download

Docs/CompositionsPage 07 / 45

Compositions

The project file, font declarations, and every composition field: size, fps, duration (including "auto"), background, motionBlur, grain, props and description, plus multiple compositions and --comp.

View .md Ask Claude Ask ChatGPT

A composition is one canvas: a size, a frame rate, a duration and a stack of layers. A project file holds one or more of them. This page covers the project file and every composition field; layers have their own pages.

#The project file

project.jsonjson
{  "fonts": [    { "family": "Brand", "path": "fonts/Brand-Regular.ttf" },    { "family": "Brand", "path": "fonts/Brand-Bold.ttf" }  ],  "compositions": [    { "id": "main", "width": 1920, "height": 1080, "fps": 30, "duration": "10s", "layers": [] }  ]}
keytypenotes
compositionscomposition[]required. The first one is the default for every command
fonts{ family, path }[]font files to load in addition to the system fonts (see Fonts)
themeobject or file pathdesign tokens every composition reads as "$color.accent": colors, type styles, motion, layer styles and modes; see theme
$schemastringoptional, for editors; see JSON Schema

All file paths in a project (fonts[].path, layer src) are relative to the project file, not to the directory you run vidmake from. Absolute paths work too.

#A single composition

For a quick one-off, the file can be a single composition object with layers and no compositions wrapper. Its id defaults to main:

card.jsonjson
{ "width": 1280, "height": 720, "duration": "3s", "background": "#f4f1ea",  "layers": [{ "id": "hello", "type": "text", "text": "Hello", "fontSize": 96, "fill": "#161412" }] }

Warning

A bare composition can't declare fonts (that key belongs to the project wrapper), and editing it with vidmake set, add, unset or rm saves it back in the full { "compositions": [...] } form. Use the full form for anything you plan to keep.

#Fonts

Text layers find fonts by family name. vidmake loads every font installed on the system, plus the files listed in fonts:

json
"fonts": [  { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },  { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk-Italic.ttf" },  { "path": "fonts/JetBrainsMono.ttf" }]
  • family is the name text layers use in "font". It is matched case-insensitively, and it doesn't have to match the name inside the file, so you can call a font "Brand".
  • List several files under one family to provide weights and italics; a text layer's fontWeight and italic pick the closest face.
  • Without family, the font is registered under the name stored in the file. Run vidmake fonts --project project.json to see it.
  • serif, sans-serif and monospace always resolve to an installed font.
  • .ttf, .otf, .ttc, .woff and .woff2 files all load; web fonts need no conversion.

A missing font file stops every command with error: font ./fonts/Brand-Bold.ttf: No such file or directory (os error 2). A text layer asking for a family that doesn't exist fails validation with font family `Brand` not found. Add it to the project's `fonts` list or run `vidmake fonts` to see installed families.

Tip

Ship font files next to the project and declare them. The video then renders identically on every machine, instead of depending on what happens to be installed.

#Composition fields

fieldtypedefaultnotes
idstringrequired (main in a bare file)referenced by --comp, use layers and edit paths like main.fps
width, heightintegerrequiredpixels, greater than 0. Use even numbers for H.264/H.265
fpsnumber30frames per second, greater than 0. Fractional rates like 29.97 work
durationtime or "auto""auto"see Duration
backgroundpainttransparenta color, gradient or animated color; see Background
layerslayer[][]drawn in order: first = bottom, last = top
propsobject{}default input props for {{name}} placeholders; see Props
markersobject{}named times like {"build": "8.5s"}, used as "@build" and since('build'); see Markers
motionBlur{ samples, shutter }offcamera motion blur; see Motion blur
grain0..10film grain over the finished frame
descriptionstringfree text, shown by vidmake list

Unknown fields are errors, with a suggestion: composition `main`: unknown field `motionblur` — did you mean `motionBlur`?. Validation also warns when the size is odd, because H.264 and H.265 need even dimensions.

#Duration

duration takes any time value: 300 (frames), "10s", "1:30". The final frame count is rounded to a whole frame.

"auto", the default, measures the content: the composition lasts until the latest end of any layer with a fixed length. A layer has a fixed length when it has:

  • an explicit duration or end,
  • media: a video or audio layer's remaining length (after trimStart, divided by playbackRate), unless it has "loop": true,
  • a series: a series group's total length,
  • a component: a use layer's referenced composition length,
  • captions: the end of the last caption,
  • or it is a group containing any of the above (offset by the group's start).

Layers without a fixed length (a background rect, a looping animation) simply fill whatever duration results. If nothing has a fixed length, validation fails with could not infer a duration (no layer has a fixed length). Set `duration`, e.g. "duration": "5s".

json
{ "id": "auto", "width": 1280, "height": 720,  "layers": [    { "id": "bg", "type": "rect", "fill": "#f4f1ea" },    { "id": "clip", "type": "video", "src": "assets/clip.mp4", "trimStart": "2s" },    { "id": "outro", "type": "text", "text": "Thanks", "fill": "#161412", "start": "4s", "duration": "1.5s" }  ] }

Here the clip lasts 4 seconds (6 minus 2) and the outro ends at 5.5 seconds, so the composition is 5.5 seconds long and bg fills all of it. Change the outro and the duration follows. vidmake list shows duration="auto"; validate and timeline print the resolved length.

#Background

background is a paint drawn under every layer: a color ("#f4f1ea"), a gradient or an animated color like [[0, "#f4f1ea"], ["5s", "#e9e4d8"]].

json
"background": { "type": "radial", "center": [0.5, 0.4], "radius": 0.9, "stops": ["#f4f1ea", "#e9e4d8"] }

Without background the composition is transparent. Formats with alpha keep the transparency: WebM (VP9), MOV (ProRes 4444), GIF and PNG sequences. MP4 has no alpha channel, so transparent areas come out black. A full-size rect as the first layer does the same job as background, but can be animated, blurred and masked like any layer.

#Motion blur

json
"motionBlur": { "samples": 12, "shutter": 1 }

Camera motion blur, like Remotion's <CameraMotionBlur>. Each output frame is the average of samples renders spread evenly over the shutter frames leading up to it, so anything that moves fast leaves a trail.

fielddefaultnotes
samples6sub-frames per frame. 1 means no blur. Render time grows with the number of samples
shutter0.5how long the virtual shutter is open, in frames. 1 blurs over a full frame interval

"motionBlur": {} uses both defaults. Set "motionBlur": false on a single layer to render it at the exact frame, which keeps text and UI elements crisp while the rest of the frame blurs. render --draft turns motion blur off for a fast preview; still and storyboard include it.

00:00.0 · f 000
Composition motionBlur and grain; the lower bar opts out with motionBlur: falseDownload
comp-motion-blur.jsonjson
{  "fonts": [{ "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }],  "compositions": [{    "id": "blur", "description": "Composition motionBlur and grain; the lower bar opts out with motionBlur: false",    "width": 1280, "height": 720, "fps": 30, "duration": "3s",    "background": { "type": "linear", "angle": 180, "stops": ["#f4f1ea", "#e9e4d8"] },    "motionBlur": { "samples": 16, "shutter": 1 },    "grain": 0.06,    "layers": [      { "id": "blurred", "type": "rect", "y": "36%", "width": 160, "height": 110, "cornerRadius": 3, "fill": "#c92a26",        "x": { "keys": [[0, 200], ["1.5s", 1080, "easeInOutQuart"]], "repeat": "pingpong" } },      { "id": "sharp", "type": "rect", "y": "66%", "width": 160, "height": 110, "cornerRadius": 3, "fill": "#161412",        "motionBlur": false,        "x": { "keys": [[0, 200], ["1.5s", 1080, "easeInOutQuart"]], "repeat": "pingpong" } },      { "id": "labelBlur", "type": "text", "text": "motionBlur: { samples: 16, shutter: 1 }", "font": "JetBrains Mono",        "fontSize": 20, "fill": "#4a4640", "y": "22%" },      { "id": "labelSharp", "type": "text", "text": "layer \"motionBlur\": false", "font": "JetBrains Mono",        "fontSize": 20, "fill": "#4a4640", "y": "80%" }    ]  }]}

#Grain

"grain": 0.06 adds monochrome film grain over the finished frame. The pattern changes every frame (it is seeded by the frame number, so renders stay reproducible). Values are clamped to 0..1; 0.03 to 0.1 is a subtle range. A layer's own grain field applies grain to just that layer (Effects).

#Description

description is free text for people and agents reading the project. vidmake list prints it under each composition, which makes it a good place to document a component's props.

#Multiple compositions

A project can hold several compositions. Common reasons:

  • Formats: a 16:9 and a 9:16 cut of the same video.
  • Components: a lower third or a title card used by other compositions through use layers.
  • Separate deliverables: an intro, a teaser and the full video that share fonts and assets.
00:00.0 · f 000
One project, three compositions: a 16:9 cut and a 9:16 cut share a title componentDownload

vidmake list shows what a project contains:

vidmake list comp-formats.json
$ vidmake list comp-formats.json
landscape  1280x720 @30fps  duration="auto"  layers=2  props={}
    One project, three compositions: a 16:9 cut and a 9:16 cut share a title component
vertical  720x1280 @30fps  duration="auto"  layers=2  props={}
title  960x300 @30fps  duration="3s"  layers=2  props={"headline":"Headline"}
    Reusable title: a headline and a red rule

Every command that takes a project works on the first composition unless you pass --comp <id> (short -c): validate, timeline, inspect, trace, still, storyboard and render. Here is the vertical cut of the demo above:

bash
vidmake storyboard comp-formats.json --comp vertical --at 0.3s,1.5s,2.9s --cols 3vidmake render comp-formats.json --comp vertical -o out/vertical.mp4
vidmake storyboard comp-formats.json --comp vertical --at 0.3s,1.5s,2.9s --cols 3
$ vidmake storyboard comp-formats.json --comp vertical --at 0.3s,1.5s,2.9s --cols 3

vidmake validate --all checks every composition, including components that are only used through use:

vidmake validate comp-formats.json --all
$ vidmake validate comp-formats.json --all
✓ landscape — 90 frames (3.00s)
✓ vertical — 90 frames (3.00s)
✓ title — 90 frames (3.00s)

An unknown id lists the ones that exist: error: no composition `square`. Available: landscape, vertical, title.

Tip

Put the composition you render most often first, and components after it. vidmake add --comp <id> adds layers to a composition other than the first.

#Editing composition fields

Composition fields are addressed by id in get, set and unset:

bash
vidmake get project.json main.durationvidmake set project.json main.duration '"8s"'vidmake set project.json main.background '"#fbf9f4"'vidmake set project.json main.motionBlur '{"samples": 8, "shutter": 0.5}'vidmake unset project.json main.grain

See Editing for paths and the other edit commands.

#Next steps