File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 33import os
44import argparse
55import pathlib
6+ import time , datetime
7+ import cv2
68from manim import config , WHITE
79from manim .utils .file_ops import open_file as open_media_file
810
@@ -57,8 +59,20 @@ def main():
5759 scene = gs .GitSim (args )
5860 scene .render ()
5961
62+ if not args .animate :
63+ video = cv2 .VideoCapture (str (scene .renderer .file_writer .movie_file_path ))
64+ success , image = video .read ()
65+ if success :
66+ t = datetime .datetime .fromtimestamp (time .time ()).strftime ("%m-%d-%y_%H-%M-%S" )
67+ image_file_name = "git-sim-" + args .subcommand + "_" + t + ".jpg"
68+ image_file_path = os .path .join (os .path .join (config .media_dir , "images" ), image_file_name )
69+ cv2 .imwrite (image_file_path , image )
70+
6071 try :
61- open_media_file (scene .renderer .file_writer .movie_file_path )
72+ if not args .animate :
73+ open_media_file (image_file_path )
74+ else :
75+ open_media_file (scene .renderer .file_writer .movie_file_path )
6276 except FileNotFoundError :
6377 print ("Error automatically opening video player, please manually open the video file to view animation." )
6478
Original file line number Diff line number Diff line change 2121 python_requires = '>=3.7' ,
2222 install_requires = [
2323 'gitpython' ,
24- 'manim'
24+ 'manim' ,
25+ 'opencv-python' ,
2526 ],
2627 keywords = 'git sim simulation simulate git-simulate git-simulation git-sim manim animation gitanimation' ,
2728 project_urls = {
You can’t perform that action at this time.
0 commit comments