Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Command line
#. You can save the logs to a file by using :code:`--log_to_file`
#. Read :code:`tex_template` from config file if not specified by :code:`--tex_template`.
#. Add experimental javascript rendering with :code:`--use_js_renderer`
#. Add :code:`-q/--quality [k|h|m|l]` flag and removed :code:`-m/-l` flags.
#. Add :code:`-q/--quality [k|p|h|m|l]` flag and removed :code:`-m/-l` flags.
#. Removed :code:`--sound` flag


Expand Down
7 changes: 4 additions & 3 deletions docs/source/tutorials/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ The output looks as follows.
:options: -ELLIPSIS, +NORMALIZE_WHITESPACE

usage: manim [-h] [-o OUTPUT_FILE] [-p] [-f] [--leave_progress_bars] [-a] [-w] [-s] [-g] [-i] [--disable_caching] [--flush_cache] [--log_to_file] [-c BACKGROUND_COLOR]
[--background_opacity BACKGROUND_OPACITY] [--media_dir MEDIA_DIR] [--log_dir LOG_DIR] [--tex_template TEX_TEMPLATE] [--dry_run] [-t] [-q {k,h,m,l}] [--low_quality] [--medium_quality]
[--high_quality] [--fourk_quality] [-r RESOLUTION] [-n FROM_ANIMATION_NUMBER] [--use_js_renderer] [--js_renderer_path JS_RENDERER_PATH] [--config_file CONFIG_FILE] [--custom_folders]
[--background_opacity BACKGROUND_OPACITY] [--media_dir MEDIA_DIR] [--log_dir LOG_DIR] [--tex_template TEX_TEMPLATE] [--dry_run] [-t] [-q {k,p,h,m,l}] [--low_quality] [--medium_quality]
[--high_quality] [--production_quality] [--fourk_quality] [-r RESOLUTION] [-n FROM_ANIMATION_NUMBER] [--use_js_renderer] [--js_renderer_path JS_RENDERER_PATH] [--config_file CONFIG_FILE] [--custom_folders]
[-v {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [--progress_bar True/False]
{cfg} ... file [scene_names [scene_names ...]]

Expand Down Expand Up @@ -88,11 +88,12 @@ optional arguments:
Specify a custom TeX template file
--dry_run Do a dry run (render scenes but generate no output files)
-t, --transparent Render a scene with an alpha channel
-q {k,h,m,l}, --quality {k,h,m,l}
-q {k,p,h,m,l}, --quality {k,p,h,m,l}
Render at specific quality, short form of the --*_quality flags
--low_quality Render at low quality
--medium_quality Render at medium quality
--high_quality Render at high quality
--production_quality Render at default production quality
--fourk_quality Render at 4K quality
-r RESOLUTION, --resolution RESOLUTION
Resolution, passed as "height,width". Overrides any quality flags, if present
Expand Down
2 changes: 1 addition & 1 deletion manim/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _parse_config(config_parser, args):
# and are stored in 'camera_config'. Note the highest resolution
# passed as argument will be used.
quality = _determine_quality(args)
section = config_parser[quality if quality != "production" else "CLI"]
section = config_parser[quality if quality != constants.DEFAULT_QUALITY else "CLI"]

# Loop over low quality for the keys, could be any quality really
config = {opt: section.getint(opt) for opt in config_parser["low_quality"]}
Expand Down
13 changes: 11 additions & 2 deletions manim/config/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def _parse_cli(arg_list, input=True):
"-q",
"--quality",
choices=constants.QUALITIES.values(),
default=constants.DEFAULT_QUALITY_SHORT,
help="Render at specific quality, short form of the --*_quality flags",
)
parser.add_argument(
Expand All @@ -360,6 +361,11 @@ def _parse_cli(arg_list, input=True):
action="store_true",
help="Render at high quality",
)
parser.add_argument(
"--production_quality",
action="store_true",
help="Render at default production quality",
)
parser.add_argument(
"--fourk_quality",
action="store_true",
Expand Down Expand Up @@ -650,7 +656,10 @@ def _determine_quality(args):
}

for quality in constants.QUALITIES.keys():
if getattr(args, quality) or (
if quality == constants.DEFAULT_QUALITY:
# Skip so we prioritize anything that overwrites the default quality.
pass
elif getattr(args, quality) or (
hasattr(args, "quality") and args.quality == constants.QUALITIES[quality]
):
return quality
Expand All @@ -662,4 +671,4 @@ def _determine_quality(args):
)
return old_qualities[quality]

return "production"
return constants.DEFAULT_QUALITY
4 changes: 4 additions & 0 deletions manim/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ class MyText(Text):
# Video qualities
QUALITIES = {
"fourk_quality": "k",
"production_quality": "p",
"high_quality": "h",
"medium_quality": "m",
"low_quality": "l",
}

DEFAULT_QUALITY = "production_quality"
DEFAULT_QUALITY_SHORT = QUALITIES[DEFAULT_QUALITY]
7 changes: 4 additions & 3 deletions tests/test_cli_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@


def test_quality_flags():
# Assert that quality is None when not specifying it
# Assert that quality is the default when not specifying it
parsed = _parse_cli([], False)

assert not parsed.quality
assert parsed.quality == constants.DEFAULT_QUALITY_SHORT
assert _determine_quality(parsed) == constants.DEFAULT_QUALITY

for quality in constants.QUALITIES.keys():
# Assert that quality is properly set when using -q*
Expand Down Expand Up @@ -41,4 +42,4 @@ def test_quality_flags():
parsed = _parse_cli([], False)

assert not getattr(parsed, quality)
assert "production" == _determine_quality(parsed)
assert _determine_quality(parsed) == constants.DEFAULT_QUALITY