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]
81
81
82
82
The ` [global options] ` apply to the overarching ` git-sim ` simulation itself, including:
83
83
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.
87
87
` --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 ` .
88
89
89
90
Animation-only global options (to be used in conjunction with ` --animate ` ):
90
91
Original file line number Diff line number Diff line change 5
5
import time , datetime
6
6
import cv2
7
7
import git
8
+ import subprocess
8
9
from manim import config , WHITE
9
10
from manim .utils .file_ops import open_file as open_media_file
10
11
@@ -98,6 +99,12 @@ def main():
98
99
help = "Display commit history in the reverse direction" ,
99
100
action = "store_true" ,
100
101
)
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
+ )
101
108
102
109
subparsers = parser .add_subparsers (dest = "subcommand" , help = "subcommand help" )
103
110
@@ -253,6 +260,18 @@ def main():
253
260
scene = gs .GitSim (args )
254
261
scene .render ()
255
262
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
+
256
275
if not args .animate :
257
276
video = cv2 .VideoCapture (str (scene .renderer .file_writer .movie_file_path ))
258
277
success , image = video .read ()
You can’t perform that action at this time.
0 commit comments