Bodymovin Renderer is a Rust library for rendering frames from Bodymovin JSON data and handling video frames. This library provides utilities for processing animations, converting image buffers to video frames, and more.
- Parse Bodymovin JSON data to extract animation details.
- Render frames from animations using image buffers.
- Convert image buffers into video frames with timestamp handling.
- Easily customizable frame rate and time base for accurate video rendering.
To install Rust on macOS, follow these steps:
-
Install Homebrew (if you don't already have it):
Open a terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Install Rust using Homebrew:
brew install rust
-
Verify the installation:
rustc --version
You should see the Rust version printed in the terminal.
To install Rust on Linux, follow these steps:
-
Install Rust using rustup:
Open a terminal and run:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Follow the on-screen instructions to complete the installation.
-
Configure your current shell:
source $HOME/.cargo/env
-
Verify the installation:
rustc --version
You should see the Rust version printed in the terminal.
To update Rust to the latest version, run:
rustup update
To build the project, run:
cargo build
To run the project, run:
cargo run
To test the project, run:
cargo test
To format the code, run:
cargo fmt
To use this library, add the following to your Cargo.toml
:
[dependencies]
image = "0.24" # Or the latest version
num-rational = "0.4" # Or the latest version
rayon = "1.7" # Or the latest version
serde = { version = "1.0", features = ["derive"] }
Below is a basic example demonstrating how to render frames from Bodymovin JSON and convert them into video frames:
use bodymovin_renderer::bodymovin::{get_all_frames, save_frame, BodymovinError};
fn main() -> Result<(), BodymovinError> {
// Paths to the necessary files and directories
let bodymovin_json = "path/to/bodymovin.json";
let assets_dir = "path/to/bodymovin/assets";
let output_dir = "path/to/output";
// Render all frames from Bodymovin JSON
let frames = get_all_frames(&bodymovin_json, &assets_dir)?;
// Save each frame
for (frame_number, frame) in frames.into_iter().enumerate() {
save_frame(&frame, output_dir, frame_number as u32)?;
}
Ok(())
}
This example code demonstrates how to use the library to process frames and convert them into a video-friendly format:
- Rendering Frames: Using
get_all_frames
to render frames from a Bodymovin JSON file. - Saving Frames: Using the
save_frame
function to store processed frames in a specified directory.
get_all_frames
: Function to render frames from Bodymovin JSON.
We welcome contributions! Feel free to submit issues or pull requests to improve the library.
- Implement additional features for more animation effects.
- Improve error handling and performance optimizations.
- Enhance documentation with more examples and use cases.
This project is licensed under the MIT License. See the LICENSE file for details.