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.
You can install Tanim CLI using cargo:
cargo install tanim-cli
The following features are available for installation:
embedded-ffmpeg: Embeds FFmpeg functionality via the rsmpeg crate.ffmpeg-bin: Uses an external FFmpeg binary for video encoding.typst-lib: Uses statically linked typst.typst-bin: Uses an external Typst binary for rendering.The default feature includes all of the above. If --typst-command or --ffmpeg-command is provided, tanim will use the specified executable. If the library-based features (embedded-ffmpeg or typst-lib) are disabled and no explicit path is provided via CLI, tanim will default to searching for ffmpeg or typst in your system PATH.
You can specify features during installation like this:
cargo install tanim-cli --no-default-features --features embedded-ffmpeg,typst-lib
The 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-cli to 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:
https://github.com/user-attachments/assets/8669607a-e385-4fcf-a33b-53627a5d3512
https://github.com/user-attachments/assets/ee742e51-c172-4eac-90c6-1d2aa02ac85e
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 to out.mp4.--frames <frames>: The range of frames to render (e.g., 0..=240). Defaults to 0..=240.--ppi <ppi>: The pixels per inch for rendering. Defaults to 150.0.--variable <variable>: The name of the variable to pass to the Typst file. Defaults to t.--codec <codec>: The video codec to use. Defaults to libx264.--crf <crf>: The Constant Rate Factor for quality control (lower is better).--preset <preset>: The encoding preset. Defaults to medium.For more details on all available options, run tanim-cli --help.
To build Tanim CLI from source:
git clone https://github.com/liquidhelium/tanim-cli.git
cargo build --release
The executable will be located at target/release/tanim-cli.
58 commits
Rust
67.3%
TypeScript
23.4%
PowerShell
5.6%
Typst
3.8%
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.
You can install Tanim CLI using cargo:
cargo install tanim-cli
The following features are available for installation:
embedded-ffmpeg: Embeds FFmpeg functionality via the rsmpeg crate.ffmpeg-bin: Uses an external FFmpeg binary for video encoding.typst-lib: Uses statically linked typst.typst-bin: Uses an external Typst binary for rendering.The default feature includes all of the above. If --typst-command or --ffmpeg-command is provided, tanim will use the specified executable. If the library-based features (embedded-ffmpeg or typst-lib) are disabled and no explicit path is provided via CLI, tanim will default to searching for ffmpeg or typst in your system PATH.
You can specify features during installation like this:
cargo install tanim-cli --no-default-features --features embedded-ffmpeg,typst-lib
The 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-cli to 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:
https://github.com/user-attachments/assets/8669607a-e385-4fcf-a33b-53627a5d3512
https://github.com/user-attachments/assets/ee742e51-c172-4eac-90c6-1d2aa02ac85e
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 to out.mp4.--frames <frames>: The range of frames to render (e.g., 0..=240). Defaults to 0..=240.--ppi <ppi>: The pixels per inch for rendering. Defaults to 150.0.--variable <variable>: The name of the variable to pass to the Typst file. Defaults to t.--codec <codec>: The video codec to use. Defaults to libx264.--crf <crf>: The Constant Rate Factor for quality control (lower is better).--preset <preset>: The encoding preset. Defaults to medium.For more details on all available options, run tanim-cli --help.
To build Tanim CLI from source:
git clone https://github.com/liquidhelium/tanim-cli.git
cargo build --release
The executable will be located at target/release/tanim-cli.
58 commits
Rust
67.3%
TypeScript
23.4%
PowerShell
5.6%
Typst
3.8%