The idea of creating animations using typst comes from WenSim. His bash script renders each frame as a .png file, then merge them into a video. This project can be seen as a statically linked, concurrent version of his script.
Tanim CLI is a command-line tool for creating animations and videos using Typst. It allows you to render Typst documents into a video file, by varying a numerical variable over a range of frames.
- Render Typst documents to video.
- Customize frame range, resolution (PPI), and video encoder options.
- Pass a variable to your Typst file that changes with each frame.
You can install Tanim CLI using cargo:
cargo install tanim-cliThe basic command to render a video is:
tanim-cli [OPTIONS] <input>Where <input> is your Typst file.
-
Create a Typst file named
animation.typ:#let t = sys.inputs.at("t", default: 300) #rect(width: 100%, height: 100%, fill: rgb("f0f0f0")) #text(16pt, "Frame: " + str(t))
-
Run
tanim-clito render the animation:tanim-cli --frames 0..=120 --output animation.mp4 animation.typ
This will create a video file animation.mp4 with 121 frames, where the text changes from "Frame: 0" to "Frame: 120".
Here are a couple of examples of what you can create with Tanim CLI:
manim.mp4
physics.mp4
Here are the available command-line arguments:
<input>: The path to the input Typst file.--output <output>: The path to the output video file. Defaults toout.mp4.--frames <frames>: The range of frames to render (e.g.,0..=240). Defaults to0..=240.--ppi <ppi>: The pixels per inch for rendering. Defaults to150.0.--variable <variable>: The name of the variable to pass to the Typst file. Defaults tot.--codec <codec>: The video codec to use. Defaults tolibx264.--crf <crf>: The Constant Rate Factor for quality control (lower is better).--preset <preset>: The encoding preset. Defaults tomedium.
For more details on all available options, run tanim-cli --help.
To build Tanim CLI from source:
- Clone the repository:
git clone https://github.com/liquidhelium/tanim-cli.git
- Build the project:
cargo build --release
The executable will be located at target/release/tanim-cli.