How to Configure Manim Output Resolution and Quality Settings (480p, 720p, 1080p, 4K)
Manim determines video resolution through built-in quality flags (-l, -m, --hd, --uhd), a custom -r resolution argument, or a user-defined YAML configuration file that overrides default presets.
The 3b1b/manim engine generates mathematical animations by rendering scenes to video files. Controlling the output resolution and quality settings ensures your renders match specific platform requirements or production standards. Manim provides multiple mechanisms to set these parameters, ranging from quick CLI shortcuts to granular configuration file overrides.
Built-in Quality Shortcuts
Manim ships with four mutually exclusive CLI flags that map to predefined resolutions stored in manimlib/default_config.yml. These shortcuts are parsed in manimlib/config.py and automatically configure the camera resolution.
The available quality presets are:
-l/--low_quality→ 854 × 480 (480p)-m/--medium_quality→ 1280 × 720 (720p)--hd→ 1920 × 1080 (Full HD)--uhd→ 3840 × 2160 (4K)
When invoked, the get_resolution_from_args function in manimlib/config.py translates these flags into a (width, height) tuple and assigns it to config.camera.resolution.
Render a scene in 720p using the medium-quality flag:
manim -m -pqh my_scene.py MyScene
Render the same scene in 4K:
manim --uhd -pqh my_scene.py MyScene
Custom Resolution Settings
For non-standard dimensions or specific platform requirements, Manim accepts explicit resolution values via the CLI or a custom configuration file.
Explicit Resolution Flag
Use the -r or --resolution argument followed by a WIDTHxHEIGHT string. The parser in manimlib/config.py splits this string into integers and applies it directly to the camera configuration.
Render a custom 1440p (2560 × 1440) video:
manim -r 2560x1440 -pqh my_scene.py MyScene
Configuration File Overrides
Advanced users can override the built-in resolution_options by creating a custom_config.yml file. During initialize_manim_config, Manim merges the custom file with manimlib/default_config.yml, allowing you to redefine the presets associated with quality flags.
Create a my_config.yml with custom resolutions:
resolution_options:
low: (640, 360) # smaller low-quality
med: (960, 540) # smaller medium-quality
high: (2560, 1440) # custom HD (2K)
4k: (3840, 2160) # standard 4K
Invoke the custom configuration:
manim --config_file my_config.yml -l -pqh my_scene.py MyScene
The -l flag now renders at 640 × 360 instead of the default 854 × 480.
How Resolution Configuration Works Under the Hood
Manim’s resolution pipeline involves three layers: CLI argument parsing, default configuration values, and user-defined overrides.
The manimlib/config.py file contains the get_resolution_from_args function, which checks for quality flags (-l, -m, --hd, --uhd) and the -r resolution string. If a quality flag is detected, it retrieves the corresponding tuple from resolution_options defined in manimlib/default_config.yml.
The initialize_manim_config function loads default_config.yml, then merges any user-provided YAML file specified via --config_file. This merge allows custom resolution_options to shadow the defaults. Finally, the resolved (width, height) tuple is stored in manim_config.camera.resolution, which the rendering engine and FFmpeg encoder use to generate the final video file.
Summary
- Built-in shortcuts (
-l,-m,--hd,--uhd) provide instant access to 480p, 720p, 1080p, and 4K resolutions defined inmanimlib/default_config.yml. - Custom resolutions are supported via the
-r WIDTHxHEIGHTCLI argument for non-standard dimensions. - Configuration files allow permanent overrides of quality presets by creating a YAML file and passing it with
--config_file. - Resolution logic is handled in
manimlib/config.pybyget_resolution_from_argsand applied toconfig.camera.resolutionfor the rendering pipeline.
Frequently Asked Questions
What is the default resolution in Manim?
If no quality flag or resolution argument is provided, Manim uses the value specified in manimlib/default_config.yml under camera.resolution. Typically, this defaults to 1920 × 1080 (Full HD) unless modified by a custom configuration file.
How do I render a 4K video in Manim?
Use the --uhd flag when invoking Manim from the command line. This flag maps to 3840 × 2160 resolution as defined in resolution_options within default_config.yml. Example: manim --uhd -pqh my_scene.py MyScene.
Can I set a custom resolution like 1440p?
Yes. Use the -r or --resolution flag followed by the desired dimensions in WIDTHxHEIGHT format. For 1440p (2560 × 1440), run: manim -r 2560x1440 -pqh my_scene.py MyScene. The get_resolution_from_args function in manimlib/config.py parses this string into the camera configuration.
Where are the quality presets defined?
The quality presets (low, med, high, 4k) are defined in manimlib/default_config.yml under the resolution_options key. You can view the default mappings there or override them by creating a custom_config.yml file and passing it via the --config_file CLI argument.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →