Media Selection
One intake node for uploads, folders, or Reddit — with trimming and resizing built in
- media_path
- media_type
- media_info
- height
- width
- duration
- fps
Every captioning workflow starts with the same question: where does the media come from? Media Selection is the pack's single answer to that - one node that pulls images or videos from four different sources, optionally trims and resizes them, and hands you a clean, normalized result with all the metadata you'd otherwise probe for by hand.
The media_source dropdown is the heart of it, with four modes:
- Upload Media - you pick a file through the upload widget (
uploaded_image_file/uploaded_video_file). - Randomize Media from Path - give it a
media_path(a directory, searched recursively) and it picks a random file. This is the batch-captioning mode: point it at a folder of images and let the seed step through them. - Reddit Post - paste a
reddit_urland it downloads the post's media. - Randomize from Subreddit - give it a subreddit URL or name (
r/picsorhttps://www.reddit.com/r/pics/) and aseed, and it grabs a random post. Great for stress-testing captioning against uncontrolled content.
Alongside that, media_type (image/video) and seed (only for the two randomize modes - and the tooltip's warning is the real deal: change the seed to force re-execution, because a cached result won't re-randomize on its own).
Then the optional normalization knobs. max_duration trims videos longer than N seconds to the first N (0 = keep the whole thing). resize_mode gives you None (original), Auto (by orientation) - which snaps to 832×480 landscape / 480×832 portrait, the Wan-flavored defaults used across the pack - or Custom, with resize_width/resize_height to specify. That auto mode is the one most people want: it lands your media on the pack's native canvas sizes before captioning, so the width/height outputs downstream match what a Wan T2I pass expects.
Outputs are a full media dossier: media_path (the resolved file path), media_type, media_info (a text summary - title/source/file size for Reddit, or a processing info block), plus height, width, duration, and fps as separate typed outputs. That last quartet is the underrated part - duration and fps for video, dimensions for both - so downstream nodes (Frame Extractor, Media Describe's dimension inference) don't have to re-probe the file.
Installing
Part of Swiss Army Knife:
- ComfyUI Manager: search "Swiss Army Knife", install, restart.
- Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/sammykumar/ComfyUI-SwissArmyKnife.git
cd ComfyUI-SwissArmyKnife
pip install -e .
Gotchas
- Reddit modes hit the network and can be flaky - rate limits, deleted posts, and type mismatches (a subreddit meant for images serving a video) all happen. The node warns on type mismatch and uses what it actually detected.
- Randomize + seed caching: the seed is both the randomizer and the re-execution trigger. Same seed, same pick; new seed, new pick.
- Directory mode is recursive - the tooltip says "including all subdirectories," so point it somewhere you actually want searched.
- Media Selection outputs a path, not a tensor. That's deliberate - the rest of the pack consumes paths.
It's the intake valve for the whole pipeline. Once you've got Media Selection feeding Media Describe, the captioning loop runs on whatever you throw at it - one file or a thousand.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| media_source | COMBO | Reddit Post | Choose whether to upload media, randomize from a directory path, download from a Reddit post, or randomize from a subreddit |
| media_type | COMBO | image | Select the type of media to process |
| seed | INT | 00–18446744073709550000 | Seed for randomization when using 'Randomize Media from Path' or 'Randomize from Subreddit'. Use different seeds to force re-execution. |
| media_pathopt | STRING | Directory path to randomly select media from, including all subdirectories (used when media_source is Randomize Media from Path) | |
| uploaded_image_fileopt | STRING | Path to uploaded image file (managed by upload widget) | |
| uploaded_video_fileopt | STRING | Path to uploaded video file (managed by upload widget) | |
| reddit_urlopt | STRING | Reddit post URL (used when media_source is Reddit Post) | |
| subreddit_urlopt | STRING | Subreddit URL or name (e.g., 'r/pics' or 'https://www.reddit.com/r/pics/') - used when media_source is Randomize from Subreddit | |
| max_durationopt | FLOAT | 0.00–300 | Maximum duration in seconds for videos (0 = use full video). Video will be trimmed if longer. |
| resize_modeopt | COMBO | None | Resize mode: None (original size), Auto (832x480 landscape, 480x832 portrait), Custom (specify dimensions) |
| resize_widthopt | INT | 83264–8192 | Target width for Custom resize mode |
| resize_heightopt | INT | 48064–8192 | Target height for Custom resize mode |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| media_path | STRING | — |
| media_type | STRING | — |
| media_info | STRING | — |
| height | INT | — |
| width | INT | — |
| duration | FLOAT | — |
| fps | FLOAT | — |