mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Write scene insertions into a subdirectory
This commit is contained in:
parent
09e9e65ba4
commit
29cb6f76fe
1 changed files with 12 additions and 5 deletions
|
@ -9,6 +9,7 @@ import sys
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydub import AudioSegment
|
from pydub import AudioSegment
|
||||||
from tqdm.auto import tqdm as ProgressDisplay
|
from tqdm.auto import tqdm as ProgressDisplay
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from manimlib.constants import FFMPEG_BIN
|
from manimlib.constants import FFMPEG_BIN
|
||||||
from manimlib.logger import log
|
from manimlib.logger import log
|
||||||
|
@ -299,15 +300,21 @@ class SceneFileWriter(object):
|
||||||
self.video_codec = "libx264rgb"
|
self.video_codec = "libx264rgb"
|
||||||
self.pixel_format = "rgb32"
|
self.pixel_format = "rgb32"
|
||||||
|
|
||||||
|
def get_insert_file_path(self, index: int) -> Path:
|
||||||
|
movie_path = Path(self.get_movie_file_path())
|
||||||
|
scene_name = movie_path.stem
|
||||||
|
insert_dir = Path(movie_path.parent, "inserts")
|
||||||
|
guarantee_existence(str(insert_dir))
|
||||||
|
return Path(insert_dir, f"{scene_name}_{index}{movie_path.suffix}")
|
||||||
|
|
||||||
def begin_insert(self):
|
def begin_insert(self):
|
||||||
# Begin writing process
|
# Begin writing process
|
||||||
self.write_to_movie = True
|
self.write_to_movie = True
|
||||||
self.init_output_directories()
|
self.init_output_directories()
|
||||||
movie_path = self.get_movie_file_path()
|
index = 0
|
||||||
count = 0
|
while (insert_path := self.get_insert_file_path(index)).exists():
|
||||||
while os.path.exists(name := movie_path.replace(".", f"_insert_{count}.")):
|
index += 1
|
||||||
count += 1
|
self.inserted_file_path = str(insert_path)
|
||||||
self.inserted_file_path = name
|
|
||||||
self.open_movie_pipe(self.inserted_file_path)
|
self.open_movie_pipe(self.inserted_file_path)
|
||||||
|
|
||||||
def end_insert(self):
|
def end_insert(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue