Skip to content

Conversation

@Gunther-Schulz
Copy link

@Gunther-Schulz Gunther-Schulz commented Sep 29, 2025

All code and this PR description was generated by AI.

🚀 Overview

This PR introduces a new "Keep only longest video" feature for sliding window generation.

✨ New Features

Keep Only Longest Video Option

  • Space-Saving Feature: New GUI checkbox to enable keeping only the longest generated video during sliding window generation
  • Automatic Cleanup: Intelligently deletes previous shorter videos before saving new longer ones
  • Backward Compatible: Feature is disabled by default to maintain existing workflows
  • Abort-Safe: If generation is interrupted, users retain the longest video generated so far
  • Clean Output Management: Keeps output folders organized during extended generation sessions

Enhanced Sliding Window Pipeline

  • Integrated Parameter: New sliding_window_keep_only_longest parameter in generate_video function
  • UI Integration: Seamless checkbox control in the web interface
  • Smart File Management: Automatic detection and removal of shorter video files
  • Progress Preservation: Maintains generation progress while optimizing storage

🔧 Technical Implementation

Core Changes

  • GUI Controls: Added checkbox in sliding window section for user control
  • Parameter Pipeline: Integrated new parameter through entire video generation pipeline
  • File Management Logic: Implemented intelligent video cleanup system
  • State Management: Proper handling of file lists and UI state

File System Integration

  • Smart Deletion: Only removes files when new longer videos are successfully created
  • Path Management: Robust file path handling for cleanup operations
  • Safety Checks: Prevents accidental deletion of important files

🎯 Use Cases

Clean Workflows

  • Organized Outputs: Maintains tidy output directories
  • Easy Management: Reduces need for manual file cleanup
  • Professional Results: Delivers clean, organized final outputs

📋 Technical Details

New Parameters

  • sliding_window_keep_only_longest - Boolean flag for enabling cleanup mode
  • Integrated into UI pipeline and generation functions
  • Default: False (maintains backward compatibility)

File Management Logic

  • Detects existing video files in output directory
  • Compares file sizes/lengths to determine "longest"
  • Safely removes shorter videos before saving new ones
  • Updates UI file lists to maintain consistency

Error Handling

  • Robust file operation error handling
  • Safe cleanup operations with rollback capability
  • Graceful handling of interrupted generations

🔗 Files Changed

  • wgp.py - Main implementation of keep longest feature, UI fixes, and settings fix
  • .gitignore - Updated patterns for better repository management

@Gunther-Schulz Gunther-Schulz changed the title [Feauture] Optionally keep longest video only when generating with sliding window (like Framepack) [Feauture] optionally keep Only Longest Video Option for Sliding Window Generation Sep 29, 2025
@Gunther-Schulz Gunther-Schulz changed the title [Feauture] optionally keep Only Longest Video Option for Sliding Window Generation [Feature] optionally keep Only Longest Video Option for Sliding Window Generation Sep 29, 2025
@Tophness
Copy link
Collaborator

Wait, it didn't already work that way?
That was one of the things I hated about framepack. There were a ton of redundant temp files littered in the output folder as it was building the final video, and it kept them there when it was done.

@Gunther-Schulz Gunther-Schulz changed the title [Feature] optionally keep Only Longest Video Option for Sliding Window Generation [Feature] Optionally keep Only Longest Video Option for Sliding Window Generation Sep 29, 2025
@Gunther-Schulz Gunther-Schulz changed the title [Feature] Optionally keep Only Longest Video Option for Sliding Window Generation [Feature] Optionally keep Only Longest Video Option for Sliding Window Generation (like FramePack) Sep 29, 2025
@Gunther-Schulz
Copy link
Author

Wait, it didn't already work that way? That was one of the things I hated about framepack. There were a ton of redundant temp files littered in the output folder as it was building the final video, and it kept them there when it was done.

Recent version of framepack actually have that option now.

@Gunther-Schulz Gunther-Schulz changed the title [Feature] Optionally keep Only Longest Video Option for Sliding Window Generation (like FramePack) [Feature] Optionally keep Only Longest Video Option for Sliding Window Generatione Sep 29, 2025
@Gunther-Schulz Gunther-Schulz changed the title [Feature] Optionally keep Only Longest Video Option for Sliding Window Generatione [Feature] Optionally keep Only Longest Video Option for Sliding Window Generation Sep 29, 2025
Gunther-Schulz and others added 2 commits September 30, 2025 17:21
- Implement LCMScheduler with RectifiedFlow (LTX) dynamics
- Combine Latent Consistency Model with rectified flow scheduling
- Optimize for 2-8 step ultra-fast inference with Lightning LoRAs
- Add proper flow matching dynamics with shift parameter support
- Update UI to show 'lcm + ltx' option in sampler dropdown
@deepbeepmeep
Copy link
Owner

Shouldnt this feature be a general switch in the Config Tab rather than a per model switch ?

@Tophness
Copy link
Collaborator

Shouldnt this feature be a general switch in the Config Tab rather than a per model switch ?

Yea that makes more sense imo

@Gunther-Schulz
Copy link
Author

Gunther-Schulz commented Sep 30, 2025

Shouldnt this feature be a general switch in the Config Tab rather than a per model switch ?

Agreed, should it go in the "General" config tab?

@Gunther-Schulz Gunther-Schulz marked this pull request as draft October 1, 2025 14:53
…g tab

- Added sliding_window_keep_only_longest dropdown in General config tab
- Setting is now stored in server_config and persists across sessions
- Removed per-model checkboxes from sliding window tabs
- Access setting directly from server_config in generate_video function
- Added cleanup status to sliding window info message
- Default value: False (disabled) for backward compatibility
- Created shared/utils/sliding_window_cleanup.py for cleanup functions
- Moved cleanup_previous_video() function to utility module
- Added should_cleanup_video() helper function
- Added get_cleanup_status_text() for status messages
- Updated wgp.py to use the new utility functions
- Improves code organization and reusability
- Updated cleanup_previous_video() to handle condition checks internally
- Removed inline condition checks from wgp.py
- Cleaner separation: wgp.py only has minimal GUI glue code
- All business logic now contained in utility module
@Gunther-Schulz Gunther-Schulz marked this pull request as ready for review October 1, 2025 16:49
@Gunther-Schulz
Copy link
Author

Gunther-Schulz commented Oct 1, 2025

refactor done. moved the config location and moved the application logic to another file. ready to merge

@Gunther-Schulz Gunther-Schulz marked this pull request as draft October 1, 2025 19:35
@Gunther-Schulz Gunther-Schulz marked this pull request as ready for review October 1, 2025 19:42
@deepbeepmeep
Copy link
Owner

thx, but I think this could be made much simpler:
In generate_video():
with lock:
if window_no > 1 and keep_only_last_file:
old_file = file_list[-1]
file_list[-1]= path
file_settings_list[-1]=(configs if no > 0 else configs.copy())
os.path.remove(old_file)
else:
file_list.append(path)
file_settings_list.append(configs if no > 0 else configs.copy())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants