mirror of
https://github.com/3b1b/manim.git
synced 2025-07-29 04:53:34 +08:00
Changed the way Scene write to videos, where it writes each play or wait call as a separate file, and later concatenates them together.
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import inspect
|
||||
import os
|
||||
import numpy as np
|
||||
|
||||
from manimlib.constants import THIS_DIR
|
||||
from manimlib.constants import VIDEO_DIR
|
||||
|
||||
|
||||
@ -35,6 +34,40 @@ def get_movie_output_directory(scene_class, camera_config, frame_duration):
|
||||
return guarantee_existance(os.path.join(directory, sub_dir))
|
||||
|
||||
|
||||
def get_partial_movie_output_directory(scene_class, camera_config, frame_duration):
|
||||
directory = get_movie_output_directory(scene_class, camera_config, frame_duration)
|
||||
return guarantee_existance(
|
||||
os.path.join(directory, scene_class.__name__)
|
||||
)
|
||||
|
||||
|
||||
def get_image_output_directory(scene_class, sub_dir="images"):
|
||||
directory = get_scene_output_directory(scene_class)
|
||||
return guarantee_existance(os.path.join(directory, sub_dir))
|
||||
|
||||
|
||||
def get_sorted_integer_files(directory,
|
||||
min_index=0,
|
||||
max_index=np.inf,
|
||||
remove_non_integer_files=False,
|
||||
remove_indices_greater_than=None):
|
||||
indexed_files = []
|
||||
for file in os.listdir(directory):
|
||||
if '.' in file:
|
||||
index_str = file[:file.index('.')]
|
||||
else:
|
||||
index_str = file
|
||||
|
||||
full_path = os.path.join(directory, file)
|
||||
if index_str.isdigit():
|
||||
index = int(index_str)
|
||||
if remove_indices_greater_than is not None:
|
||||
if index > remove_indices_greater_than:
|
||||
os.remove(full_path)
|
||||
continue
|
||||
if index >= min_index and index < max_index:
|
||||
indexed_files.append((index, file))
|
||||
elif remove_non_integer_files:
|
||||
os.remove(full_path)
|
||||
indexed_files.sort(key=lambda p: p[0])
|
||||
return map(lambda p: p[1], indexed_files)
|
||||
|
Reference in New Issue
Block a user