From 52300c40b7c773a89bc39f751d9739b3ccdd26f7 Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Tue, 3 Aug 2021 17:03:59 +0000 Subject: [PATCH] Add a mode to renderer console command to show progress. --- bemani/utils/afputils.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/bemani/utils/afputils.py b/bemani/utils/afputils.py index e666006..33d0d1c 100644 --- a/bemani/utils/afputils.py +++ b/bemani/utils/afputils.py @@ -534,10 +534,17 @@ def render_path( only_depths: Optional[str] = None, only_frames: Optional[str] = None, verbose: bool = False, + show_progress: bool = False, ) -> int: + if show_progress: + print("Loading textures, shapes and animation instructions...") + renderer = AFPRenderer(single_threaded=disable_threads, enable_aa=enable_anti_aliasing) load_containers(renderer, containers, need_extras=True, verbose=verbose) + if show_progress: + print("Calculating render parameters...") + # Verify the correct params. if output.lower().endswith(".gif"): fmt = "GIF" @@ -634,7 +641,9 @@ def render_path( if fmt in ["GIF", "WEBP"]: # Write all the frames out in one file. duration = renderer.compute_path_frame_duration(path) - images = list( + frames = renderer.compute_path_frames(path) + images: List[Image] = [] + for i, img in enumerate( renderer.render_path( path, verbose=verbose, @@ -644,7 +653,11 @@ def render_path( only_frames=requested_frames, movie_transform=transform, ) - ) + ): + if show_progress: + print(f"Rendered animation frame {i + 1}/{frames}.") + images.append(img) + if len(images) > 0: try: dirof = os.path.dirname(os.path.abspath(output)) @@ -957,6 +970,12 @@ def main() -> int: action="store_true", help="Display verbuse debugging output", ) + render_parser.add_argument( + "-s", + "--show-progress", + action="store_true", + help="Display per-frame rendering progress", + ) list_parser = subparsers.add_parser('list', help='List out the possible paths to render from a series of SWFs') list_parser.add_argument( @@ -1025,6 +1044,7 @@ def main() -> int: scale_height=args.scale_height, only_depths=args.only_depths, only_frames=args.only_frames, + show_progress=args.show_progress, verbose=args.verbose, ) else: