mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 16:58:12 +00:00
Ability to set custom start / end frames (#14)
* Accept start / end frames in job submissions. Start / end frame support for Blender * Remove old render_all_frames variables and misc cleanup * Client work - Client determines frame count for FFMPEG and shows frame picker UI
This commit is contained in:
@@ -22,17 +22,16 @@ class BlenderRenderWorker(BaseRenderWorker):
|
||||
self.blender_engine = self.args.get('engine', 'BLENDER_EEVEE').upper()
|
||||
self.export_format = self.args.get('export_format', None) or 'JPEG'
|
||||
self.camera = self.args.get('camera', None)
|
||||
self.render_all_frames = self.args.get('render_all_frames', False) or \
|
||||
'-a' in (self.args.get('raw', None) or "").split(' ')
|
||||
|
||||
# Stats
|
||||
self.__frame_percent_complete = 0.0
|
||||
|
||||
# Scene Info
|
||||
self.scene_info = Blender.get_scene_info(input_path)
|
||||
self.total_frames = (int(self.scene_info.get('frame_end', 1)) - int(self.scene_info.get('frame_start', 1)) + 1) \
|
||||
if self.render_all_frames else 1
|
||||
self.current_frame = int(self.scene_info.get('frame_start', 1))
|
||||
self.start_frame = int(self.scene_info.get('start_frame', 1))
|
||||
self.end_frame = int(self.scene_info.get('end_frame', self.start_frame))
|
||||
self.project_length = (self.end_frame - self.start_frame) + 1
|
||||
self.current_frame = -1
|
||||
|
||||
def generate_worker_subprocess(self):
|
||||
|
||||
@@ -44,10 +43,12 @@ class BlenderRenderWorker(BaseRenderWorker):
|
||||
if self.camera:
|
||||
cmd.extend(['--python-expr', f"import bpy;bpy.context.scene.camera = bpy.data.objects['{self.camera}'];"])
|
||||
|
||||
cmd.extend(['-E', self.blender_engine, '-o', self.output_path, '-F', self.export_format])
|
||||
# add dash at end of given path to separate frame numbers
|
||||
path_with_ending_dash = os.path.splitext(self.output_path)[0] + "-" + os.path.splitext(self.output_path)[1]
|
||||
cmd.extend(['-E', self.blender_engine, '-o', path_with_ending_dash, '-F', self.export_format])
|
||||
|
||||
# all frames or single
|
||||
cmd.extend(['-a'] if self.render_all_frames else ['-f', str(self.current_frame)])
|
||||
# set frame range
|
||||
cmd.extend(['-s', self.start_frame, '-e', self.end_frame, '-a'])
|
||||
|
||||
# Convert raw args from string if available
|
||||
raw_args = self.get_raw_args()
|
||||
@@ -96,10 +97,10 @@ class BlenderRenderWorker(BaseRenderWorker):
|
||||
match = re.match(r'Time: (.*) \(Saving', line)
|
||||
if match:
|
||||
time_completed = match.groups()[0]
|
||||
if self.render_all_frames:
|
||||
logger.debug(f'Frame {self.current_frame} completed in {time_completed}')
|
||||
else:
|
||||
logger.info(f'Render completed in {time_completed}')
|
||||
frame_count = self.current_frame - self.end_frame + self.total_frames
|
||||
logger.info(f'Frame #{self.current_frame} - '
|
||||
f'{frame_count} of {self.total_frames} completed in {time_completed} | '
|
||||
f'Total Elapsed Time: {datetime.now() - self.start_time}')
|
||||
else:
|
||||
logger.debug(line)
|
||||
else:
|
||||
@@ -118,13 +119,14 @@ class BlenderRenderWorker(BaseRenderWorker):
|
||||
|
||||
def post_processing(self):
|
||||
output_dir = os.listdir(os.path.dirname(self.output_path))
|
||||
if self.render_all_frames and len(output_dir) > 1:
|
||||
if self.total_frames > 1 and len(output_dir) > 1:
|
||||
from ..utilities.ffmpeg_helper import image_sequence_to_video
|
||||
logger.info("Generating preview for image sequence")
|
||||
|
||||
# get proper file extension
|
||||
found_output = next(obj for obj in output_dir if os.path.basename(self.output_path) in obj)
|
||||
glob_pattern = self.output_path + '%04d' + ('.' + found_output.split('.')[-1] if found_output else "")
|
||||
path_with_ending_dash = os.path.splitext(self.output_path)[0] + "-"
|
||||
found_output = next(obj for obj in output_dir if os.path.basename(path_with_ending_dash) in obj)
|
||||
glob_pattern = path_with_ending_dash + '%04d' + ('.' + found_output.split('.')[-1] if found_output else "")
|
||||
|
||||
try:
|
||||
image_sequence_to_video(source_glob_pattern=glob_pattern,
|
||||
|
||||
Reference in New Issue
Block a user