Skip to content
dmtrKovalenkoPublic

About

programmatic video rendering framework that is actually fast

Topics

Resources

Stars

2.9k stars

Watchers

57 watching

Forks

Latest commit

 

History

292 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fframes

Video vibe coding framework that is actually fast.
Write your video in Rust and SVG, render it on the GPU.

crates.io docs.rs MIT license @fframes_rust on X

fframes-intro-1080p.mp4

This 128 second video was vibed in 48 minutes and rendered in 36 seconds.
It is an fframes project: examples/fframes-intro.


Ask your agent for a video

fframes ships a skill for coding agents. Add it once:

npx skills add https://fframes.studio

Then tell the agent what video you want. The skill walks it from an empty folder to a rendered .mp4: install fframes, create a project, design the motion, place the sound, check the result.

The fframes API is explicit and verbose, which is why it stayed unreleased for years. An agent with a good skill file writes that kind of code without complaint.

Your agent cannot watch the video

A coding agent cannot play a video or listen to a soundtrack, so every generated project comes with a command line that turns the video into PNGs and text.

Your agent You
inspect checks every frame without rendering pixels. It reports missing fonts or images, text cut off by the canvas, invalid SVG and panics, each with its time and scene.

strip lays evenly spaced frames out on one contact sheet, onion blends frames to show the path and easing of a movement, frame writes full-size PNGs.

audio analyze reports loudness (LUFS), true peak, clipping and silence per scene.
preview opens a GPU window with sound to play, pause, seek and step frame by frame.

The editor runs the video compiled to WebAssembly in the browser, with a timeline to scrub.

render writes the final file. render --draft encodes one scene at half size in about a second.

Every command runs as cargo run --release -- <command> inside the project:

command output
timeline the scenes with their frame and second ranges, and every audio track with its mix settings
inspect problems in a frame every 0.25 s and the first and last frame of every scene; exit code 2 on errors
strip <scene> -n 12 strip.png, a labelled contact sheet
frame <scene>@end,<scene>@50% full-size PNGs in frames/
onion "<scene>@0..<scene>@1s" -n 6 onion.png, the blended movement
audio analyze --waveform w.png the loudness report and a waveform with scene lines and cue ticks
preview the real-time window, for a human
render [--draft] the video, or a part of it

<scene> is the name of a scene struct in your video. Times read as 120 (frame), 3.2s, 50%, <scene>@1.2s, and ranges like <scene>@0..<scene>@1s. Add --json to parse the output.

Why it is fast

  • The Skia backend draws on the GPU, Metal on macOS and Vulkan on Linux and Windows, about 10x faster than the built-in CPU backend.
  • Parts of a frame without {expressions} are hashed at compile time, so the renderers draw them once and reuse them.
  • fframes links ffmpeg's libav libraries instead of piping frames to a separate process.
  • When SVG is not enough, SkSL or pasted Shadertoy GLSL runs as a layer of any frame.

What your agent writes

Every frame is an SVG tree returned by a Rust function, written with the svgr! macro. From examples/hello-world, shortened: a square moves along a timeline and a line of text prints the current frame.

Show the code
impl Video for HelloWorldVideo<'_> {
    const FPS: usize = 30;
    const WIDTH: usize = 1920;
    const HEIGHT: usize = 1080;

    fn duration(&self) -> fframes::Duration<'_> {
        fframes::Duration::Seconds(30.)
    }

    fn audio(&self) -> AudioMap<'_> {
        AudioMap::none()
    }

    fn render_frame(&self, frame: Frame, ctx: &FFramesContext) -> fframes::Svgr<'_> {
        fframes::svgr!(
            <svg
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 1920 1080"
                width={ctx.current_video_size.width}
                height={ctx.current_video_size.height}
            >
                <rect
                    x="400"
                    y="400"
                    width="200"
                    height="200"
                    fill="blue"
                    transform={frame.animate(fframes::timeline!(
                        at 0., animate Transform::translate(0, 0) => Transform::translate(200, 480), Easing::Linear,
                        at 2. => 6.0, animate Transform::translate(200, 480) => Transform::translate(750, -400), Easing::Linear,
                        at 6.0 => 10.0, animate Transform::translate(750, -400) => Transform::translate(1310, 480), Easing::Linear,
                    ))}
                />

                <text
                    x="100"
                    y="440"
                    font-family="JetBrains Mono"
                    font-size="74"
                    font-weight="500"
                    fill="#3b5563"
                >
                    {format!("This frame index: {}, second: {:.2}", frame.index, frame.seconds())}
                </text>
            </svg>
        )
    }
}

The skill's guides are plain Markdown, so you can read them too: the workflow, the API cheat sheet, design and sound. The full API reference is on docs.rs/fframes.

Examples

Click a poster to watch the example. The README in each example folder has the video inline, and just render <example> renders the full one.

fframes-intro
fframes-intro
the 128 second launch video, everything placed on the beat grid of its soundtrack
signal-lab
signal-lab
a 24 second motion study: product UI, data storytelling and a technical explainer
shaders
shaders
GPU shader layers composed with SVG: an SkSL background and a Shadertoy raymarcher clipped into a card
shader-mode
shader-mode
a 31-second shader promo with reference audio, a moving panel wall, native preview footage and 18 GPU shader programs, rendered with Skia on Metal or Vulkan.
The preview is silent: its soundtrack is not in the repository.
neon-triangle
neon-triangle
a minimal shader clip built to make banding and motion artifacts easy to spot
hello-world
hello-world
a simple "hello world" video
beta
beta
a complicated multi-scene example (our beta announce video)
marketing
marketing
our marketing video
audio-announce
audio-announce
an automated workflow to create audio visualisation with automated subtitles
podcast
podcast
an audio visualization for a podcast placeholder video
teej-podcast
teej-podcast
teej's podcast with video and chapters visualization
tiktok
tiktok
a TikTok-like vertical video
conference-splash-screen
conference-splash-screen
one splash screen per conference talk, rendered in batch
low-poly-art
low-poly-art
a renderer stress test: animal art with a lot of polygons
pixel-memory
pixel-memory
my dog's memorial video generator (totally randomized)
lottie
lottie
an 18 second vertical launch video for Lottie support: every animation is a Lottie file and the music is synthesized in Rust
made-of-motion
made-of-motion
a 20 second promo with pixel objects, a perspective carousel, thermal shaders and per-exposure vector ink, an adaptation of a reference film
arm
arm
a 37 second 3D short: a lab robot with a camera eye spells fframes, drops a letter and picks it up again, rendered with fframes-3d on the GPU
svg-in-3d
svg-in-3d
an svgr UI on the screen of a turning 3D monitor, showing a 3D cube with the svgr logo: four nested levels of SVG and 3D that never leave the GPU

From the repository root, just run podcast opens an example in the editor with live reload and just render podcast writes it to a file.

Without an agent

cargo install --locked cargo-fframes
cargo fframes new my-video
cd my-video && cargo run --release -- preview

cargo fframes new takes --template single-scene|multi-scene, --format landscape|portrait|square|uhd, --fps, --title and --backend. On macOS and Linux (arm64, x86_64) the first build downloads prebuilt Skia and ffmpeg libraries and takes under a minute on a fast machine; other targets and feature combinations compile them from source (up to ~20 minutes). Later builds take seconds. --backend cpu skips Skia (no preview window, slower renders). To track main, install with --git https://github.com/dmtrKovalenko/fframes.

Requirements

Rust and, for working on the editor, NodeJS. fframes links ffmpeg's libav libraries statically. A prebuilt build is downloaded for macOS and Linux (arm64 and x86_64) and compiled from source for other targets or FFMPEG_FORCE_BUILD=1; either way the system encoders they link against have to be installed.

The examples enable fframes/build-portable on native non-Windows targets. CI builds the whole workspace, combining the examples' x264, x265, VPX and Opus features; no published FFmpeg archive currently matches that combination, so it falls back to a source build. Without build-portable, that build uses -march=native -mtune=native. Caching it and restoring it on a runner with a different CPU can cause SIGILL (illegal instruction). The feature omits those flags for source builds while keeping matching prebuilt downloads enabled, and also applies to FFmpeg used by the compile-time media macro.

Within this workspace, use the same setting for native builds that will be cached or run on other machines:

[target.'cfg(not(any(target_arch = "wasm32", windows)))'.dependencies]
fframes = { workspace = true, features = ["build-portable"] }

build-portable also enables FFmpeg's source-build support, so the examples exclude Windows (which links a shared FFmpeg installation) and browser targets. Setting FFMPEG_MARCH or FFMPEG_MTUNE, even to an empty string, bypasses prebuilt downloads; prefer the feature when you want portable source fallbacks and prebuilt downloads.

macOS
brew install pkg-config ffmpeg x264 x265 opus nasm ninja
Linux

for debian based distros:

sudo apt-get install -y yasm nasm ffmpeg libx264-dev libx265-dev libopus-dev libclang-dev clang ninja-build libvpx-dev libasound2-dev

for arch based distros:

sudo pacman -S ninja yasm nasm ffmpeg x264 x265 opus clang

for nix users:

nix-shell
Windows

On Windows ffmpeg is not compiled from source. Instead fframes links a prebuilt FFmpeg 9.0 shared build (for example ffmpeg-n9.0-latest-win64-gpl-shared-9.0.zip from BtbN/FFmpeg-Builds) and needs LLVM for bindgen:

winget install LLVM.LLVM
# unzip the ffmpeg build somewhere, then point the build to it:
$env:FFMPEG_DIR = "C:\ffmpeg-n9.0-latest-win64-gpl-shared-9.0"
$env:LIBCLANG_PATH = "C:\Program Files\LLVM\bin"
# the ffmpeg DLLs must be reachable when building (proc macros load them) and running
$env:PATH = "$env:FFMPEG_DIR\bin;$env:PATH"

vcpkg install ffmpeg works as well instead of FFMPEG_DIR. Codecs come from the prebuilt build, so leave the codec features (h264, h265, ...) off: they request a from-source ffmpeg build which is not supported on Windows.

Codecs

Cargo features of the fframes crate choose which codecs and hardware acceleration libraries are linked:

[dependencies]
# this will enable and try to link libx264 during the build
fframes = { version = "1", features = ["h264", "libav-agree-gpl"] }

All the build and linking of codecs and other system libs are leveraging the ffmpeg build system, so for troubleshooting please refer the ffmpeg compilation guide.

Troubleshooting
  • Build fails in ffmpeg-sys-fframes: a system library from the list above is missing (nasm, pkg-config, the codec packages).
  • Build fails in the Skia bindings with a bindgen or libclang error (only when Skia is compiled from source, e.g. with both metal and vulkan enabled): point LIBCLANG_PATH at a working libclang, on macOS Xcode's: export LIBCLANG_PATH=$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib.
  • Text renders in the wrong font: inspect reports No match for ... font-family; put the font file in the project's media/ folder and use its exact family name.

Working on fframes

Agents working on fframes itself should start from AGENTS.md. For humans, install the just command runner and init the repo:

npm install --global pnpm # the package manager for the nodejs based editor
cargo install --locked just cargo-watch wasm-bindgen-cli wasm-pack
just init-repo
just watch-editor # in a separate terminal, to work on the editor

License

fframes is released under the MIT License.

About

programmatic video rendering framework that is actually fast

Topics

Resources

Stars

2.9k stars

Watchers

57 watching

Forks

Releases

Packages

Contributors

Languages