File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -81,10 +81,11 @@ $ git-sim [global options] <subcommand> [subcommand options]
8181
8282The ` [global options] ` apply to the overarching ` git-sim ` simulation itself, including:
8383
84- ` --light-mode ` : Use a light mode color scheme instead of default dark mode.
85- ` --animate ` : Instead of outputting a static image, animate the Git command behavior in a .mp4 video.
86- ` --disable-auto-open, -d ` : Disable the automatic opening of the image/video file after generation.
84+ ` --light-mode ` : Use a light mode color scheme instead of default dark mode.
85+ ` --animate ` : Instead of outputting a static image, animate the Git command behavior in a .mp4 video.
86+ ` --disable-auto-open, -d ` : Disable the automatic opening of the image/video file after generation.
8787` --reverse, -r ` : Display commit history in the reverse direction.
88+ ` --video-format ` : Output format for the video file, i.e. ` mp4 ` or ` webm ` . Default output format is ` mp4 ` .
8889
8990Animation-only global options (to be used in conjunction with ` --animate ` ):
9091
Original file line number Diff line number Diff line change 55import time , datetime
66import cv2
77import git
8+ import subprocess
89from manim import config , WHITE
910from manim .utils .file_ops import open_file as open_media_file
1011
@@ -98,6 +99,12 @@ def main():
9899 help = "Display commit history in the reverse direction" ,
99100 action = "store_true" ,
100101 )
102+ parser .add_argument (
103+ "--video-format" ,
104+ help = "Output format for the animation files. Supports mp4 and webm" ,
105+ type = str ,
106+ default = "mp4" ,
107+ )
101108
102109 subparsers = parser .add_subparsers (dest = "subcommand" , help = "subcommand help" )
103110
@@ -253,6 +260,18 @@ def main():
253260 scene = gs .GitSim (args )
254261 scene .render ()
255262
263+ if args .video_format == "webm" :
264+ webm_file_path = str (scene .renderer .file_writer .movie_file_path )[:- 3 ] + "webm"
265+ cmd = f"ffmpeg -y -i { scene .renderer .file_writer .movie_file_path } -hide_banner -loglevel error -c:v libvpx-vp9 -crf 50 -b:v 0 -b:a 128k -c:a libopus { webm_file_path } "
266+ print ("Converting video output to .webm format..." )
267+ # Start ffmpeg conversion
268+ p = subprocess .Popen (cmd , shell = True )
269+ p .wait ()
270+ # if the conversion is successful, delete the .mp4
271+ if os .path .exists (webm_file_path ):
272+ os .remove (scene .renderer .file_writer .movie_file_path )
273+ scene .renderer .file_writer .movie_file_path = webm_file_path
274+
256275 if not args .animate :
257276 video = cv2 .VideoCapture (str (scene .renderer .file_writer .movie_file_path ))
258277 success , image = video .read ()
You can’t perform that action at this time.
0 commit comments