Skip to content

Commit

Permalink
'fill_sequence_gaps' operator usability, #33
Browse files Browse the repository at this point in the history
Allow to fill the gaps of the given sequence and also copy the frames within the frame range of the scene when the operator is called for the second time
  • Loading branch information
p2or authored Dec 15, 2022
1 parent d215527 commit 5871cad
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions loom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,7 @@ def draw(self, context):
row.prop(lum, "ignore_scene_range", text="", icon='RENDER_RESULT')
fg = row.operator(LOOM_OT_fill_sequence_gaps.bl_idname, text="Fill Gaps with Copies")
fg.sequence_path = lum.sequence_encode
fg.scene_range = lum.ignore_scene_range
fg.scene_range = not lum.ignore_scene_range
txt = "Render Missing Frames"
di = spl.operator(LOOM_OT_render_input_dialog.bl_idname, icon='RENDER_STILL', text=txt)
di.frame_input = lum.lost_frames
Expand Down Expand Up @@ -3357,14 +3357,13 @@ def execute(self, context):
self.report({'WARNING'},"No valid image sequence")
return {"CANCELLED"}

""" Detect missing frames """
""" Assemble missing frames """
frame_numbers = sorted(list(image_sequence.keys()))
#start_frame, end_frame = fn[0], fn[-1]
missing_frame_list = self.missing_frames(frame_numbers)
frames_to_copy = {}

""" Copy images """
if missing_frame_list:
frames_to_copy = {}
f_prev = frame_numbers[0]
for frame in range(frame_numbers[0], frame_numbers[-1]+1):
if frame not in image_sequence:
Expand All @@ -3373,16 +3372,18 @@ def execute(self, context):
else:
f_prev = frame

""" Extend to frame range of the scene """
if self.scene_range:
for i in range(context.scene.frame_start, frame_numbers[0]):
path_copy = self.re_path(basedir, name_real, i, hashes, ext)
frames_to_copy.setdefault(image_sequence[frame_numbers[0]], []).append(path_copy)

for o in range(frame_numbers[-1]+1, context.scene.frame_end+1):
path_copy = self.re_path(basedir, name_real, o, hashes, ext)
frames_to_copy.setdefault(image_sequence[frame_numbers[-1]], []).append(path_copy)

""" Extend to frame range of the scene """
if self.scene_range:
for i in range(context.scene.frame_start, frame_numbers[0]):
path_copy = self.re_path(basedir, name_real, i, hashes, ext)
frames_to_copy.setdefault(image_sequence[frame_numbers[0]], []).append(path_copy)

for o in range(frame_numbers[-1]+1, context.scene.frame_end+1):
path_copy = self.re_path(basedir, name_real, o, hashes, ext)
frames_to_copy.setdefault(image_sequence[frame_numbers[-1]], []).append(path_copy)

""" Copy the Images """
if frames_to_copy:
try:
from shutil import copyfile
for src, dest in frames_to_copy.items():
Expand All @@ -3393,9 +3394,8 @@ def execute(self, context):
lum.lost_frames = ""
except OSError:
self.report({'ERROR'}, "Error while trying to copy frames")

else:
self.report({'INFO'},"Nothing to do")
self.report({'INFO'},"No Gaps, nothing to do")
return {'FINISHED'}

def invoke(self, context, event):
Expand Down

0 comments on commit 5871cad

Please sign in to comment.