Timegroup
The timegroup element is the fundamental organizing unit of an Editframe video.
The timegroup element is used to declare several kinds of video timelines. Timegroups can be nested to create rich timelines.
The outer-most timegroup is the root timegroup. It is the parent of all other timegroups. The pixel dimensions of the root timegroup are used to determine the aspect ratio of the video. And the computed duration of the root timegroup is used to determine the duration of the video.
Examples
Mode: fixed
The most simple timegroup is a fixed duration timegroup. While it doesn't make for a very compelling video, we can use the fixed time group to create static content.
Mode: sequence
The sequence timegroup plays its children in sequence. Here we have three items that each play for a fixed duration of 5, 8, and 3 seconds. The duration of the sequence timegroup is the sum of the durations of its children. It's kind of like flexbox, but for time.
Mode: contain
The contain timegroup plays its children simultaneously. The duration of the contain timegroup is the maximum duration of its children. Here, we have three items that each play for a fixed duration of 5, 8, and 3 seconds. The duration of the contain timegroup is the maximum duration of its children, which is 8 seconds. As you scrub the timeline, you'll see that the last item plays for the entire duration of the timegroup.
These three timegroup modes can be combined to create rich timelines of all kinds.
Mode: fit
Fit timegroups expand their duration to fit the duration of their parent timegroup. This can be used create background elements that play for the duration of the video.
In this example, you can change the duration of the sequence items to see how the fit element will maintain the duration of the timegroup containing it.
CSS Variable: --ef-duration
The timegroup element supports animation control. This is useful for creating complex animations that are timed to the video.
In this example, we have specified a fade-in and fade-out animation that will run on the titlecard and subtitle.
To apply the animation, we use the style
attribute to set the animation on the titlecard and subtitle.
<p
class="text-3xl"
style="
animation: fade-in 2s ease-in-out paused,
fade-out 2s ease-in-out calc(var(--ef-duration) - 2s) paused
"
>
Five Second Titlecard
</p>
The var(--ef-duration)
variable is a special variable that is set by the timegroup element. It is the duration of the nearest parent timegroup. By using this variable we can ensure that the fadeout will always start at the same time relative to the end of the timegroup.
This is great for creating templates where you don't know exactly how long the final media will be. Either because it might change during production, or because it will be filled with dynamic during templated rendering.
CSS Variable: --ef-progress
The timegroup element also supports progress control. This is useful for creating interactive media.
In this example, we have specified a progress animation that will run on the titlecard and subtitle. The progress animation is a simple scale animation that will run from 0 to 100% based on the progress of the timegroup.
<!-- We can use the --ef-progress variable to create a scale animation that runs from 0 to 100% based on the progress of the timegroup. -->
<p class="text-3xl" style="scale(var(--ef-progress))">Five Second Titlecard</p>
<!-- We can also use the --ef-progress variable to create a progress bar that fills up from 0 to 100% based on the progress of the timegroup. -->
<div class="h-2 w-1/2 bg-slate-400">
<div class="bg-blue-400 h-full" style={{width: `var(--ef-progress)`}}></div>
</div>
Mode: sequence
with overlap
and transitions
CSS Variables: --ef-transition-duration
and --ef-transition-out-start
When using an overlap, the timegroup element will automatically calculate the --ef-transition-duration
and --ef-transition-out-start
variables. These variables are useful for creating transitions between sequence items. Again, they help us create templates that are dynamic and can be reused with different content.
Repeating the same example, we can see the --ef-transition-duration
and --ef-transition-out-start
variables in action.
Controlling transitions with CSS is a powerful way to create complex animations and interactive media. You might be surprised how much you can do with just a few lines of CSS and SVG. Checkout the CSS Animation Control section for more examples.
Frame Rate and Time Quantization
To ensure that animations and media playback are perfectly synchronized, ef-timegroup
quantizes all time updates to a consistent frame grid. This is controlled by the fps
(frames per second) attribute.
When you set the currentTime
on a timegroup, the value is automatically rounded to the nearest frame boundary based on the configured fps
. This process, known as time quantization, is crucial for preventing timing inconsistencies and producing predictable, smooth output, especially in a rendering environment.
Attributes
mode
mode
mode
string
contain
The temporal mode of the timegroup. Can be fixed
, sequence
, contain
, or fit
.
This is the most important attribute of the timegroup element. It is used to define the video timeline.
Fixed timegroups have an explicit, set duration. (see the duration
attribute).
Sequence timegroups play their children in sequence, sort of like flexbox for time. (see the overlap
attribute to create transitions between sequence items).
Contain timegroups play their children simultaneously, and the duration of the contain timegroup is the maximum duration of its children.
Fit timegroups expand their duration to fit the duration of their parent timegroup. This can be used create background elements that play for the duration of the video.
These modes can be combined to create rich timelines of all kinds.
See below for examples.
overlap
overlap
overlap
timestring
0s
A string representing time duration (e.g. "5s", "1.5s", "500ms")
The overlap duration between sequential items in a sequence timegroup. This property is only applied when the mode
attribute is set to sequence
. This can be combined with css animation to create transitions between sequence items.
duration
duration
duration
timestring
A string representing time duration (e.g. "5s", "1.5s", "500ms")
The duration of the timegroup. Values written to this property are only applied when the timegroup is in fixed
mode.
Otherwise the value is computed based on the duration of the children.
Sequence timegroups will be the sum of the durations of its children.
Contain timegroups will be the duration of the longest temporal element in the timegroup.
currentTime
currenttime
currentTime
number
0
Explicitly set the current time of the timegroup.
This is useful for creating editors and other interactive applications with the editframe elements.
For example, a custom scrubber element could be used to set the currentTime
property of the timegroup.
When nesting timegroups, only set this property on the root-most timegroup. The value will be propagated to all child timegroups.
Writes to this property will be reflected in the currentTimeMs
property.
currentTimeMs
currenttime
currentTimeMs
number
0
The current time of the timegroup in milliseconds.
Writes to this property will be reflected in the currentTime
property.
fit
fit
fit
string
none
Controls how the timegroup fits within its parent container visually. Can be none
, contain
, or cover
.
This property is used to control the visual scaling behavior when the timegroup's aspect ratio doesn't match its parent container.
none
: No fitting applied, content maintains its natural sizecontain
: Scales content to fit within the parent while maintaining aspect ratiocover
: Scales content to fill the parent while maintaining aspect ratio
Note: This is different from the temporal mode
property. The fit
property controls visual layout, while mode
controls timeline behavior.
fps
fps
fps
number
30
Sets the frames per second for the timegroup. This value is used to quantize all time updates to frame boundaries, ensuring predictable seeking and synchronization. This is especially important during rendering to produce a smooth video output.