vidmake v0.2.1
Download

Docs/LayersPage 16 / 45

Video

Video layers — sizing and fit, trimStart, playbackRate, loop, default duration, and the sound of a clip (muted, volume, fadeIn, fadeOut) mixed into the output.

View .md Ask Claude Ask ChatGPT

A video layer plays a clip from a file. Its picture behaves like an image (same sizing, fit and cornerRadius), and its sound is mixed into the rendered output.

json
{ "id": "clip", "type": "video", "src": "assets/clip.mp4", "width": 960, "height": 540, "cornerRadius": 4,  "trimStart": "2s", "volume": 0.5 }
fielddefaultnotes
srcrequiredAny file ffmpeg can read (mp4, mov, webm, mkv, animated gif...). Relative to the project file.
width, heightnative sizeOne keeps the aspect ratio; both define a box.
fitcovercover, contain, fill or none, as for images.
cornerRadius0Rounds the picture.
trimStart0Where in the source to start, as a time ("2s").
playbackRate1Speed: 0.5 is half speed, 2 double. Must be > 0. A plain number.
loopfalseStart the source over when it ends.
mutedfalseDrop the clip's sound.
volume1Gain for the clip's sound. A number or animated.
fadeIn, fadeOut0Fade the clip's sound in at its start and out at its end (times).

#Look before you place

vidmake probe prints the duration, size, frame rate and whether a file has sound, which is everything you need to size a layer and plan its timing:

vidmake probe assets/clip.mp4
$ vidmake probe assets/clip.mp4
[
  {
    "path": "assets/clip.mp4",
    "kind": "video",
    "duration": 6.0,
    "width": 1280,
    "height": 720,
    "fps": 30.0,
    "hasVideo": true,
    "hasAudio": true,
    "videoCodec": "h264",
    "audioCodec": "aac",
    "sampleRate": 48000
  }
]

#Duration

Without duration or end, a video lasts as long as the rest of its source: (media length − trimStart) ÷ playbackRate, rounded down to whole frames. The 6 s clip above with "trimStart": "2s" lasts 4 s; at "playbackRate": 2 it would last 2 s. That makes video a fixed-length layer, which is what series and "duration": "auto" compositions need.

  • "loop": true without a duration lasts the rest of its parent, repeating the source.
  • A duration longer than the remaining source holds the last frame (and the sound stops).
  • A shorter duration (or end) simply cuts the clip.

#Trimming and speed

trimStart skips into the source. Write it as a time string: a bare number is in composition frames, like every time in vidmake.

playbackRate changes the speed of the picture and the sound together. Sound keeps its pitch (ffmpeg's atempo), so a 0.5× talking head sounds slow, not deep.

00:00.0 · f 000
One clip three times: playbackRate 0.5, 1 and 2 (watch the timecode in each corner)Download
video-speed.jsonjson
{  "fonts": [{ "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }],  "compositions": [{    "id": "speed", "description": "One clip three times: playbackRate 0.5, 1 and 2 (watch the timecode in each corner)",    "width": 1280, "height": 720, "fps": 30, "duration": "3s", "background": "#f4f1ea",    "layers": [      { "id": "slow", "type": "video", "src": "assets/clip.mp4", "x": 220, "y": "44%", "width": 360, "height": 203,        "cornerRadius": 2, "muted": true, "playbackRate": 0.5 },      { "id": "normal", "type": "video", "src": "assets/clip.mp4", "x": 640, "y": "44%", "width": 360, "height": 203,        "cornerRadius": 2, "muted": true },      { "id": "fast", "type": "video", "src": "assets/clip.mp4", "x": 1060, "y": "44%", "width": 360, "height": 203,        "cornerRadius": 2, "muted": true, "playbackRate": 2 },      { "id": "label", "type": "text", "x": "=220 + i * 420", "y": "70%", "repeat": 3, "font": "JetBrains Mono",        "fontSize": 20, "letterSpacing": 0.6, "lineHeight": 1.6, "fill": "#4a4640",        "text": "playbackRate ${pick(i, ['0.5', '1', '2'])}\nsource ${t * pick(i, [0.5, 1, 2]):1}s" }    ]  }]}

Frames are resampled to the composition's frame rate, so a 24 or 60 fps source plays at the right speed in a 30 fps composition.

#Sizing and fit

Sizing works exactly like images: native size by default, one dimension keeps the aspect ratio, both make a box that fit fills (cover crops, contain letterboxes, fill stretches). The full-frame background:

json
{ "id": "bg", "type": "video", "src": "broll.mp4", "width": "100%", "height": "100%", "muted": true,  "brightness": 0.6 }

Frames are decoded at the size they are shown (never above the source resolution), so a small picture-in-picture costs much less than a full-frame clip. Filters (blur, brightness, saturation), shadows, masks and presets all work on video:

00:00.0 · f 000
A darkened, blurred full-frame video behind a trimmed picture-in-picture cardDownload
video-pip.jsonjson
{  "fonts": [{ "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" }],  "compositions": [{    "id": "pip", "description": "A darkened, blurred full-frame video behind a trimmed picture-in-picture card",    "width": 1280, "height": 720, "fps": 30, "duration": "4s",    "layers": [      { "id": "bg", "type": "video", "src": "assets/clip.mp4", "width": "100%", "height": "100%", "muted": true,        "brightness": 0.35, "saturation": 0.4, "blur": 12 },      { "id": "card", "type": "video", "src": "assets/clip.mp4", "x": "62%", "y": "50%", "width": 640, "height": 360,        "trimStart": "2s", "volume": 0.4, "fadeIn": "0.5s", "fadeOut": "0.5s", "cornerRadius": 4,        "shadow": { "color": "#000000aa", "blur": 28, "y": 16 }, "enter": "pop", "exit": "fade" },      { "id": "title", "type": "text", "text": "Trimmed\nat 2s", "anchor": "left", "x": 70, "y": "50%", "align": "left",        "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 84, "letterSpacing": -3.8, "lineHeight": 0.95,        "fill": "#efebe2", "start": "0.3s", "enter": "fadeRight", "exit": "fade" }    ]  }]}

#Sound

A video's sound is mixed into the output (mp4, webm, mov and the audio-only formats) unless the layer is muted. Several clips and audio layers mix together at their own volumes; nothing is normalized or ducked automatically, so lower the music under speech yourself with volume.

  • volume is a linear gain: 0.5 is quieter, 1 is the source level, above 1 boosts. It accepts keyframes and expressions, e.g. [[0, 0], ["1s", 1]].
  • fadeIn and fadeOut are audio fades. To fade the picture, use opacity or an enter/exit preset such as "fade".
  • muted: true removes the sound entirely, which also removes the clip from the audio-reactive analysis (amp, bass, beat).
  • vidmake render --muted drops all sound from one render without editing the project.

vidmake timeline marks layers that contribute sound with ♪ and lists every clip that will be mixed, with its trim and rate:

vidmake timeline video-pip.json
$ vidmake timeline video-pip.json
Composition `pip` — 1280x720 @ 30fps, 120 frames (4.00s)

ID     TYPE         START      END      DUR  DETAILS
bg     video        0.00s    4.00s    4.00s  src:assets/clip.mp4
card   video        0.00s    4.00s    4.00s  enter:pop exit:fade src:assets/clip.mp4 ♪
title  text         0.30s    4.00s    3.70s  enter:fadeRight exit:fade "Trimmed ⏎ at 2s"

       |0s             1s             2s             3s             |
bg     |████████████████████████████████████████████████████████████|
card   |████████████████████████████████████████████████████████████|
title  |····████████████████████████████████████████████████████████|

Audio:
  card                    0.00s →    4.00s  src:assets/clip.mp4  trim:2.00s rate:1

Tip

Background b-roll is almost always "muted": true. Leaving it on mixes the b-roll's soundtrack under your music and voice-over.

#Gotchas

  • Times in trimStart are composition frames when written as numbers. "trimStart": 2 skips two frames, not two seconds.
  • fadeIn/fadeOut don't touch the picture. Use "enter": "fade" for a visual fade.
  • Rendering needs ffmpeg. Decoding and mixing use ffmpeg/ffprobe from PATH (or VIDMAKE_FFMPEG/VIDMAKE_FFPROBE); see Rendering.
  • Animated GIFs play as video; as an image they show their first frame only.