A community-maintained Python framework for creating mathematical animations.
Separate verbosity level of project with ffmpeg loglevel
azarzadavila48827d5a8411
diff --git a/manim/config.py b/manim/config.pyindex 5ab17cabd..360cb1c06 100644--- a/manim/config.py+++ b/manim/config.py@@ -88,6 +88,7 @@ def _parse_config(config_parser, args):args, config_parser, file_writer_config, successfully_read_files = _run_config()+logger.setLevel(file_writer_config["verbose"]) # Set logger levelif _from_command_line():logger.info(f"Read configuration files: {os.path.abspath(successfully_read_files[-1])}")_init_dirs(file_writer_config)diff --git a/manim/constants.py b/manim/constants.pyindex e8acf30e6..40ebedd6c 100644--- a/manim/constants.py+++ b/manim/constants.py@@ -148,3 +148,12 @@ COLOR_MAP.update({name.replace("_C", ""): COLOR_MAP[name]if name.endswith("_C")})PALETTE = list(COLOR_MAP.values())locals().update(COLOR_MAP)+VERBOSE_CHOICES = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", "SILENT"]+VERBOSE_FFMPEG_MAP = {+ "DEBUG": 16,+ "INFO": 16,+ "WARNING": 16,+ "ERROR": 16,+ "CRITICAL": 8,+ "SILENT": -8,+}diff --git a/manim/default.cfg b/manim/default.cfgindex 4cc02531c..6a1487ada 100644--- a/manim/default.cfg+++ b/manim/default.cfg@@ -40,7 +40,7 @@ show_file_in_finder = Falsequiet = False# -v, --verbose-verbose = 32+verbose = INFO# --soundsound = Falsediff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.pyindex 54f4246f2..6cbf53a52 100644--- a/manim/scene/scene_file_writer.py+++ b/manim/scene/scene_file_writer.py@@ -391,7 +391,7 @@ class SceneFileWriter(object):'-r', str(fps), # frames per second'-i', '-', # The imput comes from a pipe'-an', # Tells FFMPEG not to expect any audio- '-loglevel', str(file_writer_config["verbose"]),+ '-loglevel', str(file_writer_config["ffmpeg"]),]# TODO, the test for a transparent background should not be based on# the file extension.@@ -472,7 +472,7 @@ class SceneFileWriter(object):'-f', 'concat','-safe', '0','-i', file_list,- '-loglevel', 'error',+ '-loglevel', str(file_writer_config["ffmpeg"]),]if self.write_to_movie:@@ -514,7 +514,7 @@ class SceneFileWriter(object):"-map", "0:v:0",# select audio stream from second file"-map", "1:a:0",- '-loglevel', 'error',+ '-loglevel', str(file_writer_config["ffmpeg"]),# "-shortest",temp_file_path,]diff --git a/manim/utils/config_utils.py b/manim/utils/config_utils.pyindex d6bb86a80..cd21b7b1e 100644--- a/manim/utils/config_utils.py+++ b/manim/utils/config_utils.py@@ -124,7 +124,15 @@ def _parse_file_writer_config(config_parser, args):# Read in the log levelverbose = getattr(args, "verbose")- fw_config["verbose"] = default.getint("verbose") if verbose is None else verbose+ verbose = default["verbose"] if verbose is None else verbose+ fw_config["verbose"] = verbose+ if verbose == "SILENT":+ # SILENT is not a predefined value but by placing it higher then all the others, a quieter logger is set+ fw_config["verbose"] = 60+ ffmpeg = getattr(args, "ffmpeg")+ if ffmpeg is None and default.getint("ffmpeg", None) is not None:+ ffmpeg = default.getint("ffmpeg")+ fw_config["ffmpeg"] = constants.VERBOSE_FFMPEG_MAP[verbose] if ffmpeg is None else ffmpegreturn fw_config@@ -319,10 +327,17 @@ def _parse_cli(arg_list, input=True):parser.add_argument("-v", "--verbose",+ type=str,+ help="Verbosity level. Also changes the ffmpeg log level unless the latter is specified",+ metavar="loglevel",+ choices=constants.VERBOSE_CHOICES,+ )+ parser.add_argument(+ "-L", "--ffmpeg",type=int,- help="Verbosity level. Passed on to ffmpeg, the lower the value the quieter the output",+ help="Log level for ffmpeg",metavar="loglevel",- choices=[-8, 0, 8, 16, 24, 32, 40, 48, 56]+ choices=[-8, 0, 8, 16, 24, 32, 40, 48, 56],)return parser.parse_args(arg_list)