mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Enabling transparent background of exported videos
This commit is contained in:
parent
a03aa64ae3
commit
d3a39f2e65
2 changed files with 12 additions and 5 deletions
|
@ -95,6 +95,7 @@ def get_configuration():
|
|||
"save_pngs" : args.save_pngs,
|
||||
#If -t is passed in (for transparent), this will be RGBA
|
||||
"saved_image_mode": "RGBA" if args.transparent else "RGB",
|
||||
"movie_file_extension" : ".mov" if args.transparent else ".mp4",
|
||||
"quiet" : args.quiet or args.write_all,
|
||||
"ignore_waits" : args.preview,
|
||||
"write_all" : args.write_all,
|
||||
|
@ -237,6 +238,7 @@ def main():
|
|||
"write_to_movie",
|
||||
"output_directory",
|
||||
"save_pngs",
|
||||
"movie_file_extension",
|
||||
"start_at_animation_number",
|
||||
"end_at_animation_number",
|
||||
]
|
||||
|
|
|
@ -570,18 +570,23 @@ class Scene(Container):
|
|||
FFMPEG_BIN,
|
||||
'-y', # overwrite output file if it exists
|
||||
'-f', 'rawvideo',
|
||||
'-vcodec','rawvideo',
|
||||
'-s', '%dx%d'%(width, height), # size of one frame
|
||||
'-pix_fmt', 'rgba',
|
||||
'-r', str(fps), # frames per second
|
||||
'-i', '-', # The imput comes from a pipe
|
||||
'-an', # Tells FFMPEG not to expect any audio
|
||||
'-vcodec', 'mpeg',
|
||||
'-c:v', 'libx264',
|
||||
'-pix_fmt', 'yuv420p',
|
||||
'-loglevel', 'error',
|
||||
temp_file_path,
|
||||
]
|
||||
if self.movie_file_extension == ".mov":
|
||||
# This is if the background of the exported video
|
||||
# should be transparent.
|
||||
command += ['-vcodec', 'png']
|
||||
else:
|
||||
command += [
|
||||
'-c:v', 'libx264',
|
||||
'-pix_fmt', 'yuv420p',
|
||||
]
|
||||
command += [temp_file_path]
|
||||
# self.writing_process = sp.Popen(command, stdin=sp.PIPE, shell=True)
|
||||
self.writing_process = sp.Popen(command, stdin=sp.PIPE)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue