vidmake v0.2.1
Download

Docs/CompositionsPage 08 / 45

Time

How vidmake measures time: numbers are frames, strings like "1.5s", "500ms", "45f" and "1:02.5" are converted at the composition's fps, markers name the beats, and every animation time is local to its layer.

View .md Ask Claude Ask ChatGPT

vidmake counts time in frames. Anywhere a time is expected, a number means frames and a string can use seconds, milliseconds, frames or minutes. Animation times are local: they count from the layer's own start, not from the start of the video.

#Time formats

you writemeansat 30 fps
4545 frames1.5 s
"45f"45 frames1.5 s
"1.5s"1.5 seconds45 frames
"500ms"500 milliseconds15 frames
"1:02.5"1 minute 2.5 seconds (m:ss)1875 frames
"1:00:00"1 hour (h:mm:ss)108000 frames
"2.5"2.5 frames (a string without a unit is still frames)0.083 s

Strings are converted with the composition's fps, so "2s" is 60 frames at 30 fps and 120 frames at 60 fps. Whitespace around the number is ignored. Anything else is an error that lists the valid forms: invalid time `2sec` (use frames, "2.5s", "500ms", "90f" or "m:ss").

Convert between the forms here:

Tip

Prefer seconds strings in hand-written projects. "start": "2s" stays two seconds if you change the composition from 30 to 60 fps; "start": 60 becomes one second.

Warning

A bare number is always frames. "duration": 3 is three frames (a tenth of a second at 30 fps), not three seconds. This is the most common timing mistake; vidmake timeline makes it obvious.

#Fractional frames

Times don't have to land on whole frames. "0.25s" at 30 fps is 7.5 frames, and animations are evaluated at fractional times too (motion blur samples between frames, for instance). Two things are rounded: a composition's total length (to a whole number of frames), and the frame you ask for on the command line (-t 0.25s inspects frame 8).

#Where times are used

placefields
compositionduration
every layerstart, duration, end
keyframesthe time of each key: ["1s", 500], { "t": "1s", "v": 500 }
tweensstart (alias delay), end, duration
presetsduration, delay in enter / exit objects, and a motion's duration
transitionsduration
stagger (text, groups, repeat)over, max, each
repeatdelay between copies
video and audiotrimStart, fadeIn, fadeOut, and the times in a volume curve
captionsinline items and words times (caption files use seconds)
particleslifetime
CLI-t, --frames, --at, --every, --from, --to

Two places use seconds instead of frames, because they are not time fields: the expression variable t (and gt, dur), and the numbers inside .srt/.vtt/.json caption files.

#A layer's time window

Every layer is on screen during a window defined by three fields:

fielddefaultmeaning
start0when the layer appears, relative to its parent
durationthe rest of the parenthow long it stays
endalternative to duration: when it disappears, relative to the parent. duration wins if both are set

The default duration depends on the layer: media layers (video, audio) last as long as their media (after trimStart, divided by playbackRate), use layers as long as the composition they reference, series groups as long as their scenes, captions until the last caption ends. Everything else lasts until the end of its parent.

json
{ "id": "title", "type": "text", "text": "Hi", "start": "1s", "duration": "2s" }{ "id": "title", "type": "text", "text": "Hi", "start": "1s", "end": "3s" }

Both layers are visible from 1 s to 3 s. Outside its window a layer isn't drawn, doesn't play sound and takes no space in a layout. Nothing extends past its parent: a child of a group that ends at 4 s is cut at 4 s, whatever its own duration says.

#Local time

All animation inside a layer is measured from the layer's own start. In the demo below, the three dots have the same keyframes, "x": [[0, 320], ["1.5s", 1080]], and different start values. Each one makes the same 1.5-second move, beginning whenever its layer begins:

00:00.0 · f 000
One animation, three start times: keyframe times count from each layer's own startDownload
time-local.jsonjson
{  "fonts": [    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }  ],  "compositions": [{    "id": "local", "description": "One animation, three start times: keyframe times count from each layer's own start",    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",    "layers": [      { "id": "track", "type": "rect", "repeat": { "count": 3, "layout": "column", "spacing": 150 }, "x": 700, "y": "50%",        "width": 760, "height": 2, "fill": "#d8d1c1" },      { "id": "label", "type": "text", "repeat": { "count": 3, "layout": "column", "spacing": 150 }, "anchor": "right", "x": 270,        "y": "50%", "font": "JetBrains Mono", "fontSize": 20, "fill": "#8a857a", "text": "\"start\": \"${i}s\"" },      { "id": "dot0", "type": "ellipse", "start": 0, "y": 210, "width": 36, "fill": "#161412",        "x": [[0, 320], ["1.5s", 1080, "easeInOutCubic"]] },      { "id": "dot1", "type": "ellipse", "start": "1s", "y": 360, "width": 36, "fill": "#161412",        "x": [[0, 320], ["1.5s", 1080, "easeInOutCubic"]] },      { "id": "dot2", "type": "ellipse", "start": "2s", "y": 510, "width": 36, "fill": "#161412",        "x": [[0, 320], ["1.5s", 1080, "easeInOutCubic"]] },      { "id": "clock", "type": "text", "repeat": { "count": 3, "layout": "column", "spacing": 150, "delay": "1s" }, "anchor": "left",        "x": 1110, "y": "50%", "font": "JetBrains Mono", "fontSize": 22, "fill": "#161412", "text": "t = ${t:1}s" },      { "id": "global", "type": "text", "text": "composition time ${gt:1}s", "font": "JetBrains Mono", "fontSize": 20,        "letterSpacing": 2.4, "uppercase": true, "fill": "#c92a26", "y": "12%" },      { "id": "code", "type": "text", "text": "each dot: \"x\": [[0, 320], [\"1.5s\", 1080]]", "font": "JetBrains Mono",        "fontSize": 20, "fill": "#8a857a", "y": "89%" }    ]  }]}

The timeline confirms the windows:

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

ID       TYPE         START      END      DUR  DETAILS
track.0  rect         0.00s    4.00s    4.00s  
track.1  rect         0.00s    4.00s    4.00s  
track.2  rect         0.00s    4.00s    4.00s  
label.0  text         0.00s    4.00s    4.00s  ""start": "0s""
label.1  text         0.00s    4.00s    4.00s  ""start": "1s""
label.2  text         0.00s    4.00s    4.00s  ""start": "2s""
dot0     ellipse      0.00s    4.00s    4.00s  
dot1     ellipse      1.00s    4.00s    3.00s  
dot2     ellipse      2.00s    4.00s    2.00s  
clock.0  text         0.00s    4.00s    4.00s  "t = 0.0s"
clock.1  text         1.00s    4.00s    3.00s  "t = 0.0s"
clock.2  text         2.00s    4.00s    2.00s  "t = 0.0s"
global   text         0.00s    4.00s    4.00s  "composition time 0.0s"
code     text         0.00s    4.00s    4.00s  "each dot: "x": [[0, 320], ["1.5s", 1080]"

         |0s             1s             2s             3s             |
track.0  |████████████████████████████████████████████████████████████|
track.1  |████████████████████████████████████████████████████████████|
track.2  |████████████████████████████████████████████████████████████|
label.0  |████████████████████████████████████████████████████████████|
label.1  |████████████████████████████████████████████████████████████|
label.2  |████████████████████████████████████████████████████████████|
dot0     |████████████████████████████████████████████████████████████|
dot1     |···············█████████████████████████████████████████████|
dot2     |······························██████████████████████████████|
clock.0  |████████████████████████████████████████████████████████████|
clock.1  |···············█████████████████████████████████████████████|
clock.2  |······························██████████████████████████████|
global   |████████████████████████████████████████████████████████████|
code     |████████████████████████████████████████████████████████████|

trace shows the middle dot in composition time: invisible until 1 s, then the same curve the first dot ran at 0 s.

vidmake trace time-local.json -l dot1 --every 0.25s --from 0.5s --to 2.75s
$ vidmake trace time-local.json -l dot1 --every 0.25s --from 0.5s --to 2.75s
 FRAME    TIME        X        Y       W       H    ROT  SCALE  OPAC  NOTES
    15   0.50s  (not visible)
    23   0.77s  (not visible)
    30   1.00s    320.0    360.0    36.0    36.0    0.0   1.00  1.00  
    38   1.27s    337.1    360.0    36.0    36.0    0.0   1.00  1.00  
    45   1.50s    432.6    360.0    36.0    36.0    0.0   1.00  1.00  
    53   1.77s    724.8    360.0    36.0    36.0    0.0   1.00  1.00  
    60   2.00s    967.4    360.0    36.0    36.0    0.0   1.00  1.00  
    68   2.27s   1068.6    360.0    36.0    36.0    0.0   1.00  1.00  
    75   2.50s   1080.0    360.0    36.0    36.0    0.0   1.00  1.00  
    83   2.77s   1080.0    360.0    36.0    36.0    0.0   1.00  1.00

Local time applies to everything that animates:

  • keyframe times and tween start/end/duration,
  • enter presets (which play at the layer's start) and exit presets (which play at its end),
  • text stagger and reveal, and the expression variables t, f and p.

#Groups nest time

A layer inside a group is timed relative to the group. Its start counts from the group's start, and its animations count from its own start, as always:

json
{ "id": "scene2", "type": "group", "start": "5s", "duration": "4s", "children": [  { "id": "headline", "type": "text", "text": "Part two", "enter": "fadeUp" },  { "id": "detail", "type": "text", "text": "Details", "y": "65%", "start": "1s", "enter": "fadeUp" }] }

headline appears at 5 s and detail at 6 s on the composition's clock. Move scene2 to "start": "8s" and both move with it, animations included. This is how you build a video out of scenes without recalculating anything; a series goes one step further and computes the starts for you.

#Markers

Once a video has more than a few beats, the same times end up typed in many places: the card arrives at 2.5s, so the progress bar, the node color and the label all change at 2.5s too, each written in its own layer's local time. Markers name a beat once, in composition time, and every layer points at the name:

json
"markers": { "title": "0.3s", "underline": "@title+0.7s", "sub": "@underline+0.6s", "out": "3.4s" }
00:00.0 · f 000
Markers name the beats once; layers start at @title, draw on at @underline and read since('underline')Download
time-markers.jsonjson
{  "fonts": [    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }  ],  "compositions": [{    "id": "markers", "description": "Markers name the beats once; layers start at @title, draw on at @underline and read since('underline')",    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",    "markers": { "title": "0.3s", "underline": "@title+0.7s", "sub": "@underline+0.6s", "out": "3.4s" },    "layers": [      { "id": "title", "type": "text", "text": "Name the beats", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 116,        "letterSpacing": -5, "fill": "#161412", "y": 250, "start": "@title", "end": "@out", "enter": "fadeUp", "exit": "fade",        "decoration": { "type": "underline", "color": "#c92a26", "thickness": 6, "offset": 10,          "progress": { "from": 0, "to": 1, "start": "@underline", "duration": "0.5s", "ease": "easeOutCubic" } } },      { "id": "sub", "type": "text", "text": "then point at them from any layer", "font": "Schibsted Grotesk", "fontSize": 40, "fill": "#4a4640",        "y": 380, "start": "@sub", "end": "@out", "enter": "fadeUp", "exit": "fade" },      { "id": "clock", "type": "text", "text": "since('underline') = ${since('underline'):2}s", "font": "JetBrains Mono", "fontSize": 22,        "fill": "#161412", "y": 470 },      { "id": "rail", "type": "rect", "anchor": "left", "x": 100, "y": 600, "width": 1080, "height": 2, "fill": "#d8d1c1" },      { "id": "tick", "type": "rect", "width": 2, "height": 26, "y": 600, "fill": "#161412",        "x": "=100 + 1080 * pick(i, [marker('title'), marker('underline'), marker('sub'), marker('out')]) / 4",        "repeat": 4 },      { "id": "tick-name", "type": "text", "text": "@${pick(i, ['title', 'underline', 'sub', 'out'])}", "font": "JetBrains Mono", "fontSize": 16,        "fill": "#8a857a", "y": 640, "x": "=100 + 1080 * pick(i, [marker('title'), marker('underline'), marker('sub'), marker('out')]) / 4",        "repeat": 4 },      { "id": "playhead", "type": "rect", "width": 3, "height": 46, "y": 600, "fill": "#c92a26", "x": "=100 + 1080 * gt / 4" }    ]  }]}
  • In time values. "@name", "@name+0.25s" and "@name-10" work wherever a time does: start, end, duration (a marker there means "until the marker"), keyframe times, tween start/end and preset delay. vidmake converts the marker into the right local time for you, so "start": "@sub" puts a layer at 1.6s even inside a group that starts at 1s, inside a series, or on a repeat copy.
  • In expressions. since('name') is the seconds since the marker (negative before it) and marker('name') is the marker's time in the layer's local seconds. "opacity": "=map(since('strike'), 0, 0.3, 1, 0.3)" dims a layer right after the strike, whatever the layer's own start.
  • Chained. A marker can be written relative to an earlier one ("@title+0.7s"), so moving one beat moves everything after it.
  • Scoped. Markers belong to their composition. A component used through use sees its own markers.

Retiming a video is now one edit: change "underline": "@title+0.7s" and the line, the subtitle that follows it and the clock all move together. An unknown name is an error that lists the markers you have.

#Time in expressions

Expressions see time in both units, local and global:

variablemeaning
tseconds since the layer started
fframes since the layer started
pprogress through the layer, 0 at its start to 1 at its end
dur, durfthe layer's duration in seconds and frames
gt, gfseconds and frames since the composition started
fpsthe composition's frame rate
since('m'), marker('m')seconds since a marker, and the marker's local time
json
"rotation": "=t * 90","opacity": "=map(f, 0, 15, 0, 1)","width": "=pw * p","text": "${gt:1}s"

"=t * 90" turns 90 degrees per second; map(f, 0, 15, 0, 1) fades in over the first 15 frames; "=pw * p" grows a progress bar across the parent over the layer's life. The demo above prints t next to each dot and gt at the top, so you can watch local and global time side by side.

#Time on the command line

Every CLI flag that takes a time accepts the same formats:

flagcommandsexample
-t, --timeinspect, still-t 2.5s, -t 1:02
-f, --frameinspect, still-f 75
--atstoryboard--at 0,1.5s,2s,90
--framesrender--frames 1s-3s (end exclusive), --frames 0-90
--every, --from, --totrace--every 0.25s --from 1s --to 3s

Markers work in all of them: still -t @ship, storyboard --at @title,@underline+0.3s,@out, render --frames @title..@out (use .. or -@ between markers, since @a-10 is an offset), and trace --from @underline. timeline lists the markers and draws them under the Gantt chart.

Warning

-t 2 means frame 2, not two seconds: the same "numbers are frames" rule applies. Write -t 2s.

A time outside the composition is an error: frame 270 is outside the composition (0..120).

#Frame rate

fps is a composition field (default 30). A component used through use can have its own frame rate; its timing is converted to the parent's, and validation warns that expressions using frame numbers may differ. Using seconds strings and t rather than frame numbers and f keeps a project independent of its frame rate.

#Next steps