[effects]docs
Start

Your first video

A project is a directory of Odin files. It exports one procedure, effects_video, that describes the video. This page builds one from nothing.

One file#

Make a directory and put this in main.odin:

package spot

import fx "effects:fx"

SCENES := [?]fx.Scene {
	{name = "intro", start = 0, dur = 3.4, draw = intro},
}

@(export)
effects_video :: proc() -> ^fx.Video {
	return fx.video({name = "Spot", scenes = SCENES[:]})
}

intro :: proc(s: fx.Shot) {
	fx.backdrop(.Night)
	rise := 30 * (1 - fx.ep(s.t, s.start, s.start + 0.6))
	if fx.group({o = fx.fade(s), y = rise}) {
		fx.caption("No browser in the loop.", {160, 440}, 112, fx.theme.nt)
	}
	fx.grain(0.035)
}

Line by line:

  • The package name can be anything. effects:fx is the library; the renderer tells the compiler where it is.
  • SCENES is the timeline: one scene called intro, starting at 0, 3.4 seconds long, drawn by the procedure intro. The table is a global because fx.video copies the slice it is given and the literal has to live long enough to be copied.
  • effects_video is what the renderer looks for. fx.video fills in what you leave out: 1920×1080, 60 fps, a black background, and a duration that ends with the last scene.
  • intro draws one frame. s is a Shot: s.t is the video's time, s.start when this scene began.
A frame of the scenes-first demo
2.11 / 3.40 sscenes-first
scenes_first :: proc(s: fx.Shot) {
    fx.backdrop(.Night)
    rise := 30 * (1 - fx.ep(s.t, s.start, s.start + 0.6))
    if fx.group({o = fx.fade(s), y = rise}) {
        fx.caption("No browser in the loop.", {160, 440}, 112, fx.theme.nt)
    }
    fx.grain(0.035)
}
The scene above, running in your browser.

Look at a frame#

Before rendering anything, draw single frames:

$ build/effects still projects/spot 0.3 1.5
built spot in 0.38s (-o:none)
/…/projects/spot/.effects/stills/0000.30.png
/…/projects/spot/.effects/stills/0001.50.png

still compiles the project without optimization (fast to build) and writes a PNG for every time you name. This is the quickest way to check a change, and the way an agent checks its own work.

Watch it#

$ build/effects-edit projects/spot

The editor plays the video on the GPU and shows the scenes on a timeline. Leave it open: every time you save a source file it recompiles (about 0.4 s) and swaps the new code in under the playhead. A compile error is shown over the preview. See the editor.

A second scene#

Scenes are drawn in list order and may overlap, which is how one scene fades out over the next:

SCENES := [?]fx.Scene {
	{name = "intro", start = 0,   dur = 3.4, draw = intro},
	{name = "claim", start = 3.0, dur = 4,   draw = claim},
}

claim :: proc(s: fx.Shot) {
	if fx.group({o = fx.fade(s)}) {
		fx.backdrop(.Night)
		arrive := fx.Letters{t0 = s.start + 0.3, step = 0.03, rise = 40}
		fx.letters("Every frame is a function of time.", {160, 470}, fx.headline(96), fx.theme.nt, arrive)
	}
}

The whole scene is inside one group, so its background fades in over the end of intro. letters is from type in motion: each letter rises 40 px, 0.03 s after the one before, starting 0.3 s into the scene.

Render it#

$ build/effects render projects/spot
built spot in 3.01s (-o:speed)
rendering 420 frames (0.00s–7.00s) at 1920x1080, 60 fps, 5 workers, x264
rendered 420 frames in 6.5s (64.6 fps)
/…/projects/spot/.effects/spot.mp4

render compiles with optimization, gives every worker thread its own stretch of frames and its own encoder, and joins the pieces without re-encoding. That output is from an 8-core machine that had memory for five workers: seven seconds of 1080p60 in six and a half. Everything a project produces goes into its .effects/ directory, which you can delete at any time.

Where things go#

projects/spot/
  main.odin          # effects_video and the scene table
  intro.odin         # one file per scene is a good habit
  assets/            # fonts, images, footage, audio
  timing.json        # written by the editor when you drag things
  .effects/          # build output, stills, renders, caches

Paths in your code are relative to the project directory. Next: scenes and time.

Edit this page · Plain Markdown · All docs in one file