Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video Remixer: fix crop offset validation, purge previous kept scene files #348

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions tabs/video_remixer_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1802,10 +1802,12 @@ def next_button1(self,
format_markdown(f"Crop values should be <= Resize values", "warning"),\
*empty_args

if crop_offset_x < -1 or crop_offset_x > crop_w - 1 or \
crop_offset_y < -1 or crop_offset_y > crop_h - 1:
if crop_offset_x < -1 or \
crop_offset_x > resize_w - crop_w or \
crop_offset_y < -1 or \
crop_offset_y > resize_h - crop_h:
return gr.update(selected=self.TAB_REMIX_SETTINGS), \
format_markdown(f"Crop Offset values should be >= -1 and less than Crop values",
format_markdown(f"Crop Offset values should be >= -1 and <= (Resize - Crop)",
"warning"),\
*empty_args

Expand Down Expand Up @@ -2445,6 +2447,11 @@ def _next_button5(self,
scene_files = get_files(self.state.clips_path)
if scene_files:
try:
scene_filenames = []
for scene_file in scene_files:
_, filename, ext = split_filepath(scene_file)
scene_filenames.append(filename + ext)
self.state.purge_files(self.state.project_path, scene_filenames)
move_files(self.state.clips_path, self.state.project_path)
for file in scene_files:
messages.append(f"Scene video {file} moved to {self.state.project_path}")
Expand Down
6 changes: 6 additions & 0 deletions video_remixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,12 @@ def delete_path(self, path):
else:
return None

def purge_files(self, path : str, files : list, purged_path=None, additional_path=""):
if not path or not files:
return None
file_paths = [os.path.join(path, filename) for filename in files]
return self.purge_paths(file_paths, purged_path, False, additional_path)

def purge_paths(self, path_list : list, keep_original=False, purged_path=None,
skip_empty_paths=False, additional_path=""):
"""Purge a list of paths to the purged content directory
Expand Down
Loading