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.
{ "id": "clip", "type": "video", "src": "assets/clip.mp4", "width": 960, "height": 540, "cornerRadius": 4, "trimStart": "2s", "volume": 0.5 }| field | default | notes |
|---|---|---|
src | required | Any file ffmpeg can read (mp4, mov, webm, mkv, animated gif...). Relative to the project file. |
width, height | native size | One keeps the aspect ratio; both define a box. |
fit | cover | cover, contain, fill or none, as for images. |
cornerRadius | 0 | Rounds the picture. |
trimStart | 0 | Where in the source to start, as a time ("2s"). |
playbackRate | 1 | Speed: 0.5 is half speed, 2 double. Must be > 0. A plain number. |
loop | false | Start the source over when it ends. |
muted | false | Drop the clip's sound. |
volume | 1 | Gain for the clip's sound. A number or animated. |
fadeIn, fadeOut | 0 | Fade 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
[
{
"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": truewithout adurationlasts the rest of its parent, repeating the source.- A
durationlonger than the remaining source holds the last frame (and the sound stops). - A shorter
duration(orend) 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.
{ "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:
{ "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:
{ "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.
volumeis a linear gain:0.5is quieter,1is the source level, above1boosts. It accepts keyframes and expressions, e.g.[[0, 0], ["1s", 1]].fadeInandfadeOutare audio fades. To fade the picture, useopacityor anenter/exitpreset such as"fade".muted: trueremoves the sound entirely, which also removes the clip from the audio-reactive analysis (amp,bass,beat).vidmake render --muteddrops 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
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:1Tip
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
trimStartare composition frames when written as numbers."trimStart": 2skips two frames, not two seconds. fadeIn/fadeOutdon't touch the picture. Use"enter": "fade"for a visual fade.- Rendering needs ffmpeg. Decoding and mixing use
ffmpeg/ffprobefromPATH(orVIDMAKE_FFMPEG/VIDMAKE_FFPROBE); see Rendering. - Animated GIFs play as
video; as animagethey show their first frame only.