Skip to content

Create animated tutorial videos from code files. Upload code, select lines, group animations, export as 1080p60 MP4. Built with FastAPI + React + Manim. Perfect for CS educators and content creators.

License

Notifications You must be signed in to change notification settings

HeyItsJhello/CodeAnimator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Code Animator 🎬

Create beautiful animated videos of your code with the use of Manim (A Python based Animation Library)! Available as both a web application and a command-line tool.

This was originally created to help with some Godot / Xogot showcases for my code, editting line after line of code became tedious so I decided to learn MANIM to create this project for my exact needs.


Python FastAPI React Vite Manim License: MIT GitHub Stars


Getting Started πŸš€

1. Clone the Repository

git clone https://github.com/HeyItsJhello/CodeAnimator.git
cd CodeAnimator

2. Choose Your Setup

You can use Code Animator in two ways:

  • Web Application (Recommended) - Full-featured browser interface with live preview
  • Command-Line Tool - Traditional CLI for local use

See the sections below for setup instructions for each option.


Features ✨

  • 🌐 Web Interface: Easy-to-use browser-based UI with live code preview
  • πŸ’» CLI Tool: Traditional command-line interface for local use
  • πŸ“ Animate any code file (Python, JavaScript, Java, C++, GDScript, and more)
  • 🎯 Choose specific line ranges to animate
  • 🎨 Group lines to appear together in sequences
  • πŸ’¬ Option to include/exclude comments
  • πŸŽ₯ Customizable syntax highlighting with line numbers
  • πŸ”’ Privacy-focused: Uploaded files are automatically deleted after processing
  • πŸ“Ί High Quality: All videos rendered at 1080p60

Example πŸŽ₯

example_1-12.mp4

🌐 Web Application (Recommended)

Prerequisites

Make sure you have Node.js and Python installed on your system.

Backend:

pip install fastapi uvicorn manim --break-system-packages

Frontend:

cd frontend
npm install

Quick Start

  1. Start the Backend:
cd backend
python main.py
# Server runs on http://localhost:8000
  1. Start the Frontend:
cd frontend
npm run dev
# UI runs on http://localhost:5173
  1. Use the Web Interface:
  • Open http://localhost:5173 in your browser
  • Upload your code file
  • Select line range (start/end lines)
  • Customize Syntax Highlighting for your preference
  • Choose whether to include comments
  • Define animation groups (or press "Add Group" with empty input for all remaining lines)
  • Click "Generate Animation"
  • Your video downloads automatically!

3.5. EXAMPLE: Screenshot 2026-01-13 at 11 15 25β€―PM

Privacy & Security πŸ”’

The web application is designed with privacy in mind:

  • Uploaded code files are deleted immediately after video generation
  • All temporary media files are cleaned up automatically
  • Generated videos are deleted from the server after download
  • No user data is retained on the server

Supported File Types

  • Python (.py)
  • JavaScript (.js, .jsx)
  • TypeScript (.ts, .tsx)
  • Java (.java)
  • C/C++ (.c, .cpp, .h)
  • Go (.go)
  • Rust (.rs)
  • Ruby (.rb)
  • PHP (.php)
  • Swift (.swift)
  • Kotlin (.kt)
  • GDScript (.gd) - Godot Engine scripts

πŸ’» Command-Line Tool

  • If you want to use this for a class or something (I have no clue sometimes)

Prerequisites

pip install manim --break-system-packages

Or with a virtual environment:

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install manim

Quick Start

Step 1: Run the interactive setup

python CodeAnimator.py

Step 2: Answer the prompts

Enter the path to the script file: example_script.py
βœ“ File found: 35 lines total

--- Line Range ---
Starting line: 6
Ending line: 20

Include comments in the video? (y/n): n

--- Line Groups ---
Enter line numbers for each group (space-separated)
Press Enter without input to show all remaining lines

Group 1 lines: 8 9 10
Group 2 lines: 13 14
Group 3 lines: 17 18 19
Group 4 lines: [press enter to finish]

Step 3: Render the animation

The script will output the command to run. For example:

Low quality (fast preview):

manim -pql --disable_caching --flush_cache -o example_6-20 CodeAnimator.py CodeAnimation

High quality (production):

manim -pqh --disable_caching --flush_cache -o example_6-20 CodeAnimator.py CodeAnimation

CLI Usage Examples πŸ’‘

Screenshot 2026-01-13 at 11 16 48β€―PM

Example 1: Animate a function definition

File: my_script.py
Starting line: 1
Ending line: 15
Include comments: y

Group 1: 1 2 3          # Function signature and docstring
Group 2: 5 6 7 8        # First logical block
Group 3: 10 11 12       # Second logical block
Group 4: 14 15          # Return statement

Example 2: Show algorithm steps

File: algorithm.py
Starting line: 20
Ending line: 45
Include comments: n

Group 1: 22 23 24       # Initialization
Group 2: 26 27 28 29    # Main loop
Group 3: 31 32          # Condition check
Group 4: [press enter]  # All remaining lines

How It Works πŸ”§

Web Application

  1. Upload: User uploads code file through web interface
  2. Configure: User selects line ranges and animation groups with live preview
  3. Process: Backend receives file and configuration
  4. Render: Manim generates 1080p60 video with syntax highlighting
  5. Download: Video is sent to user and all data is deleted from server

CLI Tool

  1. Interactive Input: Script prompts for all necessary information
  2. Configuration: Saves choices to temporary config file at /tmp/anim_config.txt
  3. Code Parsing: Reads source file and filters based on settings
  4. Animation: Creates Manim scene with syntax highlighting and line numbers
  5. Video Output: Generates MP4 file in media/videos/CodeAnimator/[quality]/

Line Grouping Tips πŸ’­

  • Logical blocks: Group lines that form a complete thought
  • Related operations: Lines that work together
  • Sequential reveals: Build up complexity gradually
  • Highlight changes: Show before/after states

Example grouping strategies:

  • Variable declarations together
  • Loop/condition + body
  • Function calls with their setup
  • Error handling blocks
  • Leave input empty to show all remaining lines at once

Manim Quality Flags πŸŽ›οΈ

  • -ql: Low quality (480p15, faster rendering)
  • -qm: Medium quality (720p30)
  • -qh: High quality (1080p60) ← Web app uses this
  • -qk: 4K quality (2160p60)

Additional flags:

  • -p: Preview after rendering
  • --disable_caching: Disable caching for clean renders
  • --flush_cache: Clean up SVG files after rendering

Troubleshooting πŸ”

Web Application

Problem: Backend not connecting

  • Solution: Make sure backend is running on port 8000: cd backend && python main.py

Problem: Frontend not loading

  • Solution: Make sure you ran npm install and npm run dev in the frontend folder

Problem: Video generation fails

  • Solution: Check that Manim is installed correctly with manim --version

CLI Tool

Problem: "File not found"

  • Solution: Use absolute path or ensure you're in the correct directory

Problem: "Line X is outside range"

  • Solution: Check that line numbers are within the starting/ending range

Problem: "No lines appear in video"

  • Solution: Make sure you entered at least one group of lines

Problem: Manim not found

  • Solution: Install with pip install manim --break-system-packages

API Endpoints πŸ”Œ

For those who want to integrate programmatically:

  • POST /api/animate - Upload file and generate animation
  • GET /api/download/{video_id} - Download generated video
  • GET /api/videos - List all videos (usually empty due to auto-cleanup)
  • DELETE /api/videos/{video_id} - Delete a specific video

Project Structure πŸ“

CodeAnimator/
β”œβ”€β”€ CodeAnimator.py          # Main CLI animation script
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py             # FastAPI backend server
β”‚   β”œβ”€β”€ requirements.txt    # Python dependencies
β”‚   β”œβ”€β”€ uploads/            # Temporary file uploads (auto-cleaned)
β”‚   β”œβ”€β”€ outputs/            # Generated videos (auto-cleaned)
β”‚   └── media/              # Manim media files (auto-cleaned)
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.jsx        # Main React component
β”‚   β”‚   └── main.jsx       # React entry point
β”‚   β”œβ”€β”€ package.json       # Node dependencies
β”‚   └── vite.config.js     # Vite configuration
└── README.md              # This file

Video Output 🎬

Web Application:

  • Videos are automatically downloaded to your browser's download folder
  • Named as: {filename}_{startLine}-{endLine}.mp4
  • Quality: 1080p60 (always)

CLI Tool:

  • Videos are saved to: media/videos/CodeAnimator/{quality}/{filename}_{startLine}-{endLine}.mp4
  • Quality: Depends on the flag you used (-ql, -qm, -qh, -qk)

License πŸ“„

This project is licensed under the MIT License

MIT License

Contributing 🀝

Contributions are welcome! Feel free to:

  • Report bugs or issues
  • Suggest new features
  • Submit pull requests
  • Improve documentation

Visit the GitHub repository to contribute!


Happy Animating! πŸŽ‰

About

Create animated tutorial videos from code files. Upload code, select lines, group animations, export as 1080p60 MP4. Built with FastAPI + React + Manim. Perfect for CS educators and content creators.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published