Skip to content

Commit

Permalink
Fix transparent background videos
Browse files Browse the repository at this point in the history
  • Loading branch information
3b1b committed Feb 15, 2023
1 parent 01c51db commit 557cb66
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion manimlib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,12 @@ def get_file_writer_config(args: Namespace, custom_config: dict) -> dict:
result["video_codec"] = args.vcodec
elif args.transparent:
result["video_codec"] = 'prores_ks'
result["pixel_format"] = ''
elif args.gif:
result["video_codec"] = ''

if args.pix_fmt:
result["pix_fmt"] = args.pix_fmt
result["pixel_format"] = args.pix_fmt

return result

Expand Down
6 changes: 5 additions & 1 deletion manimlib/scene/scene_file_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ def open_movie_pipe(self, file_path: str) -> None:
fps = self.scene.camera.fps
width, height = self.scene.camera.get_pixel_shape()

vf_arg = 'vflip'
if self.pixel_format.startswith("yuv"):
vf_arg += f',eq=saturation={self.saturation}:gamma={self.gamma}'

command = [
FFMPEG_BIN,
'-y', # overwrite output file if it exists
Expand All @@ -266,7 +270,7 @@ def open_movie_pipe(self, file_path: str) -> None:
'-pix_fmt', 'rgba',
'-r', str(fps), # frames per second
'-i', '-', # The input comes from a pipe
'-vf', f'vflip,eq=saturation={self.saturation}:gamma={self.gamma}',
'-vf', vf_arg,
'-an', # Tells FFMPEG not to expect any audio
'-loglevel', 'error',
]
Expand Down

0 comments on commit 557cb66

Please sign in to comment.