feat: add List Video Files node with filtering, load cap, and deep search
This commit is contained in:
@@ -21,6 +21,7 @@ ComfyUI-FrameIO focuses on **efficient frame storage, loading, and reuse** for l
|
||||
- **Frame range selector** (`start`, `end`, `step`)
|
||||
- **Auto-detect frame count** (set `frame_count=0`)
|
||||
- **Execution Trigger** node for flow control
|
||||
- **List Video Files** node to scan input directory
|
||||
- Safe with duplicate paths (from deduplication)
|
||||
|
||||
### ⚡ Optimized for AI Video
|
||||
@@ -86,6 +87,8 @@ Load images directly from a `STRING_LIST`.
|
||||
- `images` (IMAGE)
|
||||
- `count` (INT)
|
||||
|
||||
> This is the **recommended loader** when using frame deduplication.
|
||||
|
||||
---
|
||||
|
||||
### 🔹 List Video Files (Input Dir)
|
||||
@@ -94,13 +97,13 @@ Scans your ComfyUI `input` folder for video files.
|
||||
**Inputs**
|
||||
- `subfolder` (STRING) - Subfolder within the input directory.
|
||||
- `filter` (STRING) - Wildcard filter (default `*`).
|
||||
- `load_cap` (INT) - Maximum number of files to return (default `100`, 0 for no limit).
|
||||
- `deep_search` (true / false) - Search subdirectories recursively (default `false`).
|
||||
|
||||
**Outputs**
|
||||
- `paths` (STRING_LIST) - List of absolute paths.
|
||||
- `count` (INT) - Number of files found.
|
||||
|
||||
> This is the **recommended loader** when using frame deduplication.
|
||||
|
||||
---
|
||||
|
||||
## 🧠 Why ComfyUI-FrameIO?
|
||||
|
||||
+25
-8
@@ -8,6 +8,8 @@ class ListVideoFiles:
|
||||
"required": {
|
||||
"subfolder": ("STRING", {"default": ""}),
|
||||
"filter": ("STRING", {"default": "*"}),
|
||||
"load_cap": ("INT", {"default": 100, "min": 0, "max": 10000, "step": 1}),
|
||||
"deep_search": (("false", "true"), {"default": "false"}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +20,13 @@ class ListVideoFiles:
|
||||
DESCRIPTION = """
|
||||
Lists video file paths from the ComfyUI input directory.
|
||||
- Filters by common video extensions (mp4, mkv, mov, avi, webm, etc.).
|
||||
- `load_cap`: Maximum number of files to return (0 for no limit).
|
||||
- `deep_search`: If true, searches all subdirectories recursively.
|
||||
- Returns a list of strings and the total count.
|
||||
- Useful for batch processing multiple videos.
|
||||
"""
|
||||
|
||||
def execute(self, subfolder, filter):
|
||||
def execute(self, subfolder, filter, load_cap, deep_search):
|
||||
deep_search = deep_search == "true"
|
||||
input_dir = folder_paths.get_input_directory()
|
||||
target_dir = os.path.abspath(os.path.join(input_dir, subfolder))
|
||||
|
||||
@@ -36,15 +40,28 @@ Lists video file paths from the ComfyUI input directory.
|
||||
}
|
||||
|
||||
files = []
|
||||
for root, _, filenames in os.walk(target_dir):
|
||||
for filename in filenames:
|
||||
ext = os.path.splitext(filename)[1].lower()
|
||||
if ext in video_extensions:
|
||||
if filter == "*" or filter.lower() in filename.lower():
|
||||
files.append(os.path.abspath(os.path.join(root, filename)))
|
||||
if deep_search:
|
||||
for root, _, filenames in os.walk(target_dir):
|
||||
for filename in filenames:
|
||||
ext = os.path.splitext(filename)[1].lower()
|
||||
if ext in video_extensions:
|
||||
if filter == "*" or filter.lower() in filename.lower():
|
||||
files.append(os.path.abspath(os.path.join(root, filename)))
|
||||
else:
|
||||
for filename in os.listdir(target_dir):
|
||||
full_path = os.path.join(target_dir, filename)
|
||||
if os.path.isfile(full_path):
|
||||
ext = os.path.splitext(filename)[1].lower()
|
||||
if ext in video_extensions:
|
||||
if filter == "*" or filter.lower() in filename.lower():
|
||||
files.append(os.path.abspath(full_path))
|
||||
|
||||
# Sort files naturally
|
||||
files.sort()
|
||||
|
||||
# Apply load cap
|
||||
if load_cap > 0:
|
||||
files = files[:load_cap]
|
||||
|
||||
return (files, len(files))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user