Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51993c0a2c | ||
|
|
b043f6f1a7 | ||
|
|
29c986cfdc | ||
|
|
171ad422b9 | ||
|
|
f4061f4255 | ||
|
|
8d139cdfc5 | ||
|
|
fae68ecb77 | ||
|
|
661c33a926 | ||
|
|
9b27bc9c4c | ||
|
|
de530e2eac | ||
|
|
7d81a43133 | ||
|
|
0067575b0c | ||
|
|
8cc90794d8 | ||
|
|
d82ed510b9 | ||
|
|
3f06362f9c | ||
|
|
d37e0cd026 | ||
|
|
38bdddded8 | ||
|
|
f0f6ca9f0c | ||
|
|
d47a6743e3 | ||
|
|
ab8389d598 | ||
|
|
5b10b3a23f | ||
|
|
f2d966afd1 | ||
|
|
182abca56f | ||
|
|
c1c9831378 | ||
|
|
6418940761 | ||
|
|
72af858975 | ||
|
|
80e5221403 | ||
|
|
f658ac58b0 | ||
|
|
adb1eaacc4 | ||
|
|
b0f8b5ec55 | ||
|
|
a3984bf656 | ||
|
|
232e1dcdb7 | ||
|
|
ab67a1f77f | ||
|
|
2af3fd9c83 | ||
|
|
9986ded109 | ||
|
|
197ac04a8c | ||
|
|
be2a2a1444 | ||
|
|
76eb4fc7e7 | ||
|
|
057f2bd05a | ||
|
|
172252ab02 | ||
|
|
ebc81ea57e | ||
|
|
bc235e96e5 | ||
|
|
6572b49386 | ||
|
|
d593e01fc9 | ||
|
|
009aa95d98 | ||
|
|
b61b3efc94 | ||
|
|
6cfed25a8e | ||
|
|
27e175aa08 | ||
|
|
6224bae13c | ||
|
|
bd49afae19 | ||
|
|
13e4d73dbd | ||
|
|
37584519e8 | ||
|
|
1ed921b6fb | ||
|
|
15e5803a06 | ||
|
|
a0327f6ddd | ||
|
|
e65612bb28 | ||
|
|
11d79b252d | ||
|
|
7e5cadaa06 | ||
|
|
94d302e112 | ||
|
|
fb26f3ae06 | ||
|
|
11638b0557 | ||
|
|
ad81fbcca1 | ||
|
|
9cc91ffba8 | ||
|
|
0450466422 | ||
|
|
d5442cd659 |
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"attribution": {
|
||||
"commit": "",
|
||||
"pr": ""
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,10 @@ SECURITY.md
|
||||
.claude/
|
||||
/docs/
|
||||
|
||||
# the skill an AI agent installs from the repository (npx skills add);
|
||||
# nothing in the pack loads it
|
||||
/skills/
|
||||
|
||||
# README media: GitHub shows it on the repository page, nothing in the
|
||||
# pack loads it
|
||||
/assets/
|
||||
|
||||
+212
@@ -2,6 +2,218 @@
|
||||
|
||||
All notable changes to ComfyUI-AusBoss are documented here.
|
||||
|
||||
## 2.26.3 - 2026-11-17
|
||||
|
||||
- **Tone match now works on inpaints.** On a Crop For Inpaint 🆎 crop,
|
||||
Stitch Inpaint 🆎 read the colour shift in the soft edge around the
|
||||
painted area. Workflows such as Krea 2 Inpaint Masked let the model paint
|
||||
a little wider than that edge, so the edge came back close to your picture
|
||||
and the slider hardly did anything: in a test on skin it took off a
|
||||
third of the shift at 1. It is now read just inside the painted area and
|
||||
takes off more than half, on a picture of any size. A workflow that already had Tone match on for
|
||||
an inpaint gives a slightly different picture, closer to the original's
|
||||
colour. When the painted area holds something new, it is matched to your
|
||||
picture right beside it where the two look alike, such as new skin where
|
||||
a shirt was. Something different from what is beside it, such as a
|
||||
swimsuit over skin, is left as painted; before, Tone match could tint the
|
||||
whole patch with the opposite colour. Outpaints, blend in and Tone match 0
|
||||
are unchanged.
|
||||
|
||||
- **Copy a crop node's picture without its handles.** Right-click the picture
|
||||
on Image Crop + Rotate + Pad and choose Copy image. By default it copies
|
||||
the original picture. To include crop, rotation, padding and resize, turn
|
||||
on Copy with crop, rotation and padding in the gear menu. Editing controls
|
||||
and guides are never copied. Open image provides a clean
|
||||
picture to copy with the browser on plain HTTP addresses too.
|
||||
|
||||
- **H3 Prompt Writer: a swap reads the new person's looks however you type
|
||||
them.** `@1 looks like ...` on the same line as the swap sentence, and
|
||||
clothes on a line of their own (`@1 is wearing a black suit.`), were
|
||||
left out of the prompt without a word, and the clip often came back
|
||||
unchanged. Both are now used.
|
||||
|
||||
- **H3 Prompt Writer no longer drops lines.** When one line held two
|
||||
people talking, like `The phone says: "Get a job." @1 looks up and says:
|
||||
"What?"`, only the first words reached the prompt. Each quote is its own
|
||||
moment now. A swap's `@1 looks like` line also keeps only the looks: a
|
||||
sentence after it that names an `@` again, like `The trees behind @1 stay
|
||||
the same.`, is read as its own line instead of going into the description
|
||||
with a raw `@1`. `"Hi," she says` is spoken as "Hi." instead of "Hi,.",
|
||||
and a Chinese or Japanese line keeps its own full stop: "。", not "。.".
|
||||
|
||||
- **H3 Prompt Writer can carry a line across a cut.** End the words with
|
||||
`...` and the person keeps talking into the next shot, without saying the
|
||||
words twice. On the last line, `...` lets the clip end mid-sentence. A line
|
||||
too long for its shot carries on the same way instead of a warning.
|
||||
|
||||
- **H3 Prompt Writer makes 4-second clips.** The shortest length went from
|
||||
5 to 4 seconds.
|
||||
|
||||
- **H3 Prompt Writer can put the person from your video somewhere new.** With
|
||||
Copy its moves and no person picture, the person in the video keeps their
|
||||
own look and moves. Give a picture the job place and type `He dances in @1.`
|
||||
Before, the node asked for a person picture and stopped. Copy its moves
|
||||
also takes its length from the video now, like Swap, Change something and
|
||||
New voice.
|
||||
|
||||
- **H3 Prompt Writer can restyle a video from a picture.** With Change
|
||||
something and a style or place picture, the look comes from the picture
|
||||
instead of the video. Type `It looks like @1.` A clip with nobody in it,
|
||||
like an empty hallway, no longer gets a made-up person in its prompt.
|
||||
|
||||
- **H3 Prompt Writer can make a thing do the moves.** With Copy its moves or
|
||||
Swap the person and no person picture, a thing picture your lines make do
|
||||
the action (a cartoon hand, a toy) takes the moves in its own look. A thing
|
||||
that is held or worn stays a prop.
|
||||
|
||||
- **H3 Prompt Writer's job lists take a click again.** Picking a job from a
|
||||
chip's list closed the list without changing the job.
|
||||
|
||||
- **H3 Prompt Writer's job lists match the node.** The pick list on each
|
||||
picture and on the video opens under its chip in the node's own colours
|
||||
and grows with the zoom. Before, it was the browser's small plain list.
|
||||
|
||||
- **An AI agent can now learn the video workflows from the repository.**
|
||||
`npx skills add ausboss/ComfyUI-AusBoss` gives your agent a skill for the
|
||||
MiniMax H3 Pika Person Swap and Pika Remix workflows: how to write the
|
||||
words, which model files to get, and how to run a workflow in your
|
||||
ComfyUI. The same page is at https://ausboss-examples.vercel.app/skill.md.
|
||||
|
||||
- **The "AusBoss was updated" message no longer asks for a reload by
|
||||
mistake.** After the Manager switched the pack to another version, a
|
||||
page reload before ComfyUI restarted brought up the message, telling you
|
||||
the page was older than the pack when it was newer. A restart was what
|
||||
was needed. Now the message only comes up when the pack really is newer
|
||||
than the page, and versions such as 2.25.10 and 2.25.9 are compared as
|
||||
numbers.
|
||||
|
||||
- **LoRA routes only open files on ComfyUI's LoRA list.** The LoRA
|
||||
Loader's info, hash and preview routes used to hand the name they were
|
||||
given to ComfyUI's file lookup and check the answer afterwards. Now the
|
||||
name is matched against the list first, and a name that is not on it is
|
||||
refused before anything on disk is looked up.
|
||||
- **Image Folder 🆎 checks a folder or picture name as text before the
|
||||
disk.** A drive letter in the middle of a name, or a control character,
|
||||
is refused like `..`, and the joined path is checked before it is
|
||||
resolved as well as after. The list no longer sends each picture's size
|
||||
and time; the thumbnail's cache tag is a short hash instead.
|
||||
- **Error messages no longer pass on server paths.** When a model,
|
||||
decoder or encoder fails, its message can name a file on the server's
|
||||
disk. SAM 3 masks, LoRA loading and video saving now keep the kind of
|
||||
error and drop its words when they name a path, since node errors reach
|
||||
the browser and stay in the history.
|
||||
|
||||
## 2.26.2 - 2026-11-14
|
||||
|
||||
- **Loaders never look up a file name they refused.** Before each run,
|
||||
Load Image 🆎, Load Image + Pad 🆎, Image Crop + Rotate + Pad 🆎 and both
|
||||
Video Crop + Rotate + Pad nodes check whether their file changed. When the
|
||||
name was one they do not accept, such as a whole path or a network share,
|
||||
that check still looked it up on disk. On Windows, looking up a share
|
||||
contacts its server and hands it the computer's login. Now a refused name
|
||||
is only compared as text.
|
||||
- **The pack's scripts are found without looking up the address.** The pack
|
||||
tags its scripts with a version as the browser asks for them. It found
|
||||
each one by joining the address the browser sent to its own folder and
|
||||
looking the result up on disk, and only then checked that the file was
|
||||
its own. Now it looks the address up in a list of its scripts made when
|
||||
ComfyUI starts, so no address reaches the disk.
|
||||
- **Save Image's Save button copies only pictures it holds.** With Auto
|
||||
save off, the list of a run's held pictures was a file in ComfyUI's temp
|
||||
folder. That folder takes uploads, so a planted list could copy another
|
||||
file on the server into the output folder. The list now stays in
|
||||
ComfyUI's memory, and a held picture is found only by its run, its number
|
||||
and one of Save Image's formats. The Save button works for the last 256
|
||||
runs, up to 10,000 pictures each; held pictures still go when ComfyUI
|
||||
restarts, as before.
|
||||
|
||||
## 2.26.1 - 2026-11-14
|
||||
|
||||
- **A path that starts with `~` is no longer expanded.** Image Folder used
|
||||
to turn a pasted `~/...` path into a full one before checking that it sits
|
||||
inside ComfyUI's folders; now only a path written out in full is checked.
|
||||
LaMa Inpaint only opens a model from ComfyUI's `models/lama` list. Nothing
|
||||
outside those folders could be read before either; this removes the code
|
||||
that looked as if it could.
|
||||
|
||||
## 2.26.0 - 2026-11-14
|
||||
|
||||
- **Missing LoRAs show in ComfyUI's missing-models list.** When a workflow
|
||||
needs a LoRA you don't have, ComfyUI's Issues panel now lists it with the
|
||||
other missing models, so **Download all** fetches it too. Before, the
|
||||
list skipped every LoRA in a LoRA Loader 🆎, and Run then stopped on
|
||||
"missing LoRA file". A LoRA that moved to another folder, or a row that is
|
||||
switched off, is not listed.
|
||||
|
||||
- **Link tiles and title tiles snap by the edge you see.** A tile draws a
|
||||
card inside a wider see-through frame, and Snap into line used that frame,
|
||||
so tiles lined up with a gap around them, and a tile you dragged never
|
||||
snapped at all. Now a dragged tile lines up, and other nodes line up with
|
||||
it, by the card's own edges.
|
||||
|
||||
- **Cards work in App mode.** App mode is ComfyUI's simple form view of a
|
||||
workflow: a few labelled fields and a Run button. A field from a node
|
||||
with a card (a picture or video loader, H3 Prompt Writer) used to show
|
||||
as an empty row there. Now it shows a real control: a file list with an
|
||||
upload button, a video list, a text box. Back in the graph, the node
|
||||
looks the same as before.
|
||||
- **The video crop nodes take uploads in App mode.** Video Crop + Rotate +
|
||||
Pad and its Clip version now tell ComfyUI that their video list takes
|
||||
uploads, as the picture nodes do. In App mode the clip field gets the same
|
||||
picker as a picture field: your videos as thumbnails, an Upload button and
|
||||
a folder button. On the node itself nothing changes.
|
||||
|
||||
- **Models you already have are picked for you.** When a workflow asks for
|
||||
a model file you keep in a subfolder (`minimax-h3/model.safetensors`),
|
||||
ComfyUI used to mark its loader red until you clicked **Use it** on the
|
||||
workflow's Guide. Now the Guide switches the loader to your copy as the
|
||||
workflow opens and says so in a short message. That matters most in App
|
||||
mode, which shows no Guide to click. With two copies in different
|
||||
subfolders it still asks. Turn it off in Settings, 🆎 AusBoss, Models.
|
||||
|
||||
- **The video clip's timing is three boxes: Start, Duration, Ends at.** On
|
||||
Video Crop + Rotate + Pad (Clip), the Length on/off switch is gone. Drag
|
||||
the start to move the clip, drag the end or type a Duration to change how
|
||||
long it is, and switch between seconds and frames. Details sit in hover
|
||||
text; a short note shows only when something needs fixing, with a button
|
||||
to fix it. Saved workflows open with the same values and run the same.
|
||||
- **A linked frame rate no longer stops the clip's start too early.** With
|
||||
a rate wired in, a typed start of frame 60 used to settle on frame 7; it
|
||||
now lands where you put it, and the start handle stops only where the
|
||||
Duration no longer fits. A rate set inside a subgraph now counts as
|
||||
known, so the clip shows its length before you run.
|
||||
- **Linked clip lengths say where they come from.** A box set by another
|
||||
node shows a **linked** button that jumps to that node. A cap that the
|
||||
video cannot fill says how many frames you get, and a count only known
|
||||
when the graph runs shows the room left after the start.
|
||||
- **H3 Prompt Writer says how much of the clip H3 uses.** When the video
|
||||
comes from the clip node, it shows how many of the clip's frames H3
|
||||
makes and where in the video that stops, and which Durations use all of
|
||||
it.
|
||||
- **Crop + Rotate + Pad panels fill the node's width.** The rows under the
|
||||
picture used to stop at 460 px and sit in the middle of a wide node.
|
||||
- **Load Video uses the same timing boxes as the clip node.** Start,
|
||||
Duration and Ends at replace the IN and OUT fields and the separate
|
||||
Limit row, with the same seconds | frames switch. Saved workflows open
|
||||
with the same values and run the same.
|
||||
- **Load Video counts the frames the file really has.** The face used to
|
||||
work the count out from the length and could say one frame too many (248
|
||||
for a 247-frame clip); it now reads it from the file.
|
||||
- **Load Audio has Start, Duration and Ends at boxes.** They replace the IN
|
||||
and OUT times and the separate Max length row, so the red "cut" stripe is
|
||||
gone: the Duration is the length you get.
|
||||
- **A number wired through a Reroute or a subgraph now shows on the face.**
|
||||
The clip node, Load Video, Load Audio and Layout Boxes read a linked
|
||||
number the same way, so it no longer drops out behind a Reroute, a
|
||||
subgraph or an older Primitive node.
|
||||
|
||||
## 2.25.3 - 2026-11-13
|
||||
|
||||
- **The video clip's frame readout explains itself.** On Video Crop + Rotate
|
||||
+ Pad (Clip), the small `fr 52 · 0:02.17` beside Play now says in plain
|
||||
words, when you point at it, which frame the picture shows and how many
|
||||
seconds into the video it is. The help page explains it too.
|
||||
|
||||
## 2.25.2 - 2026-11-13
|
||||
|
||||
- **The video clip's IN handle always drags.** On Video Crop + Rotate + Pad
|
||||
|
||||
+8
-2
@@ -210,8 +210,7 @@ example_workflows/ # example workflows (regular workflow JSON, not API JSON)
|
||||
never a classic canvas number widget on a finished node face. Units
|
||||
(`px`, `MP`, `×`) ride inside the box in a fixed-width slot that every
|
||||
single-field row reserves, so the numbers down a card share one centre
|
||||
line. Known, deliberate exceptions: the Seed card's seed (typed) and Load
|
||||
Video's trim timecodes (typed).
|
||||
line. Known, deliberate exception: the Seed card's seed (typed).
|
||||
- **Node faces are widget cards.** A node whose face would be classic
|
||||
LiteGraph widgets (full-width rows with an arrow at each end) gets an
|
||||
entry in `js/widget_cards/index.js` instead: `mountWidgetCard` from
|
||||
@@ -234,6 +233,13 @@ example_workflows/ # example workflows (regular workflow JSON, not API JSON)
|
||||
widget per row. A value that is meant to be wired rather than typed is a
|
||||
backend `forceInput: True` socket (Math Expression `a`/`b`/`c`), and a
|
||||
multi-type string such as `"FLOAT,INT"` accepts either kind of link.
|
||||
- **App mode** is ComfyUI's form view of a workflow (fields and a Run
|
||||
button). A file list from the input folder declares its upload flag
|
||||
(`image_upload`, `video_upload`, `audio_upload`): the form builds the
|
||||
field's Upload button from it, and without it the field is a bare list.
|
||||
`tests/test_video_upload_flag.py` holds the video lists to it. A card's
|
||||
hidden widgets reach the form through `js/app_mode/`, so a card needs
|
||||
nothing of its own for App mode.
|
||||
- Preview-carrying nodes (Select Frame, Mask Refine, Mask by Name, LaMa
|
||||
Inpaint, Save Image) share
|
||||
`js/input_preview/`: a thin bar (node tools left, a small `preview`
|
||||
|
||||
@@ -49,6 +49,16 @@ After an update, through Manager or `git pull`, restart ComfyUI and hard-refresh
|
||||
|
||||
The pack uses the Pillow, NumPy, Torch and PyAV that come with ComfyUI. Each example lists the models it needs on its Workflow Note. LaMa Inpaint also needs [`big-lama.pt`](https://github.com/Sanster/models/releases/download/add_big_lama/big-lama.pt) in `ComfyUI/models/lama/`. The pack never downloads weights by itself.
|
||||
|
||||
### Using an AI agent
|
||||
|
||||
Your agent (Claude Code, Codex, Cursor or another one) can learn the video workflows: how to write the words for them, set them up, and run them on your computer.
|
||||
|
||||
```bash
|
||||
npx skills add ausboss/ComfyUI-AusBoss
|
||||
```
|
||||
|
||||
Or tell it: "Read https://ausboss-examples.vercel.app/skill.md and help me use these workflows." The skill is [skills/ausboss-workflows/SKILL.md](skills/ausboss-workflows/SKILL.md). For picking and wiring single nodes, point it at the [agent guide](js/docs/agents/README.md).
|
||||
|
||||
### Upgrading from 1.x
|
||||
|
||||
2.0 removed **LM Studio Chat** (use **Text** for a fixed prompt) and Align Image's `offset_x` and `offset_y` outputs. Math Expression's `a`, `b` and `c` are sockets now instead of typed boxes, so put constants in the expression itself. 1.2 removed **Drop Shadow**, **Pad Image** (use **Load Image + Pad**) and **Frame Chooser**. Save Image writes only inside ComfyUI's output folder. The [changelog](CHANGELOG.md) has the details.
|
||||
@@ -180,13 +190,13 @@ The example keeps the clip's audio when there is any. The outpaint LoRA needs a
|
||||
|
||||
### Load Video
|
||||
|
||||
Upload a video, or pick one from the Source list, which plays the clip under the pointer. Trim it with IN and OUT handles or typed timecodes. The player plays the part you kept and can loop it. Width and height resize while decoding, and setting only one keeps the shape. `every_nth` skips frames and lowers the reported fps so the timing stays right, and `max_frames` caps how many frames load.
|
||||
Upload a video, or pick one from the Source list, which plays the clip under the pointer. Set the part you want with Start, Duration and Ends at, in seconds or frames, or drag the handles under the player. The player plays the part you kept and can loop it. Width and height resize while decoding, and setting only one keeps the shape. `every_nth` skips frames and lowers the reported fps so the timing stays right, and the Duration caps how many frames load.
|
||||
|
||||
It returns the frames, audio, frame count, fps, width, height, duration and a core `VIDEO`. Only the part you kept is decoded, and it checks memory before a large load. When you save the frames, wire its fps into the save node.
|
||||
|
||||
### Load Audio
|
||||
|
||||
Upload a sound file, or pick one from the Source list, and the node shows it as a wave. Drag the IN and OUT handles to keep only the part you want, or type the times. Press play to hear just that part. Set **Max length** to the longest sound the next step can take, such as a video's length: anything past it turns red and is cut off, so you see what comes out before you run. Click the red length next to OUT to move OUT to the cut.
|
||||
Upload a sound file, or pick one from the Source list, and the node shows it as a wave. Drag the two handles to keep only the part you want, or type a Start, a Duration or an Ends at. Press play to hear just that part. Set the Duration to the length the next step needs, such as a video's length.
|
||||
|
||||
It returns the `audio` you kept and its length in `seconds`. Only that part is decoded. [Help page](js/docs/AUSBOSS_NODES_LoadAudio.md).
|
||||
|
||||
@@ -196,7 +206,7 @@ Picks one frame from a video, then gives you the same rotate, crop and pad contr
|
||||
|
||||
### Video Crop + Rotate + Pad → Clip
|
||||
|
||||
Applies one rotate, crop and pad to every frame of a trimmed clip. It has the source picker, a timeline with a playhead and frame-accurate IN and OUT handles, frame skipping, a frame limit, the transform handles and output resizing. While you drag a trim handle, the node shows the exact first or last frame the run keeps. The bright part of the selection is what gets output.
|
||||
Applies one rotate, crop and pad to every frame of a trimmed clip. It has the source picker, a timeline with a playhead and frame-accurate start and end handles, Start, Duration and Ends at boxes, frame skipping, the transform handles and output resizing. While you drag a trim handle, the node shows the exact first or last frame the run keeps. The bright part of the selection is what gets output.
|
||||
|
||||
Fill, feather and the resize budget are in **Crop, pad & resize** below the timeline, and a new clip keeps them. That matters for video outpainting, because the black, hard-edged canvas the model needs survives a source swap. A fresh Clip node starts with that canvas, and the editor's **Reset transform** goes back to it. **Frames for** trims the end to the frame count the next video model takes: LTX (8n+1) or Wan (4n+1). Tap a ratio to pad the clip to it; a new clip is padded to the lit ratio too. The padlock keeps the shape while you drag a handle.
|
||||
|
||||
@@ -486,7 +496,7 @@ People who download your workflow get the nodes through ComfyUI-Manager's missin
|
||||
- Hold Shift while you turn the green rotation handle to snap to 15° steps.
|
||||
- In the full-screen editor, the mouse wheel zooms, and the middle mouse button or Alt-drag pans. On the node itself, the wheel and middle mouse button still move the graph.
|
||||
- **Alt+E** opens the selected node's transform editor. Change the key in Settings → Keybindings.
|
||||
- The video editors have frame stepping, playback and exact timeline seeking, on the node face as well as in the editor. The Clip node's IN and OUT handles sit on the source's own frames, so the frame shown for IN is the first one decoded and the frame shown for OUT is the last.
|
||||
- The video editors have frame stepping, playback and exact timeline seeking, on the node face as well as in the editor. The Clip node's start and end handles sit on the source's own frames, so the frame shown at the start is the first one decoded and the frame shown at the end is the last.
|
||||
- Your own aspect presets go in `ausboss_presets.json` beside the pack. Copy [`ausboss_presets_example.json`](ausboss_presets_example.json) to start. Your file survives updates.
|
||||
|
||||
LoRA Loader and Latent Size have their own gear menus for per-node preferences.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="105" height="20" role="img" aria-label="release: v2.25.2">
|
||||
<title>release: v2.25.2</title>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="105" height="20" role="img" aria-label="release: v2.26.3">
|
||||
<title>release: v2.26.3</title>
|
||||
<path fill="#555" d="M0 0h48v20H0z"/>
|
||||
<path fill="#00b4aa" d="M48 0h57v20H48z"/>
|
||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||
<text x="24" y="14">release</text>
|
||||
<text x="76.5" y="14">v2.25.2</text>
|
||||
<text x="76.5" y="14">v2.26.3</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 425 B After Width: | Height: | Size: 425 B |
@@ -0,0 +1,45 @@
|
||||
// App mode for nodes with cards: the simple form view shows a real control
|
||||
// for each field instead of an empty row. The logic is in
|
||||
// js/shared/app_mode.mjs; this file watches which mode the open workflow is
|
||||
// in and hands the fields over.
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { createAppModeSync, workflowMode } from "../shared/app_mode.mjs";
|
||||
|
||||
const sync = createAppModeSync({
|
||||
find(nodeId, name) {
|
||||
const graph = app.rootGraph ?? app.graph;
|
||||
const node = graph?.getNodeById?.(/^\d+$/.test(nodeId) ? Number(nodeId) : nodeId);
|
||||
const widget = node?.widgets?.find((entry) => entry.name === name);
|
||||
return widget ? { node, widget } : null;
|
||||
},
|
||||
changed(node) {
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
},
|
||||
});
|
||||
|
||||
let queued = false;
|
||||
// After the current task: a card hides its widgets in a microtask once the
|
||||
// node has loaded, and the form's fields are shown after that.
|
||||
function schedule() {
|
||||
if (queued) return;
|
||||
queued = true;
|
||||
setTimeout(() => {
|
||||
queued = false;
|
||||
try {
|
||||
const workflow = app.extensionManager?.workflow?.activeWorkflow;
|
||||
sync(workflowMode(workflow), (app.rootGraph ?? app.graph)?.extra?.linearData);
|
||||
} catch (error) {
|
||||
console.warn("[AusBoss] App mode fields:", error);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: "ausboss.app.mode",
|
||||
setup() {
|
||||
app.extensionManager?.workflow?.$subscribe?.(schedule);
|
||||
},
|
||||
afterConfigureGraph() {
|
||||
schedule();
|
||||
},
|
||||
});
|
||||
+20
-1
@@ -49,6 +49,25 @@ function askForReload(installed) {
|
||||
}
|
||||
}
|
||||
|
||||
// "2.26.2" -> [2, 26, 2]. Anything else, such as "unknown", is null.
|
||||
function parseVersion(version) {
|
||||
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(typeof version === "string" ? version : "");
|
||||
return match ? match.slice(1).map(Number) : null;
|
||||
}
|
||||
|
||||
// Only a server newer than the page means this tab runs old files. The page
|
||||
// is newer when the Manager switched the pack on disk and the page was
|
||||
// reloaded before ComfyUI restarted, and then a restart is what is needed.
|
||||
// Two version numbers cannot tell that apart from a downgrade with the tab
|
||||
// left open, which needs a reload, so in that case the guard says nothing.
|
||||
function serverIsNewer(installed, running) {
|
||||
const server = parseVersion(installed);
|
||||
const page = parseVersion(running);
|
||||
if (!server || !page) return false;
|
||||
const step = server.findIndex((part, index) => part !== page[index]);
|
||||
return step >= 0 && server[step] > page[step];
|
||||
}
|
||||
|
||||
// The installed version this page already asked a reload for. A server that
|
||||
// drops and comes back several times must not stack the same message.
|
||||
let asked = null;
|
||||
@@ -58,7 +77,7 @@ async function check() {
|
||||
try {
|
||||
const installed = (await (await api.fetchApi("/ausboss/pack_version")).json())?.version;
|
||||
const running = await runningVersion();
|
||||
if (!installed || installed === "unknown" || !running || installed === running || installed === asked) return;
|
||||
if (!serverIsNewer(installed, running) || installed === asked) return;
|
||||
asked = installed;
|
||||
const listing = await (await api.fetchApi("/ausboss/pack_modules")).json();
|
||||
await refreshModules(Array.isArray(listing?.modules) ? listing.modules : []);
|
||||
|
||||
@@ -84,31 +84,42 @@ from.
|
||||
|
||||
Connect a video, then pick what it is for:
|
||||
|
||||
- **copy its moves**: your person does the moves in the video. It needs a
|
||||
picture of your person. Say where in your lines:
|
||||
`@1 dances on a rooftop at sunset.` The clothes can come from words or from an
|
||||
outfit picture.
|
||||
- **copy its moves**: someone does the moves in the video. With a picture of
|
||||
your person, your person does them. Say where in your lines:
|
||||
`@1 dances on a rooftop at sunset.` With no person picture, the person in
|
||||
the video keeps their own moves and goes somewhere new: give a picture the
|
||||
job **place** and type `He dances in @1.` The clothes can come from words or
|
||||
from an outfit picture. It doesn't have to be a person: give a cartoon hand,
|
||||
a toy or a mascot the job **thing** and type `@1 waves.` It does the moves in
|
||||
its own look, and nothing of the video's subject is kept.
|
||||
- **swap the person**: your person takes over from the one in the video. The
|
||||
place, the moves and the camera stay. With two person pictures, the first
|
||||
replaces the person on the left and the second replaces the person on the
|
||||
right. To choose who goes, type one line per picture, for example
|
||||
`@1 replaces the man in the hat`. Put spoken words in quotes and name
|
||||
the speaker. If a voice comes from off screen, say so in the line.
|
||||
A line like `@1 dances.` is not read as who goes; only a description such
|
||||
as `the man in the hat` is. With two people, name who speaks.
|
||||
- **change something**: keep the video and describe the change, for example
|
||||
`She wears a red raincoat`. Be specific about what should change.
|
||||
`She wears a red raincoat`. Be specific about what should change. To change
|
||||
the whole look, connect a picture with the job **style** (or **place**, for
|
||||
the same room looking different) and type `It looks like @1.` A clip with
|
||||
nobody in it, such as an empty hallway, stays empty.
|
||||
- **keep going**: more of the same clip, from where it ends. Say what happens
|
||||
next, or leave the box empty and it just carries on. Connect the whole clip:
|
||||
the node sends H3 only the last 2 seconds.
|
||||
- **new voice**: the same clip with a new voice. Connect the voice, and type
|
||||
what they say in quotes.
|
||||
This keeps the person in the clip, so a person picture is not allowed here;
|
||||
use **swap the person** to change who is in it.
|
||||
|
||||
If your swap keeps the video's audio, connect it to **video_sound** and turn on
|
||||
**More → Clip's own sound**. The writer uses the clip to estimate when each
|
||||
line is spoken and keeps only the incoming people's words in the swap prompt.
|
||||
Type a time such as `3.2s:` to set it yourself. This switch starts off.
|
||||
|
||||
With an active video, **swap the person**, **change something** and **new voice**
|
||||
use the incoming clip to set the frame count. **Length** says **From the clip**;
|
||||
With an active video, **copy its moves**, **swap the person**, **change
|
||||
something** and **new voice** use the incoming clip to set the frame count. **Length** says **From the clip**;
|
||||
set the clip's length upstream. The bar does not show a guessed duration or offer
|
||||
retiming controls for these jobs. H3 rounds the frame count to a supported length.
|
||||
Other video jobs, or turning the video off, use the editable **Length** again.
|
||||
@@ -137,6 +148,9 @@ workflows and scripts keep their previous behavior when it is absent.
|
||||
`ends on her sitting by the window`.
|
||||
- **Speech**: put the words in quotes: `@1 says "we are late."` Each person
|
||||
keeps their own voice.
|
||||
- **Talking over a cut**: end the words with `...` and the line keeps going
|
||||
into the next shot, said once. On the last line, `...` means the clip ends
|
||||
mid-sentence.
|
||||
- **Words on a sign**: name the sign: `a neon sign reads "OPEN"`.
|
||||
- **Sound and music**: use the **Sound** and **Music** boxes, or type
|
||||
`sound: rain on a tin roof` and `music: slow sad piano`. With no music you get
|
||||
@@ -195,7 +209,7 @@ as not plugged in.
|
||||
- **Sound** (`sound`): what the clip sounds like, for the whole clip. Same as a
|
||||
`sound:` line.
|
||||
- **Music** (`music`): the music for the whole clip. Same as a `music:` line.
|
||||
- **Length** (`seconds`): how long the clip is, 5 to 15.
|
||||
- **Length** (`seconds`): how long the clip is, 4 to 15.
|
||||
- **Camera** (`camera`): how the camera moves the whole way through.
|
||||
- **Look** (`look`): from the picture keeps your photo's look. The others redraw
|
||||
the clip. Clay and 3D don't work from words, so change your picture first with
|
||||
|
||||
@@ -24,6 +24,15 @@ pan. **Save & close** keeps your edits. **Cancel** or Escape puts everything
|
||||
back, and asks first if anything changed. You do not need the editor: a run
|
||||
uses what the node shows.
|
||||
|
||||
Right-click the picture and choose **Copy image** to copy the original picture,
|
||||
without added padding, rotation, crop, resize, handles or guides. To include
|
||||
your edits, open the gear and turn on **Copy with crop, rotation and padding**.
|
||||
That also includes resize, and is remembered for this browser. **Open image**
|
||||
follows the same choice. This works on the node and in the editor.
|
||||
Direct copying needs localhost or HTTPS. On a plain HTTP address, choose
|
||||
**Open image**, then right-click that
|
||||
picture and use the browser's **Copy image**.
|
||||
|
||||
## On the node
|
||||
|
||||
From top to bottom:
|
||||
|
||||
@@ -5,37 +5,31 @@ clip, a song or any sound a video model or a save node takes, when you want
|
||||
one part of the file and not the whole thing.
|
||||
|
||||
The node shows the whole file as a wave, so you can see where the loud parts
|
||||
are. The part that comes out is bright. Drag the white **IN** and **OUT**
|
||||
handles to set where it starts and stops, drag the bright part to slide it,
|
||||
or click somewhere else on the wave to move it there. You can also type a time
|
||||
under the wave, in seconds (`12.5`) or minutes and seconds (`1:02.5`).
|
||||
are. The part that comes out is bright. Under the wave are three boxes:
|
||||
**Start**, **Duration** and **Ends at**, in seconds. Drag the left handle to
|
||||
move the start, drag the right handle or type a Duration to change how long
|
||||
the sound is, or drag the bright part to slide it. Click somewhere else on
|
||||
the wave to move it there. Typing **Ends at** sets the Duration for you.
|
||||
|
||||
Press **▶** to hear only the part that comes out. **LOOP** plays it again and
|
||||
again.
|
||||
|
||||
## Max length
|
||||
Set the Duration to the length the next step needs, such as the length of
|
||||
the video you are making. An empty Duration runs to the end of the file.
|
||||
|
||||
Set **Max length** to the longest sound the next step can take, such as the
|
||||
length of the video you are making. The start stays where it is, and anything
|
||||
past the limit turns red with a dashed line where it is cut. Next to OUT,
|
||||
the node shows how long the sound that comes out is, such as `15.0 s`. It
|
||||
turns red when part of your pick is cut; hold the mouse over it to see how
|
||||
much, and click it to move OUT to the cut. Play stops at the cut, so what you
|
||||
hear is what comes out. `0` means no limit.
|
||||
|
||||
Max length can be wired. When the wire comes from a number node such as
|
||||
Float 🆎, the wave shows the cut for that number; otherwise the length's tooltip says
|
||||
`max wired` and the run still cuts the sound to the wired length.
|
||||
A box set by another node, such as Float 🆎, shows a **linked** button that
|
||||
jumps to that node, and the wave shows the part that number picks.
|
||||
|
||||
## Controls
|
||||
|
||||
- **Source** (`audio`): a sound file in ComfyUI's input folder. **Upload**
|
||||
adds one. Videos are listed as well, for their sound.
|
||||
- **Max length** (`max_seconds`): the longest the sound may be, in seconds.
|
||||
`0` means no limit.
|
||||
- **IN** (`start_seconds`): where the sound starts.
|
||||
- **OUT** (`end_seconds`): where the sound stops. `0` means the end of the
|
||||
file.
|
||||
- **Start** (`start_seconds`): where the sound starts.
|
||||
- **Duration** (`max_seconds`): how long the sound is, in seconds. Empty, or
|
||||
`0`, runs to the end of the file.
|
||||
- **Ends at**: where the sound stops. Typing it sets the Duration.
|
||||
A workflow saved with an end time (`end_seconds`) keeps it and runs the
|
||||
same.
|
||||
|
||||
## Outputs
|
||||
|
||||
@@ -49,4 +43,4 @@ Float 🆎, the wave shows the cut for that number; otherwise the length's toolt
|
||||
- The sound keeps its own sample rate and channels.
|
||||
- A start past the end of the file stops the run with a message that says so.
|
||||
- The wave is drawn in the browser from the file itself; nothing extra is
|
||||
stored with the workflow besides the four values above.
|
||||
stored with the workflow besides the node's own values.
|
||||
|
||||
@@ -1,37 +1,33 @@
|
||||
# Load Video
|
||||
|
||||
Loads a video from ComfyUI's input folder as an `IMAGE` frame batch plus its
|
||||
audio. One responsive player shows the source and previews the selected trim.
|
||||
Drag the high-contrast **IN** and **OUT** handles below it, drag the selected
|
||||
range to move the whole window, or type a time into the two fields, in seconds
|
||||
(`95.5`) or as a timecode (`1:35.5`). Click the strip outside the selection to
|
||||
move the window to that spot.
|
||||
The playhead follows each edit, so the frame at either boundary is visible
|
||||
while trimming. In **Source**, the list plays the clip under the pointer, muted, and filters as you type.
|
||||
audio. The player shows the video; the timing card under it picks the part
|
||||
that comes out.
|
||||
|
||||
Playback is constrained to the selected window. **LOOP** repeats it; turn loop
|
||||
off and playback pauses at OUT. The reload button refreshes the source without
|
||||
creating a second preview. The player takes the height you give the node:
|
||||
drag the node taller for a bigger picture. A tall video is shown whole, never
|
||||
cropped.
|
||||
The timing card has three boxes: **Start**, **Duration** and **Ends at**.
|
||||
Drag the left handle on the bar to move the start, drag the right handle or
|
||||
type a Duration to change how long the clip is, or drag the middle of the
|
||||
clip to slide it. **s | fr** switches every box between seconds and frames;
|
||||
it only changes what you see, never a saved value. **Use as start** starts
|
||||
the clip at the frame in the picture, and **Whole video** puts the clip back
|
||||
to the full file. In **Source**, the list plays the clip under the pointer,
|
||||
muted, and filters as you type.
|
||||
|
||||
**FRAME** switches the loader into a frame picker: the trim strip becomes a
|
||||
single scrub rail, and only the frame at the marker loads — a one-image batch,
|
||||
ready for image workflows without a separate frame-select node. Click or drag
|
||||
anywhere on the rail to choose the frame, or type an exact time into the AT
|
||||
field. Playback runs the whole source freely in this mode so you can hunt for
|
||||
the right moment. Picking a frame moves IN to that time. When you toggle back,
|
||||
OUT stays where it was, unless the frame is at or after OUT: then OUT moves to
|
||||
the end of the video.
|
||||
The player takes the height you give the node: drag the node taller for a
|
||||
bigger picture. A tall video is shown whole, never cropped. **LOOP** plays
|
||||
the clip again and again; with it off, playback pauses at the clip's end.
|
||||
The reload button refreshes the source.
|
||||
|
||||
The label between IN and OUT reports what one Run will actually load — e.g.
|
||||
`0:04.0 of 0:10.0 · 48 frames @ 12 fps`, or `1 frame at 0:05.2` while FRAME
|
||||
is on. The preview cannot re-render `every_nth` frame drops or a `max_frames`
|
||||
cap, so it counts them instead: the frame total and playback rate come from
|
||||
the source's real frame rate (probed from the file, since the browser's
|
||||
player never exposes it) with `every_nth` and `max_frames` applied. When a
|
||||
deciding value arrives over a link, or the rate cannot be probed, the count
|
||||
drops out rather than guessing.
|
||||
**FRAME** turns the loader into a frame picker: only the frame at the marker
|
||||
loads, as a one-image batch, ready for image workflows without a separate
|
||||
frame-select node. Drag the bar to choose the frame, or type it into the
|
||||
**FRAME** box. Playback runs the whole video in this mode so you can hunt for
|
||||
the right moment. Picking a frame moves the clip's start there.
|
||||
|
||||
The boxes count real frames: the frame rate and frame count come from the
|
||||
file itself, so a 4.1 s clip at 60 fps reads 247 frames, the same number
|
||||
the run loads. When a box is set by another node it shows a **linked**
|
||||
button that jumps to that node.
|
||||
|
||||
## Drop a video onto the node
|
||||
|
||||
@@ -48,21 +44,21 @@ embedded workflow replaces the whole graph.
|
||||
|
||||
- **Source** (`video`): A file in the input folder; **Upload** adds new ones.
|
||||
A video ComfyUI made, named like `clip.mp4 [output]`, loads too.
|
||||
- **IN** (`start_seconds`): Skip everything before this time.
|
||||
- **OUT** (`end_seconds`): Stop at this time; `0` means the source end until a
|
||||
handle is moved.
|
||||
- **Every nth** (`every_nth`): Keep one frame in this many — `2` halves the frame count.
|
||||
The `fps` output divides to match, so the clip still plays at real speed
|
||||
downstream.
|
||||
- **Limit** (`max_frames`): Stop after this many kept frames; `0` loads the
|
||||
whole trim window. Caps memory on long clips — the decode ends early
|
||||
instead of loading and discarding.
|
||||
- **LOOP**: Repeat the selected window during preview. It starts on and is
|
||||
saved with the workflow.
|
||||
- **FRAME** (`single_frame`): Load only the frame at the IN time (the field
|
||||
reads **AT** while FRAME is on) as a one-image batch; `end_seconds`,
|
||||
`every_nth`, and `max_frames` are ignored while it is on.
|
||||
- **↻**: Reload the selected source preview.
|
||||
- **Start** (`start_seconds`): Skip everything before this time.
|
||||
- **Duration** (`max_frames`): How many frames the clip keeps. **Whole
|
||||
video** removes the limit, so the clip runs to the end (the widget holds
|
||||
`0`). The decode stops early, so a short clip from a long video stays
|
||||
quick.
|
||||
- **Ends at**: Where the clip stops. Typing it sets the Duration. A
|
||||
workflow saved with an end time (`end_seconds`) keeps it and runs the same.
|
||||
- **Every nth** (`every_nth`): Keep one frame in this many; `2` halves the
|
||||
frame count. The `fps` output divides to match, so the clip still plays at
|
||||
real speed downstream.
|
||||
- **LOOP**: Repeat the clip during preview. It starts on and is saved with
|
||||
the workflow.
|
||||
- **FRAME** (`single_frame`): Load only the frame at the marker as a
|
||||
one-image batch; the Duration and Every nth are ignored while it is on.
|
||||
- **↻**: Reload the source preview.
|
||||
- **Width** / **Height** (`custom_width` / `custom_height`): `0` keeps the
|
||||
source size. Set one side only and the other follows the aspect ratio,
|
||||
rounded to an even number.
|
||||
|
||||
@@ -266,6 +266,14 @@ red with advice to re-pick. Thumbnails, the info card, and range lookups
|
||||
all use the resolved name, so a moved file keeps its previews and Civitai
|
||||
data.
|
||||
|
||||
A missing LoRA is also listed in ComfyUI's own missing-models list (the
|
||||
Issues panel, and the "Download all" button) next to the other models the
|
||||
workflow needs, with a Download button when the workflow saved where the
|
||||
file comes from. Rows that are switched off, at zero strength, or whose
|
||||
file moved folders are left off that list, because the run does not need
|
||||
them or finds them anyway. Rows that come into the node over a link are
|
||||
listed by the node that sets them, not here.
|
||||
|
||||
The run side matches: a stale saved path resolves by name at load time
|
||||
(exact → unique case-insensitive path → unique basename, with a one-line
|
||||
console note when it remaps). A LoRA that is genuinely missing **stops the
|
||||
|
||||
@@ -65,7 +65,7 @@ file's name. A caption on the `caption_text` input writes the paired `.txt`.
|
||||
are saved under the name and folder set above, in the format picked,
|
||||
with the workflow inside if **Embed workflow** is on. They wait in
|
||||
ComfyUI's temp folder, which is emptied when ComfyUI restarts, so save
|
||||
what you want before that.
|
||||
what you want before that. The Save button works for the last 256 runs.
|
||||
- **Preview steps** (`step_preview`, off by default): the switch left of
|
||||
**preview** shows the picture while it is being made, one step at a time,
|
||||
where the saved image goes, with a **STOP** button on the bar. Stop a run
|
||||
|
||||
@@ -155,9 +155,25 @@ correction turns the corner without a crease.
|
||||
The shift is subtracted from the pasted region before the blend. In the
|
||||
padding that is the whole shift; inside the feathered band the paste
|
||||
alpha scales it, which is exactly the share of each band pixel the
|
||||
sampler painted. Source pixels stay bit-identical. A crop stitcher, which
|
||||
has no source rectangle, gets a single global shift measured in its
|
||||
blend band instead.
|
||||
sampler painted. Source pixels stay bit-identical.
|
||||
|
||||
A Crop For Inpaint crop has no source rectangle, so it gets one shift for
|
||||
the whole painted area. That shift is read inside the painted area, in the
|
||||
32 pixels next to its edge: the same pixels before and after, taking the
|
||||
middle value. Those 32 pixels are counted at the size the model painted, so
|
||||
a large picture is read the same way and takes no longer. Most inpaint workflows let the model paint a little wider
|
||||
than the paste, so the soft edge itself comes back close to your picture
|
||||
and shows only a fraction of the drift. When the painted area holds
|
||||
something new (less than half of that rim agrees, or the change is larger
|
||||
than 20 LAB units, such as a black jacket over skin), it is not drift: the
|
||||
old pixels in that place show something else. The new part is then
|
||||
compared with your untouched picture right beside it, each side averaged
|
||||
within 48 pixels of the seam. Where the two sides look alike (within 20
|
||||
LAB units, on at least a quarter of the seam, such as new skin next to
|
||||
skin), the gap between them is taken off. Where they do not, such as a
|
||||
jacket next to skin, Tone match leaves that picture as painted. Before,
|
||||
the soft edge was read there instead, and a model that repaints the edge
|
||||
too could tint the whole patch: a yellow swimsuit over skin came back blue.
|
||||
|
||||
On a Crop + Rotate + Pad canvas the source rectangle is the crop, so it
|
||||
can also hold the rotation's empty corners and any transparency. The
|
||||
|
||||
@@ -14,28 +14,43 @@ model that paints black regions.
|
||||
- **Inputs**: Pick an existing input video (the list plays the clip under the pointer, muted, and filters as you type), click **Load**, or drop a video file
|
||||
onto the node. The old source widgets remain compatible with saved workflows, but
|
||||
are now driven by this compact card. Choosing another video keeps the canvas
|
||||
settings - Fill, Feather, **Align**, Resize, Every nth, Frames for, Length - and
|
||||
settings - Fill, Feather, **Align**, Resize, Every nth, Frames for, Duration - and
|
||||
fits the new clip to the lit ratio button, the way **Fit** is set. Rotation, crop,
|
||||
padding, IN/OUT and the playhead start over.
|
||||
padding, the clip's timing and the playhead start over.
|
||||
- **Outputs** (`source_mode` / `local_path`): Pick a video from ComfyUI's output folder,
|
||||
such as one you just rendered. The list shows the newest first and previews the video
|
||||
under the pointer. The video is read in place, without an upload copy. In an API prompt
|
||||
it is named the way ComfyUI names a file there: `clip.mp4 [output]`. A whole path such
|
||||
as `/home/me/ComfyUI/output/clip.mp4` is not read, for queued runs and the editor's live
|
||||
preview alike.
|
||||
- **Play / Pause** beside the scrubber previews the selected frames and stops at OUT. Press Play at OUT to start from IN again.
|
||||
- **Timeline** (right under the preview and size line): The rail on the node and in the editor is one timeline. Press or
|
||||
drag anywhere on it to scrub the **playhead**, with Length on or off; the stage shows
|
||||
that frame. Drag the **IN** or **OUT** handle to trim: the playhead rides on the handle, so what you see
|
||||
is the first (IN) or last (OUT) frame the run keeps, and it stays there when you let
|
||||
go. IN and OUT are frames, snapped to the source's frame grid; the boxes under the
|
||||
rail take a frame number, and `start_seconds` / `end_seconds` are derived from them
|
||||
(OUT is exclusive, 0 means the end of the source). Arrow keys on a handle move one
|
||||
second, Shift one frame. **OUT always sits on the last frame the run outputs**, so
|
||||
the handle and the bright bar end together; with Every nth or Frames for it steps to the
|
||||
frames the run keeps, and a dim tail marks frames the window holds but the run
|
||||
drops. In the editor, **Set IN** / **Set OUT** (or the **I** / **O** keys) put a
|
||||
trim point at the playhead, and **Full clip** resets the window. The editor also
|
||||
- **Play / Pause** beside the timeline plays the clip from its start and stops at its end. Pause and Play again to carry on from where you stopped.
|
||||
- **Timeline** (right under the picture): Press or drag anywhere on it to look at
|
||||
another frame; the picture shows it. Point at the bar to see where you are, the
|
||||
clip in words and the source's frame rate. Drag the **start** handle to move the
|
||||
clip (its Duration stays), and the **end** handle to change the Duration. The
|
||||
start stops where the whole Duration still fits, and a short note says so.
|
||||
**Use as start** starts the clip at the frame on the picture.
|
||||
- **Start / Duration / Ends at**: the clip in three boxes. Start and Ends at are
|
||||
places in the source video; Duration is how long the clip is. Type any of them,
|
||||
or drag over a box to scrub it. The small **s | fr** switch shows them in seconds
|
||||
or frames: Start and Ends at count source frames, Duration counts the frames the
|
||||
clip sends on, at the output rate. Point at a box for the other unit and what it
|
||||
covers. Typing a Start that leaves too little video is allowed: an amber note says
|
||||
how many frames still fit and offers to shorten the clip or move the start.
|
||||
- **Linked timing**: when another node feeds `start_frame`, `end_frame`,
|
||||
`frame_load_cap` or `fixed_frames`, that box is locked and its label shows a small
|
||||
**linked** button that jumps to the node. `fixed_frames` is an exact count;
|
||||
`frame_load_cap` is only a limit, so when the video ends first the note says how
|
||||
many frames you get. A count only worked out when the graph runs (a Math
|
||||
Expression, say) shows as **at run time**, and the timeline shows striped room
|
||||
after the start instead of a clip. A rate typed inside a subgraph counts as known.
|
||||
- **Technical details**: `start_seconds` / `end_seconds` are derived from the frames
|
||||
(the end is exclusive, 0 means the end of the source), and the Duration is stored
|
||||
as `max_frames`. Arrow keys on a handle move one second, Shift one frame. With
|
||||
Every nth or Frames for the end steps to the frames the run keeps, and a dim tail
|
||||
marks frames the window holds but the run drops.
|
||||
In the editor, **Set IN** / **Set OUT** (or the **I** / **O** keys) put a
|
||||
trim point at the playhead, and **Whole video** resets the clip. The editor also
|
||||
has buttons for the first and last frame, steps of 1, 25, 50 and 100 frames, and
|
||||
**Play**. Arrow keys step one frame (10 with Shift), Home and End jump to the
|
||||
ends, and Space plays or pauses. **Save & close** keeps your edits; **Cancel** or
|
||||
@@ -55,23 +70,16 @@ model that paints black regions.
|
||||
fill colour with a faint hatch, so black bands show on the black stage. A fresh clip node starts
|
||||
with black and feather 0 and the editor's **Reset transform** returns to them;
|
||||
the image nodes keep their grey fill and feathered mask.
|
||||
- **Length** (`max_frames`): the one other way to set how long the clip is. **Off**
|
||||
(the default): OUT ends the clip. **On**: a number of output frames from IN; OUT
|
||||
sits that many frames after IN and follows it when you drag IN, and dragging OUT or
|
||||
typing the number changes the Length. To move the whole clip, drag IN or the small
|
||||
grip in the middle of the kept part (the grip also slides a trimmed window with
|
||||
Length off). When the Length is as long as the clip or longer, the row says
|
||||
"= the whole clip": the clip's own end is OUT, and dragging IN starts the clip
|
||||
later without changing the Length. The Length stays when you
|
||||
swap the video, so a workflow built for 97 frames keeps taking 97. Turning it on or
|
||||
off never moves anything: the count becomes the OUT, or the OUT the count. If the
|
||||
source ends first, the footer says how many frames are left. **To start** moves IN
|
||||
to the start of the source.
|
||||
- **Whole video / To start** (bottom right of the timing card): **Whole video**
|
||||
uses the whole source, with no Duration limit. When the length is linked, the
|
||||
button reads **To start** and moves the start to the beginning instead. The
|
||||
Duration stays when you swap the video, so a workflow built for 97 frames keeps
|
||||
taking 97.
|
||||
- **Every nth** (`every_nth`): Thin the batch. The `fps` output divides to match
|
||||
every_nth, so the clip keeps real-time downstream; a Length counts the frames kept.
|
||||
every_nth, so the clip keeps real-time downstream; a Duration counts the frames kept.
|
||||
- **Frames for** (`frame_snap`): Keep a frame count a video model takes:
|
||||
**LTX (8n+1)** (49, 97, 121) or **Wan (4n+1)**. **any** keeps every frame in the window.
|
||||
OUT drags and the Length step through those counts.
|
||||
Dragging the end and typing a Duration step through those counts.
|
||||
With it on, `frame_count`, `duration`, the audio window and the stitcher all match the
|
||||
clip the sampler hands back, so wiring `frame_count` into the empty latent's length
|
||||
never leaves the stitch with more source frames than generated ones.
|
||||
@@ -103,7 +111,7 @@ with the padlock on it also takes away the bands the lock added.
|
||||
**Reset** on the node clears rotation, crop and padding and turns the padlock off;
|
||||
fill, feather, **Align** and the timeline stay.
|
||||
**Reset transform** in the editor resets rotation, crop, padding, fill, feather and
|
||||
**Align**; it keeps the source, current frame, trim, Length, resize and stitch
|
||||
**Align**; it keeps the source, current frame, trim, Duration, resize and stitch
|
||||
settings. **Align** makes the width and height divide evenly by the number
|
||||
you pick: padding grows by a few pixels, and a side with no padding is trimmed by
|
||||
a few instead. Some models need sizes divisible by 8, 16 or 32; 1 turns it off.
|
||||
@@ -163,8 +171,8 @@ Five optional sockets sit on the left, above the editor:
|
||||
| `force_rate` | Sample at this fps before Every nth. 0 keeps the source rate. Drops or repeats frames to keep playback speed. Accepts FLOAT or INT. |
|
||||
| `start_frame` | Zero-based source start frame. Overrides timeline IN. |
|
||||
| `end_frame` | Exclusive source end frame. 0 means the end of the source. Overrides timeline OUT. |
|
||||
| `fixed_frames` | Exact output frames from IN; the source must be long enough. Connected, it sets the length: OUT, Length and Frames for step aside. |
|
||||
| `frame_load_cap` | Maximum frames after rate conversion and Every nth, before Frames for. 0 means unlimited. Connected, it sets the length in place of Length. When the count is known, dragging IN stops at the last start that fits the kept frames. |
|
||||
| `fixed_frames` | Exact output frames from IN; the source must be long enough. Connected, it sets the length: Duration, Ends at and Frames for step aside. |
|
||||
| `frame_load_cap` | Maximum frames after rate conversion and Every nth, before Frames for. 0 means unlimited. Connected, it sets the length in place of Duration. When the count is known, dragging the start stops at the last start that fits the kept frames. |
|
||||
| `last_seconds` | Load only this many seconds from the end of the clip, or of the part before OUT. 0 loads all of it. Use it to carry on from a clip: a long clip then costs no more memory than a short one. |
|
||||
|
||||
Frame bounds use the source's frame-rate grid, independent of `force_rate`.
|
||||
@@ -178,17 +186,17 @@ For example, start 24 and end 72 select two seconds from a 24 fps source.
|
||||
A 12 fps forced rate returns 24 frames; a cap of 10 then keeps only the first
|
||||
10 of those. Audio and duration follow the returned batch.
|
||||
|
||||
A connected start or end locks that handle and its IN/OUT field on both
|
||||
A connected start or end locks that handle and its box on both
|
||||
the node and fullscreen editor. Hover to see why. Disconnect to restore
|
||||
local control. While timing inputs are connected, the preview shows the local
|
||||
trim as a reference and avoids claiming an output count before the linked
|
||||
values are evaluated at run time.
|
||||
|
||||
**A connected length input takes over the length.** Connect a count to
|
||||
`fixed_frames` (exact) or `frame_load_cap` (at most) and the OUT handle goes
|
||||
away, OUT and Length grey out, and only IN is left to set: the clip starts at
|
||||
IN and the input decides where it ends. Literal Integer/Float nodes (including
|
||||
`fixed_frames` (exact) or `frame_load_cap` (at most) and the end handle goes
|
||||
away, Duration and Ends at lock, and only Start is left to set: the clip starts
|
||||
there and the input decides where it ends. Literal Integer/Float nodes (including
|
||||
AusBoss cards and reroutes) show the resulting frames on the rail before
|
||||
running; calculated counts show "at run time". An older workflow that saved a
|
||||
Fixed frames number without a connection reads as a Length; the first change
|
||||
Fixed frames number without a connection reads as a Duration; the first change
|
||||
here turns it into one.
|
||||
|
||||
@@ -60,10 +60,12 @@ answered on the same line as the button.
|
||||
- A found file swaps its Download button for an **✓ installed** pill; hovering
|
||||
the pill shows where it was found. A file that lives in a subfolder still
|
||||
counts. When a loader in the workflow still asks for the bare file name,
|
||||
which ComfyUI cannot find there (it marks that loader red), the row says
|
||||
where the file is instead (**in LTXV 2.3/**) and **Use it** points those
|
||||
loaders at the copy it found. The check only asks the ComfyUI server for its
|
||||
own model lists.
|
||||
which ComfyUI cannot find there (it marks that loader red), the note points
|
||||
that loader at your copy by itself and says so in a short message. If you
|
||||
have two copies in different subfolders, the row says where one is
|
||||
(**in LTXV 2.3/**) and **Use it** picks it. To always choose yourself, turn
|
||||
off Settings, 🆎 AusBoss, Models, **Pick found files**. The check only asks
|
||||
the ComfyUI server for its own model lists.
|
||||
- **↻ check files** re-runs the check after you move files in. ComfyUI's own
|
||||
**R** refresh triggers it as well.
|
||||
- Folder `input` is for a sample image or clip shipped with the workflow: it
|
||||
|
||||
@@ -20,21 +20,36 @@ export function outputWindow(durationValue, startValue, endValue, maxValue = 0)
|
||||
return { start, end, keepEnd, length: keepEnd - start, cut: Math.max(0, end - keepEnd) };
|
||||
}
|
||||
|
||||
// "0:12.0" style, the way the IN and OUT fields write a time.
|
||||
export function secondsLabel(value) {
|
||||
const seconds = Math.max(0, finite(value));
|
||||
if (seconds < 60) return `${seconds.toFixed(1)} s`;
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
return `${minutes}:${(seconds - minutes * 60).toFixed(1).padStart(4, "0")}`;
|
||||
const hundredth = (value) => Math.round(value * 100) / 100;
|
||||
|
||||
// What the face stores for a pick from `start` to `end`: a Start and a
|
||||
// Duration (max_seconds, with end_seconds at 0, "to the end"). A pick that
|
||||
// reaches the end of the file needs no Duration. When another node sets the
|
||||
// Duration or the end, the pick is stored as a start and an end instead.
|
||||
// A key left out is not written.
|
||||
export function pickWrites(durationValue, startValue, endValue, { maxLinked = false, endLinked = false } = {}) {
|
||||
const duration = Math.max(0, finite(durationValue));
|
||||
const start = hundredth(Math.min(Math.max(0, finite(startValue)), duration));
|
||||
const end = hundredth(Math.max(start, Math.min(finite(endValue), duration)));
|
||||
const toEnd = end >= duration - 0.005;
|
||||
if (endLinked) return { start };
|
||||
if (maxLinked) return { start, end: toEnd ? 0 : end };
|
||||
return { start, end: 0, max: toEnd ? 0 : Math.max(0.01, hundredth(end - start)) };
|
||||
}
|
||||
|
||||
// The line between IN and OUT: what comes out, and what the max cuts off.
|
||||
export function outputSummary(window, { maxFromLink = false } = {}) {
|
||||
if (!window || window.length <= 0) return "";
|
||||
const parts = [secondsLabel(window.length)];
|
||||
if (window.cut > 0.005) parts.push(`cut ${secondsLabel(window.cut)}`);
|
||||
if (maxFromLink) parts.push("max wired");
|
||||
return parts.join(" · ");
|
||||
// A value typed into Start, Duration or Ends at, as the pick it makes.
|
||||
// Start keeps the Duration; Duration and Ends at keep the start. An empty
|
||||
// or 0 Duration, and an empty Ends at, run to the end of the file.
|
||||
export function typedPick(key, value, window, durationValue, minimum = 0.1) {
|
||||
const duration = Math.max(0, finite(durationValue));
|
||||
const clampTime = (time) => Math.min(duration, Math.max(0, finite(time)));
|
||||
if (key === "start") {
|
||||
const start = clampTime(value);
|
||||
return { start, end: Math.min(duration, start + window.length) };
|
||||
}
|
||||
if (value == null || (key === "duration" && !(finite(value) > 0))) return { start: window.start, end: duration };
|
||||
const end = key === "duration" ? window.start + Math.max(minimum, finite(value)) : Math.max(window.start + minimum, finite(value));
|
||||
return { start: window.start, end: clampTime(end) };
|
||||
}
|
||||
|
||||
// Loud and quiet across the file: for each of `buckets` slices, the lowest
|
||||
|
||||
+118
-110
@@ -1,30 +1,35 @@
|
||||
// Load Audio 🆎 - the wave, the trim and the player.
|
||||
// Load Audio 🆎 - the wave, the timing and the player.
|
||||
//
|
||||
// The card above (js/widget_cards) holds Source and Max length. This panel
|
||||
// draws the whole file as a wave: the part that comes out is bright, the
|
||||
// part a Max length cuts off is red, and the rest is dim. Drag a handle to
|
||||
// move IN or OUT, drag the middle to slide the pick, or click elsewhere to
|
||||
// move it there. Play plays only what comes out. The widgets underneath
|
||||
// (start_seconds, end_seconds, max_seconds) stay the source of truth.
|
||||
// The card above (js/widget_cards) holds Source. This panel draws the whole
|
||||
// file as a wave: the part that comes out is bright and the rest is dim.
|
||||
// Under it, Start, Duration and Ends at, as on the video nodes. Drag a
|
||||
// handle on the wave to move the start or the end, drag the middle to slide
|
||||
// the sound, or click elsewhere to move it there. Play plays only what comes
|
||||
// out. The widgets underneath stay the source of truth: the Duration is
|
||||
// max_seconds with end_seconds at 0. A saved end (or a linked Max length)
|
||||
// still works: the part a Max length cuts off shows red.
|
||||
import { api } from "../../../scripts/api.js";
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { BRAND, chainCallback, keepDomWidgetWidthAuto, notifyAusbossChange, showToast } from "../shared/index.mjs";
|
||||
import { keepKeyInField } from "../shared/canvas_passthrough.mjs";
|
||||
import { WIDGET_FRAME, fillNodeHeight } from "../shared/panel_layout.mjs";
|
||||
import { formatTimecode, parseTimecode } from "../shared/timecode.mjs";
|
||||
import { formatTimecode } from "../shared/timecode.mjs";
|
||||
import { inputNumber } from "../shared/clip_rate.mjs";
|
||||
import { makeScrubInput } from "../shared/scrub_input.mjs";
|
||||
import { linkedNodeInfo } from "../shared/timing_links.mjs";
|
||||
import { parseImageReference } from "../shared/pad_canvas.mjs";
|
||||
import { mediaViewQuery, splitMediaName } from "../shared/video_preview.mjs";
|
||||
import { ensureVideoCss, hideCanvasWidget, makeToolButton } from "../shared/video_ui.mjs";
|
||||
import { MIN_TRIM_SECONDS, dragTrimHandle, slideTrimWindow } from "../load_video/trim_preview.mjs";
|
||||
import { grabZone, outputSummary, outputWindow, secondsLabel, wavePeaks } from "./audio_window.mjs";
|
||||
import { grabZone, outputWindow, pickWrites, typedPick, wavePeaks } from "./audio_window.mjs";
|
||||
|
||||
const NODE_NAME = "AUSBOSS_NODES_LoadAudio";
|
||||
const PANEL_WIDGET = "ausboss_load_audio_wave";
|
||||
// The frontend's own player for an audio_upload input. The wave replaces it.
|
||||
const CORE_AUDIO_WIDGET = "audioUI";
|
||||
const MIN_WIDTH = 280;
|
||||
// 8px root padding + the wave's 28px floor + 6px gap + the 22px play, IN/OUT and loop row.
|
||||
const PANEL_MIN_HEIGHT = 64;
|
||||
// 8px root padding + the wave's 28px floor + 6px gap + the 38px Start,
|
||||
// Duration and Ends at row (a label over a box).
|
||||
const PANEL_MIN_HEIGHT = 80;
|
||||
// Opens small and neat: 300 px wide, with a wave about as tall as a field
|
||||
// (32 px). Drag the corner down for a taller wave.
|
||||
const DEFAULT_WIDTH = 300;
|
||||
@@ -50,26 +55,32 @@ function hideCoreAudio(node) {
|
||||
}
|
||||
}
|
||||
|
||||
// A wired Max length: the number the wire carries, when the far end is a
|
||||
// node that shows it (Float, Integer, a Primitive). null when it can't be known.
|
||||
function wiredMax(node) {
|
||||
const input = node.inputs?.find((slot) => slot?.widget?.name === "max_seconds");
|
||||
if (!input || input.link == null) return { wired: false, value: null };
|
||||
const graph = node.graph;
|
||||
const link = graph?.getLink?.(input.link) ?? graph?.links?.get?.(input.link) ?? graph?.links?.[input.link];
|
||||
const origin = link ? graph?.getNodeById?.(link.origin_id) : null;
|
||||
const shown = origin?.widgets?.find((widget) => typeof widget?.value === "number");
|
||||
return { wired: true, value: shown ? Number(shown.value) : null };
|
||||
function linked(node, name) {
|
||||
return !!node.inputs?.some((slot) => slot?.widget?.name === name && slot.link != null);
|
||||
}
|
||||
|
||||
// A value as the run will see it: the widget, or the number a linked input
|
||||
// carries when the far end is a typed number (through Reroutes and
|
||||
// subgraphs). null when only the run knows it.
|
||||
function valueOf(state, name, widget) {
|
||||
if (!linked(state.node, name)) return Number(widget?.value) || 0;
|
||||
return inputNumber(state.node, name, null);
|
||||
}
|
||||
|
||||
function maxSeconds(state) {
|
||||
const wired = wiredMax(state.node);
|
||||
if (wired.wired) return { value: wired.value ?? 0, fromLink: true, known: wired.value != null };
|
||||
return { value: Number(state.maxWidget?.value) || 0, fromLink: false, known: true };
|
||||
const fromLink = linked(state.node, "max_seconds");
|
||||
const value = valueOf(state, "max_seconds", state.maxWidget);
|
||||
return { value: value ?? 0, fromLink, known: value != null };
|
||||
}
|
||||
|
||||
function currentWindow(state) {
|
||||
return outputWindow(state.duration, state.startWidget.value, state.endWidget.value, maxSeconds(state).value);
|
||||
const start = valueOf(state, "start_seconds", state.startWidget) ?? 0;
|
||||
const max = maxSeconds(state).value;
|
||||
let end = valueOf(state, "end_seconds", state.endWidget) ?? 0;
|
||||
// No end and a Duration: the Duration is where the sound stops, so
|
||||
// nothing past it shows as cut off. Only an end past the Duration does.
|
||||
if (!(end > 0) && max > 0 && state.duration > 0) end = Math.min(state.duration, Math.max(0, start) + max);
|
||||
return outputWindow(state.duration, start, end, max);
|
||||
}
|
||||
|
||||
async function loadPeaks(name, route) {
|
||||
@@ -105,16 +116,15 @@ function ensureAudioCss() {
|
||||
.ausboss-audio-error{pointer-events:auto;border:0;background:transparent;color:#e6bf87;font:11px system-ui;cursor:pointer;white-space:nowrap}
|
||||
.ausboss-audio-root canvas.ausboss-audio-wave{position:absolute;inset:0;width:100%;height:100%;display:block;}
|
||||
.ausboss-audio-root .ausboss-video-stage:not(.is-empty) .ausboss-video-status{display:none;}
|
||||
.ausboss-audio-root .ausboss-audio-row{display:flex;align-items:center;gap:6px;flex:none;padding:0 2px;}
|
||||
.ausboss-audio-root .ausboss-audio-row .ausboss-video-values{flex:1 1 auto;min-width:0;}
|
||||
.ausboss-audio-root .ausboss-audio-play{min-width:30px;font-size:10px;}
|
||||
.ausboss-audio-root .ausboss-audio-length{flex:none;padding:0 2px;color:#7fd9d2;font-size:10px;font-variant-numeric:tabular-nums;white-space:nowrap;cursor:default;}
|
||||
.ausboss-audio-root .ausboss-audio-length:empty{display:none;}
|
||||
.ausboss-audio-root .ausboss-audio-length.has-cut{color:#ff9aa0;cursor:pointer;text-decoration:underline dotted rgba(224,82,90,.8);text-underline-offset:2px;}
|
||||
.ausboss-audio-root .ausboss-audio-row .ausboss-video-tool{flex:none;}
|
||||
.ausboss-audio-root .ausboss-video-values{display:flex;gap:8px;}
|
||||
.ausboss-audio-root .ausboss-video-value input{width:48px;}
|
||||
.ausboss-audio-root .ausboss-audio-length{margin-left:auto;}
|
||||
.ausboss-audio-root .ausboss-audio-wave-row{display:flex;align-items:stretch;gap:6px;flex:1 1 auto;min-height:28px;}
|
||||
.ausboss-audio-root .ausboss-audio-wave-row .ausboss-video-stage{flex:1 1 auto;min-width:0;}
|
||||
.ausboss-audio-root .ausboss-audio-play{flex:none;align-self:center;min-width:30px;font-size:10px;}
|
||||
.ausboss-audio-fields{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;flex:none;padding:0 2px;color:#ddd;font:11px system-ui;}
|
||||
.ausboss-audio-field{display:flex;flex-direction:column;gap:2px;min-width:0;}
|
||||
.ausboss-audio-field .ausboss-scrub{width:100%;box-sizing:border-box;}
|
||||
.ausboss-audio-field-label{display:flex;align-items:center;gap:6px;min-width:0;color:#cadddb;}
|
||||
.ausboss-audio-go{border:0;background:transparent;padding:0;color:#45d6cb;font:600 10px system-ui;text-decoration:underline;cursor:pointer;}
|
||||
.ausboss-audio-go[hidden]{display:none;}
|
||||
`;
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
@@ -192,21 +202,31 @@ function draw(state) {
|
||||
}
|
||||
}
|
||||
|
||||
// One box's look: its value, whether it can be typed, and the "linked"
|
||||
// button when another node sets it.
|
||||
function showField(state, key, value, lockedBy, tip) {
|
||||
const field = state.fields[key];
|
||||
field.control.set(value);
|
||||
field.control.root.style.opacity = lockedBy ? ".45" : "";
|
||||
field.control.root.inert = Boolean(lockedBy);
|
||||
field.go.hidden = !lockedBy;
|
||||
field.cell.title = lockedBy ? `Set by ${lockedBy.title}. Click "linked" to go to that node.` : tip;
|
||||
if (lockedBy) field.go.onclick = () => lockedBy.go?.();
|
||||
}
|
||||
|
||||
function updateFace(state) {
|
||||
const win = currentWindow(state);
|
||||
const max = maxSeconds(state);
|
||||
if (document.activeElement !== state.startInput) state.startInput.value = formatTimecode(win.start);
|
||||
if (document.activeElement !== state.endInput) state.endInput.value = formatTimecode(win.end);
|
||||
if (state.duration > 0) {
|
||||
const summary = outputSummary(win, { maxFromLink: max.fromLink && !max.known });
|
||||
state.summary.textContent = win.length > 0 ? secondsLabel(win.length) : "";
|
||||
state.summary.classList.toggle("has-cut", win.cut > 0.005);
|
||||
state.summary.title = win.cut > 0.005
|
||||
? `${summary}. Max length is ${max.value} s, so ${formatTimecode(win.keepEnd)} to ${formatTimecode(win.end)} is cut off (red). Click to move OUT to ${formatTimecode(win.keepEnd)}.`
|
||||
: `${summary}: ${formatTimecode(win.start)} to ${formatTimecode(win.keepEnd)} comes out.`;
|
||||
} else {
|
||||
state.summary.textContent = "";
|
||||
}
|
||||
const link = (name) => (linked(state.node, name) ? linkedNodeInfo(state.node, name) : null);
|
||||
// A linked value the page cannot read is only known when the graph runs:
|
||||
// its box, and the boxes that depend on it, stay empty.
|
||||
const known = (name) => !linked(state.node, name) || inputNumber(state.node, name, null) != null;
|
||||
const has = state.duration > 0;
|
||||
const startKnown = has && known("start_seconds");
|
||||
const lengthKnown = startKnown && known("max_seconds") && known("end_seconds");
|
||||
showField(state, "start", startKnown ? win.start : null, link("start_seconds"), `Where the sound starts in the file, of ${formatTimecode(state.duration)}.`);
|
||||
showField(state, "duration", lengthKnown ? win.length : null, link("max_seconds"),
|
||||
win.cut > 0.005 ? `How long the sound is. It stops ${formatTimecode(win.cut)} before the saved end (red).` : "How long the sound is. Clear it, or type 0, to run to the end of the file.");
|
||||
showField(state, "end", lengthKnown ? win.keepEnd : null, link("end_seconds"), "Where the sound stops in the file. Typing it changes the Duration.");
|
||||
draw(state);
|
||||
}
|
||||
|
||||
@@ -217,12 +237,19 @@ function writeWidget(widget, value) {
|
||||
widget.callback?.(next);
|
||||
}
|
||||
|
||||
// The pick, stored the way the face shows it (pickWrites): a Start and a
|
||||
// Duration, or a start and an end when another node sets the Duration.
|
||||
function writeTrim(state, bounds) {
|
||||
state.writing = true;
|
||||
try {
|
||||
writeWidget(state.startWidget, bounds.start);
|
||||
// OUT at the very end stays 0, the widget's own "to the end".
|
||||
writeWidget(state.endWidget, bounds.end >= state.duration - 0.005 ? 0 : bounds.end);
|
||||
const startLinked = linked(state.node, "start_seconds");
|
||||
const writes = pickWrites(state.duration, startLinked ? currentWindow(state).start : bounds.start, bounds.end, {
|
||||
maxLinked: linked(state.node, "max_seconds") || !state.maxWidget,
|
||||
endLinked: linked(state.node, "end_seconds"),
|
||||
});
|
||||
if (!startLinked) writeWidget(state.startWidget, writes.start);
|
||||
if (writes.end !== undefined) writeWidget(state.endWidget, writes.end);
|
||||
if (writes.max !== undefined) writeWidget(state.maxWidget, writes.max);
|
||||
} finally {
|
||||
state.writing = false;
|
||||
}
|
||||
@@ -248,7 +275,7 @@ function installDrag(state) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const initial = infoAt(event.clientX);
|
||||
const bounds = { start: initial.win.start, end: initial.win.end };
|
||||
const bounds = { start: initial.win.start, end: initial.win.keepEnd };
|
||||
const anchor = initial.fraction * state.duration;
|
||||
const downX = event.clientX;
|
||||
let moved = false;
|
||||
@@ -262,7 +289,7 @@ function installDrag(state) {
|
||||
const next = infoAt(clientX);
|
||||
if (initial.zone === "start" || initial.zone === "end") {
|
||||
const now = currentWindow(state);
|
||||
writeTrim(state, dragTrimHandle(state.duration, { start: now.start, end: now.end }, initial.zone, next.fraction, MIN_TRIM_SECONDS));
|
||||
writeTrim(state, dragTrimHandle(state.duration, { start: now.start, end: now.keepEnd }, initial.zone, next.fraction, MIN_TRIM_SECONDS));
|
||||
} else if (initial.zone === "move") {
|
||||
writeTrim(state, slideTrimWindow(state.duration, bounds, next.fraction * state.duration - anchor));
|
||||
} else {
|
||||
@@ -336,19 +363,6 @@ function installPlayer(state) {
|
||||
state.stopPlayer = () => { audio.pause(); stop(); };
|
||||
}
|
||||
|
||||
function commitTimeInput(state, edge, input) {
|
||||
if (state.duration <= 0) return;
|
||||
const seconds = parseTimecode(input.value);
|
||||
const win = currentWindow(state);
|
||||
if (seconds === null) {
|
||||
input.value = formatTimecode(edge === "start" ? win.start : win.end);
|
||||
return;
|
||||
}
|
||||
writeTrim(state, dragTrimHandle(state.duration, { start: win.start, end: win.end }, edge, seconds / state.duration, MIN_TRIM_SECONDS));
|
||||
notifyAusbossChange();
|
||||
input.blur();
|
||||
}
|
||||
|
||||
function watchWidget(state, widget) {
|
||||
if (!widget || widget.__ausbossAudioWatch) return;
|
||||
widget.__ausbossAudioWatch = true;
|
||||
@@ -385,37 +399,44 @@ function buildPanel(node) {
|
||||
playButton.classList.add("ausboss-audio-play");
|
||||
const loopButton = makeToolButton("LOOP", "Play it again and again");
|
||||
stage.append(canvas, status);
|
||||
// Play and Loop sit either side of the wave, so neither covers a handle.
|
||||
loopButton.classList.add("ausboss-audio-play");
|
||||
const waveRow = document.createElement("div");
|
||||
waveRow.className = "ausboss-audio-wave-row";
|
||||
waveRow.append(playButton, stage, loopButton);
|
||||
|
||||
const values = document.createElement("div");
|
||||
values.className = "ausboss-video-values";
|
||||
const makeValue = (labelText, title) => {
|
||||
const wrap = document.createElement("div");
|
||||
wrap.className = "ausboss-video-value";
|
||||
const label = document.createElement("label");
|
||||
label.textContent = labelText;
|
||||
const input = document.createElement("input");
|
||||
input.type = "text";
|
||||
input.inputMode = "decimal";
|
||||
input.placeholder = "m:ss.s";
|
||||
input.title = title;
|
||||
input.addEventListener("keydown", (event) => {
|
||||
keepKeyInField(event);
|
||||
if (event.key === "Enter") input.dispatchEvent(new Event("change"));
|
||||
});
|
||||
wrap.append(label, input);
|
||||
return { wrap, input };
|
||||
// Start, Duration and Ends at, as on the video nodes, in seconds.
|
||||
const fieldsRow = document.createElement("div");
|
||||
fieldsRow.className = "ausboss-audio-fields";
|
||||
const fields = {};
|
||||
const commit = (key, value) => {
|
||||
const state = node.__ausbossLoadAudio;
|
||||
if (!state || state.duration <= 0) return;
|
||||
writeTrim(state, typedPick(key, value, currentWindow(state), state.duration, MIN_TRIM_SECONDS));
|
||||
};
|
||||
const startValue = makeValue("IN", "Where the sound starts. Type seconds (12.5) or a time (0:12.5).");
|
||||
const endValue = makeValue("OUT", "Where the sound stops. Type seconds (24) or a time (0:24.0).");
|
||||
// How long the output is, beside OUT and off the wave. Red when Max
|
||||
// length cuts the pick short; the tooltip says how much.
|
||||
const summary = document.createElement("div");
|
||||
summary.className = "ausboss-audio-length";
|
||||
values.append(startValue.wrap, endValue.wrap);
|
||||
const row = document.createElement("div");
|
||||
row.className = "ausboss-audio-row";
|
||||
row.append(playButton, values, summary, loopButton);
|
||||
root.append(stage, row);
|
||||
for (const [key, caption] of [["start", "Start"], ["duration", "Duration"], ["end", "Ends at"]]) {
|
||||
const cell = document.createElement("div");
|
||||
cell.className = "ausboss-audio-field";
|
||||
const label = document.createElement("span");
|
||||
label.className = "ausboss-audio-field-label";
|
||||
label.textContent = caption;
|
||||
const go = document.createElement("button");
|
||||
go.type = "button";
|
||||
go.className = "ausboss-audio-go";
|
||||
go.textContent = "linked";
|
||||
go.hidden = true;
|
||||
label.append(go);
|
||||
const control = makeScrubInput({
|
||||
value: 0, min: 0, max: 86400, step: 0.1, fineStep: 0.01, decimals: 2, minDecimals: 0, unit: "s", unitWidth: 14,
|
||||
allowEmpty: true,
|
||||
onChange: (value) => commit(key, value),
|
||||
onSettle: () => notifyAusbossChange(),
|
||||
});
|
||||
cell.append(label, control.root);
|
||||
fieldsRow.append(cell);
|
||||
fields[key] = { cell, control, go };
|
||||
}
|
||||
root.append(waveRow, fieldsRow);
|
||||
|
||||
const widget = node.addDOMWidget(PANEL_WIDGET, "ausboss_audio", root, {
|
||||
serialize: false,
|
||||
@@ -435,22 +456,11 @@ function buildPanel(node) {
|
||||
audio.preload = "auto";
|
||||
const abort = new AbortController();
|
||||
const state = node.__ausbossLoadAudio = {
|
||||
node, root, stage, canvas, status, playButton, loopButton, summary, audio,
|
||||
startInput: startValue.input, endInput: endValue.input,
|
||||
node, root, stage, canvas, status, playButton, loopButton, audio, fields,
|
||||
audioWidget, startWidget, endWidget, maxWidget: findWidget(node, "max_seconds"),
|
||||
duration: 0, peaks: null, abort, writing: false, dragging: false, raf: 0, loading: 0,
|
||||
};
|
||||
|
||||
// Clicking the red length moves OUT to where the sound really ends.
|
||||
summary.addEventListener("click", (event) => {
|
||||
const win = currentWindow(state);
|
||||
if (win.cut <= 0.005) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
writeTrim(state, { start: win.start, end: win.keepEnd });
|
||||
notifyAusbossChange();
|
||||
});
|
||||
|
||||
const updateLoop = () => loopButton.classList.toggle("active", loopEnabled(node));
|
||||
updateLoop();
|
||||
loopButton.addEventListener("click", (event) => {
|
||||
@@ -509,8 +519,6 @@ function buildPanel(node) {
|
||||
watchWidget(state, startWidget);
|
||||
watchWidget(state, endWidget);
|
||||
watchWidget(state, state.maxWidget);
|
||||
startValue.input.addEventListener("change", () => commitTimeInput(state, "start", startValue.input));
|
||||
endValue.input.addEventListener("change", () => commitTimeInput(state, "end", endValue.input));
|
||||
const observer = new ResizeObserver(() => draw(state));
|
||||
observer.observe(stage);
|
||||
state.observer = observer;
|
||||
|
||||
+145
-355
@@ -1,9 +1,11 @@
|
||||
import { api } from "../../../scripts/api.js";
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { chainCallback, keepDomWidgetWidthAuto, notifyAusbossChange } from "../shared/index.mjs";
|
||||
import { keepKeyInField } from "../shared/canvas_passthrough.mjs";
|
||||
import { WIDGET_FRAME, fillNodeHeight } from "../shared/panel_layout.mjs";
|
||||
import { formatTimecode, parseTimecode } from "../shared/timecode.mjs";
|
||||
import { inputNumber } from "../shared/clip_rate.mjs";
|
||||
import { clipInfo, windowSeconds } from "../shared/timeline_math.mjs";
|
||||
import { mountTransformTrim } from "../shared/transform_trim.mjs";
|
||||
import { linkedNodeInfo, timingUnits } from "../shared/timing_links.mjs";
|
||||
import { parseImageReference } from "../shared/pad_canvas.mjs";
|
||||
import {
|
||||
mediaInfo,
|
||||
@@ -19,42 +21,31 @@ import {
|
||||
suppressCoreVideoPreview,
|
||||
} from "../shared/video_ui.mjs";
|
||||
import {
|
||||
MIN_TRIM_SECONDS,
|
||||
clampTrimSeek,
|
||||
closestTrimHandle,
|
||||
dragTrimHandle,
|
||||
loadSummary,
|
||||
playbackBoundaryAction,
|
||||
singleFrameFraction,
|
||||
singleFrameTime,
|
||||
slideTrimWindow,
|
||||
trimAfterFramePick,
|
||||
trimBounds,
|
||||
trimFractions,
|
||||
} from "./trim_preview.mjs";
|
||||
|
||||
const NODE_NAME = "AUSBOSS_NODES_LoadVideo";
|
||||
const PREVIEW_WIDGET = "ausboss_load_video_viewer";
|
||||
const PREVIEW_CHROME = 88;
|
||||
// The shared video root's CSS minimum: 8px root padding + the stage's 112px
|
||||
// floor + 6px gap + the 76px trim strip. The declared floor adds
|
||||
// WIDGET_FRAME on top, or the element comes up short and clips the trim
|
||||
// strip's bottom border at the node's minimum height.
|
||||
const PANEL_MIN_HEIGHT = 202;
|
||||
// 8px root padding + the stage's 112px floor + 6px gap + the 152px timing
|
||||
// card (js/shared/transform_trim.mjs). The declared floor adds WIDGET_FRAME
|
||||
// on top, or the element comes up short and clips the card's bottom border
|
||||
// at the node's minimum height.
|
||||
const PANEL_MIN_HEIGHT = 278;
|
||||
// Height the node opens at. It used to fall out of the panel's computeSize;
|
||||
// with the panel free to follow the node, the default has to be stated. The
|
||||
// chrome covers the transport row and the trim strip under the player.
|
||||
const DEFAULT_NODE_SIZE = [380, responsivePreviewHeight(380) + PREVIEW_CHROME + 190];
|
||||
// extra covers the tools over the picture and the timing card under it.
|
||||
const DEFAULT_NODE_SIZE = [380, responsivePreviewHeight(380) + PREVIEW_CHROME + 210];
|
||||
const TRIM_EPSILON = 0.04;
|
||||
|
||||
function findWidget(node, name) {
|
||||
return node.widgets?.find((widget) => widget.name === name);
|
||||
}
|
||||
|
||||
function roundHundredth(value) {
|
||||
return Math.round(Number(value || 0) * 100) / 100;
|
||||
}
|
||||
|
||||
function getLoopEnabled(node) {
|
||||
node.properties ??= {};
|
||||
if (node.properties.ausboss_load_video_loop === undefined) {
|
||||
@@ -66,14 +57,25 @@ function getLoopEnabled(node) {
|
||||
function setEmpty(state, text) {
|
||||
state.stage.classList.add("is-empty");
|
||||
state.status.textContent = text;
|
||||
state.status.hidden = false;
|
||||
}
|
||||
|
||||
function setReady(state, text) {
|
||||
state.stage.classList.remove("is-empty");
|
||||
state.status.textContent = text;
|
||||
state.status.hidden = !text;
|
||||
}
|
||||
|
||||
// The run's window in seconds, as the timing card works it out (Start, and
|
||||
// the Duration or the end), or the plain start/end before the video's frame
|
||||
// rate is known.
|
||||
function currentBounds(state) {
|
||||
const info = clipInfo(state.metadata);
|
||||
const window = state.card?.window?.();
|
||||
if (info.fps > 0 && window && Number.isFinite(window.first)) {
|
||||
const last = Number.isFinite(window.last) ? window.last : info.count - 1;
|
||||
return { start: window.first / info.fps, end: Math.min(info.duration || Infinity, (last + 1) / info.fps) };
|
||||
}
|
||||
return trimBounds(state.video.duration, state.startWidget.value, state.endWidget.value);
|
||||
}
|
||||
|
||||
@@ -82,271 +84,116 @@ function isSingleFrame(state) {
|
||||
}
|
||||
|
||||
// Where the preview belongs for the current mode: the chosen frame, or the
|
||||
// trim window's IN point.
|
||||
// clip's start.
|
||||
function homeTime(state) {
|
||||
return isSingleFrame(state)
|
||||
? singleFrameTime(state.video.duration, state.startWidget.value)
|
||||
: currentBounds(state).start;
|
||||
}
|
||||
|
||||
function applyMode(state) {
|
||||
const single = isSingleFrame(state);
|
||||
state.root.classList.toggle("is-single-frame", single);
|
||||
state.frameButton?.classList.toggle("active", single);
|
||||
state.startLabel.textContent = single ? "AT" : "IN";
|
||||
state.range.title = single
|
||||
? "Drag or click to choose the frame that loads"
|
||||
: "Drag either handle to set the trim; drag the selected range to move it";
|
||||
updateTrimFace(state);
|
||||
}
|
||||
|
||||
function widgetLinkDriven(node, name) {
|
||||
return !!node.inputs?.some((input) => input?.widget?.name === name && input.link != null);
|
||||
}
|
||||
|
||||
// The honest "what will actually load" text for the label under the trim
|
||||
// strip, or "" when there is nothing honest to say. Any of the deciding
|
||||
// widgets driven by a link means its face value is stale, so the count
|
||||
// drops out rather than guessing.
|
||||
function trimLoadSummary(state, duration, bounds) {
|
||||
const deciders = ["start_seconds", "end_seconds", "every_nth", "max_frames", "single_frame"];
|
||||
if (deciders.some((name) => widgetLinkDriven(state.node, name))) return "";
|
||||
return loadSummary(
|
||||
duration,
|
||||
bounds,
|
||||
state.sourceFps,
|
||||
state.everyNthWidget?.value,
|
||||
state.maxFramesWidget?.value,
|
||||
isSingleFrame(state),
|
||||
);
|
||||
}
|
||||
|
||||
// The <video> element never exposes the source frame rate, so the frame
|
||||
// count in the label needs a probe of the pack's metadata route. Fail-soft:
|
||||
// on any error the label simply omits the count and the timecodes stand.
|
||||
async function probeSourceFps(state, name) {
|
||||
state.sourceFps = 0;
|
||||
// Frame rate and the real frame count come from the pack's metadata route:
|
||||
// the <video> element knows neither, and its length rounds up a frame.
|
||||
// Fail-soft: without it the card waits for a source.
|
||||
async function probeMetadata(state, name) {
|
||||
state.metadata = null;
|
||||
try {
|
||||
const query = new URLSearchParams({ source_mode: "input folder", video: name });
|
||||
const type = parseImageReference(name)?.type;
|
||||
if (type && type !== "input") {
|
||||
query.set("source_mode", "local path");
|
||||
query.set("local_path", name);
|
||||
}
|
||||
const response = await api.fetchApi(`/ausboss/transform/video/metadata?${query}`);
|
||||
if (!response.ok) return;
|
||||
const metadata = await response.json();
|
||||
if (state.videoWidget.value !== name) return; // a newer selection won
|
||||
state.sourceFps = Math.max(0, Number(metadata?.fps) || 0);
|
||||
updateTrimFace(state);
|
||||
state.metadata = metadata;
|
||||
state.card?.sync();
|
||||
} catch (_error) {
|
||||
/* no fps, no frame count */
|
||||
/* no metadata, no timing card numbers */
|
||||
}
|
||||
}
|
||||
|
||||
function writeWidget(widget, value) {
|
||||
const next = roundHundredth(value);
|
||||
if (Math.abs(Number(widget.value || 0) - next) < 0.0001) return;
|
||||
widget.value = next;
|
||||
widget.callback?.(next);
|
||||
function setWidget(widget, value) {
|
||||
if (!widget) return;
|
||||
if (widget.value === value) return;
|
||||
widget.value = value;
|
||||
widget.callback?.(value);
|
||||
}
|
||||
|
||||
function writeTrim(state, bounds, seekEdge = null) {
|
||||
state.writing = true;
|
||||
try {
|
||||
writeWidget(state.startWidget, bounds.start);
|
||||
writeWidget(state.endWidget, bounds.end);
|
||||
} finally {
|
||||
state.writing = false;
|
||||
}
|
||||
updateTrimFace(state);
|
||||
if (state.video.readyState >= 1 && seekEdge) {
|
||||
state.video.currentTime = seekEdge === "start"
|
||||
? bounds.start
|
||||
: Math.max(bounds.start, bounds.end - TRIM_EPSILON);
|
||||
}
|
||||
state.node.setDirtyCanvas?.(true, true);
|
||||
state.node.graph?.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
|
||||
function writeFrameTime(state, timeValue) {
|
||||
const duration = Number.isFinite(state.video.duration) ? state.video.duration : 0;
|
||||
const time = singleFrameTime(duration, timeValue);
|
||||
state.writing = true;
|
||||
try {
|
||||
writeWidget(state.startWidget, time);
|
||||
} finally {
|
||||
state.writing = false;
|
||||
}
|
||||
updateTrimFace(state);
|
||||
if (state.video.readyState >= 1) state.video.currentTime = time;
|
||||
state.node.setDirtyCanvas?.(true, true);
|
||||
state.node.graph?.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
|
||||
function updateTrimFace(state) {
|
||||
const duration = Number.isFinite(state.video.duration) ? state.video.duration : 0;
|
||||
if (isSingleFrame(state)) {
|
||||
const time = singleFrameTime(duration, state.startWidget.value);
|
||||
const percent = singleFrameFraction(duration, time) * 100;
|
||||
state.selection.style.width = "0%";
|
||||
state.startHandle.style.left = `${percent}%`;
|
||||
if (document.activeElement !== state.startInput) state.startInput.value = formatTimecode(time);
|
||||
// "1 frame at 0:05.2" - the count comes from the same pure summary the
|
||||
// trim label uses, so both modes report what one Run will load.
|
||||
const summary = trimLoadSummary(state, duration, null);
|
||||
state.durationLabel.textContent = duration > 0
|
||||
? `${summary || "frame"} at ${formatTimecode(time)}`
|
||||
: "load a video to pick a frame";
|
||||
if (duration > 0) state.status.textContent = `frame at ${formatTimecode(time)}`;
|
||||
return;
|
||||
}
|
||||
const bounds = trimBounds(duration, state.startWidget.value, state.endWidget.value);
|
||||
const fractions = trimFractions(duration, bounds);
|
||||
const startPercent = fractions.start * 100;
|
||||
const endPercent = fractions.end * 100;
|
||||
state.selection.style.left = `${startPercent}%`;
|
||||
state.selection.style.width = `${Math.max(0, endPercent - startPercent)}%`;
|
||||
state.startHandle.style.left = `${startPercent}%`;
|
||||
state.endHandle.style.left = `${endPercent}%`;
|
||||
if (document.activeElement !== state.startInput) state.startInput.value = formatTimecode(bounds.start);
|
||||
if (document.activeElement !== state.endInput) state.endInput.value = formatTimecode(bounds.end);
|
||||
const selected = Math.max(0, bounds.end - bounds.start);
|
||||
// The preview cannot re-render every_nth or max_frames, so the label
|
||||
// reports them instead: "0:04.0 of 0:10.0 · 48 frames @ 12 fps".
|
||||
const summary = trimLoadSummary(state, duration, bounds);
|
||||
state.durationLabel.textContent = duration > 0
|
||||
? `${formatTimecode(selected)} of ${formatTimecode(duration)}${summary ? ` · ${summary}` : ""}`
|
||||
: "load a video to trim";
|
||||
state.status.textContent = duration > 0
|
||||
? `${formatTimecode(bounds.start)} → ${formatTimecode(bounds.end)}`
|
||||
: state.status.textContent;
|
||||
}
|
||||
|
||||
function installTrimDrag(state) {
|
||||
const { range } = state;
|
||||
const infoAt = (clientX) => {
|
||||
const rect = range.getBoundingClientRect();
|
||||
const duration = Number.isFinite(state.video.duration) ? state.video.duration : 0;
|
||||
const bounds = currentBounds(state);
|
||||
const fractions = trimFractions(duration, bounds);
|
||||
const x = clientX - rect.left;
|
||||
const hit = 10;
|
||||
let zone = "jump";
|
||||
const closest = closestTrimHandle(
|
||||
fractions.start,
|
||||
fractions.end,
|
||||
rect.width ? x / rect.width : 0,
|
||||
rect.width,
|
||||
hit,
|
||||
);
|
||||
if (closest) zone = closest;
|
||||
else if (x > fractions.start * rect.width && x < fractions.end * rect.width) zone = "move";
|
||||
return { rect, duration, bounds, fraction: rect.width ? x / rect.width : 0, zone };
|
||||
};
|
||||
|
||||
range.addEventListener("pointermove", (event) => {
|
||||
if (state.dragging) return;
|
||||
if (isSingleFrame(state)) {
|
||||
range.style.cursor = "ew-resize";
|
||||
return;
|
||||
}
|
||||
const { zone } = infoAt(event.clientX);
|
||||
range.style.cursor = zone === "start" || zone === "end"
|
||||
? "ew-resize"
|
||||
: zone === "move" ? "grab" : "pointer";
|
||||
});
|
||||
|
||||
range.addEventListener("pointerdown", (event) => {
|
||||
if (event.button !== 0 || state.dragging) return;
|
||||
const initial = infoAt(event.clientX);
|
||||
if (initial.duration <= 0) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (isSingleFrame(state)) {
|
||||
// Frame-picker gesture: the strip is one scrub rail. A click already
|
||||
// sets the frame; a drag keeps refining it until release.
|
||||
state.dragging = true;
|
||||
try { range.setPointerCapture(event.pointerId); } catch (_error) { /* mouse fallback */ }
|
||||
const scrub = (clientX) => {
|
||||
const next = infoAt(clientX);
|
||||
writeFrameTime(state, next.fraction * next.duration);
|
||||
};
|
||||
scrub(event.clientX);
|
||||
const move = (moveEvent) => {
|
||||
if (!(moveEvent.buttons & 1)) { finish(); return; }
|
||||
scrub(moveEvent.clientX);
|
||||
};
|
||||
const finish = () => {
|
||||
if (!state.dragging) return;
|
||||
state.dragging = false;
|
||||
range.removeEventListener("pointermove", move);
|
||||
try { range.releasePointerCapture(event.pointerId); } catch (_error) { /* already released */ }
|
||||
// One notification per gesture: the frame changed on pointerdown.
|
||||
notifyAusbossChange();
|
||||
};
|
||||
range.addEventListener("pointermove", move);
|
||||
range.addEventListener("pointerup", finish, { once: true });
|
||||
range.addEventListener("pointercancel", finish, { once: true });
|
||||
range.addEventListener("lostpointercapture", finish, { once: true });
|
||||
return;
|
||||
}
|
||||
state.dragging = true;
|
||||
try { range.setPointerCapture(event.pointerId); } catch (_error) { /* mouse fallback */ }
|
||||
const downX = event.clientX;
|
||||
const anchorTime = initial.fraction * initial.duration;
|
||||
let moved = false;
|
||||
|
||||
const apply = (clientX) => {
|
||||
const next = infoAt(clientX);
|
||||
if (initial.zone === "start" || initial.zone === "end") {
|
||||
writeTrim(
|
||||
state,
|
||||
dragTrimHandle(next.duration, currentBounds(state), initial.zone, next.fraction),
|
||||
initial.zone,
|
||||
);
|
||||
} else if (initial.zone === "move") {
|
||||
const pointerTime = next.fraction * next.duration;
|
||||
writeTrim(
|
||||
state,
|
||||
slideTrimWindow(next.duration, initial.bounds, pointerTime - anchorTime),
|
||||
"start",
|
||||
);
|
||||
} else {
|
||||
const span = initial.bounds.end - initial.bounds.start;
|
||||
const centeredStart = next.fraction * next.duration - span / 2;
|
||||
writeTrim(
|
||||
state,
|
||||
slideTrimWindow(next.duration, initial.bounds, centeredStart - initial.bounds.start),
|
||||
"start",
|
||||
);
|
||||
// The timing card: the clip node's own, with Start, Duration and Ends at,
|
||||
// or, while FRAME is on, its frame picker. The player above it is the
|
||||
// picture, so the card leaves out its own Play button.
|
||||
function mountCard(state) {
|
||||
const { node } = state;
|
||||
const widgetFor = (name) => node.widgets?.find((widget) => widget.name === name);
|
||||
const fps = () => clipInfo(state.metadata).fps;
|
||||
const single = isSingleFrame(state);
|
||||
const card = mountTransformTrim({
|
||||
get: (name, fallback) => {
|
||||
if (name === "frame_index") return state.head ?? 0;
|
||||
const widget = widgetFor(name);
|
||||
return widget ? widget.value : fallback;
|
||||
},
|
||||
set: (name, value) => {
|
||||
state.writing = true;
|
||||
try { setWidget(widgetFor(name), value); } finally { state.writing = false; }
|
||||
if (state.video.readyState >= 1 && !state.video.paused) return;
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
},
|
||||
has: (name) => Boolean(widgetFor(name)),
|
||||
driven: (name) => widgetLinkDriven(node, name),
|
||||
number: (name, fallback) => inputNumber(node, name, fallback),
|
||||
metadata: () => state.metadata,
|
||||
trim: !single,
|
||||
play: false,
|
||||
isPlaying: () => !state.video.paused,
|
||||
onTogglePlayback: () => {},
|
||||
onSeek: (frame, settled) => {
|
||||
state.head = frame;
|
||||
const rate = fps();
|
||||
if (single && rate > 0) {
|
||||
state.writing = true;
|
||||
try { setWidget(state.startWidget, windowSeconds(clipInfo(state.metadata), frame, frame).start_seconds); } finally { state.writing = false; }
|
||||
}
|
||||
};
|
||||
|
||||
const move = (moveEvent) => {
|
||||
if (!(moveEvent.buttons & 1)) { finish(moveEvent); return; }
|
||||
if (!moved && Math.abs(moveEvent.clientX - downX) < 3) return;
|
||||
moved = true;
|
||||
apply(moveEvent.clientX);
|
||||
};
|
||||
const finish = (finishEvent) => {
|
||||
if (!state.dragging) return;
|
||||
state.dragging = false;
|
||||
range.removeEventListener("pointermove", move);
|
||||
try { range.releasePointerCapture(event.pointerId); } catch (_error) { /* already released */ }
|
||||
if (!moved && initial.zone === "jump") {
|
||||
const next = infoAt(finishEvent?.clientX ?? downX);
|
||||
const span = initial.bounds.end - initial.bounds.start;
|
||||
const centeredStart = next.fraction * next.duration - span / 2;
|
||||
writeTrim(
|
||||
state,
|
||||
slideTrimWindow(next.duration, initial.bounds, centeredStart - initial.bounds.start),
|
||||
"start",
|
||||
);
|
||||
}
|
||||
// One notification per gesture, on release — never per pointermove.
|
||||
if (moved || initial.zone === "jump") notifyAusbossChange();
|
||||
};
|
||||
range.addEventListener("pointermove", move);
|
||||
range.addEventListener("pointerup", finish, { once: true });
|
||||
range.addEventListener("pointercancel", finish, { once: true });
|
||||
range.addEventListener("lostpointercapture", finish, { once: true });
|
||||
if (state.video.readyState >= 1 && rate > 0) state.video.currentTime = Math.min(state.video.duration || Infinity, (frame + 0.5) / rate);
|
||||
if (settled) notifyAusbossChange();
|
||||
},
|
||||
onCommit: notifyAusbossChange,
|
||||
linkInfo: (name) => linkedNodeInfo(node, name),
|
||||
units: () => timingUnits(),
|
||||
setUnits: (next) => timingUnits(next),
|
||||
});
|
||||
state.card?.root.remove();
|
||||
state.card = card;
|
||||
state.cardSlot.append(card.root);
|
||||
return card;
|
||||
}
|
||||
|
||||
function applyMode(state) {
|
||||
const single = isSingleFrame(state);
|
||||
state.root.classList.toggle("is-single-frame", single);
|
||||
state.frameButton?.classList.toggle("active", single);
|
||||
if (state.cardMode !== single) {
|
||||
state.cardMode = single;
|
||||
mountCard(state);
|
||||
}
|
||||
state.card?.sync();
|
||||
}
|
||||
|
||||
// The playhead follows the player, so the card's marker and readout move
|
||||
// with the picture.
|
||||
function followPlayer(state) {
|
||||
const rate = clipInfo(state.metadata).fps;
|
||||
if (!(rate > 0)) return;
|
||||
const frame = Math.max(0, Math.floor(state.video.currentTime * rate + 1e-6));
|
||||
if (frame === state.head) return;
|
||||
state.head = frame;
|
||||
state.card?.sync();
|
||||
}
|
||||
|
||||
function installPlayback(state) {
|
||||
@@ -356,9 +203,9 @@ function installPlayback(state) {
|
||||
state.playRaf = 0;
|
||||
};
|
||||
const tick = () => {
|
||||
if (video.paused || video.ended) { stopTick(); return; }
|
||||
// Frame picking plays the whole source freely — the trim window is not
|
||||
// in force, so there is no boundary to loop or stop at.
|
||||
if (video.paused || video.ended) { stopTick(); followPlayer(state); return; }
|
||||
// Frame picking plays the whole source freely - the clip is not in
|
||||
// force, so there is no boundary to loop or stop at.
|
||||
if (!isSingleFrame(state)) {
|
||||
const bounds = currentBounds(state);
|
||||
const action = playbackBoundaryAction(video.currentTime, bounds, getLoopEnabled(state.node), TRIM_EPSILON);
|
||||
@@ -367,9 +214,11 @@ function installPlayback(state) {
|
||||
} else if (action === "stop") {
|
||||
video.pause();
|
||||
video.currentTime = Math.max(bounds.start, bounds.end - TRIM_EPSILON);
|
||||
followPlayer(state);
|
||||
return;
|
||||
}
|
||||
}
|
||||
followPlayer(state);
|
||||
state.playRaf = requestAnimationFrame(tick);
|
||||
};
|
||||
video.addEventListener("play", () => {
|
||||
@@ -390,7 +239,7 @@ function installPlayback(state) {
|
||||
state.correctingSeek = true;
|
||||
video.currentTime = target;
|
||||
}, { signal: state.abort.signal });
|
||||
video.addEventListener("seeked", () => { state.correctingSeek = false; }, { signal: state.abort.signal });
|
||||
video.addEventListener("seeked", () => { state.correctingSeek = false; followPlayer(state); }, { signal: state.abort.signal });
|
||||
state.stopTick = stopTick;
|
||||
}
|
||||
|
||||
@@ -401,8 +250,8 @@ function watchTrimWidget(state, widget) {
|
||||
widget.callback = function (...args) {
|
||||
const result = prior?.apply(this, args);
|
||||
if (!state.writing) {
|
||||
updateTrimFace(state);
|
||||
if (state.video.readyState >= 1) state.video.currentTime = homeTime(state);
|
||||
state.card?.sync();
|
||||
if (state.video.readyState >= 1 && state.video.paused) state.video.currentTime = homeTime(state);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
@@ -416,7 +265,10 @@ function watchFrameWidget(state, widget) {
|
||||
const result = prior?.apply(this, args);
|
||||
if (!isSingleFrame(state)) {
|
||||
const reopened = trimAfterFramePick(state.startWidget.value, state.endWidget.value);
|
||||
if (reopened) writeTrim(state, reopened);
|
||||
if (reopened) {
|
||||
state.writing = true;
|
||||
try { setWidget(state.endWidget, reopened.end); } finally { state.writing = false; }
|
||||
}
|
||||
}
|
||||
applyMode(state);
|
||||
if (state.video.readyState >= 1) state.video.currentTime = homeTime(state);
|
||||
@@ -424,28 +276,6 @@ function watchFrameWidget(state, widget) {
|
||||
};
|
||||
}
|
||||
|
||||
function commitTimeInput(state, edge, input) {
|
||||
const duration = Number.isFinite(state.video.duration) ? state.video.duration : 0;
|
||||
if (duration <= 0) return;
|
||||
const seconds = parseTimecode(input.value);
|
||||
if (seconds === null) {
|
||||
// Malformed entry: restore the previous value and keep focus for a retry.
|
||||
const bounds = currentBounds(state);
|
||||
input.value = formatTimecode(edge === "start" ? bounds.start : bounds.end);
|
||||
return;
|
||||
}
|
||||
if (isSingleFrame(state)) {
|
||||
writeFrameTime(state, seconds);
|
||||
notifyAusbossChange();
|
||||
input.blur();
|
||||
return;
|
||||
}
|
||||
const fraction = seconds / duration;
|
||||
writeTrim(state, dragTrimHandle(duration, currentBounds(state), edge, fraction), edge);
|
||||
notifyAusbossChange();
|
||||
input.blur();
|
||||
}
|
||||
|
||||
function buildPreview(node) {
|
||||
if (node.__ausbossLoadVideo) return node.__ausbossLoadVideo;
|
||||
const videoWidget = findWidget(node, "video");
|
||||
@@ -461,6 +291,8 @@ function buildPreview(node) {
|
||||
hideCanvasWidget(startWidget);
|
||||
hideCanvasWidget(endWidget);
|
||||
if (frameWidget) hideCanvasWidget(frameWidget);
|
||||
// Every nth and the frame limit (the Duration) live in the timing card;
|
||||
// the widget card hides their widgets (js/widget_cards).
|
||||
|
||||
const root = document.createElement("div");
|
||||
root.className = "ausboss-video-root";
|
||||
@@ -475,7 +307,7 @@ function buildPreview(node) {
|
||||
status.textContent = "Choose or upload a video";
|
||||
const tools = document.createElement("div");
|
||||
tools.className = "ausboss-video-tools";
|
||||
const loopButton = makeToolButton("LOOP", "Loop playback inside the selected trim");
|
||||
const loopButton = makeToolButton("LOOP", "Play the clip again and again");
|
||||
loopButton.classList.add("ausboss-video-loop");
|
||||
const reloadButton = makeToolButton("↻", "Reload the selected source video");
|
||||
const frameButton = frameWidget
|
||||
@@ -485,45 +317,12 @@ function buildPreview(node) {
|
||||
tools.append(loopButton, reloadButton);
|
||||
stage.append(video, status, tools);
|
||||
|
||||
const trim = document.createElement("div");
|
||||
trim.className = "ausboss-video-trim";
|
||||
const range = document.createElement("div");
|
||||
range.className = "ausboss-video-range";
|
||||
range.title = "Drag either handle to set the trim; drag the selected range to move it";
|
||||
const selection = document.createElement("div");
|
||||
selection.className = "ausboss-video-selection";
|
||||
const startHandle = document.createElement("div");
|
||||
startHandle.className = "ausboss-video-handle";
|
||||
const endHandle = document.createElement("div");
|
||||
endHandle.className = "ausboss-video-handle is-end";
|
||||
range.append(selection, startHandle, endHandle);
|
||||
const values = document.createElement("div");
|
||||
values.className = "ausboss-video-values";
|
||||
const makeValue = (labelText) => {
|
||||
const wrap = document.createElement("div");
|
||||
wrap.className = "ausboss-video-value";
|
||||
const label = document.createElement("label");
|
||||
label.textContent = labelText;
|
||||
const input = document.createElement("input");
|
||||
input.type = "text";
|
||||
input.inputMode = "decimal";
|
||||
input.placeholder = "m:ss.s";
|
||||
input.title = `${labelText} point - type seconds (95.5) or a timecode (1:35.5, 1:02:03.5)`;
|
||||
input.addEventListener("keydown", (event) => {
|
||||
keepKeyInField(event);
|
||||
if (event.key === "Enter") input.dispatchEvent(new Event("change"));
|
||||
});
|
||||
wrap.append(label, input);
|
||||
return { wrap, input, label };
|
||||
};
|
||||
const startValue = makeValue("IN");
|
||||
const endValue = makeValue("OUT");
|
||||
endValue.wrap.classList.add("is-end");
|
||||
const durationLabel = document.createElement("div");
|
||||
durationLabel.className = "ausboss-video-duration";
|
||||
values.append(startValue.wrap, durationLabel, endValue.wrap);
|
||||
trim.append(range, values);
|
||||
root.append(stage, trim);
|
||||
// The timing card goes here (mountCard): the clip node's Start,
|
||||
// Duration and Ends at, or the frame picker while FRAME is on.
|
||||
const cardSlot = document.createElement("div");
|
||||
cardSlot.className = "ausboss-video-timing";
|
||||
cardSlot.style.flex = "none";
|
||||
root.append(stage, cardSlot);
|
||||
|
||||
const widget = node.addDOMWidget(PREVIEW_WIDGET, "ausboss_video", root, {
|
||||
serialize: false,
|
||||
@@ -544,15 +343,9 @@ function buildPreview(node) {
|
||||
const abort = new AbortController();
|
||||
const state = node.__ausbossLoadVideo = {
|
||||
node, root, stage, video, status, loopButton, reloadButton, frameButton,
|
||||
trim, range, selection, startHandle, endHandle, startInput: startValue.input,
|
||||
endInput: endValue.input, startLabel: startValue.label, durationLabel,
|
||||
cardSlot, card: null, cardMode: null, metadata: null, head: 0,
|
||||
videoWidget, startWidget, endWidget, frameWidget,
|
||||
// Absent on a backend without these widgets; the summary then reads
|
||||
// its defaults (keep every frame, no cap).
|
||||
everyNthWidget: findWidget(node, "every_nth"),
|
||||
maxFramesWidget: findWidget(node, "max_frames"),
|
||||
sourceFps: 0,
|
||||
widget, abort, writing: false, dragging: false, correctingSeek: false, playRaf: 0,
|
||||
widget, abort, writing: false, correctingSeek: false, playRaf: 0,
|
||||
};
|
||||
|
||||
const updateLoopButton = () => loopButton.classList.toggle("active", getLoopEnabled(node));
|
||||
@@ -583,9 +376,9 @@ function buildPreview(node) {
|
||||
if (!name || typeof name !== "string") {
|
||||
video.pause();
|
||||
video.removeAttribute("src");
|
||||
state.sourceFps = 0;
|
||||
state.metadata = null;
|
||||
setEmpty(state, "Choose or upload a video");
|
||||
updateTrimFace(state);
|
||||
state.card?.sync();
|
||||
return;
|
||||
}
|
||||
const parts = splitMediaName(name);
|
||||
@@ -595,7 +388,7 @@ function buildPreview(node) {
|
||||
const type = parseImageReference(name)?.type ?? "input";
|
||||
video.src = api.apiURL(`/view?${mediaViewQuery({ ...parts, type }, "input")}`);
|
||||
video.load();
|
||||
probeSourceFps(state, name);
|
||||
probeMetadata(state, name);
|
||||
};
|
||||
state.refresh = refresh;
|
||||
reloadButton.addEventListener("click", (event) => {
|
||||
@@ -605,31 +398,23 @@ function buildPreview(node) {
|
||||
});
|
||||
|
||||
video.addEventListener("loadedmetadata", () => {
|
||||
const single = isSingleFrame(state);
|
||||
const bounds = currentBounds(state);
|
||||
if (!single && bounds.end - bounds.start < MIN_TRIM_SECONDS && video.duration >= MIN_TRIM_SECONDS) {
|
||||
writeTrim(state, { start: Math.max(0, bounds.end - MIN_TRIM_SECONDS), end: bounds.end });
|
||||
}
|
||||
video.currentTime = homeTime(state);
|
||||
setReady(state, single
|
||||
? `frame at ${formatTimecode(homeTime(state))}`
|
||||
: `${formatTimecode(currentBounds(state).start)} → ${formatTimecode(currentBounds(state).end)}`);
|
||||
// Quiet source hint: resolution and duration from the loaded metadata.
|
||||
// The card says where the clip is; the stage only names the source on hover.
|
||||
setReady(state, "");
|
||||
const sourceInfo = mediaInfo(null, video);
|
||||
durationLabel.title = sourceInfo ? `Source: ${sourceInfo}` : "";
|
||||
updateTrimFace(state);
|
||||
stage.title = sourceInfo ? `Source: ${sourceInfo}` : "";
|
||||
state.card?.sync();
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
}, { signal: abort.signal });
|
||||
video.addEventListener("error", () => setEmpty(state, "Preview could not load this video"), { signal: abort.signal });
|
||||
|
||||
installTrimDrag(state);
|
||||
installPlayback(state);
|
||||
watchTrimWidget(state, startWidget);
|
||||
watchTrimWidget(state, endWidget);
|
||||
watchFrameWidget(state, frameWidget);
|
||||
watchTrimWidget(state, findWidget(node, "every_nth"));
|
||||
watchTrimWidget(state, findWidget(node, "max_frames"));
|
||||
applyMode(state);
|
||||
startValue.input.addEventListener("change", () => commitTimeInput(state, "start", startValue.input));
|
||||
endValue.input.addEventListener("change", () => commitTimeInput(state, "end", endValue.input));
|
||||
|
||||
const priorVideoCallback = videoWidget.callback;
|
||||
videoWidget.callback = function (...args) {
|
||||
@@ -664,6 +449,11 @@ app.registerExtension({
|
||||
}
|
||||
});
|
||||
});
|
||||
// A wire into a timing input changes what the card can show.
|
||||
chainCallback(nodeType.prototype, "onConnectionsChange", function () {
|
||||
const state = this.__ausbossLoadVideo;
|
||||
if (state) queueMicrotask(() => state.card?.sync());
|
||||
});
|
||||
chainCallback(nodeType.prototype, "onRemoved", function () {
|
||||
const state = this.__ausbossLoadVideo;
|
||||
state?.stopTick?.();
|
||||
|
||||
@@ -13,6 +13,7 @@ import { makeScrubInput } from "../shared/scrub_input.mjs";
|
||||
import { isAppShortcut, keepKeyInField } from "../shared/canvas_passthrough.mjs";
|
||||
import { resetUnknownValues } from "../shared/widget_card_math.mjs";
|
||||
import { boxRowInputs, boxRowsWidget, boxesOf, hostBox, rowsInputName, workflowNodes } from "../shared/lora_box.mjs";
|
||||
import { coreLoraList, syncFileWidgets } from "../shared/lora_file_widgets.mjs";
|
||||
import {
|
||||
SETTINGS_PROPERTY as SWITCHES_PROPERTY, releaseStackGroup, releaseStackRow, renameStackGroup, stackGroupOwners, stackRowOwners,
|
||||
} from "../shared/workflow_switches.mjs";
|
||||
@@ -724,9 +725,47 @@ function commitRows(state, rows, { structural = false, record = true } = {}) {
|
||||
state.node.graph?.setDirtyCanvas(true, true);
|
||||
if (structural) renderRows(state);
|
||||
else updateRowValues(state);
|
||||
syncLoraFiles(state.node);
|
||||
if (record) notifyAusbossChange();
|
||||
}
|
||||
|
||||
// ComfyUI's missing-models list sees a row's file only through a list
|
||||
// widget, so each row that needs a file gets a hidden one
|
||||
// (js/shared/lora_file_widgets.mjs). Rows that come in over a link (from a
|
||||
// box or another node) are not this node's to list.
|
||||
function syncLoraFiles(node) {
|
||||
if (node?.type !== NODE_CLASS) return;
|
||||
const widget = node.widgets?.find((item) => item.name === "loras");
|
||||
if (!widget) return;
|
||||
const fed = node.inputs?.find((item) => item?.name === "loras")?.link != null;
|
||||
syncFileWidgets(node, fed ? [] : parseRows(widget.value), {
|
||||
installed: () => coreLoraList(globalThis.LiteGraph?.registered_node_types?.LoraLoader?.nodeData)
|
||||
?? node.__ausbossLoraState?.available ?? null,
|
||||
hide: hideWidget,
|
||||
onPick: (rowId, name) => pickRowFile(node, rowId, name),
|
||||
});
|
||||
}
|
||||
|
||||
// ComfyUI put another file in a row's hidden list (a replacement picked in
|
||||
// its Issues panel): the row takes that file.
|
||||
function pickRowFile(node, rowId, name) {
|
||||
const widget = node.widgets?.find((item) => item.name === "loras");
|
||||
if (!widget) return;
|
||||
const rows = parseRows(widget.value);
|
||||
const row = rows.find((item) => item.id === rowId);
|
||||
if (!row || row.name === name) return;
|
||||
row.name = name;
|
||||
const state = node.__ausbossLoraState;
|
||||
if (state && !state.disposed && !state.readOnly && state.widget === widget) {
|
||||
commitRows(state, rows, { structural: true });
|
||||
return;
|
||||
}
|
||||
widget.value = serializeRows(rows);
|
||||
node.graph?.setDirtyCanvas(true, true);
|
||||
syncLoraFiles(node);
|
||||
notifyAusbossChange();
|
||||
}
|
||||
|
||||
// A box shows its loader's rows the way the loader does: one strength per
|
||||
// row, or model and CLIP apart.
|
||||
function linked(state) {
|
||||
@@ -3027,6 +3066,7 @@ function syncRows(state) {
|
||||
state.toggleSnapshot = snapshotEnabled(state.rows);
|
||||
renderRows(state);
|
||||
fitNode(state);
|
||||
syncLoraFiles(state.node);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3324,6 +3364,12 @@ app.registerExtension({
|
||||
});
|
||||
chainCallback(nodeType.prototype, "onConfigure", function () {
|
||||
resetUnknownValues(this.widgets, RESET_UNKNOWN);
|
||||
// Now, not later: ComfyUI reads its missing-models list right after
|
||||
// the workflow is restored.
|
||||
syncLoraFiles(this);
|
||||
});
|
||||
chainCallback(nodeType.prototype, "onConnectionsChange", function () {
|
||||
syncLoraFiles(this);
|
||||
});
|
||||
},
|
||||
// A box (subgraph node) shows the rows of a loader inside once they come
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// App mode and the pack's cards. Pure logic, no DOM: tested under node:test.
|
||||
//
|
||||
// App mode is ComfyUI's simple form view of a workflow: a saved list of
|
||||
// fields (extra.linearData.inputs) and a Run button. Each field is a
|
||||
// widget. A node with a card or panel hides its standard widgets and shows
|
||||
// its own controls instead, and App mode reads that hidden flag too, so the
|
||||
// form drew an empty row for every field on such a node.
|
||||
//
|
||||
// While a workflow is in App mode, the widgets its form lists are shown
|
||||
// again; App mode draws its own control for each. Back in the graph they are
|
||||
// hidden again, so the node's face is unchanged. Only listed widgets move.
|
||||
import { hideWidget, isWidgetHidden, showWidget } from "./widget_visibility.mjs";
|
||||
|
||||
export const APP_MODE = "app";
|
||||
|
||||
// "app", "graph" or "builder:..." for the open workflow.
|
||||
export function workflowMode(workflow) {
|
||||
return workflow?.activeMode ?? workflow?.initialMode ?? "graph";
|
||||
}
|
||||
|
||||
// The form's fields as { nodeId, widget } pairs. A field is saved as
|
||||
// [nodeId, widgetName] or [nodeId, widgetName, { description }].
|
||||
export function appFields(linearData) {
|
||||
const inputs = Array.isArray(linearData?.inputs) ? linearData.inputs : [];
|
||||
const fields = [];
|
||||
for (const entry of inputs) {
|
||||
if (!Array.isArray(entry) || entry.length < 2) continue;
|
||||
const [nodeId, widget] = entry;
|
||||
if ((typeof nodeId !== "string" && typeof nodeId !== "number") || typeof widget !== "string") continue;
|
||||
fields.push({ nodeId: String(nodeId), widget });
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
// find(nodeId, widgetName) -> { node, widget } or null
|
||||
// changed(node) is called after a widget on that node changed visibility.
|
||||
export function createAppModeSync({ find, changed = () => {} }) {
|
||||
const lent = new Map(); // widget -> node, shown for the form
|
||||
return function sync(mode, linearData) {
|
||||
if (mode === APP_MODE) {
|
||||
for (const { nodeId, widget: name } of appFields(linearData)) {
|
||||
const found = find(nodeId, name);
|
||||
if (!found?.widget || !isWidgetHidden(found.widget)) continue;
|
||||
showWidget(found.widget);
|
||||
// An explicit false, not a deleted flag: the frontend keeps its own
|
||||
// copy of the hidden state and only hears about a written value.
|
||||
if (found.widget.options) found.widget.options.hidden = false;
|
||||
lent.set(found.widget, found.node);
|
||||
changed(found.node);
|
||||
}
|
||||
return lent.size;
|
||||
}
|
||||
for (const [widget, node] of lent) {
|
||||
if (hideWidget(widget)) changed(node);
|
||||
}
|
||||
lent.clear();
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
+64
-16
@@ -1,30 +1,78 @@
|
||||
// Read only literal numeric sources. Calculated inputs must remain unknown
|
||||
// until execution; never evaluate an arbitrary upstream graph for a label.
|
||||
export function inputNumber(node, name, fallback) {
|
||||
const input = node.inputs?.find((slot) => slot.name === name || slot.widget?.name === name);
|
||||
if (input?.link == null) return fallback;
|
||||
const graph = node.graph;
|
||||
let linkId = input.link;
|
||||
// A subgraph's output that comes straight from a literal inside it (Person
|
||||
// Swap's "Pick the model files" hands out its video fps that way) counts as
|
||||
// that literal: it is still a typed number, not a calculation.
|
||||
function tableLink(graph, id) {
|
||||
if (id == null || !graph) return null;
|
||||
return graph.getLink?.(id) ?? graph.links?.get?.(id) ?? graph.links?.[id] ?? graph._links?.get?.(id) ?? null;
|
||||
}
|
||||
|
||||
// The link into one of a node's inputs: the frontend's own accessor first
|
||||
// (newer frontends warn on reading input.link), the link table after it.
|
||||
// undefined when nothing is connected.
|
||||
function linkInto(node, index, graph) {
|
||||
if (typeof node?.getInputLink === "function" && node.graph) {
|
||||
try {
|
||||
return node.getInputLink(index) ?? undefined;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
const id = node?.inputs?.[index]?.link;
|
||||
return id == null ? undefined : tableLink(node.graph ?? graph, id);
|
||||
}
|
||||
|
||||
// Where a linked input really comes from: the node and output slot at the
|
||||
// far end, through Reroutes and into a subgraph whose output is wired
|
||||
// straight to a node inside it. null for a muted or bypassed source, a loop,
|
||||
// or a subgraph output with nothing behind it. undefined when the input is
|
||||
// not linked at all.
|
||||
export function linkOrigin(node, name) {
|
||||
const index = node?.inputs?.findIndex((slot) => slot?.name === name || slot?.widget?.name === name) ?? -1;
|
||||
if (index < 0) return undefined;
|
||||
let graph = node.graph;
|
||||
let link = linkInto(node, index, graph);
|
||||
if (link === undefined) return undefined;
|
||||
const seen = new Set();
|
||||
for (let depth = 0; depth < 16; depth++) {
|
||||
if (seen.has(linkId)) return null;
|
||||
seen.add(linkId);
|
||||
const link = graph?.links?.[linkId] ?? graph?._links?.get?.(linkId);
|
||||
const source = graph?.getNodeById?.(link?.origin_id);
|
||||
if (!link || seen.has(link)) return null;
|
||||
seen.add(link);
|
||||
const source = graph?.getNodeById?.(link.origin_id);
|
||||
if (!source || (source.mode ?? 0) !== 0) return null;
|
||||
if (source.type === "Reroute") {
|
||||
linkId = source.inputs?.[0]?.link;
|
||||
if (linkId == null) return null;
|
||||
if ((source.comfyClass ?? source.type) === "Reroute") {
|
||||
link = linkInto(source, 0, graph) ?? null;
|
||||
continue;
|
||||
}
|
||||
if (!["PrimitiveFloat", "PrimitiveInt", "AUSBOSS_NODES_Integer", "AUSBOSS_NODES_Float"].includes(source.type) || link.origin_slot !== 0) return null;
|
||||
if (source.inputs?.some((slot) => slot.name === "value" && slot.link != null)) return null;
|
||||
const value = source.widgets?.find((widget) => widget.name === "value")?.value;
|
||||
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
||||
const inner = source.subgraph;
|
||||
if (inner && typeof source.isSubgraphNode === "function" && source.isSubgraphNode()) {
|
||||
link = tableLink(inner, inner.outputs?.[link.origin_slot]?.linkIds?.[0]);
|
||||
graph = inner;
|
||||
continue;
|
||||
}
|
||||
return { node: source, slot: link.origin_slot };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const LITERALS = ["PrimitiveFloat", "PrimitiveInt", "AUSBOSS_NODES_Integer", "AUSBOSS_NODES_Float"];
|
||||
|
||||
export function inputNumber(node, name, fallback) {
|
||||
const origin = linkOrigin(node, name);
|
||||
if (origin === undefined) return fallback;
|
||||
if (!origin) return null;
|
||||
const { node: source, slot } = origin;
|
||||
// ComfyUI's older Primitive node holds the value of the widget it feeds.
|
||||
if ((source.comfyClass ?? source.type) === "PrimitiveNode") {
|
||||
const value = source.widgets?.[0]?.value;
|
||||
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
||||
}
|
||||
if (!LITERALS.includes(source.type) || slot !== 0) return null;
|
||||
if (source.inputs?.some((input) => input.name === "value" && input.link != null)) return null;
|
||||
const value = source.widgets?.find((widget) => widget.name === "value")?.value;
|
||||
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
||||
}
|
||||
|
||||
export function clipOutputRate(node, sourceFps, everyNth = 1) {
|
||||
const forced = inputNumber(node, "force_rate", 0);
|
||||
const nth = inputNumber(node, "every_nth", everyNth);
|
||||
|
||||
+114
-11
@@ -4,6 +4,7 @@
|
||||
// source of truth: a chip only changes their value.
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { BRAND, chainCallback } from "./index.mjs";
|
||||
import { THEME as T, FONT_UI } from "./theme.mjs";
|
||||
import { liftSocket } from "./widget_card.mjs";
|
||||
import { commitWidgetValue, comboValues } from "./widget_card_math.mjs";
|
||||
|
||||
@@ -21,9 +22,15 @@ function ensureCss() {
|
||||
.ausboss-chip img{flex:none;width:18px;height:18px;margin-left:-5px;border-radius:9px;object-fit:cover}
|
||||
.ausboss-chip b{flex:none;color:${BRAND};font:700 10px ui-monospace,SFMono-Regular,Menlo,monospace}
|
||||
.ausboss-chip em{flex:none;color:#6f8886;font-style:normal;font-weight:500}
|
||||
.ausboss-chip select{field-sizing:content;min-width:0;max-width:120px;height:22px;padding:0 11px 0 0;border:none;background:transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' fill='none' stroke='%236f8886' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right 1px center;color:#d8ecea;font:inherit;appearance:none;-webkit-appearance:none;cursor:pointer;text-overflow:ellipsis}
|
||||
.ausboss-chip select:focus-visible{outline:2px solid ${BRAND};outline-offset:2px}
|
||||
.ausboss-chip select option{background:#0f1516;color:#d8ecea}
|
||||
.ausboss-chip-pick{min-width:0;max-width:120px;height:22px;padding:0 12px 0 0;border:none;background:transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' fill='none' stroke='%236f8886' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right 1px center;color:#d8ecea;font:inherit;cursor:pointer;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-align:left}
|
||||
.ausboss-chip-pick:focus-visible{outline:2px solid ${BRAND};outline-offset:2px;border-radius:3px}
|
||||
.ausboss-chip.open{border-color:${BRAND}}
|
||||
.ausboss-chip-menu{position:fixed;z-index:10000;box-sizing:border-box;padding:.33em;border:1px solid ${T.rule};border-radius:.66em;background:${T.card};box-shadow:0 10px 32px rgba(0,0,0,.55);font:500 12px/1.25 ${FONT_UI};color:${T.inkSoft}}
|
||||
.ausboss-chip-item{display:flex;align-items:center;gap:.5em;padding:.45em .75em .45em .5em;border-radius:.4em;white-space:nowrap;cursor:pointer;user-select:none}
|
||||
.ausboss-chip-item::before{content:"";flex:none;width:.9em;text-align:center;color:${T.brand}}
|
||||
.ausboss-chip-item.current::before{content:"\\2713"}
|
||||
.ausboss-chip-item.current{color:${T.brandInk}}
|
||||
.ausboss-chip-item.hot{background:${T.fill};color:${T.ink}}
|
||||
.ausboss-chip.off{border-style:dashed;background:transparent;color:#56706d}
|
||||
.ausboss-chip.off:hover{border-color:#2a3437}
|
||||
.ausboss-chip.wired{color:#8ba3a1}
|
||||
@@ -56,17 +63,109 @@ function add(parent, tag, text, className) {
|
||||
return child;
|
||||
}
|
||||
|
||||
// The open job list, one at a time across every chip on the page.
|
||||
let openMenu = null;
|
||||
|
||||
// The job list a chip opens. A native <select> lets the browser draw its own
|
||||
// list (small system font, light highlight, pinned to the select's left
|
||||
// edge); this one wears the node's colours, sits under the whole chip and
|
||||
// grows with the canvas zoom like the chip does.
|
||||
function openJobMenu(chipElement, button, values, current, choose) {
|
||||
openMenu?.close();
|
||||
const menu = add(document.body, "div", undefined, "ausboss-chip-menu");
|
||||
menu.setAttribute("role", "listbox");
|
||||
const items = values.map((value) => {
|
||||
const item = add(menu, "div", value, "ausboss-chip-item");
|
||||
item.setAttribute("role", "option");
|
||||
if (value === current) { item.classList.add("current"); item.setAttribute("aria-selected", "true"); }
|
||||
return item;
|
||||
});
|
||||
let hot = -1;
|
||||
const setHot = (index) => {
|
||||
items[hot]?.classList.remove("hot");
|
||||
hot = (index + items.length) % items.length;
|
||||
items[hot]?.classList.add("hot");
|
||||
items[hot]?.scrollIntoView({ block: "nearest" });
|
||||
};
|
||||
setHot(Math.max(0, values.indexOf(current)));
|
||||
|
||||
// The chip is drawn scaled with the canvas: the list matches that size,
|
||||
// starts at the chip's left edge and is at least as wide as the chip.
|
||||
function place() {
|
||||
const box = chipElement.getBoundingClientRect();
|
||||
const zoom = Math.min(2.5, Math.max(0.85, box.height / (chipElement.offsetHeight || 24)));
|
||||
menu.style.fontSize = `${12 * zoom}px`;
|
||||
menu.style.minWidth = `${box.width}px`;
|
||||
const width = menu.offsetWidth;
|
||||
const height = menu.offsetHeight;
|
||||
let top = box.bottom + 4;
|
||||
if (top + height > window.innerHeight - 8 && box.top - height - 4 >= 8) top = box.top - height - 4;
|
||||
menu.style.left = `${Math.max(8, Math.min(box.left, window.innerWidth - width - 8))}px`;
|
||||
menu.style.top = `${Math.max(8, top)}px`;
|
||||
}
|
||||
|
||||
const abort = new AbortController();
|
||||
const close = () => {
|
||||
abort.abort();
|
||||
menu.remove();
|
||||
chipElement.classList.remove("open");
|
||||
if (openMenu?.menu === menu) openMenu = null;
|
||||
};
|
||||
const pick = (index) => { close(); button.focus(); choose(values[index]); };
|
||||
items.forEach((item, index) => {
|
||||
item.addEventListener("pointermove", () => { if (hot !== index) setHot(index); });
|
||||
item.addEventListener("click", () => pick(index));
|
||||
});
|
||||
menu.addEventListener("pointerdown", (event) => event.stopPropagation());
|
||||
const outside = (event) => !menu.contains(event.target) && !button.contains(event.target);
|
||||
const on = { capture: true, signal: abort.signal };
|
||||
window.addEventListener("pointerdown", (event) => { if (outside(event)) close(); }, on);
|
||||
window.addEventListener("wheel", (event) => { if (outside(event)) close(); }, { ...on, passive: true });
|
||||
// The page fires resize on its own now and then: the list follows the chip
|
||||
// instead of vanishing, and goes only when the chip itself is gone.
|
||||
window.addEventListener("resize", () => (chipElement.isConnected ? place() : close()), on);
|
||||
// Only the window itself losing focus (another app, another tab). Pressing an item takes
|
||||
// focus off the chip's button, and a capturing blur listener would hear that and close
|
||||
// the list before the click lands. The press keeps focus on the button instead.
|
||||
window.addEventListener("blur", (event) => { if (event.target === window) close(); }, { signal: abort.signal });
|
||||
menu.addEventListener("mousedown", (event) => event.preventDefault());
|
||||
window.addEventListener("keydown", (event) => {
|
||||
const step = { ArrowDown: 1, ArrowUp: -1 }[event.key];
|
||||
if (step) setHot(hot + step);
|
||||
else if (event.key === "Home") setHot(0);
|
||||
else if (event.key === "End") setHot(items.length - 1);
|
||||
else if (event.key === "Enter" || event.key === " ") pick(hot);
|
||||
else if (event.key === "Escape" || event.key === "Tab") { close(); if (event.key === "Escape") button.focus(); }
|
||||
else return;
|
||||
if (event.key !== "Tab") { event.preventDefault(); event.stopPropagation(); }
|
||||
}, on);
|
||||
|
||||
place();
|
||||
chipElement.classList.add("open");
|
||||
openMenu = { owner: button, menu, close };
|
||||
}
|
||||
|
||||
function choice(node, name, into) {
|
||||
const widget = widgetOf(node, name);
|
||||
const select = add(into, "select");
|
||||
for (const value of comboValues(widget)) add(select, "option", value).value = value;
|
||||
select.value = widget?.value ?? "";
|
||||
select.title = widget?.options?.tooltip ?? "";
|
||||
select.addEventListener("change", () => {
|
||||
if (widget) commitWidgetValue(node, widget, select.value, app.canvas);
|
||||
const button = add(into, "button", undefined, "ausboss-chip-pick");
|
||||
button.type = "button";
|
||||
button.setAttribute("aria-haspopup", "listbox");
|
||||
button.title = widget?.options?.tooltip ?? "";
|
||||
const show = (value) => { button.textContent = String(value ?? ""); };
|
||||
show(widget?.value);
|
||||
const choose = (value) => {
|
||||
show(value);
|
||||
if (widget && value !== widget.value) commitWidgetValue(node, widget, value, app.canvas);
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
};
|
||||
button.addEventListener("pointerdown", (event) => event.stopPropagation());
|
||||
button.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
if (openMenu?.owner === button) { openMenu.close(); return; }
|
||||
const values = comboValues(widget).map(String);
|
||||
openJobMenu(into, button, values, String(widget?.value ?? ""), choose);
|
||||
});
|
||||
return (values) => { if (document.activeElement !== select) select.value = values[name] ?? ""; };
|
||||
return (values) => { if (openMenu?.owner !== button) show(values[name]); };
|
||||
}
|
||||
|
||||
// The jobs have no socket of their own, but a page saved by an earlier
|
||||
@@ -90,6 +189,7 @@ export function castChips(node) {
|
||||
let syncs = [];
|
||||
let latest = {};
|
||||
const build = (values) => {
|
||||
if (openMenu && element.contains(openMenu.owner)) openMenu.close();
|
||||
element.textContent = "";
|
||||
syncs = [];
|
||||
for (const number of [1, 2, 3, 4]) {
|
||||
@@ -136,7 +236,10 @@ export function castChips(node) {
|
||||
for (const run of syncs) run(values);
|
||||
};
|
||||
const watch = setInterval(() => sync(latest), WATCH);
|
||||
chainCallback(node, "onRemoved", () => clearInterval(watch));
|
||||
chainCallback(node, "onRemoved", () => {
|
||||
clearInterval(watch);
|
||||
if (openMenu && element.contains(openMenu.owner)) openMenu.close();
|
||||
});
|
||||
chainCallback(node, "onConfigure", () => queueMicrotask(() => keepOldJobLinks(node)));
|
||||
return { element, sync };
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { linkOrigin } from "./clip_rate.mjs";
|
||||
|
||||
// The same live-input rule used by the writer timeline: muted/bypassed
|
||||
// sources do not reach this node. This inspects the wire, never media bytes.
|
||||
export function linkSource(node, name) {
|
||||
@@ -9,8 +11,45 @@ export function linkSource(node, name) {
|
||||
return (source?.mode ?? 0) === 0 ? source ?? null : null;
|
||||
}
|
||||
|
||||
// Keep in step with Python video_frames (node_h3_prompt_writer.py): H3 makes
|
||||
// 5 frames plus steps of 17, at most 15 s at 24 fps, rounding a clip down.
|
||||
export const H3_FPS = 24;
|
||||
export function h3VideoFrames(frames) {
|
||||
const count = Math.trunc(Number(frames));
|
||||
if (!(count > 0)) return null;
|
||||
return Math.max(1, Math.floor((Math.min(count, 15 * H3_FPS) - 5) / 17)) * 17 + 5;
|
||||
}
|
||||
|
||||
// What the clip node's face last worked out for its run ({frames,
|
||||
// startSeconds, endSeconds}), or null when the clip is not that node or its
|
||||
// count is only known at run time.
|
||||
export function clipTimingFor(node) {
|
||||
// Through Reroutes and subgraphs, as every linked value is read.
|
||||
const timing = linkOrigin(node, "video")?.node?.__ausbossClipTiming;
|
||||
return timing && timing.frames > 0 ? timing : null;
|
||||
}
|
||||
|
||||
// The words under "From the clip": what H3 will make of the clip's frames.
|
||||
export function clipLengthWords(timing) {
|
||||
if (!timing) return null;
|
||||
const made = h3VideoFrames(timing.frames);
|
||||
const seconds = (frames) => String(Number((frames / H3_FPS).toFixed(2)));
|
||||
if (made < timing.frames) {
|
||||
const up = made + 17;
|
||||
const room = timing.roomFrames ?? Infinity;
|
||||
const stops = timing.startSeconds + made / H3_FPS;
|
||||
return {
|
||||
title: `H3 makes ${made} of the clip's ${timing.frames} frames · ${seconds(made)} s`,
|
||||
note: `Stops at ${String(Number(stops.toFixed(2)))} s in the video. To use all of it, set the clip's Duration to ${seconds(made)} s${up <= Math.min(room, 15 * H3_FPS) ? ` or ${seconds(up)} s` : ""}.`,
|
||||
warn: true,
|
||||
};
|
||||
}
|
||||
if (made === timing.frames) return { title: `H3 uses all ${made} frames · ${seconds(made)} s`, note: "The clip is already a length H3 makes.", warn: false };
|
||||
return { title: `H3 makes ${made} frames · ${seconds(made)} s`, note: `That is its shortest length; the clip has ${timing.frames} frames.`, warn: true };
|
||||
}
|
||||
|
||||
// Keep in step with Python KEEPS_ITS_LENGTH. Other jobs use seconds normally.
|
||||
export function clipSetsDuration(node, values) {
|
||||
return ["swap the person", "new voice", "change something"].includes(values.video_job)
|
||||
return ["copy its moves", "swap the person", "new voice", "change something"].includes(values.video_job)
|
||||
&& linkSource(node, "video") !== null;
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import { app } from "../../../scripts/app.js";
|
||||
// Must match `version` in pyproject.toml — scripts/release_preflight.py
|
||||
// enforces it. The backend serves its copy at /ausboss/pack_version; a
|
||||
// mismatch means the browser cached JavaScript from an older install.
|
||||
export const AUSBOSS_JS_VERSION = "2.25.2";
|
||||
export const AUSBOSS_JS_VERSION = "2.26.3";
|
||||
|
||||
export const BRAND = "#00b4aa"; // AusBoss teal — keep node accents consistent.
|
||||
export const BRAND_DARK = "#007f78";
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
// what it always was. The turn is made in canvas pixels, so a turned box is a
|
||||
// true rectangle on a canvas of any shape (nodes/_layout_boxes_helpers.py
|
||||
// turns it the same way).
|
||||
import { linkOrigin } from "./clip_rate.mjs";
|
||||
|
||||
export const DIM_MIN = 64;
|
||||
export const DIM_MAX = 16384;
|
||||
@@ -683,8 +684,10 @@ const isNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
||||
// (Integer, Primitive). Reroutes are followed. Null when the input is not
|
||||
// wired or the value is only known once the workflow runs.
|
||||
export function wiredNumber(node, inputName) {
|
||||
const source = wiredSource(node, inputName);
|
||||
return source ? wiredFrom(source.node, source.slot) : null;
|
||||
// Through Reroutes and into subgraphs (js/shared/clip_rate.mjs), then
|
||||
// this node's own rule for which numbers count.
|
||||
const origin = linkOrigin(node, inputName);
|
||||
return origin ? wiredFrom(origin.node, origin.slot) : null;
|
||||
}
|
||||
|
||||
// The node (and its output slot) an input is wired to, through Reroutes.
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
// ComfyUI's missing-models list (the Issues panel, "Download all") only
|
||||
// looks at list widgets: a model is listed when a list on some node holds a
|
||||
// file name that is not one of its choices. LoRA Loader keeps its files in
|
||||
// the rows' text, so a LoRA a workflow needs never made that list, and
|
||||
// "Download all" then Run stopped on "missing LoRA file".
|
||||
//
|
||||
// The loader therefore carries one hidden list widget per row that needs a
|
||||
// file. Nothing else reads them: they are kept out of the saved workflow and
|
||||
// the prompt, have no socket, and are made again from the rows every time.
|
||||
// The rows stay the one source of truth.
|
||||
|
||||
import { resolveLoraName } from "./lora_stack.mjs";
|
||||
|
||||
export const FILE_WIDGET_PREFIX = "ausboss_lora_file_";
|
||||
export const FILE_WIDGET_FLAG = "ausbossLoraFile";
|
||||
|
||||
// Rows the server needs a file for when it runs: named, on, in a group that
|
||||
// is on, and not at zero strength (nodes/_lora_helpers.py, missing_lora_rows).
|
||||
export function rowsNeedingFiles(rows) {
|
||||
return (Array.isArray(rows) ? rows : []).filter((row) => {
|
||||
const name = typeof row?.name === "string" ? row.name.trim() : "";
|
||||
if (!name || row.enabled === false || row.group_off === true) return false;
|
||||
const strength = Number(row.strength ?? 1);
|
||||
const clip = Number(row.strength_clip ?? strength);
|
||||
return !(strength === 0 && clip === 0);
|
||||
});
|
||||
}
|
||||
|
||||
// The list ComfyUI checks a row's file against. A file the loader would
|
||||
// find anyway (saved in another folder, or with other capitals) counts as
|
||||
// installed; so does every file while the install's list is unknown, so a
|
||||
// slow list never shows a false alarm.
|
||||
export function fileChoices(name, installed) {
|
||||
if (!Array.isArray(installed)) return [name];
|
||||
return resolveLoraName(name, installed).status === "missing" ? installed : [...installed, name];
|
||||
}
|
||||
|
||||
// The install's LoRA files as ComfyUI's own LoRA loader lists them. The node
|
||||
// list arrives before any workflow opens, so this answers at once; null when
|
||||
// there is no such node to ask.
|
||||
export function coreLoraList(definition) {
|
||||
const spec = definition?.input?.required?.lora_name;
|
||||
if (!Array.isArray(spec)) return null;
|
||||
if (Array.isArray(spec[0])) return spec[0];
|
||||
if (spec[0] === "COMBO" && Array.isArray(spec[1]?.options)) return spec[1].options;
|
||||
return null;
|
||||
}
|
||||
|
||||
export function isFileWidget(widget) {
|
||||
return Boolean(widget?.[FILE_WIDGET_FLAG]);
|
||||
}
|
||||
|
||||
// Bring the node's file widgets in line with its rows. `installed()` returns
|
||||
// the install's files (or null), `hide(widget)` folds a widget away, and
|
||||
// `onPick(rowId, name)` runs when ComfyUI puts another file in a widget
|
||||
// (choosing a replacement in the Issues panel). Returns true when a widget
|
||||
// was added or removed.
|
||||
export function syncFileWidgets(node, rows, { installed, hide, onPick }) {
|
||||
if (!node || !Array.isArray(node.widgets)) return false;
|
||||
const needed = rowsNeedingFiles(rows);
|
||||
const current = node.widgets.filter(isFileWidget);
|
||||
let changed = false;
|
||||
needed.forEach((row, index) => {
|
||||
let widget = current[index];
|
||||
if (!widget) {
|
||||
widget = node.addWidget("combo", `${FILE_WIDGET_PREFIX}${index + 1}`, row.name, (value) => {
|
||||
if (typeof value === "string" && value !== widget.ausbossRowName) onPick?.(widget.ausbossRowId, value);
|
||||
}, { values: () => fileChoices(widget.value, installed?.()), serialize: false });
|
||||
widget[FILE_WIDGET_FLAG] = true;
|
||||
widget.serialize = false;
|
||||
hide?.(widget);
|
||||
changed = true;
|
||||
}
|
||||
widget.value = row.name;
|
||||
widget.ausbossRowName = row.name;
|
||||
widget.ausbossRowId = row.id;
|
||||
});
|
||||
for (const widget of current.slice(needed.length)) {
|
||||
if (typeof node.removeWidget === "function") node.removeWidget(widget);
|
||||
else {
|
||||
const at = node.widgets.indexOf(widget);
|
||||
if (at >= 0) node.widgets.splice(at, 1);
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// bar as long as the clip, with the cuts as marks. The server reads the script with the same code a run uses,
|
||||
// so the bar shows what will happen. It also colours the script box, so the
|
||||
// words the node reads as instructions (@1, 3s:, a cut) stand out.
|
||||
import { clipSetsDuration, linkSource } from "./h3_duration.mjs";
|
||||
import { clipLengthWords, clipSetsDuration, clipTimingFor, linkSource } from "./h3_duration.mjs";
|
||||
import { api } from "../../../scripts/api.js";
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { BRAND, chainCallback } from "./index.mjs";
|
||||
@@ -38,7 +38,8 @@ function ensureCss() {
|
||||
.ausboss-strip-handle::before{content:"";position:absolute;left:5px;top:5px;bottom:5px;width:2px;border-radius:1px;background:rgba(207,232,229,.35)}
|
||||
.ausboss-strip-handle:hover::before,.ausboss-strip-handle.dragging::before{background:#cfe8e5}
|
||||
.ausboss-strip-handle span{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);padding:1px 4px;border-radius:3px;background:#cfe8e5;color:#0b0f10;font-size:9px;white-space:nowrap;display:none}
|
||||
.ausboss-strip-handle.dragging span{display:block}
|
||||
.ausboss-strip-handle:hover span,.ausboss-strip-handle.dragging span{display:block}
|
||||
.ausboss-strip-handle.cuts::before{background:${BRAND}}
|
||||
.ausboss-strip-block.movable{cursor:grab;touch-action:none}
|
||||
.ausboss-strip-block.moving{z-index:3;cursor:grabbing;opacity:.85;box-shadow:0 4px 14px rgba(0,0,0,.5)}
|
||||
.ausboss-strip-drop{position:absolute;top:-3px;bottom:-3px;z-index:4;width:3px;margin-left:-2px;border-radius:2px;background:#f5b53d;pointer-events:none}
|
||||
@@ -108,7 +109,12 @@ export function momentStrip(node) {
|
||||
const label = document.createElement("span");
|
||||
handle.append(label);
|
||||
handle.style.left = `${rows[index].from}%`;
|
||||
handle.title = range ? "Drag to set when this moment starts. Click to add or remove a cut." : "Click to add or remove a cut.";
|
||||
const isCut = Boolean(rows[index].cut);
|
||||
handle.classList.toggle("cuts", isCut);
|
||||
// Shown on hover: what a click does here. Dragging swaps it for the time.
|
||||
const hint = isCut ? "\u2702 join" : "\u2702 cut";
|
||||
label.textContent = hint;
|
||||
handle.title = `${isCut ? "Click to join these two shots." : "Click to cut to a new shot here."}${range ? " Drag to set when this moment starts." : ""}`;
|
||||
track.append(handle);
|
||||
handle.addEventListener("pointerdown", (event) => {
|
||||
if (event.button !== 0) return;
|
||||
@@ -134,6 +140,7 @@ export function momentStrip(node) {
|
||||
handle.removeEventListener("pointerup", stop);
|
||||
handle.removeEventListener("pointercancel", stop);
|
||||
handle.classList.remove("dragging");
|
||||
label.textContent = hint;
|
||||
if (!moved) commitScript((text) => toggleCut(text, rows[index].line));
|
||||
else if (second !== null && second !== rows[index].start) commitScript((text) => retime(text, rows[index].line, second));
|
||||
};
|
||||
@@ -290,12 +297,15 @@ export function momentStrip(node) {
|
||||
asked += 1;
|
||||
ruler.textContent = "";
|
||||
track.textContent = "";
|
||||
const message = el("ausboss-strip-words", "Length comes from the clip");
|
||||
// Say what H3 will make of the clip's frames, when the clip node knows
|
||||
// its count; it rounds down to 5 + 17n, so a 48-frame clip gives 39.
|
||||
const words = clipLengthWords(clipTimingFor(node));
|
||||
const message = el("ausboss-strip-words", words?.title ?? "Length comes from the clip");
|
||||
message.style.cssText = "display:flex;align-items:center;height:100%";
|
||||
track.append(message);
|
||||
note.textContent = "Set the clip's length upstream. Timing controls are unavailable here.";
|
||||
note.textContent = words?.note ?? "Set the clip's length on the clip node. H3 makes 5 + 17n frames (22, 39, 56 ...), rounding the clip down.";
|
||||
note.title = note.textContent;
|
||||
note.classList.remove("warn");
|
||||
note.classList.toggle("warn", Boolean(words?.warn));
|
||||
return;
|
||||
}
|
||||
if (wired(node, "script")) {
|
||||
|
||||
@@ -59,14 +59,15 @@ export function dragRange(rows, index, seconds) {
|
||||
export function stripCaption(report) {
|
||||
if (report?.warning) return { text: report.warning, warn: true };
|
||||
const moments = report?.moments ?? [];
|
||||
if (!moments.length) return { text: "Each line becomes a moment.", warn: false };
|
||||
if (!moments.length) return { text: "Each line becomes a moment. A blank line between lines is a cut.", warn: false };
|
||||
const count = moments.length === 1 ? "1 moment" : `${moments.length} moments`;
|
||||
const cuts = moments.filter((moment) => moment.cut).length;
|
||||
if (cuts) return { text: `${count}, ${cuts === 1 ? "1 cut" : `${cuts} cuts`}.`, warn: false };
|
||||
// Say how to cut, since nothing on the bar shows it until you hover an edge.
|
||||
if (cuts) return { text: `${count}, ${cuts === 1 ? "1 cut" : `${cuts} cuts`}. Click a cut on the bar to join the shots.`, warn: false };
|
||||
const each = moments.map((moment) => trimmed(moment.end - moment.start));
|
||||
if (moments.length === 1) return { text: `${count}, ${each[0]} s, one take.`, warn: false };
|
||||
if (moments.length === 1) return { text: `${count}, ${each[0]} s, one take. Add a line for the next moment, a blank line to cut.`, warn: false };
|
||||
const even = each.every((length) => length === each[0]);
|
||||
return { text: even ? `${count}, ${each[0]} s each, one take.` : `${count}, one take.`, warn: false };
|
||||
return { text: `${even ? `${count}, ${each[0]} s each` : count}, one take. Click between two moments to cut there.`, warn: false };
|
||||
}
|
||||
|
||||
// The seconds the bar under the script marks: every second up to 10 s,
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
// 2.0 draws each node as an element on the page, which can run past those
|
||||
// bounds (its frame, a footer), so there the element itself is measured.
|
||||
// Groups are drawn on the canvas in both looks.
|
||||
//
|
||||
// A frameless tile (a link tile, a title, a note tile) draws only a card
|
||||
// inside a transparent node, so what people see is the card, not the node's
|
||||
// bounds. Such a node names that card as `ausbossOutlineElement`, and its
|
||||
// outline is the card's, in both looks.
|
||||
|
||||
function graphRectOf(element, canvas) {
|
||||
const box = element.getBoundingClientRect();
|
||||
@@ -34,6 +39,11 @@ export function nodeElements() {
|
||||
}
|
||||
|
||||
export function outlineOf(item, canvas, { node = true, elements = null } = {}) {
|
||||
const face = node && !item?.flags?.collapsed ? item?.ausbossOutlineElement : null;
|
||||
if (face?.isConnected && canvas?.canvas && canvas.ds) {
|
||||
const rect = graphRectOf(face, canvas);
|
||||
if (rect) return rect;
|
||||
}
|
||||
if (node && globalThis.LiteGraph?.vueNodesMode === true && item?.id != null && canvas?.canvas && canvas.ds) {
|
||||
const element = elements
|
||||
? elements.get(String(item.id))
|
||||
|
||||
@@ -28,11 +28,15 @@ export function setTileFace(node, root, enabled, onEdit) {
|
||||
});
|
||||
}
|
||||
const listeners = new AbortController();
|
||||
// Snap into line and Line up use the card people see, not the
|
||||
// transparent node around it (js/shared/outline.mjs).
|
||||
node.ausbossOutlineElement = root.querySelector(".ausboss-callout-card,.ausboss-note-card") || root;
|
||||
installTileDrag(node, root, listeners.signal, onEdit);
|
||||
installTileResize(node, root, listeners.signal);
|
||||
originalDescriptors.set(node, { descriptors, listeners });
|
||||
} else {
|
||||
previous.listeners.abort();
|
||||
delete node.ausbossOutlineElement;
|
||||
for (const [key, descriptor] of previous.descriptors) {
|
||||
if (descriptor) Object.defineProperty(node, key, descriptor);
|
||||
else delete node[key];
|
||||
@@ -44,6 +48,9 @@ export function setTileFace(node, root, enabled, onEdit) {
|
||||
|
||||
function skipBadges() {}
|
||||
|
||||
// Sent from a tile's own drag after each move: js/snap_lines/ lines it up.
|
||||
export const TILE_MOVE = "ausboss-tile-move";
|
||||
|
||||
// A normal node moves by its header. Give the tile that gesture while
|
||||
// keeping a short click on a link or the info button as its usual action.
|
||||
function installTileDrag(node, root, signal, onEdit) {
|
||||
@@ -87,6 +94,9 @@ function installTileDrag(node, root, signal, onEdit) {
|
||||
for (const start of press.starts) start.item.pos = [start.x + dx / zoom, start.y + dy / zoom];
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
event.stopPropagation();
|
||||
// The move stops here (Nodes 2.0 would pan the canvas with it), so tell
|
||||
// Snap into line separately, after the tile has been placed.
|
||||
root.dispatchEvent(new CustomEvent(TILE_MOVE, { bubbles: true, detail: event }));
|
||||
}, capture);
|
||||
const finish = (event) => {
|
||||
if (event.pointerId !== press?.id) return;
|
||||
|
||||
@@ -273,7 +273,14 @@ export function clipLengthPlan(info, values = {}) {
|
||||
latestStart = clamp(Math.floor((end - lastTick - TRIM_EPSILON) * info.fps), 0, endFrame);
|
||||
}
|
||||
}
|
||||
if (values.resampled) return { ...base, last: cap > 0 ? null : window.last, requested, latestStart };
|
||||
if (values.resampled) {
|
||||
// A known output rate places every output frame: the backend samples
|
||||
// and holds on ticks at start + k / rate (decode_video_range), so the
|
||||
// count, the last source frame shown and the end are all known here.
|
||||
if (!(values.outputFps > 0) || !(info.fps > 0)) return { ...base, last: cap > 0 ? null : window.last, requested, latestStart };
|
||||
const resampled = resampledFrames(info, values, nth, requested, snap);
|
||||
return { ...base, ...resampled, requested, latestStart, truncated: requested != null && resampled.frames < requested };
|
||||
}
|
||||
const kept = keptFrames(window, nth, cap, snap);
|
||||
return { ...base, last: kept.lastKept, frames: kept.frames, requested, latestStart, truncated: requested != null && kept.frames < requested };
|
||||
};
|
||||
@@ -288,6 +295,27 @@ export function clipLengthPlan(info, values = {}) {
|
||||
return capped(mode === "length" ? stored : 0);
|
||||
}
|
||||
|
||||
// Output frames of a run that resamples to a known rate: ticks at
|
||||
// start + k / tickRate while before the end, thinned by every nth, capped,
|
||||
// then snapped. `last` is the source frame the final tick holds.
|
||||
export function resampledFrames(info, values, everyNth = 1, cap = null, snap = "free") {
|
||||
const nth = Math.max(1, Math.floor(finite(everyNth, 1)) || 1);
|
||||
const tickRate = finite(values.outputFps) * nth;
|
||||
const duration = info.duration || info.count / info.fps;
|
||||
const start = Math.max(0, finite(values.start));
|
||||
const end = finite(values.end) > 0 ? Math.min(finite(values.end), duration) : duration;
|
||||
const ticks = Math.max(0, Math.ceil((end - start) * tickRate - TRIM_EPSILON));
|
||||
let frames = Math.ceil(ticks / nth);
|
||||
if (cap != null && cap > 0) frames = Math.min(frames, cap);
|
||||
frames = snapFrameCount(frames, snap);
|
||||
const first = frameWindow(info, start, values.end).first;
|
||||
const lastTime = start + Math.max(0, frames - 1) * nth / tickRate;
|
||||
const last = clamp(Math.floor(lastTime * info.fps + TRIM_EPSILON), first, info.count - 1);
|
||||
const windowLast = frameWindow(info, start, values.end).last;
|
||||
// The last frame is held for one output frame, but never past the video.
|
||||
return { first, last, windowLast, frames, endSeconds: Math.min(end, start + frames / finite(values.outputFps)) };
|
||||
}
|
||||
|
||||
// Playback rate for a label, trimmed of float noise: 24 -> "24",
|
||||
// 23.976023... -> "23.976".
|
||||
export function formatFps(value) {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// Small pieces every timing card shares (the clip node, Load Video, Load
|
||||
// Audio): the seconds | frames choice and the "linked" button that goes to
|
||||
// the node feeding a value.
|
||||
import { app } from "../../../scripts/app.js";
|
||||
|
||||
// Seconds or frames on a timing card: a per-browser choice, like a view
|
||||
// setting. It never changes a stored value.
|
||||
const UNITS_KEY = "AusBoss.ClipTiming.Units";
|
||||
let unitsCache = null;
|
||||
export function timingUnits(next) {
|
||||
if (next === "s" || next === "f") {
|
||||
unitsCache = next;
|
||||
try { localStorage.setItem(UNITS_KEY, next); } catch { /* private window */ }
|
||||
return next;
|
||||
}
|
||||
if (unitsCache) return unitsCache;
|
||||
try { unitsCache = localStorage.getItem(UNITS_KEY) === "f" ? "f" : "s"; } catch { unitsCache = "s"; }
|
||||
return unitsCache;
|
||||
}
|
||||
|
||||
// The node feeding a linked input, by its title, with a way to go to it.
|
||||
export function linkedNodeInfo(node, name) {
|
||||
const slot = node.inputs?.find((input) => input?.name === name || input?.widget?.name === name);
|
||||
if (slot?.link == null) return null;
|
||||
const graph = node.graph;
|
||||
const link = graph?.links?.get?.(slot.link) ?? graph?.links?.[slot.link] ?? graph?._links?.get?.(slot.link);
|
||||
const source = graph?.getNodeById?.(link?.origin_id);
|
||||
if (!source) return { title: "the subgraph's input", go: null };
|
||||
const title = source.title || source.type || "another node";
|
||||
return {
|
||||
title,
|
||||
go: () => {
|
||||
try {
|
||||
app.canvas?.selectNode?.(source);
|
||||
app.canvas?.centerOnNode?.(source);
|
||||
app.canvas?.setDirty?.(true, true);
|
||||
} catch { /* an older canvas */ }
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { api } from "../../../scripts/api.js";
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { linkedNodeInfo, timingUnits as clipUnits } from "./timing_links.mjs";
|
||||
import { PANEL_LABELS } from "./panel_controls.mjs";
|
||||
import { hideInputsInDef, hideWidget } from "./widget_visibility.mjs";
|
||||
import { mountTransformTrim } from "./transform_trim.mjs";
|
||||
@@ -81,6 +82,7 @@ import {
|
||||
} from "./transform_geometry.mjs";
|
||||
import { clampFrame, clipInfo, frameTime } from "./timeline_math.mjs";
|
||||
import { liftSocket } from "./widget_card.mjs";
|
||||
import { COPY_EDITS_SETTING, copyPicture, transformPicture } from "./transform_picture.mjs";
|
||||
|
||||
const HIDDEN_WIDGETS = [
|
||||
"image", "upload",
|
||||
@@ -103,11 +105,10 @@ const trimInputDriven = (node, name) => node.inputs?.some(
|
||||
|
||||
const RESIZE_METHODS = ["lanczos", "area", "bicubic", "bilinear", "nearest-exact"];
|
||||
// The widest the control rows get on a big node; the picture takes the rest.
|
||||
const CONTROL_MAX_WIDTH = 460;
|
||||
const TRANSFORM_DEFAULTS = resetTransformValues(false);
|
||||
const CORE_IMAGE_PREVIEW_WIDGET = "$$canvas-image-preview";
|
||||
|
||||
// The gear on the image node's source card. Display choices only, kept for
|
||||
// The gear on the image node's source card. Browser preferences, kept for
|
||||
// every image node on this browser (settings_menu.mjs stores them).
|
||||
const SETTINGS_SCOPE = "image_crop_rotate_pad";
|
||||
const SETTINGS_SCHEMA = [
|
||||
@@ -115,6 +116,7 @@ const SETTINGS_SCHEMA = [
|
||||
key: "show_mask", label: "Show the mask on the picture", type: "toggle", default: true,
|
||||
hint: "Teal over the parts of your picture the model paints: a mask drawn in the MaskEditor, or see-through parts of a PNG.",
|
||||
},
|
||||
COPY_EDITS_SETTING,
|
||||
];
|
||||
let transformSettings = null;
|
||||
function settings() {
|
||||
@@ -150,7 +152,7 @@ function installStyles() {
|
||||
style.id = "ausboss-transform-styles";
|
||||
style.textContent = `
|
||||
.ausboss-transform-panel{display:flex;flex-direction:column;gap:8px;padding:8px;color:#ddd;font:12px system-ui;box-sizing:border-box;width:100%;height:100%;overflow:hidden}
|
||||
.ausboss-transform-panel>:not(.ausboss-transform-preview){width:100%;max-width:${CONTROL_MAX_WIDTH}px;align-self:center;box-sizing:border-box}
|
||||
.ausboss-transform-panel>:not(.ausboss-transform-preview){width:100%;align-self:stretch;box-sizing:border-box}
|
||||
.ausboss-transform-preview{width:100%;flex:1 1 180px;min-height:0;border:1px solid #50555b;border-radius:8px;background:#111;display:block;touch-action:none}
|
||||
.ausboss-transform-source{display:flex;flex-direction:column;gap:7px;flex:0 0 auto;padding:8px;border:1px solid rgba(0,184,174,.28);border-radius:8px;background:rgba(0,0,0,.24)}
|
||||
.ausboss-transform-source-image{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center}
|
||||
@@ -189,13 +191,14 @@ function installStyles() {
|
||||
.ausboss-transform-group-meta{min-width:0;overflow:hidden;text-overflow:ellipsis}
|
||||
.ausboss-transform-group-body{display:flex;flex-direction:column;gap:7px;padding:8px;box-sizing:border-box}
|
||||
.ausboss-transform-group-body[hidden]{display:none}
|
||||
.ausboss-transform-readout{flex:0 0 auto;margin-top:-3px;color:#c9d0d6;font:11px/14px system-ui;font-variant-numeric:tabular-nums;text-align:center;overflow:hidden;cursor:default;user-select:none}
|
||||
.ausboss-transform-readout{flex:0 0 auto;margin:-5px 0 -3px;color:#c9d0d6;font:11px/14px system-ui;font-variant-numeric:tabular-nums;text-align:center;overflow:hidden;cursor:default;user-select:none}
|
||||
.ausboss-transform-readout:empty{display:none}
|
||||
.ausboss-transform-readout span{color:#8ca8a5}.ausboss-transform-readout b{color:#fff;font-weight:600}
|
||||
.ausboss-transform-readout>div,.ausboss-transform-readout i{display:flex;align-items:center;justify-content:center;gap:3px;height:14px;white-space:nowrap}
|
||||
.ausboss-transform-readout .ausboss-transform-ellipsis{min-width:0;overflow:hidden;text-overflow:ellipsis;color:inherit}
|
||||
.ausboss-transform-readout b,.ausboss-transform-readout button{flex:none}
|
||||
.ausboss-transform-readout i{color:#ffc46b;font-style:normal}
|
||||
.ausboss-transform-readout i:empty{display:none}
|
||||
.ausboss-transform-readout em{color:#8ca8a5;font-style:normal}
|
||||
.ausboss-transform-readout em.note.ausboss-transform-ellipsis{color:#ffc46b}
|
||||
.ausboss-transform-readout button{margin:0 0 0 6px;height:14px;padding:0 6px;border:1px solid #6b5a33;border-radius:3px;background:#2a2417;color:#ffd79a;font:600 9.5px/12px system-ui;cursor:pointer;vertical-align:top}
|
||||
@@ -2320,6 +2323,11 @@ function buildTrim(state) {
|
||||
onTogglePlayback: () => timelineCommand(state, "play"),
|
||||
onSeek: (frame, settled) => scrubTo(state, frame, settled),
|
||||
onCommit: notifyAusbossChange,
|
||||
linkInfo: (name) => linkedNodeInfo(state.node, name),
|
||||
// H3 Prompt Writer reads this to say what H3 makes of the clip.
|
||||
publish: (timing) => { state.node.__ausbossClipTiming = timing; },
|
||||
units: () => clipUnits(),
|
||||
setUnits: (next) => { clipUnits(next); for (const view of state.trimViews) view.sync(); },
|
||||
});
|
||||
state.trimViews.add(control);
|
||||
return control.root;
|
||||
@@ -2340,6 +2348,7 @@ function setPlayhead(state, index) {
|
||||
// also snaps the widgets to the decoded frame.
|
||||
function scrubTo(state, index, settled) {
|
||||
if (state.playing) stopPlayback(state, false);
|
||||
state.pausedAt = null;
|
||||
const frame = setPlayhead(state, index);
|
||||
syncTimelineRange(state);
|
||||
if (settled) { void seekFrame(state); return; }
|
||||
@@ -2400,7 +2409,11 @@ function startPlayback(state) {
|
||||
const trim = [...state.trimViews][0];
|
||||
const { first, last } = trim.window();
|
||||
const head = clampFrame(value(state.node, "frame_index", 0), info);
|
||||
let next = head < first || head >= last ? first : head + 1;
|
||||
// Play shows the clip from its start, so what plays is what the run
|
||||
// keeps; only a resume right after a pause inside the clip carries on.
|
||||
const resume = state.pausedAt != null && state.pausedAt === head && head >= first && head < last;
|
||||
let next = resume ? head + 1 : first;
|
||||
state.pausedAt = null;
|
||||
state.playing = true;
|
||||
syncTimelineRange(state);
|
||||
const session = ++state.playbackSession;
|
||||
@@ -2421,6 +2434,7 @@ function startPlayback(state) {
|
||||
function stopPlayback(state, settle = true) {
|
||||
const wasPlaying = Boolean(state.playing);
|
||||
state.playing = false;
|
||||
if (wasPlaying) state.pausedAt = clampFrame(value(state.node, "frame_index", 0), clipInfo(state.metadata));
|
||||
state.playbackSession = (state.playbackSession || 0) + 1; // orphan in-flight ticks
|
||||
if (state.playbackTimer) clearTimeout(state.playbackTimer);
|
||||
state.playbackTimer = null;
|
||||
@@ -3094,6 +3108,68 @@ function drawRotateGlyph(context, x, y, radius, color) {
|
||||
// node itself can still drag, and pointercancel plus mouseleave both end a
|
||||
// gesture in case the capture was refused.
|
||||
function attachStageHandlers(state, canvas, signal) {
|
||||
if (state.kind === "image") {
|
||||
canvas.addEventListener("contextmenu", (event) => {
|
||||
event.preventDefault(); event.stopPropagation();
|
||||
if (!state.image) return;
|
||||
const picture = async () => {
|
||||
let source = state.image;
|
||||
const sourceWidth = state.sourceWidth, sourceHeight = state.sourceHeight;
|
||||
const current = values(state.node), resize = resizeRequest(state.node);
|
||||
const includeEdits = settings().copy_edits;
|
||||
if (includeEdits && maskLayer(state)) {
|
||||
if (value(state.node, "painted_area", "fill") === "keep picture") {
|
||||
// The browser loses colours under fully transparent pixels. Core's
|
||||
// RGB view restores the stored picture under MaskEditor strokes.
|
||||
source = new Image();
|
||||
source.src = api.apiURL(`/view?${mediaViewQuery(value(state.node, "image", ""))}&channel=rgb`);
|
||||
await source.decode();
|
||||
} else {
|
||||
// The stage's mask layer is capped at 2048px. Copy from the source
|
||||
// at full size, using the same rule for which pixels stay picture.
|
||||
const full = document.createElement("canvas");
|
||||
full.width = sourceWidth; full.height = sourceHeight;
|
||||
const context = full.getContext("2d");
|
||||
context.drawImage(source, 0, 0);
|
||||
const pixels = context.getImageData(0, 0, full.width, full.height);
|
||||
const map = seeThroughMap(pixels.data);
|
||||
if (map) for (let i = 0; i < map.length; i++) pixels.data[i * 4 + 3] = map[i] ? 0 : 255;
|
||||
context.putImageData(pixels, 0, 0);
|
||||
source = full;
|
||||
}
|
||||
}
|
||||
return transformPicture({
|
||||
sourceWidth, sourceHeight, values: current, resize, includeEdits,
|
||||
fill: normalizeColor(current.fill_color),
|
||||
drawSource: (context) => context.drawImage(source, -sourceWidth / 2, -sourceHeight / 2, sourceWidth, sourceHeight),
|
||||
});
|
||||
};
|
||||
const report = (error) => showToast({ severity: "error", summary: "Copy image", detail: error?.message ?? String(error) });
|
||||
new globalThis.LiteGraph.ContextMenu([
|
||||
{ content: "Copy image", callback: () => {
|
||||
try {
|
||||
Promise.resolve(copyPicture(picture)).then(
|
||||
() => showToast({ summary: "Copy image", severity: "success", detail: "The picture is on the clipboard." }), report,
|
||||
);
|
||||
} catch (error) { report(error); }
|
||||
} },
|
||||
{ content: "Open image", callback: async () => {
|
||||
try {
|
||||
// A real image retains the browser's native Copy image on plain
|
||||
// HTTP too. A data URL stays usable for as long as the tab is open.
|
||||
const tab = window.open("about:blank", "_blank");
|
||||
if (!tab) throw new Error("Allow pop-ups to open the picture.");
|
||||
tab.opener = null;
|
||||
const image = tab.document.createElement("img");
|
||||
image.src = (await picture()).toDataURL("image/png");
|
||||
image.style.maxWidth = "100%";
|
||||
tab.document.title = "Crop image — right-click to copy";
|
||||
tab.document.body.append(image);
|
||||
} catch (error) { report(error); }
|
||||
} },
|
||||
], { event });
|
||||
}, { signal });
|
||||
}
|
||||
canvas.addEventListener("pointerdown", (event) => pointerDown(state, canvas, event), { signal });
|
||||
canvas.addEventListener("pointermove", (event) => pointerMove(state, canvas, event), { signal });
|
||||
canvas.addEventListener("pointerup", (event) => pointerUp(state, canvas, event), { signal });
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { keptCrop, resolveCrop, resolvePadding, rotatedSize, scaleToMegapixels } from "./transform_geometry.mjs";
|
||||
|
||||
export const COPY_EDITS_SETTING = Object.freeze({
|
||||
key: "copy_edits", label: "Copy with crop, rotation and padding", type: "toggle", default: false,
|
||||
hint: "Off: copy the original picture. On: include crop, rotation, padding and resize. Handles and guides are never copied.",
|
||||
});
|
||||
|
||||
// Render picture pixels into a separate canvas. The editor's canvas contains
|
||||
// handles, hatching and stage margins and must never be a clipboard source.
|
||||
export function transformPicture({ sourceWidth, sourceHeight, values, resize, fill, drawSource, includeEdits = false, createCanvas = () => document.createElement("canvas") }) {
|
||||
const canvas = createCanvas();
|
||||
if (!includeEdits) {
|
||||
canvas.width = sourceWidth; canvas.height = sourceHeight;
|
||||
const context = canvas.getContext("2d");
|
||||
if (!context) throw new Error("The browser could not make the picture.");
|
||||
context.translate(sourceWidth / 2, sourceHeight / 2);
|
||||
drawSource(context);
|
||||
return canvas;
|
||||
}
|
||||
const source = rotatedSize(sourceWidth, sourceHeight, values.rotation_degrees);
|
||||
const whole = resolveCrop(values, source);
|
||||
const padding = resolvePadding(values, whole);
|
||||
const crop = keptCrop(whole, padding);
|
||||
const size = resize
|
||||
? scaleToMegapixels(padding.outputWidth, padding.outputHeight, resize.megapixels, resize.steps)
|
||||
: { width: padding.outputWidth, height: padding.outputHeight };
|
||||
canvas.width = size.width; canvas.height = size.height;
|
||||
const context = canvas.getContext("2d");
|
||||
if (!context) throw new Error("The browser could not make the picture.");
|
||||
context.fillStyle = fill;
|
||||
context.fillRect(0, 0, canvas.width, canvas.height);
|
||||
context.save();
|
||||
context.scale(size.width / padding.outputWidth, size.height / padding.outputHeight);
|
||||
context.beginPath();
|
||||
context.rect(padding.left, padding.top, crop.width, crop.height);
|
||||
context.clip();
|
||||
context.translate(padding.left - crop.x + source.width / 2, padding.top - crop.y + source.height / 2);
|
||||
context.rotate((Number(values.rotation_degrees) || 0) * Math.PI / 180);
|
||||
drawSource(context);
|
||||
context.restore();
|
||||
return canvas;
|
||||
}
|
||||
|
||||
// Start the clipboard write in the click's activation, including in browsers
|
||||
// that require a promised PNG rather than a write after toBlob has finished.
|
||||
export function copyPicture(picture, { clipboard = globalThis.navigator?.clipboard, ClipboardItem = globalThis.ClipboardItem } = {}) {
|
||||
if (!clipboard?.write || !ClipboardItem) throw new Error("Open ComfyUI on localhost or HTTPS to copy directly. Choose Open image, then right-click the picture to copy it instead.");
|
||||
const png = Promise.resolve().then(() => typeof picture === "function" ? picture() : picture).then((canvas) => new Promise((resolve, reject) => {
|
||||
canvas.toBlob((blob) => blob ? resolve(blob) : reject(new Error("The browser could not make the picture.")), "image/png");
|
||||
}));
|
||||
// Also observe encoding failure when write() is refused before it reads png.
|
||||
png.catch(() => {});
|
||||
return clipboard.write([new ClipboardItem({ "image/png": png })]);
|
||||
}
|
||||
+389
-169
@@ -41,7 +41,7 @@ import {
|
||||
windowSeconds,
|
||||
} from "./timeline_math.mjs";
|
||||
|
||||
const CSS_ID = "ausboss-transform-trim-css-v4";
|
||||
const CSS_ID = "ausboss-transform-trim-css-v5";
|
||||
const HANDLE_HIT_PX = 9;
|
||||
// Connected inputs that set the length themselves, in the backend's order of
|
||||
// precedence: fixed_frames replaces the window, a cap replaces the Length.
|
||||
@@ -101,6 +101,25 @@ function installCss() {
|
||||
.ausboss-transform-trim-reset{flex:none;height:18px;box-sizing:border-box;border:1px solid #2c4d4b;border-radius:4px;background:#1b2627;color:#cadddb;font:600 10px/16px system-ui;cursor:pointer;padding:0 8px;white-space:nowrap}
|
||||
.ausboss-transform-trim-reset:hover{border-color:#8fa3a1;color:#fff}
|
||||
.ausboss-transform-trim-reset:disabled{opacity:.45;cursor:not-allowed}
|
||||
.ausboss-transform-trim-span.is-room{background:repeating-linear-gradient(90deg,rgba(0,180,170,.38) 0 6px,rgba(0,180,170,.1) 6px 12px)}
|
||||
.ausboss-transform-trim-line .ausboss-transform-trim-readout{text-align:left}
|
||||
.ausboss-transform-trim-inside{color:#45d6cb}
|
||||
.ausboss-transform-trim-outside{color:#8ca8a5}
|
||||
.ausboss-transform-trim-clip{flex:1 1 0;min-width:0;color:#45d6cb;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-variant-numeric:tabular-nums}
|
||||
.ausboss-transform-trim-fields{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;min-width:0}
|
||||
.ausboss-transform-trim-field{display:flex;flex-direction:column;gap:3px;min-width:0}
|
||||
.ausboss-transform-trim-field .ausboss-scrub{width:100%;box-sizing:border-box}
|
||||
.ausboss-transform-trim-field-label{color:#cadddb;display:flex;align-items:center;gap:6px;min-width:0}
|
||||
.ausboss-transform-trim-go[hidden]{display:none}
|
||||
.ausboss-transform-trim-sub{color:#8ca8a5;font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-variant-numeric:tabular-nums;min-height:12px}
|
||||
.ausboss-transform-trim-link{color:#9fe3dc;font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.ausboss-transform-trim-link[hidden]{display:none}
|
||||
.ausboss-transform-trim-go{border:0;background:transparent;padding:0;color:#45d6cb;font:600 10px system-ui;text-decoration:underline;cursor:pointer}
|
||||
.ausboss-transform-trim-note{display:flex;align-items:center;gap:6px;flex-wrap:wrap;color:#9fe3dc;font-size:11px;line-height:1.35}
|
||||
.ausboss-transform-trim-note[hidden]{display:none}
|
||||
.ausboss-transform-trim-note>span{flex:1 1 180px;min-width:0}
|
||||
.ausboss-transform-trim-note.warn{background:#3a2a10;box-shadow:inset 3px 0 0 #e0a040;border-radius:6px;padding:6px 8px;color:#ffdca8}
|
||||
.ausboss-transform-trim-note button[hidden]{display:none}
|
||||
`;
|
||||
document.head.append(style);
|
||||
}
|
||||
@@ -113,6 +132,8 @@ function el(tag, className = "", text = "") {
|
||||
}
|
||||
|
||||
const pct = (fraction) => `${(fraction * 100).toFixed(3)}%`;
|
||||
// Seconds for people: at most two decimals (1, 1.5, 2.17).
|
||||
const secondsText = (value) => String(Number((Number(value) || 0).toFixed(2)));
|
||||
|
||||
// options:
|
||||
// get(name, fallback) / set(name, value) widget access
|
||||
@@ -126,7 +147,12 @@ const pct = (fraction) => `${(fraction * 100).toFixed(3)}%`;
|
||||
// (the clip node) or playhead only
|
||||
// onSeek(frame, settled) the playhead moved; settled on release
|
||||
// onCommit() a stored value settled (undo point)
|
||||
export function mountTransformTrim({ get, set, has = () => true, driven = () => false, number = (name, fallback) => get(name, fallback), outputRate, metadata, trim = true, isPlaying, onTogglePlayback, onSeek, onCommit }) {
|
||||
// linkInfo(name) {title, go()} of the node feeding
|
||||
// a linked input, or null
|
||||
// publish(timing) the clip's {frames, startSeconds,
|
||||
// endSeconds, roomFrames}, or null
|
||||
// units() / setUnits(units) "s" (seconds) or "f" (frames)
|
||||
export function mountTransformTrim({ get, set, has = () => true, driven = () => false, number = (name, fallback) => get(name, fallback), outputRate, metadata, trim = true, isPlaying, onTogglePlayback, onSeek, onCommit, linkInfo = () => null, publish, units: getUnits = () => "s", setUnits = () => {}, play: showPlay = true }) {
|
||||
installCss();
|
||||
const root = el("div", "ausboss-transform-trim");
|
||||
const rail = el("div", "ausboss-transform-trim-rail");
|
||||
@@ -144,7 +170,9 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
const play = el("button", "ausboss-transform-trim-play");
|
||||
play.type = "button";
|
||||
play.addEventListener("click", onTogglePlayback);
|
||||
transport.append(play, rail);
|
||||
// A host with its own player (Load Video) leaves out the Play button.
|
||||
if (showPlay) transport.append(play);
|
||||
transport.append(rail);
|
||||
const info = () => clipInfo(metadata());
|
||||
const everyNth = () => Math.max(1, Math.trunc(Number(number("every_nth", get("every_nth", 1))) || 1));
|
||||
const snapRule = () => String(get("frame_snap", "free"));
|
||||
@@ -160,11 +188,10 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
return number(name, get(name, 0)) ?? get(name, 0);
|
||||
};
|
||||
const countAtRunTime = () => COUNT_INPUTS.some((name) => driven(name) && number(name, null) == null);
|
||||
const plan = () => {
|
||||
if (!trim) return null;
|
||||
const clip = info();
|
||||
const outFps = () => (outputRate ? outputRate() : info().fps / everyNth());
|
||||
const planValues = () => {
|
||||
const wired = wiredBy();
|
||||
return clipLengthPlan(clip, {
|
||||
return {
|
||||
start: boundSeconds("start"),
|
||||
end: boundSeconds("end"),
|
||||
everyNth: everyNth(),
|
||||
@@ -173,9 +200,48 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
fixedFrames: driven("fixed_frames") ? 0 : get("fixed_frames", 0),
|
||||
wired,
|
||||
wiredFrames: wired ? number(wired, null) : null,
|
||||
outputFps: outputRate ? outputRate() : clip.fps,
|
||||
outputFps: outputRate ? outputRate() : info().fps,
|
||||
resampled: driven("force_rate"),
|
||||
});
|
||||
};
|
||||
};
|
||||
const plan = () => (trim ? clipLengthPlan(info(), planValues()) : null);
|
||||
// Output frames that fit between IN and the end of the video: the most a
|
||||
// Duration can be from here.
|
||||
const roomFrames = () => {
|
||||
if (!trim) return null;
|
||||
const room = clipLengthPlan(info(), { ...planValues(), maxFrames: 0, fixedFrames: 0, wired: null, wiredFrames: null });
|
||||
return room.frames ?? null;
|
||||
};
|
||||
// Where the clip ends, in source seconds (exclusive), when it is known.
|
||||
const endSecondsOf = (current) => {
|
||||
const clip = info();
|
||||
if (current?.endSeconds != null) return current.endSeconds;
|
||||
if (current?.last == null || !clip.fps) return null;
|
||||
return (current.last + 1) / clip.fps;
|
||||
};
|
||||
const endDriven = () => driven("end_frame") || driven("end_seconds");
|
||||
// The latest IN that keeps the whole Duration. With a connected rate the
|
||||
// count is in output frames, so the source grid would stop IN far too soon
|
||||
// (the 2.25 face stopped a 240-frame Length at IN 7 on a 247-frame clip).
|
||||
const latestIn = (current) => {
|
||||
const clip = info();
|
||||
if (driven("force_rate")) {
|
||||
if (current.latestStart == null) return clip.count - 1;
|
||||
return current.latestStart > 0 ? current.latestStart : clip.count - 1;
|
||||
}
|
||||
return latestInFor(clip, current.requested ?? get("max_frames", 1), everyNth());
|
||||
};
|
||||
// A Duration as long as the whole video only caps it: IN moves freely and
|
||||
// the clip runs to the end.
|
||||
const durationFills = (current) => {
|
||||
if (current.mode !== "length" || current.requested == null) return false;
|
||||
const whole = roomFromStart();
|
||||
return whole != null && current.requested >= whole;
|
||||
};
|
||||
const roomFromStart = () => {
|
||||
if (!trim) return null;
|
||||
const room = clipLengthPlan(info(), { ...planValues(), start: 0, maxFrames: 0, fixedFrames: 0, wired: null, wiredFrames: null });
|
||||
return room.frames ?? null;
|
||||
};
|
||||
const currentWindow = () => {
|
||||
const clip = info();
|
||||
@@ -185,7 +251,8 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
};
|
||||
const playheadFrame = () => clampFrame(get("frame_index", 0), info());
|
||||
const controls = {};
|
||||
let syncLength = () => {};
|
||||
// A short line under the fields after a drag stops at the video's end.
|
||||
let stopNote = "";
|
||||
// IN is locked by a connected bound; OUT by a connected bound in free
|
||||
// trim, and always when a connected input sets the length.
|
||||
const locked = (edge) => {
|
||||
@@ -196,10 +263,10 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
return false;
|
||||
};
|
||||
const lockTip = (edge) => edge === "start"
|
||||
? "The starting frame is supplied by a connected input. Disconnect it to edit IN here."
|
||||
? "The starting frame is supplied by a connected input. Disconnect it to set Start here."
|
||||
: wiredBy()
|
||||
? `The connected ${wiredBy()} input sets the length, so the clip ends where it says. Disconnect it to use OUT or Length.`
|
||||
: "The ending frame is supplied by a connected input. Disconnect it to edit OUT here.";
|
||||
? `The connected ${wiredBy()} input sets the length, so the clip ends where it says. Disconnect it to set Duration or Ends at here.`
|
||||
: "The ending frame is supplied by a connected input. Disconnect it to set Ends at here.";
|
||||
const disableControl = (control, disabled, tip) => {
|
||||
if (!control) return;
|
||||
control.root.style.opacity = disabled ? ".45" : "";
|
||||
@@ -217,7 +284,16 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
const writeEnd = (first, last) => set("end_seconds", windowSeconds(info(), first, last).end_seconds);
|
||||
// An older face's Fixed frames reads as a Length; the first edit makes it
|
||||
// one, keeping the window where the fixed count had placed it.
|
||||
// The face has no modes: a clip is a Start and a Duration. A window saved
|
||||
// as IN -> OUT (Length off) becomes a Duration of the same frames on its
|
||||
// first edit, so the run outputs exactly what it did. A connected end
|
||||
// keeps the window as it is.
|
||||
const adoptLength = (current) => {
|
||||
if (current.mode === "free" && !endDriven() && current.frames != null) {
|
||||
set("max_frames", Math.max(1, current.frames));
|
||||
set("end_seconds", 0);
|
||||
return plan();
|
||||
}
|
||||
if (current.mode !== "fixed") return current;
|
||||
set("fixed_frames", 0);
|
||||
set("max_frames", Math.max(1, current.requested ?? current.frames ?? 1));
|
||||
@@ -235,9 +311,14 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
let parked;
|
||||
if (edge === "start") {
|
||||
if (current.mode === "length") {
|
||||
// A Length drags the whole window, stopping where OUT meets the end;
|
||||
// a Length past the clip's end only caps it, so IN moves freely.
|
||||
parked = Math.max(0, Math.min(clampFrame(frame, clip), latestInFor(clip, current.requested ?? get("max_frames", 1), nth)));
|
||||
// A Duration drags the whole clip, stopping where its end meets the
|
||||
// video's end; a Duration past the video's end only caps it, so IN
|
||||
// moves freely.
|
||||
const latest = latestIn(current);
|
||||
parked = Math.max(0, Math.min(clampFrame(frame, clip), latest));
|
||||
stopNote = clampFrame(frame, clip) > latest
|
||||
? `Start stops at ${secondsText(parked / clip.fps)} s so all ${current.requested} frames fit.`
|
||||
: "";
|
||||
set("end_seconds", 0);
|
||||
} else if (current.mode === "wired" && current.latestStart != null && !countAtRunTime()) {
|
||||
parked = Math.min(clampFrame(frame, clip), current.latestStart);
|
||||
@@ -247,11 +328,18 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
writeStart(parked);
|
||||
} else {
|
||||
const target = Math.max(current.first, clampFrame(frame, clip));
|
||||
const frames = framesThrough(current.first, target, nth, snapRule());
|
||||
stopNote = "";
|
||||
let frames = framesThrough(current.first, target, nth, snapRule());
|
||||
if (driven("force_rate") && outFps() > 0) {
|
||||
// Output frames at the linked rate from IN to the handle's boundary.
|
||||
frames = snapToValid(Math.max(1, Math.round(((target + 1) / clip.fps - boundSeconds("start")) * outFps())), snapRule());
|
||||
const room = roomFrames();
|
||||
if (room != null) frames = Math.min(frames, Math.max(1, room));
|
||||
}
|
||||
if (current.mode === "length") {
|
||||
set("max_frames", frames);
|
||||
set("end_seconds", 0);
|
||||
parked = Math.min(clip.count - 1, lastFrameFor(current.first, frames, nth));
|
||||
parked = plan()?.last ?? Math.min(clip.count - 1, lastFrameFor(current.first, frames, nth));
|
||||
} else {
|
||||
parked = driven("force_rate") ? target : lastFrameFor(current.first, frames, nth);
|
||||
writeEnd(current.first, parked);
|
||||
@@ -263,7 +351,8 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
// The grip slides the kept part: a Length moves with IN (OUT follows), a
|
||||
// free window keeps its span and both edges move.
|
||||
const canSlide = () => {
|
||||
if (!trim || locked("start")) return false;
|
||||
// With a connected rate, IN itself slides the clip at its Duration.
|
||||
if (!trim || locked("start") || driven("force_rate")) return false;
|
||||
const current = plan();
|
||||
if (!current || !["length", "fixed", "free"].includes(current.mode)) return false;
|
||||
if (current.mode === "free" && locked("end")) return false;
|
||||
@@ -285,26 +374,6 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
}
|
||||
moveEdge("start", first, settled);
|
||||
};
|
||||
// Length on keeps what the rail shows now as the count; off turns the
|
||||
// Length into an OUT at the same frame. Either way nothing moves.
|
||||
const setLength = (on) => {
|
||||
const current = plan();
|
||||
if (!current || current.mode === "wired" || (on === (current.mode !== "free"))) return;
|
||||
if (on) {
|
||||
const frames = current.frames ?? framesThrough(current.first, current.windowLast, everyNth(), snapRule());
|
||||
set("max_frames", Math.max(1, frames));
|
||||
set("end_seconds", 0);
|
||||
} else {
|
||||
const last = current.last ?? current.windowLast;
|
||||
writeStart(current.first);
|
||||
writeEnd(current.first, last);
|
||||
set("max_frames", 0);
|
||||
if (!driven("fixed_frames")) set("fixed_frames", 0);
|
||||
}
|
||||
sync();
|
||||
onCommit?.();
|
||||
};
|
||||
|
||||
const readout = el("span", "ausboss-transform-trim-readout");
|
||||
const summary = el("div", "ausboss-transform-trim-summary");
|
||||
|
||||
@@ -312,7 +381,7 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
const clip = info();
|
||||
const playing = isPlaying();
|
||||
play.setAttribute("aria-label", playing ? "Pause" : "Play");
|
||||
play.title = playing ? "Pause on this frame" : trim ? "Play the selected clip" : "Play the video to pick a frame";
|
||||
play.title = playing ? "Pause on this frame" : trim ? "Play the clip from its start" : "Play the video to pick a frame";
|
||||
play.classList.toggle("is-playing", playing);
|
||||
play.disabled = !clip.count;
|
||||
const head = playheadFrame();
|
||||
@@ -320,33 +389,41 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
playhead.style.left = pct(fractionOfFrame(head, clip, "center"));
|
||||
playhead.style.visibility = clip.count ? "" : "hidden";
|
||||
readout.replaceChildren();
|
||||
const current = trim ? plan() : null;
|
||||
if (clip.count) {
|
||||
readout.append(el("b", "", `fr ${head}`), document.createTextNode(` · ${formatTimecode(frameTime(head, clip))}`));
|
||||
readout.title = `Playhead: frame ${head} of ${clip.count} at ${frameTime(head, clip).toFixed(3)} s. Press or drag the rail to scrub; ${trim ? "the trim handles carry it with them." : "this is the frame the node outputs."}`;
|
||||
readout.append(document.createTextNode("Preview "), el("b", "", `${secondsText(frameTime(head, clip))} s`), document.createTextNode(` · src fr ${head}`));
|
||||
if (trim) {
|
||||
const end = countAtRunTime() ? null : current.last;
|
||||
const inside = head >= current.first && (end == null || head <= end);
|
||||
readout.append(el("span", inside ? "ausboss-transform-trim-inside" : "ausboss-transform-trim-outside", inside ? " · in the clip" : " · outside the clip"));
|
||||
}
|
||||
readout.title = `The picture shows frame ${head} of ${clip.count}, ${frameTime(head, clip).toFixed(2)} seconds into the video. Press or drag the bar to look at another frame${trim ? "; Use as start starts the clip here." : "; this is the frame the node outputs."}`;
|
||||
}
|
||||
controls.frame?.set(head);
|
||||
if (!trim) return;
|
||||
const current = plan();
|
||||
const wired = wiredBy();
|
||||
const unknown = countAtRunTime();
|
||||
const hasOut = current.last != null && current.mode !== "wired";
|
||||
const hasOut = current.last != null && current.mode !== "wired" && !unknown;
|
||||
const outFrame = current.last ?? current.windowLast;
|
||||
const startFraction = fractionOfFrame(current.first, clip, "start");
|
||||
const endFraction = fractionOfFrame(outFrame, clip, "end");
|
||||
const endSec = endSecondsOf(current);
|
||||
const endFraction = endSec != null && !unknown
|
||||
? Math.max(startFraction, Math.min(1, endSec * clip.fps / clip.count))
|
||||
: fractionOfFrame(outFrame, clip, "end");
|
||||
// Dim: frames the free window holds but the run drops (every nth, snap).
|
||||
const tailFraction = current.mode === "free" ? fractionOfFrame(current.windowLast, clip, "end") : endFraction;
|
||||
span.style.left = pct(startFraction);
|
||||
span.style.width = pct(current.last == null && current.mode !== "free" ? 0 : Math.max(0, tailFraction - startFraction));
|
||||
span.classList.toggle("is-room", unknown || current.last == null);
|
||||
// A length only the run knows: the dim part is the room the clip has.
|
||||
span.style.width = pct(unknown || current.last == null ? 1 - startFraction : Math.max(0, tailFraction - startFraction));
|
||||
kept.style.left = pct(startFraction);
|
||||
kept.style.width = current.last == null || unknown ? "0%" : pct(Math.max(0, endFraction - startFraction));
|
||||
const fills = lengthFillsClip(clip, current, everyNth());
|
||||
span.title = unknown || current.last == null ? "Room for the clip: its length is set when the graph runs." : "";
|
||||
const railWidth = rail.getBoundingClientRect().width || 0;
|
||||
const keptWidth = Math.max(0, endFraction - startFraction) * railWidth;
|
||||
grip.hidden = !canSlide() || unknown || (railWidth > 0 && keptWidth < 34);
|
||||
grip.style.left = pct((startFraction + endFraction) / 2);
|
||||
grip.title = current.mode === "free"
|
||||
? "Drag to slide the kept part: IN and OUT move together."
|
||||
: "Drag to slide the clip: OUT follows at the Length.";
|
||||
grip.title = "Drag to slide the clip; its Duration stays.";
|
||||
for (const edge of ["start", "end"]) {
|
||||
const handle = handles[edge];
|
||||
const frame = edge === "start" ? current.first : outFrame;
|
||||
@@ -359,10 +436,9 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
handle.style.cursor = isLocked ? "not-allowed" : "";
|
||||
handle.title = isLocked ? lockTip(edge)
|
||||
: edge === "start"
|
||||
? current.mode === "free" ? "Drag IN to trim; Shift + arrow moves one frame."
|
||||
: fills ? "Drag IN to start later. The Length is as long as the clip, so the clip's end is OUT."
|
||||
: "Drag IN to move the clip; OUT follows at the Length. Shift + arrow moves one frame."
|
||||
: current.mode === "free" ? "Drag OUT to trim; it lands on the last frame the run keeps." : "Drag OUT to change the Length; IN stays.";
|
||||
? durationFills(current) ? "Drag to start later. The Duration is longer than the video, so the clip runs to its end."
|
||||
: "Drag to move the clip; its Duration stays. Shift + arrow moves one frame."
|
||||
: "Drag to change the Duration; the start stays.";
|
||||
handle.setAttribute("aria-valuemin", "0");
|
||||
const maxFrame = edge === "start" && current.mode === "wired" && !unknown
|
||||
? current.latestStart ?? current.windowLast : Math.max(0, clip.count - 1);
|
||||
@@ -370,16 +446,16 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
handle.setAttribute("aria-valuenow", String(frame));
|
||||
handle.setAttribute("aria-valuetext", `frame ${frame}, ${formatTimecode(frameTime(frame, clip))}`);
|
||||
}
|
||||
controls.start_seconds?.set(current.first);
|
||||
controls.end_seconds?.set(outFrame);
|
||||
disableControl(controls.start_seconds, locked("start"), lockTip("start"));
|
||||
disableControl(controls.end_seconds, locked("end") || !hasOut, lockTip("end"));
|
||||
syncLength(current, wired);
|
||||
if (useStart) {
|
||||
useStart.disabled = !clip.count || locked("start");
|
||||
useStart.title = locked("start") ? lockTip("start") : "Start the clip at the frame on the stage. The Duration stays.";
|
||||
}
|
||||
if (clip.count) syncFields(clip, current, wired, unknown);
|
||||
if (controls.reset) {
|
||||
const free = current.mode === "free";
|
||||
controls.reset.textContent = free ? "Full clip" : "To start";
|
||||
controls.reset.title = free ? "Reset IN/OUT to the full source. Keeps Every nth and Frames for." : "Move IN to the start of the source; the length stays.";
|
||||
controls.reset.disabled = !free && locked("start");
|
||||
const free = current.mode !== "wired";
|
||||
controls.reset.textContent = free ? "Whole video" : "To start";
|
||||
controls.reset.title = free ? `Use the whole video: start at 0 with no Duration limit. Keeps Every nth${has("frame_snap") ? " and Frames for" : ""}.` : "Move the start to the beginning of the video; the linked length stays.";
|
||||
controls.reset.disabled = locked("start") && !free;
|
||||
}
|
||||
controls.every_nth?.set(get("every_nth", 1));
|
||||
disableControl(controls.every_nth, driven("every_nth"), "Every nth is supplied by a connected input.");
|
||||
@@ -387,50 +463,21 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
controls.frame_snap.value = snapRule();
|
||||
const exact = current.mode === "fixed" || (current.mode === "wired" && wired === "fixed_frames");
|
||||
controls.frame_snap.disabled = exact || driven("frame_snap");
|
||||
controls.frame_snap.title = exact ? "An exact fixed_frames count is used as it is; this does not apply." : "Keep a frame count the video model takes: LTX wants 8n+1 (49, 97, 121), Wan 4n+1. OUT and Length step to those counts. Any keeps every frame.";
|
||||
controls.frame_snap.title = exact ? "An exact fixed_frames count is used as it is; this does not apply." : "Keep a frame count the video model takes: LTX wants 8n+1 (49, 97, 121), Wan 4n+1. The Duration steps to those counts. Any keeps every frame.";
|
||||
}
|
||||
syncSummary(clip, current, wired, unknown);
|
||||
syncSummary(clip);
|
||||
};
|
||||
|
||||
const syncSummary = (clip, current, wired, unknown) => {
|
||||
const syncSummary = (clip) => {
|
||||
if (!clip.count) {
|
||||
summary.textContent = "Choose a source to set the clip window";
|
||||
summary.textContent = "Choose a source to set the clip";
|
||||
summary.title = "";
|
||||
return;
|
||||
}
|
||||
const rate = outputRate?.();
|
||||
const fps = `Source ${formatFps(clip.fps)} fps → Output ${rate == null ? "rate at run time" : `${formatFps(rate)} fps`}`;
|
||||
if (current.mode === "wired") {
|
||||
summary.textContent = current.frames == null ? `${fps} · length from ${wired} at run time` : `${fps} · ${current.frames} frames from ${wired}`;
|
||||
summary.title = `The connected ${wired} input sets the length, so only IN is set here. Disconnect it to use OUT or a Length.`;
|
||||
return;
|
||||
}
|
||||
if (unknown || current.frames == null) {
|
||||
summary.textContent = `${fps} · frame count at run time`;
|
||||
summary.title = "IN, OUT and the playhead refer to source frames. A connected input decides the exact frame count when the workflow runs. Connect the fps output to the next video node's fps input.";
|
||||
return;
|
||||
}
|
||||
const from = formatTimecode(frameTime(current.first, clip));
|
||||
const to = formatTimecode((current.last + 1) / clip.fps);
|
||||
if (current.mode === "fixed") {
|
||||
summary.textContent = current.tooLong
|
||||
? `Fixed length needs more than the source's ${clip.duration.toFixed(3)}s`
|
||||
: `${fps} · exactly ${current.frames} frames · ${from} → ${to}`;
|
||||
summary.title = "An older Fixed frames value: an exact count from IN. Any change here turns it into a Length.";
|
||||
return;
|
||||
}
|
||||
const total = current.windowLast - current.first + 1;
|
||||
const count = current.mode === "length"
|
||||
? current.truncated ? `${current.frames} of ${current.requested} frames, source ends` : `${current.frames} frames`
|
||||
: current.frames < total ? `${current.frames} of ${total} frames` : `${current.frames} frames`;
|
||||
summary.textContent = `${fps} · ${count} · ${from} → ${to}`;
|
||||
summary.title = current.mode === "length"
|
||||
? current.truncated
|
||||
? `The source ends ${current.frames} frames after IN, before the Length of ${current.requested}. Move IN earlier or shorten the Length.`
|
||||
: "Length keeps OUT this many output frames after IN; drag IN to move the clip, OUT to change the Length."
|
||||
: current.frames < total
|
||||
? `The window holds ${total} frames; every nth and the snap rule keep ${current.frames}, ending at frame ${current.last}, where OUT sits. The dim part is dropped.`
|
||||
: "Frames the run outputs, at the fps the node reports.";
|
||||
summary.textContent = `Source ${formatFps(clip.fps)} fps · ${clip.count} frames · ends at ${secondsText(clip.duration || clip.count / clip.fps)} s · clip out at ${rate == null ? "the rate set at run time" : `${formatFps(rate)} fps`}`;
|
||||
summary.title = "Start and Ends at are places in the source video. Duration counts the frames the clip sends on, at the output rate.";
|
||||
if (trim) rail.title = [clipLine?.textContent, summary.textContent, readout.textContent].filter(Boolean).join("\n");
|
||||
};
|
||||
|
||||
// --- rail gestures --------------------------------------------------------
|
||||
@@ -532,21 +579,19 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
}
|
||||
|
||||
// --- rows -----------------------------------------------------------------
|
||||
const timeRow = el("div", "ausboss-transform-trim-line");
|
||||
// The clip node: Preview (the playhead, and Use as start), the clip in
|
||||
// words with a Seconds | Frames switch, then Start, Duration and Ends at.
|
||||
// Start and Ends at are positions in the source video; Duration counts the
|
||||
// frames the clip sends on, at the output rate. No modes: dragging IN
|
||||
// slides the clip, dragging OUT or typing a Duration or an end changes the
|
||||
// Duration.
|
||||
const previewRow = el("div", "ausboss-transform-trim-line");
|
||||
let useStart = null;
|
||||
if (trim) {
|
||||
for (const [name, caption, edge] of [["start_seconds", "IN", "start"], ["end_seconds", "OUT", "end"]]) {
|
||||
const label = el("label");
|
||||
label.append(el("span", "ausboss-transform-trim-caption", caption));
|
||||
controls[name] = makeScrubInput({
|
||||
value: 0, min: 0, max: 10000000, step: 1, decimals: 0,
|
||||
title: edge === "start" ? "IN frame: the first frame the run keeps (stored as start_seconds)." : "OUT frame: the last frame the run keeps. With Length on it follows IN; typing it changes the Length.",
|
||||
onChange: (frame) => moveEdge(edge, frame, false),
|
||||
onSettle: () => { const window = currentWindow(); seek(edge === "start" ? window.first : window.last, true); onCommit?.(); },
|
||||
});
|
||||
label.append(controls[name].root);
|
||||
timeRow.append(label);
|
||||
if (edge === "start") timeRow.append(readout);
|
||||
}
|
||||
useStart = el("button", "ausboss-transform-trim-reset", "Use as start");
|
||||
useStart.type = "button";
|
||||
useStart.title = "Start the clip at the frame on the stage. The Duration stays.";
|
||||
useStart.addEventListener("click", () => moveEdge("start", playheadFrame(), true));
|
||||
} else {
|
||||
const label = el("label");
|
||||
label.append(el("span", "ausboss-transform-trim-caption", "FRAME"));
|
||||
@@ -557,67 +602,237 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
onSettle: () => seek(playheadFrame(), true),
|
||||
});
|
||||
label.append(controls.frame.root);
|
||||
timeRow.append(label, readout);
|
||||
previewRow.append(label, readout);
|
||||
}
|
||||
root.append(transport, timeRow);
|
||||
root.append(transport);
|
||||
if (!trim) root.append(previewRow);
|
||||
|
||||
// Length: off, OUT ends the clip; on, a frame count from IN (max_frames,
|
||||
// end left open), so OUT follows IN and the count survives a new source.
|
||||
if (trim && has("max_frames")) {
|
||||
const lengthRow = el("div", "ausboss-transform-trim-line wrap");
|
||||
const label = el("label", "", "Length");
|
||||
const pill = el("div", "ausboss-transform-trim-pill");
|
||||
const off = el("button", "", "off");
|
||||
const on = el("button", "", "on");
|
||||
off.type = on.type = "button";
|
||||
off.title = "OUT ends the clip: drag both handles freely.";
|
||||
on.title = "Set the clip by a frame count from IN: OUT follows IN, and the count stays when you swap the video.";
|
||||
off.addEventListener("click", () => setLength(false));
|
||||
on.addEventListener("click", () => setLength(true));
|
||||
pill.append(off, on);
|
||||
const hint = el("span", "ausboss-transform-trim-hint");
|
||||
const count = makeScrubInput({ value: 1, min: 1, max: 100000, step: 1, decimals: 0, unit: "fr", width: 72,
|
||||
title: "Output frames from IN. Under a snap rule it steps to the counts the model keeps (97, 105, ... for 8n+1).",
|
||||
onChange: (next) => {
|
||||
const current = adoptLength(plan());
|
||||
if (current.mode !== "length") { sync(); return; }
|
||||
const was = current.requested ?? get("max_frames", 1);
|
||||
set("max_frames", snapToValid(next, snapRule(), Math.sign(next - was)));
|
||||
set("end_seconds", 0);
|
||||
sync();
|
||||
},
|
||||
onSettle: () => { const window = currentWindow(); seek(window.last, true); onCommit?.(); },
|
||||
});
|
||||
label.append(pill, count.root);
|
||||
lengthRow.append(label, hint);
|
||||
root.append(lengthRow);
|
||||
syncLength = (current, wired) => {
|
||||
const active = current.mode !== "free";
|
||||
const blocked = current.mode === "wired";
|
||||
off.classList.toggle("on", !active);
|
||||
on.classList.toggle("on", active);
|
||||
off.setAttribute("aria-pressed", String(!active));
|
||||
on.setAttribute("aria-pressed", String(active));
|
||||
pill.classList.toggle("is-disabled", blocked);
|
||||
off.disabled = on.disabled = blocked;
|
||||
pill.title = blocked ? lockTip("end") : "";
|
||||
count.root.style.display = active ? "" : "none";
|
||||
const step = snapStep(snapRule());
|
||||
count.setStep(step, step);
|
||||
count.set(blocked ? (current.requested ?? current.frames ?? 0) : (current.requested ?? get("max_frames", 1)));
|
||||
disableControl(count, blocked, lockTip("end"));
|
||||
const fills = lengthFillsClip(info(), current, everyNth());
|
||||
hint.textContent = blocked ? `from ${wired}` : current.mode === "fixed" ? "exact (older setting)" : fills ? "= the whole clip" : active ? "" : "OUT ends the clip";
|
||||
hint.classList.toggle("note", fills && !blocked);
|
||||
hint.title = fills && !blocked ? `The Length (${current.requested ?? current.frames} frames) is as long as the clip, so the clip's end is OUT. Drag IN to start later; drag OUT or type a smaller Length to end sooner.` : "";
|
||||
const fields = {};
|
||||
let clipLine = null;
|
||||
let unitPill = null;
|
||||
let noteRow = null;
|
||||
let noteText = null;
|
||||
const noteButtons = [];
|
||||
if (trim) {
|
||||
const clipRow = el("div", "ausboss-transform-trim-line");
|
||||
clipLine = el("span", "ausboss-transform-trim-clip");
|
||||
unitPill = el("div", "ausboss-transform-trim-pill");
|
||||
for (const [key, words, tip] of [["s", "s", "Show times in seconds."], ["f", "fr", "Show times in frames: source frames for Start and Ends at, clip frames for Duration."]]) {
|
||||
const button = el("button", "", words);
|
||||
button.type = "button";
|
||||
button.dataset.units = key;
|
||||
button.title = tip;
|
||||
button.addEventListener("click", () => { setUnits(key); sync(); });
|
||||
unitPill.append(button);
|
||||
}
|
||||
|
||||
const grid = el("div", "ausboss-transform-trim-fields");
|
||||
const toFrames = {
|
||||
start: (value) => (getUnits() === "f" ? Math.round(value) : Math.round(value * info().fps)),
|
||||
};
|
||||
// Output frames for a Duration typed in the current units.
|
||||
const durationFrames = (value) => {
|
||||
if (getUnits() === "f") return Math.round(value);
|
||||
const rate = outFps();
|
||||
return rate > 0 ? Math.round(value * rate) : null;
|
||||
};
|
||||
// Output frames from IN to an end typed in the current units.
|
||||
const framesToEnd = (value) => {
|
||||
const clip = info();
|
||||
const current = plan();
|
||||
const end = getUnits() === "f" ? (Math.round(value) + 1) / clip.fps : value;
|
||||
if (driven("force_rate")) {
|
||||
const rate = outFps();
|
||||
return rate > 0 ? Math.round((end - boundSeconds("start")) * rate) : null;
|
||||
}
|
||||
return framesThrough(current.first, Math.ceil(end * clip.fps - 1e-7) - 1, everyNth(), snapRule());
|
||||
};
|
||||
const setDuration = (frames) => {
|
||||
if (frames == null || !Number.isFinite(frames)) return;
|
||||
const current = adoptLength(plan());
|
||||
if (current.mode !== "length") return;
|
||||
const was = current.requested ?? get("max_frames", 1);
|
||||
set("max_frames", snapToValid(Math.max(1, frames), snapRule(), Math.sign(frames - was)));
|
||||
set("end_seconds", 0);
|
||||
stopNote = "";
|
||||
};
|
||||
const defs = [
|
||||
["start", "Start", "Where the clip starts in the source video."],
|
||||
["duration", "Duration", "How long the clip is. Counted in clip frames at the output rate."],
|
||||
["end", "Ends at", "Where the clip ends in the source video. Typing it changes the Duration."],
|
||||
];
|
||||
for (const [key, caption, tip] of defs) {
|
||||
const cell = el("div", "ausboss-transform-trim-field");
|
||||
const label = el("span", "ausboss-transform-trim-field-label", caption);
|
||||
const go = el("button", "ausboss-transform-trim-go", "linked");
|
||||
go.type = "button";
|
||||
label.append(go);
|
||||
const control = makeScrubInput({
|
||||
value: 0, min: 0, max: 10000000, step: 1, decimals: 2, minDecimals: 0, unit: "s", unitWidth: 34,
|
||||
title: tip,
|
||||
onChange: (value) => {
|
||||
if (key === "start") {
|
||||
if (locked("start")) return;
|
||||
// A typed start is kept even when the Duration no longer fits;
|
||||
// the note below says what fits and offers both fixes.
|
||||
adoptLength(plan());
|
||||
const frame = clampFrame(toFrames.start(value), info());
|
||||
writeStart(frame);
|
||||
stopNote = "";
|
||||
seek(frame, false);
|
||||
return;
|
||||
}
|
||||
if (key === "duration") setDuration(durationFrames(value));
|
||||
else setDuration(framesToEnd(value));
|
||||
sync();
|
||||
},
|
||||
onSettle: () => { const window = currentWindow(); seek(key === "start" ? window.first : window.last, true); onCommit?.(); },
|
||||
});
|
||||
cell.append(label, control.root);
|
||||
grid.append(cell);
|
||||
fields[key] = { control, go, cell, label };
|
||||
}
|
||||
|
||||
noteRow = el("div", "ausboss-transform-trim-note");
|
||||
noteText = el("span");
|
||||
noteRow.append(noteText);
|
||||
for (let index = 0; index < 2; index++) {
|
||||
const button = el("button", "ausboss-transform-trim-reset");
|
||||
button.type = "button";
|
||||
noteButtons.push(button);
|
||||
noteRow.append(button);
|
||||
}
|
||||
root.append(grid, noteRow);
|
||||
}
|
||||
|
||||
// One field's look: its value in the current units, the line under it,
|
||||
// and, when another node sets it, that node's name and a Go to button.
|
||||
const showField = (key, { value, unit, decimals, sub, lockedBy, readOnly, placeholder = "" }) => {
|
||||
const field = fields[key];
|
||||
if (!field) return;
|
||||
field.control.setRange({ decimals, minDecimals: 0, step: decimals ? 0.1 : 1, fineStep: decimals ? 0.01 : 1 });
|
||||
field.control.set(value);
|
||||
if (value == null) field.control.input.value = "";
|
||||
field.control.input.placeholder = placeholder;
|
||||
const unitSlot = field.control.root.querySelector(".ausboss-scrub-unit");
|
||||
if (unitSlot) unitSlot.textContent = unit;
|
||||
const tip = lockedBy ? `Set by ${lockedBy.title}: ${sub}. Click "linked" to go to that node.` : sub;
|
||||
disableControl(field.control, readOnly, tip);
|
||||
field.cell.title = tip;
|
||||
field.go.hidden = !lockedBy;
|
||||
if (lockedBy) {
|
||||
field.go.title = `Set by ${lockedBy.title}. Click to go to that node.`;
|
||||
field.go.onclick = () => lockedBy.go?.();
|
||||
}
|
||||
};
|
||||
const showNote = (text, kind = "", actions = []) => {
|
||||
if (!noteRow) return;
|
||||
noteRow.hidden = !text;
|
||||
noteRow.classList.toggle("warn", kind === "warn");
|
||||
noteText.textContent = text;
|
||||
noteButtons.forEach((button, index) => {
|
||||
const action = actions[index];
|
||||
button.hidden = !action;
|
||||
if (action) { button.textContent = action.label; button.onclick = () => { action.run(); sync(); onCommit?.(); }; }
|
||||
});
|
||||
};
|
||||
|
||||
const syncFields = (clip, current, wired, unknown) => {
|
||||
const seconds = getUnits() !== "f";
|
||||
for (const button of unitPill.children) button.classList.toggle("on", button.dataset.units === (seconds ? "s" : "f"));
|
||||
const rate = outFps();
|
||||
const rateText = rate > 0 ? `${formatFps(rate)} fps` : "the output rate";
|
||||
const first = current.first;
|
||||
const endSec = unknown ? null : endSecondsOf(current);
|
||||
const frames = unknown ? null : current.frames;
|
||||
const startLink = locked("start") ? linkInfo(driven("start_frame") ? "start_frame" : "start_seconds") : null;
|
||||
const lengthLink = current.mode === "wired" && wired ? linkInfo(wired) : null;
|
||||
const endLink = endDriven() && current.mode === "free" ? linkInfo(driven("end_frame") ? "end_frame" : "end_seconds") : null;
|
||||
const room = roomFrames();
|
||||
const fills = durationFills(current);
|
||||
|
||||
showField("start", {
|
||||
value: seconds ? frameTime(first, clip) : first,
|
||||
unit: seconds ? "s" : "fr", decimals: seconds ? 2 : 0,
|
||||
sub: seconds ? `source frame ${first}` : `source frame · ${secondsText(frameTime(first, clip))} s`,
|
||||
lockedBy: startLink, readOnly: locked("start"),
|
||||
});
|
||||
|
||||
// Duration: what was asked for (a Duration longer than what is left
|
||||
// only caps the clip), in clip frames or seconds at the output rate.
|
||||
const asked = current.mode === "wired" ? current.requested ?? current.frames : current.mode === "length" ? current.requested : frames;
|
||||
let durationSub;
|
||||
if (current.mode === "wired" && current.frames == null && current.requested == null) {
|
||||
durationSub = room != null && rate > 0 ? `up to ${secondsText(room / rate)} s (${room} frames) fit after this start` : "set when the graph runs";
|
||||
} else if (current.mode === "wired" && wired !== "fixed_frames" && current.truncated) {
|
||||
durationSub = `the video ends first: ${frames} frames${rate > 0 ? ` (${secondsText(frames / rate)} s)` : ""}`;
|
||||
} else if (current.mode === "wired") {
|
||||
durationSub = wired === "fixed_frames" ? `${asked} clip frames required` : `up to ${asked} clip frames`;
|
||||
} else if (frames == null) {
|
||||
durationSub = "frame count at run time";
|
||||
} else if (current.truncated) {
|
||||
durationSub = `the video ends first: ${frames} frames${rate > 0 ? ` (${secondsText(frames / rate)} s)` : ""}`;
|
||||
} else {
|
||||
durationSub = seconds ? `${frames} clip frames at ${rateText}` : rate > 0 ? `clip frames · ${secondsText(frames / rate)} s at ${rateText}` : "seconds known at run time";
|
||||
}
|
||||
const durationInSeconds = seconds && rate > 0;
|
||||
showField("duration", {
|
||||
value: asked == null ? null : durationInSeconds ? asked / rate : asked,
|
||||
unit: durationInSeconds ? "s" : "fr", decimals: durationInSeconds ? 2 : 0,
|
||||
sub: durationSub, lockedBy: lengthLink,
|
||||
readOnly: current.mode === "wired" || Boolean(endLink) || asked == null,
|
||||
placeholder: current.mode === "wired" && asked == null ? "at run time" : "",
|
||||
});
|
||||
|
||||
const lastSource = endSec == null ? null : Math.min(clip.count - 1, Math.max(first, Math.ceil(endSec * clip.fps - 1e-7) - 1));
|
||||
showField("end", {
|
||||
value: endSec == null ? null : seconds ? endSec : lastSource,
|
||||
unit: seconds ? "s" : "fr", decimals: seconds ? 2 : 0,
|
||||
sub: endSec == null ? "known after the run" : seconds ? `last source frame ${lastSource}` : `last source frame · ${secondsText(endSec)} s`,
|
||||
lockedBy: endLink, readOnly: current.mode === "wired" || Boolean(endLink) || endSec == null,
|
||||
placeholder: endSec == null ? "after Run" : "",
|
||||
});
|
||||
|
||||
// The clip in words.
|
||||
if (endSec == null) {
|
||||
clipLine.textContent = `Clip from ${seconds ? `${secondsText(frameTime(first, clip))} s` : `src fr ${first}`} · length set when the graph runs`;
|
||||
} else {
|
||||
const span = seconds
|
||||
? `Clip ${secondsText(frameTime(first, clip))} → ${secondsText(endSec)} s`
|
||||
: `Clip src fr ${first} → ${lastSource}`;
|
||||
clipLine.textContent = `${span} · ${frames} frames out`;
|
||||
}
|
||||
|
||||
// What needs saying: a start that leaves too little video, a linked
|
||||
// exact count that does not fit, or a drag that stopped at the end.
|
||||
const latest = current.mode === "length" ? latestIn(current) : current.latestStart;
|
||||
if (current.mode === "wired" && wired === "fixed_frames" && current.tooLong) {
|
||||
showNote(`Needs ${asked} frames; the video is shorter.`, "warn");
|
||||
} else if (current.mode === "wired" && wired === "fixed_frames" && latest != null && first > latest && !unknown) {
|
||||
showNote(`Needs ${asked} frames; only ${room ?? "fewer"} fit from here. The run will fail.`, "warn",
|
||||
locked("start") ? [] : [{ label: `Move start to ${secondsText(latest / clip.fps)} s`, run: () => writeStart(latest) }]);
|
||||
} else if (current.mode === "length" && current.truncated && !fills) {
|
||||
const actions = [{ label: `Shorten to ${rate > 0 ? `${secondsText(frames / rate)} s` : `${frames} frames`}`, run: () => { set("max_frames", Math.max(1, frames)); set("end_seconds", 0); } }];
|
||||
if (!locked("start") && latest != null && latest < first) actions.push({ label: `Move start to ${secondsText(latest / clip.fps)} s`, run: () => writeStart(latest) });
|
||||
showNote(`Only ${frames} of ${current.requested} frames fit from here.`, "warn", actions);
|
||||
} else if (current.mode === "wired" && wired !== "fixed_frames" && current.truncated && frames != null) {
|
||||
showNote(`Video ends first: ${frames} of ${asked} frames.`);
|
||||
} else if (current.mode === "length" && fills && current.truncated) {
|
||||
showNote("Runs to the end of the video.");
|
||||
} else if (stopNote) {
|
||||
showNote(stopNote);
|
||||
} else {
|
||||
showNote("");
|
||||
}
|
||||
|
||||
publish?.(endSec == null || frames == null ? null : { frames, startSeconds: frameTime(first, clip), endSeconds: endSec, roomFrames: room });
|
||||
};
|
||||
|
||||
if (trim) {
|
||||
const sampling = el("div", "ausboss-transform-trim-line wrap");
|
||||
const nthLabel = el("label", "", "Every nth");
|
||||
controls.every_nth = makeScrubInput({ value: get("every_nth", 1), min: 1, max: 512, step: 1, decimals: 0,
|
||||
title: "Keep one frame in this many. Output fps is adjusted to keep real-time playback; a Length counts the frames kept.",
|
||||
title: "Keep one frame in this many. Output fps is adjusted to keep real-time playback; the Duration counts the frames kept.",
|
||||
onChange: (next) => { if (!driven("every_nth")) set("every_nth", next); sync(); }, onSettle: onCommit,
|
||||
});
|
||||
nthLabel.append(controls.every_nth.root);
|
||||
@@ -649,15 +864,20 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
reset.type = "button";
|
||||
reset.addEventListener("click", () => {
|
||||
const current = plan();
|
||||
if (current.mode === "free") {
|
||||
if (current.mode !== "wired") {
|
||||
// The whole video: no start, no end, no Duration limit.
|
||||
if (!locked("start")) set("start_seconds", 0);
|
||||
if (!locked("end")) set("end_seconds", 0);
|
||||
sync(); onCommit?.();
|
||||
if (!endDriven()) set("end_seconds", 0);
|
||||
set("max_frames", 0);
|
||||
if (!driven("fixed_frames")) set("fixed_frames", 0);
|
||||
stopNote = "";
|
||||
seek(0, true); onCommit?.();
|
||||
} else {
|
||||
moveEdge("start", 0, true);
|
||||
}
|
||||
});
|
||||
footer.append(summary, reset);
|
||||
sampling.append(unitPill);
|
||||
footer.append(useStart, el("span", "spacer"), reset);
|
||||
root.append(sampling, footer);
|
||||
}
|
||||
root.addEventListener("pointerdown", (event) => {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// panel's hidden storage widget stays hidden whichever renderer is on.
|
||||
|
||||
const STASH = "__ausbossVisibilityStash";
|
||||
const PAINT_KEYS = ["computeSize", "computeLayoutSize", "draw"];
|
||||
|
||||
// Collapse a widget to zero height. Returns true when this call changed
|
||||
// visibility, false when it was already hidden (callers use the return to
|
||||
@@ -27,6 +28,10 @@ export function hideWidget(widget) {
|
||||
computeSize: widget.computeSize,
|
||||
computeLayoutSize: widget.computeLayoutSize,
|
||||
draw: widget.draw,
|
||||
// Which of the three the widget carried itself. One it lacked is deleted
|
||||
// again on show: left behind as `undefined`, the frontend takes it for a
|
||||
// custom-drawn widget and App mode draws an empty row.
|
||||
own: Object.fromEntries(PAINT_KEYS.map((key) => [key, Object.prototype.hasOwnProperty.call(widget, key)])),
|
||||
hidden: widget.hidden,
|
||||
optionsHidden: options.hidden,
|
||||
optionsDescriptor: Object.getOwnPropertyDescriptor(widget, "options"),
|
||||
@@ -61,9 +66,10 @@ export function hideWidget(widget) {
|
||||
export function showWidget(widget) {
|
||||
const stash = widget?.[STASH];
|
||||
if (!stash) return false;
|
||||
widget.computeSize = stash.computeSize;
|
||||
widget.computeLayoutSize = stash.computeLayoutSize;
|
||||
widget.draw = stash.draw;
|
||||
for (const key of PAINT_KEYS) {
|
||||
if (stash.own && !stash.own[key]) delete widget[key];
|
||||
else widget[key] = stash[key];
|
||||
}
|
||||
widget.hidden = stash.hidden;
|
||||
const options = widget.options;
|
||||
try {
|
||||
@@ -84,6 +90,11 @@ export function showWidget(widget) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// True while hideWidget holds the widget hidden.
|
||||
export function isWidgetHidden(widget) {
|
||||
return Boolean(widget?.[STASH]);
|
||||
}
|
||||
|
||||
// Drive a widget toward a target visibility; true when anything changed.
|
||||
export function setWidgetVisible(widget, visible) {
|
||||
return visible ? showWidget(widget) : hideWidget(widget);
|
||||
|
||||
@@ -213,6 +213,19 @@ export function matchInstalled(name, files) {
|
||||
return loose ? { found: true, path: loose } : { found: false, path: null };
|
||||
}
|
||||
|
||||
// The copy of `name` to pick without asking: the exact path when the folder
|
||||
// has it, else the only file of that name in any subfolder. Two copies in
|
||||
// different subfolders give null: which one to use is the user's choice.
|
||||
export function onlyCopy(name, files) {
|
||||
const match = matchInstalled(name, files);
|
||||
if (!match.found) return null;
|
||||
const wanted = str(name, 1000).trim().replace(/\\/g, "/").toLowerCase();
|
||||
if (match.path.toLowerCase() === wanted) return match.path;
|
||||
const base = baseName(name).toLowerCase();
|
||||
const copies = files.filter((file) => baseName(str(file, 1000).replace(/\\/g, "/")).toLowerCase() === base);
|
||||
return copies.length === 1 ? match.path : null;
|
||||
}
|
||||
|
||||
// Node packs present in a graph, from each node type's python_module
|
||||
// ("custom_nodes.ComfyUI-AusBoss"). Core modules ("nodes",
|
||||
// "comfy_extras.*") are skipped: nobody needs to install those. The first
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
unionOf,
|
||||
} from "../shared/snap_lines.mjs";
|
||||
import { boundsOf, nodeElements, outlineOf } from "../shared/outline.mjs";
|
||||
import { TILE_MOVE } from "../shared/tile_face.mjs";
|
||||
|
||||
// Snap into line: a node or group being dragged lines up with the nodes and
|
||||
// groups around it, and a teal line shows what it lines up with. A corner
|
||||
@@ -294,6 +295,13 @@ function onPointerMove(event) {
|
||||
});
|
||||
}
|
||||
|
||||
// A frameless tile moves itself and keeps its pointer moves to itself
|
||||
// (js/shared/tile_face.mjs), then reports each move here once placed.
|
||||
function onTileMove(event) {
|
||||
if (!state.before || !event.detail) return;
|
||||
step(event.detail);
|
||||
}
|
||||
|
||||
function end() {
|
||||
state.before = null;
|
||||
state.corner = null;
|
||||
@@ -348,6 +356,7 @@ function install() {
|
||||
window.addEventListener("pointerdown", onPointerDown, true);
|
||||
window.addEventListener("pointerdown", afterPointerDown);
|
||||
window.addEventListener("pointermove", onPointerMove);
|
||||
window.addEventListener(TILE_MOVE, onTileMove);
|
||||
// Capture phase: the classic canvas stops its pointerup from bubbling.
|
||||
window.addEventListener("pointerup", end, true);
|
||||
window.addEventListener("pointercancel", end, true);
|
||||
|
||||
@@ -424,24 +424,25 @@ const CARDS = {
|
||||
],
|
||||
},
|
||||
AUSBOSS_NODES_LoadVideo: {
|
||||
minWidth: 320, first: true, hide: ["upload"],
|
||||
// Every nth and the frame limit (as Duration) are in the timing card
|
||||
// under the player (js/load_video). The card hides them, so App mode can
|
||||
// still show them as fields.
|
||||
minWidth: 320, first: true, hide: ["upload", "every_nth", "max_frames"],
|
||||
rows: [
|
||||
{ widget: "video", label: "Source", kind: "select", preview: { kind: "video", url: viewUrl },
|
||||
button: { text: PANEL_LABELS.load, title: "Upload a video into ComfyUI's input folder", onClick: (node) => node.widgets?.find((w) => w.name === "upload")?.callback?.() } },
|
||||
{ widget: "custom_width", label: "Width", suffix: "px", title: "0 keeps the source width; set one side only to keep the aspect." },
|
||||
{ widget: "custom_height", label: "Height", suffix: "px", title: "0 keeps the source height; set one side only to keep the aspect." },
|
||||
{ widget: "every_nth", label: "Every nth" },
|
||||
{ widget: "max_frames", label: "Limit" },
|
||||
],
|
||||
},
|
||||
AUSBOSS_NODES_LoadAudio: {
|
||||
// The wave, IN and OUT live in the panel under the card (js/load_audio).
|
||||
minWidth: 280, first: true, hide: ["upload"],
|
||||
// The wave and Start, Duration and Ends at live in the panel under the
|
||||
// card (js/load_audio); max_seconds is the Duration there. The card
|
||||
// hides it, so App mode can still show it as a field.
|
||||
minWidth: 280, first: true, hide: ["upload", "max_seconds"],
|
||||
rows: [
|
||||
{ widget: "audio", label: "Source", kind: "select",
|
||||
button: { text: PANEL_LABELS.load, title: "Upload a sound file into ComfyUI's input folder", onClick: (node) => node.widgets?.find((w) => w.name === "upload")?.callback?.() } },
|
||||
{ widget: "max_seconds", label: "Max length", suffix: "s", decimals: 1, trimZeros: true,
|
||||
title: "The longest the sound may be. Anything past it is cut off and shows in red. 0 means no limit." },
|
||||
],
|
||||
},
|
||||
// Load Image: the file, then where it is in the folder and the size it
|
||||
|
||||
+61
-19
@@ -15,7 +15,7 @@ import { app } from "../../../scripts/app.js";
|
||||
import { setTileFace, TILE_FACE_CSS } from "../shared/tile_face.mjs";
|
||||
import { NOTE_TYPES, serializeNoteIdentity } from "../shared/note_identity.mjs";
|
||||
import { compactAction } from "../shared/panel_controls.mjs";
|
||||
import { BRAND, chainCallback, keepDomWidgetWidthAuto, notifyAusbossChange } from "../shared/index.mjs";
|
||||
import { BRAND, chainCallback, keepDomWidgetWidthAuto, notifyAusbossChange, showToast } from "../shared/index.mjs";
|
||||
import { collectGraphNodes } from "../shared/appearance.mjs";
|
||||
import { copyToClipboard } from "../shared/clipboard.mjs";
|
||||
import { confirmDiscard } from "../shared/discard_prompt.mjs";
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
noteIsEmpty,
|
||||
noteShowsTileFace,
|
||||
normalizeNote,
|
||||
onlyCopy,
|
||||
packsFromGraph,
|
||||
parseMarkdown,
|
||||
rowFromCells,
|
||||
@@ -46,8 +47,36 @@ import {
|
||||
} from "../shared/workflow_note.mjs";
|
||||
import { comboValues, commitWidgetValue } from "../shared/widget_card_math.mjs";
|
||||
import { parseRows, serializeRows } from "../shared/lora_stack.mjs";
|
||||
import { isFileWidget } from "../shared/lora_file_widgets.mjs";
|
||||
|
||||
const CSS_ID = "ausboss-workflow-note-css";
|
||||
const PICK_FOUND_SETTING = "AusBoss.Models.PickFoundCopy";
|
||||
|
||||
function pickFoundCopies() {
|
||||
return app.ui?.settings?.getSettingValue?.(PICK_FOUND_SETTING) !== false;
|
||||
}
|
||||
|
||||
// Point the loaders (and LoRA Loader rows) that ask for a file by another
|
||||
// spelling at the copy the note found. Returns how many it changed.
|
||||
function useFoundCopy(path, loaders, loraRows, files) {
|
||||
for (const entry of loaders) {
|
||||
commitWidgetValue(entry.node, entry.widget, listedSpelling(path, entry.options), app.canvas);
|
||||
entry.node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
const stacks = new Map();
|
||||
for (const entry of loraRows) stacks.set(entry.widget, [...(stacks.get(entry.widget) ?? []), entry]);
|
||||
for (const [widget, entries] of stacks) {
|
||||
const rows = parseRows(widget.value);
|
||||
for (const entry of entries) {
|
||||
if (rows[entry.index]) rows[entry.index] = { ...rows[entry.index], name: listedSpelling(path, files) };
|
||||
}
|
||||
commitWidgetValue(entries[0].node, widget, serializeRows(rows), app.canvas);
|
||||
entries[0].node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
app.graph?.setDirtyCanvas?.(true, true);
|
||||
notifyAusbossChange();
|
||||
return loaders.length + loraRows.length;
|
||||
}
|
||||
const WIDGET_NAME = "ausboss_workflow_note_panel";
|
||||
const PANEL_MIN_WIDTH = 300;
|
||||
const CARD_MIN_HEIGHT = 160;
|
||||
@@ -417,22 +446,7 @@ function modelRow(state, row) {
|
||||
use.title = `Point ${names} at ${path}.`;
|
||||
use.addEventListener("pointerdown", (event) => event.stopPropagation());
|
||||
use.addEventListener("click", () => {
|
||||
for (const entry of loaders) {
|
||||
commitWidgetValue(entry.node, entry.widget, listedSpelling(path, entry.options), app.canvas);
|
||||
entry.node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
const stacks = new Map();
|
||||
for (const entry of loraRows) stacks.set(entry.widget, [...(stacks.get(entry.widget) ?? []), entry]);
|
||||
for (const [widget, entries] of stacks) {
|
||||
const rows = parseRows(widget.value);
|
||||
for (const entry of entries) {
|
||||
if (rows[entry.index]) rows[entry.index] = { ...rows[entry.index], name: listedSpelling(path, files) };
|
||||
}
|
||||
commitWidgetValue(entries[0].node, widget, serializeRows(rows), app.canvas);
|
||||
entries[0].node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
app.graph?.setDirtyCanvas?.(true, true);
|
||||
notifyAusbossChange();
|
||||
useFoundCopy(path, loaders, loraRows, files);
|
||||
checkModels(state, false);
|
||||
});
|
||||
action.append(pill, use);
|
||||
@@ -628,6 +642,7 @@ function renderSections(state, scroll) {
|
||||
async function checkModels(state, fresh) {
|
||||
const generation = (state.checkGeneration = (state.checkGeneration || 0) + 1);
|
||||
const rows = state.rows;
|
||||
const picked = [];
|
||||
for (const entry of rows) setDot(entry.dot, "checking", "checking…");
|
||||
const byDir = new Map();
|
||||
for (const entry of rows) {
|
||||
@@ -666,7 +681,14 @@ async function checkModels(state, fresh) {
|
||||
const elsewhere = match.found && subfolderOf(match.path);
|
||||
const loaders = elsewhere ? loadersNeeding(entry.row.name, match.path, graphListWidgets()) : [];
|
||||
const loraRows = elsewhere ? loraRowsNeeding(entry.row.name, match.path, graphLoraLoaders(), files) : [];
|
||||
if (match.found && (loaders.length || loraRows.length)) {
|
||||
if (match.found && (loaders.length || loraRows.length) && pickFoundCopies() && onlyCopy(entry.row.name, files) === match.path) {
|
||||
// One copy, so nothing to choose: the loaders take it without a
|
||||
// click (App mode shows no Guide to click in).
|
||||
useFoundCopy(match.path, loaders, loraRows, files);
|
||||
picked.push(match.path);
|
||||
setDot(entry.dot, "ok", `Found in ${subfolderOf(match.path)}/ and picked: ${match.path}`);
|
||||
entry.showInstalled(match.path);
|
||||
} else if (match.found && (loaders.length || loraRows.length)) {
|
||||
setDot(entry.dot, "ok", `Found in ${subfolderOf(match.path)}/: ${match.path}`);
|
||||
entry.showElsewhere(match.path, loaders, loraRows, files);
|
||||
} else if (match.found) {
|
||||
@@ -678,6 +700,14 @@ async function checkModels(state, fresh) {
|
||||
}
|
||||
}
|
||||
}));
|
||||
if (picked.length && generation === state.checkGeneration) {
|
||||
const folders = [...new Set(picked.map(subfolderOf))].map((folder) => `${folder}/`).join(", ");
|
||||
showToast({
|
||||
summary: "Models found",
|
||||
detail: `${picked.length === 1 ? "1 model file" : `${picked.length} model files`} found in ${folders} and picked for this workflow.`,
|
||||
life: 4000,
|
||||
});
|
||||
}
|
||||
if (state.domWidget && generation === state.checkGeneration) fitNote(state);
|
||||
}
|
||||
|
||||
@@ -756,7 +786,7 @@ function graphListWidgets() {
|
||||
seen.add(graph);
|
||||
for (const node of graph._nodes ?? graph.nodes ?? []) {
|
||||
for (const widget of node.widgets ?? []) {
|
||||
if (widget?.type !== "combo" || typeof widget.value !== "string") continue;
|
||||
if (widget?.type !== "combo" || typeof widget.value !== "string" || isFileWidget(widget)) continue;
|
||||
out.push({ node, widget, value: widget.value, options: comboValues(widget) });
|
||||
}
|
||||
if (node.subgraph) walk(node.subgraph);
|
||||
@@ -1178,6 +1208,18 @@ function buildPanel(node) {
|
||||
|
||||
app.registerExtension({
|
||||
name: "AusBoss.WorkflowNote",
|
||||
settings: [
|
||||
{
|
||||
id: PICK_FOUND_SETTING,
|
||||
name: "Pick model files found in a subfolder",
|
||||
type: "boolean",
|
||||
defaultValue: true,
|
||||
category: ["🆎 AusBoss", "Models", "Pick found files"],
|
||||
tooltip:
|
||||
"When a workflow's Guide finds a model you already have in a subfolder, the workflow switches to that "
|
||||
+ "file by itself. Off: the Guide shows a Use it button instead.",
|
||||
},
|
||||
],
|
||||
beforeRegisterNodeDef(nodeType, nodeData) {
|
||||
if (!NOTE_TYPES.has(nodeData?.name)) return;
|
||||
hideInputsInDef(nodeData, ["note"]);
|
||||
|
||||
@@ -60,6 +60,26 @@ def add_module_version(source, token):
|
||||
return _MODULE_IMPORT.sub(lambda m: f"{m.group(1)}{m.group(2)}{m.group(3)}?v={token}{m.group(2)}", source)
|
||||
|
||||
|
||||
def list_served_scripts(js_root):
|
||||
"""The pack's own scripts by their address below the js folder:
|
||||
{"shared/index.mjs": <path>}. Made once at startup, so a request is
|
||||
only looked up in it and the address a browser sends never reaches the
|
||||
disk: no whole path, network share or ".." is ever opened. Links are
|
||||
left out, and anything that resolves outside the js folder."""
|
||||
root = Path(js_root).resolve()
|
||||
scripts = {}
|
||||
for path in sorted(root.rglob("*")):
|
||||
try:
|
||||
if path.suffix not in (".js", ".mjs") or path.is_symlink() or not path.is_file():
|
||||
continue
|
||||
if not path.resolve().is_relative_to(root):
|
||||
continue
|
||||
except OSError:
|
||||
continue
|
||||
scripts[path.relative_to(root).as_posix()] = path
|
||||
return scripts
|
||||
|
||||
|
||||
def make_revalidate_middleware(pack_name, js_root=None, token=None):
|
||||
"""aiohttp middleware for this pack's scripts, nothing else touched.
|
||||
|
||||
@@ -69,7 +89,7 @@ def make_revalidate_middleware(pack_name, js_root=None, token=None):
|
||||
from aiohttp import web
|
||||
|
||||
marker = f"/extensions/{pack_name}/"
|
||||
root = Path(js_root).resolve() if js_root and token else None
|
||||
scripts = list_served_scripts(js_root) if js_root and token else None
|
||||
served = {}
|
||||
|
||||
def versioned(path):
|
||||
@@ -90,15 +110,15 @@ def make_revalidate_middleware(pack_name, js_root=None, token=None):
|
||||
|
||||
def tagged_response(request):
|
||||
"""The tagged script for this request, or None to let ComfyUI serve it."""
|
||||
if root is None or request.method not in ("GET", "HEAD"):
|
||||
if not scripts or request.method not in ("GET", "HEAD"):
|
||||
return None
|
||||
start = request.path.find(marker)
|
||||
if start < 0 or not request.path.endswith((".js", ".mjs")):
|
||||
return None
|
||||
target = scripts.get(request.path[start + len(marker):])
|
||||
if target is None:
|
||||
return None
|
||||
try:
|
||||
target = (root / request.path[start + len(marker):]).resolve()
|
||||
if not target.is_relative_to(root) or not target.is_file():
|
||||
return None
|
||||
found = versioned(target)
|
||||
except (OSError, ValueError, UnicodeDecodeError):
|
||||
return None
|
||||
|
||||
+230
-40
@@ -19,6 +19,10 @@ STYLE = "style"
|
||||
START = "start on it"
|
||||
END = "end on it"
|
||||
JOBS = (PERSON, SHEET, PLACE, OUTFIT, THING, STYLE, START, END)
|
||||
# Not a pick on the node: a thing picture that does the action of a move copy or a swap (a cartoon hand, a toy,
|
||||
# a mascot). It takes the place a person would, with its own shape and look.
|
||||
PERFORMER = "thing that moves"
|
||||
ACTORS = (PERSON, SHEET, PERFORMER)
|
||||
|
||||
MOVES = "copy its moves"
|
||||
SWAP = "swap the person"
|
||||
@@ -26,7 +30,7 @@ KEEP = "keep going"
|
||||
REVOICE = "new voice"
|
||||
EDIT = "change something"
|
||||
VIDEO_JOBS = (MOVES, SWAP, KEEP, REVOICE, EDIT)
|
||||
KEEPS_ITS_LENGTH = (SWAP, REVOICE, EDIT) # These change a clip, so the new one runs as long as the old one.
|
||||
KEEPS_ITS_LENGTH = (MOVES, SWAP, REVOICE, EDIT) # These follow a clip, so the new one runs as long as the old one.
|
||||
NEEDS_NO_WORDS = (SWAP, KEEP)
|
||||
|
||||
TOKEN = re.compile(r"@(\d)\b")
|
||||
@@ -35,14 +39,31 @@ MAIN = "@0" # The main person, for lines the node writes itself.
|
||||
BACKGROUND = "The background of {picture} is not kept."
|
||||
NOTHING_IN = "Connect a picture or a video. H3 needs one to start from."
|
||||
NEEDS_A_PERSON = {
|
||||
MOVES: "To copy the moves, connect a picture of your person and pick person for it.",
|
||||
SWAP: "To swap the person, connect a picture of the new person and pick person for it.",
|
||||
}
|
||||
# A hat or a shirt with no person picture: the user wants the video's own person to wear it.
|
||||
DRESS_THE_VIDEO_PERSON = 'To put this on the person in your video, pick the video job "change something" and type "He wears @1".'
|
||||
|
||||
SWAP_NEEDS_PERSON_THING = (
|
||||
'A swap needs a picture of the new person, and pick person for it. To show a thing in the clip, '
|
||||
'pick the video job "change something" and type "He holds @1".'
|
||||
)
|
||||
SWAP_NEEDS_PERSON_PLACE = (
|
||||
'A swap keeps the place of the video. Connect a picture of the new person and pick person for it. '
|
||||
'To change the place, pick the video job "change something" and type "It looks like @1".'
|
||||
)
|
||||
REVOICE_KEEPS_PERSON = (
|
||||
"New voice keeps the person in the clip, so a person picture can't change who is in it. "
|
||||
'Take the picture off, or pick the video job "swap the person".'
|
||||
)
|
||||
HE_SHE = re.compile(r"\b(?:he|she|they)\b", re.I)
|
||||
|
||||
# (what the label is, how it is kept). {picture} is H3's number for the picture.
|
||||
JOB_WORDS = {
|
||||
PERFORMER: (
|
||||
"{subject} is the character in {picture}, with the same shape, colours and drawing style.",
|
||||
"fully_preserved - the shape, colours and drawing style are retained.",
|
||||
),
|
||||
PERSON: (
|
||||
"{subject} is the person in {picture}, with the same face, hair and clothes.",
|
||||
"fully_preserved - the face, hair and clothes are retained.",
|
||||
@@ -91,6 +112,18 @@ MOVES_KEPT = (
|
||||
"keep the source performer's face, body, clothes, props, background and colours out of the target.\n"
|
||||
"<Video 1>: attribute_transfer - apply only its camera movement to the target scene."
|
||||
)
|
||||
# Copy its moves with no person picture: the person in the video keeps their own moves and goes where the
|
||||
# script or a place picture says.
|
||||
OWN_MOVES_ARE = (
|
||||
"{main} is the person in <Video 1>, with the same face, hair, body{clothes} and the same moves, gestures and "
|
||||
"timing.\n<Video 1> provides the camera movement."
|
||||
)
|
||||
OWN_MOVES_KEPT = (
|
||||
"{main} (appears in {shots}): {kept}\n"
|
||||
"<Video 1>: attribute_transfer - apply its person, their moves and its camera movement to the target scene; {place}"
|
||||
)
|
||||
OWN_PLACE_FROM = "the background of <Video 1> is not kept, and the place is {place}."
|
||||
OWN_PLACE_KEPT = "keep its place unless the script names a new one."
|
||||
SWAP_VIDEO = "<Video 1> supplies the place, the action, the timing, the camera movement and the look."
|
||||
SWAP_IS = "{replaced} is {who} in <Video 1>, selected for replacement."
|
||||
SWAP_VIDEO_KEPT = (
|
||||
@@ -99,7 +132,28 @@ SWAP_VIDEO_KEPT = (
|
||||
)
|
||||
SWAP_KEPT = "{replaced}: removed - replace {who} with {main} throughout."
|
||||
ONE_GOES = "the original person"
|
||||
THE_PERSON = "the person in the shot"
|
||||
APPEARANCE_LINE = re.compile(r'^\s*@([1-4])\s+looks like\s+([^"\n]+?)\s*$', re.I)
|
||||
# Two ways people type a swap that used to be dropped without a word, so the swap ran with no description and H3
|
||||
# often gave the clip back: the looks sentence on the same line as the swap sentence, and the clothes on a line of
|
||||
# their own ("@1 is wearing a black suit"). A looks sentence starts after a full stop, ! or ?; "Put @1 looks like a
|
||||
# friend here." is one sentence and stays whole.
|
||||
LOOKS_MID_LINE = re.compile(r"(?<=[.!?])[ \t]*(?=@[1-4]\s+looks like\b)", re.I)
|
||||
WEARS_LINE = re.compile(r'^\s*@([1-4])\s+(?:is\s+wearing|wears|is\s+dressed\s+in|has\s+on)\s+([^"@\n]+?)\s*$', re.I)
|
||||
QUOTE = re.compile(r'["\u201c\u201d]')
|
||||
|
||||
|
||||
def looks_on_own_lines(text):
|
||||
"""The script with each @N looks like sentence on a line of its own. A spoken line is left alone."""
|
||||
text = str(text or "")
|
||||
lines = []
|
||||
for line in text.splitlines():
|
||||
if QUOTE.search(line) or not LOOKS_MID_LINE.search(line):
|
||||
lines.append(line)
|
||||
continue
|
||||
first, *rest = LOOKS_MID_LINE.sub("\n", line).splitlines()
|
||||
lines += [re.sub(r"\s+([.,;:])$", r"\1", first), *rest]
|
||||
return "\n".join(lines) if len(lines) != len(text.splitlines()) else text
|
||||
|
||||
|
||||
# Hair and face only, no clothes, expression or background. When the line names clothes that differ from what the
|
||||
@@ -115,6 +169,7 @@ def add_looks(text, jobs, describe):
|
||||
"""A swap's script with an @N looks like line for each new person who has none, written by describe(slot), a
|
||||
small picture-reading model shown that person's picture. Without such a line H3 kept the original person for the
|
||||
first seconds (2026-11-07), so a connected model writes it when the user didn't."""
|
||||
text = looks_on_own_lines(text)
|
||||
typed = {int(match.group(1)) for match in map(APPEARANCE_LINE.match, text.splitlines()) if match}
|
||||
for slot in sorted(jobs):
|
||||
if jobs[slot] not in (PERSON, SHEET) or slot in typed:
|
||||
@@ -137,8 +192,12 @@ def swap_appearances(text, jobs, video):
|
||||
"""
|
||||
if video != SWAP:
|
||||
return text, {}
|
||||
kept, descriptions = [], {}
|
||||
for line in str(text or "").splitlines():
|
||||
kept, descriptions, clothes = [], {}, {}
|
||||
for line in looks_on_own_lines(text).splitlines():
|
||||
worn = WEARS_LINE.fullmatch(line)
|
||||
if worn and (jobs or {}).get(int(worn.group(1))) in (PERSON, SHEET):
|
||||
clothes.setdefault(int(worn.group(1)), []).append(worn.group(2).strip().rstrip(" ."))
|
||||
continue
|
||||
match = APPEARANCE_LINE.fullmatch(line)
|
||||
if match is None:
|
||||
kept.append(line)
|
||||
@@ -150,10 +209,18 @@ def swap_appearances(text, jobs, video):
|
||||
raise ValueError(f"Picture {slot} must be a person or character sheet for a swap's looks like line.")
|
||||
if slot in descriptions:
|
||||
raise ValueError(f"Describe Picture {slot} once, in one looks like line.")
|
||||
description = match.group(2).strip().rstrip(" .")
|
||||
# A sentence on the looks line that names an @ again ("The trees behind @1 stay the same.") is not how
|
||||
# the person looks: it goes back to the script as its own line, or H3 reads a raw @1 in the appearance.
|
||||
sentences = re.split(r"(?<=[.!?])\s+", match.group(2).strip())
|
||||
looks = [sentence for sentence in sentences if not TOKEN.search(sentence)]
|
||||
kept.extend(sentence for sentence in sentences if TOKEN.search(sentence))
|
||||
description = " ".join(looks).strip().rstrip(" .")
|
||||
if not description:
|
||||
raise ValueError(f"Say what Picture {slot}'s person looks like, or remove its looks like line.")
|
||||
descriptions[slot] = description
|
||||
for slot, worn in clothes.items():
|
||||
# Clothes typed on their own line join the description; with none typed, the picture still gives the hair.
|
||||
descriptions[slot] = f"{descriptions.get(slot, 'the same hair')}, wearing {' and '.join(worn)}"
|
||||
return ("\n".join(kept), descriptions) if descriptions else (text, {})
|
||||
|
||||
|
||||
@@ -204,23 +271,24 @@ CLOTHES_STAY = (
|
||||
"attribute_transfer - apply only the face and hair to the original performance; the clothes of {who} in <Video 1> "
|
||||
"stay as they are; the background of {picture} is not transferred."
|
||||
)
|
||||
KEEP_IS = (
|
||||
"<Video 1> is the video being continued, and the target video starts from its last moment.\n"
|
||||
"{main} is the main subject in <Video 1>, with the same look."
|
||||
)
|
||||
KEEP_KEPT = (
|
||||
"<Video 1> (continuation point): fully_preserved - the place, the light, the colours and the camera carry on from its last moment.\n"
|
||||
"{main} (appears in {shots}): fully_preserved - the look is retained."
|
||||
)
|
||||
KEEP_IS = "<Video 1> is the video being continued, and the target video starts from its last moment."
|
||||
KEEP_MAIN = "{main} is the main subject in <Video 1>, with the same look."
|
||||
KEEP_KEPT = "<Video 1> (continuation point): fully_preserved - the place, the light, the colours and the camera carry on from its last moment."
|
||||
KEEP_KEPT_PLACE = "<Video 1> (continuation point): fully_preserved - the light, the colours and the camera carry on from its last moment."
|
||||
KEEP_MAIN_KEPT = "{main} (appears in {shots}): fully_preserved - the look is retained."
|
||||
SOUND_GOES_ON = "<Audio 1> is the soundtrack of <Video 1>, whose sound carries on in the target video."
|
||||
SOUND_GOES_ON_KEPT = "<Audio 1>: reference - the sound continues without copying the source signal."
|
||||
EDIT_IS = (
|
||||
"<Video 1> supplies the place, the person, the action, the timing, the camera movement, the look and the sound.\n"
|
||||
"{main} is the person in <Video 1>, kept as they are: the same face, hair, body and movements, with only what the script names changed."
|
||||
)
|
||||
EDIT_KEPT = (
|
||||
"<Video 1>: partially_preserved - keep the place, the person, the action, the timing, the camera movement, the look and the sound; change only what the script names.\n"
|
||||
"{main} (appears in {shots}): fully_preserved - the face, hair and every movement are retained; only what the script names changes."
|
||||
EDIT_VIDEO = "<Video 1> supplies {supplies}."
|
||||
EDIT_IS = "{main} is the person in <Video 1>, kept as they are: the same face, hair, body and movements, with only what the script names changed."
|
||||
EDIT_VIDEO_KEPT = "<Video 1>: partially_preserved - keep {supplies}; change only what the script names."
|
||||
EDIT_KEPT = "{main} (appears in {shots}): fully_preserved - the face, hair and every movement are retained; only what the script names changes."
|
||||
# What a source video gives an edit, less what a connected picture takes over.
|
||||
EDIT_SUPPLIES = ("the place", "the person", "the action", "the timing", "the camera movement", "the look", "the sound")
|
||||
# A line that is about someone. An edit or a move copy of a clip with nobody in it (an empty hallway) names nobody.
|
||||
NAMES_SOMEONE = re.compile(
|
||||
r"@0|\b(?:he|she|him|her|his|hers|they|them|their|someone|somebody|anyone|everyone|person|people|man|men|woman|women|"
|
||||
r"guy|girl|boy|kid|child|baby|dancer|singer|actor|actress)\b",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
REVOICE_IS = "<Video 1> is the source video for the target video edit.\n{main} is the person speaking in <Video 1>, with the same face, hair and clothing."
|
||||
REVOICE_KEPT = (
|
||||
@@ -229,6 +297,15 @@ REVOICE_KEPT = (
|
||||
)
|
||||
|
||||
|
||||
# A line only names who goes when it is a noun phrase like "the child in the seat", not an action or a pronoun.
|
||||
NOUN_PHRASE = re.compile(r"^(?:the|a|an|this|that|these|those|his|her|their|everyone|someone|somebody|both|each|all)\b", re.I)
|
||||
ACTION_WORD = re.compile(
|
||||
r"\b(?:dances|walks|runs|talks|says|sits|stands|smiles|waves|jumps|enters|leaves|laughs|sings|eats|drinks|waits|"
|
||||
r"is\s+\w+ing|are\s+\w+ing)\b",
|
||||
re.I,
|
||||
)
|
||||
|
||||
|
||||
def who_goes_in(text):
|
||||
"""Who a typed swap line says goes, without the rest of the line: "Elon is @1, he replaces the man at the
|
||||
counter" is the man at the counter, and so is "Replace the man at the counter with @1."."""
|
||||
@@ -244,7 +321,10 @@ def who_goes_in(text):
|
||||
text = re.split(r"[.;!?]", text.strip(" .;!?"), maxsplit=1)[0]
|
||||
text = NAMES_NEXT.sub("", text)
|
||||
text = SAYS_WHO.sub("", TOKEN.sub("", text).strip(" .,;")).strip(" .,;")
|
||||
return re.sub(r"\s+and$", "", text).strip(" .,;")
|
||||
text = re.sub(r"\s+and$", "", text).strip(" .,;")
|
||||
if not (replaces or plain) and not (NOUN_PHRASE.match(text) and not ACTION_WORD.search(text)):
|
||||
return "" # "@1 dances" or "He dances" says what happens, not who goes.
|
||||
return text
|
||||
|
||||
|
||||
def lower_first(text):
|
||||
@@ -274,7 +354,30 @@ class Picture:
|
||||
|
||||
def swapped_in(jobs):
|
||||
"""How many people a swap puts in: one for each person or sheet picture."""
|
||||
return max(1, sum(job in (PERSON, SHEET) for job in jobs.values()))
|
||||
return max(1, sum(job in ACTORS for job in jobs.values()))
|
||||
|
||||
|
||||
# A thing a line holds, wears or uses stays a prop; any other thing named in a line is the one doing the action.
|
||||
HELD = re.compile(
|
||||
r"\b(?:holds?|holding|carr(?:y|ies|ying)|wears?|wearing|puts? on|picks? up|uses?|using|grabs?|throws?|"
|
||||
r"eats?|drinks?|with)\s+(?:\w+\s+){0,2}@(\d)\b",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
|
||||
def things_that_perform(script, jobs, video):
|
||||
"""A move copy or a swap with no person picture: a thing picture the lines make do the action (a cartoon hand
|
||||
waving, a toy dancing) takes the moves, or comes in for the one in the video. With nothing typed, a swap's thing
|
||||
comes in. A thing that is held or worn stays a thing."""
|
||||
if video not in (MOVES, SWAP) or any(job in (PERSON, SHEET) for job in (jobs or {}).values()):
|
||||
return jobs
|
||||
held = {int(slot) for slot in HELD.findall(script or "")}
|
||||
named = {int(slot) for slot in TOKEN.findall(script or "")}
|
||||
jobs = dict(jobs)
|
||||
for slot, job in jobs.items():
|
||||
if job == THING and slot not in held and (slot in named or (video == SWAP and not named)):
|
||||
jobs[slot] = PERFORMER
|
||||
return jobs
|
||||
|
||||
|
||||
def number_pictures(jobs, video=""):
|
||||
@@ -295,15 +398,20 @@ class Cast:
|
||||
self.pictures = pictures
|
||||
self.video = video
|
||||
last = max((picture.subject for picture in pictures), default=0)
|
||||
self.people = [picture for picture in pictures if picture.job in (*ACTORS, START)]
|
||||
self.moves = subject_label(last + 1) if video == MOVES else ""
|
||||
# Nobody to give the moves to: the person in the video keeps them and is the main person.
|
||||
self.own_moves = video == MOVES and not self.people
|
||||
self.video_person = True # The video's own person is in the result; notice_people can say there is none.
|
||||
# In a swap each person or sheet picture takes one person's place in the video, in picture order. The script
|
||||
# can name who goes: "the child in the seat", or "@1 the man on the left. @2 the woman in red".
|
||||
self.swappers = [picture for picture in pictures if picture.job in (PERSON, SHEET)] if video == SWAP else []
|
||||
self.swappers = [picture for picture in pictures if picture.job in ACTORS] if video == SWAP else []
|
||||
goes = len(self.swappers)
|
||||
self.whos = [f"the person on the {spot}" for spot in SPOTS[goes]] if goes > 1 else [ONE_GOES]
|
||||
self.replaced = subject_label(1) if video == SWAP else ""
|
||||
self.in_video = subject_label(last + 1) if video in (KEEP, REVOICE, EDIT) else ""
|
||||
self.people = [picture for picture in pictures if picture.job in (PERSON, SHEET, START)]
|
||||
self.in_video = subject_label(last + 1) if video in (KEEP, REVOICE, EDIT) or self.own_moves else ""
|
||||
if video == KEEP and self.people: # A person picture is the main person; the video adds no second subject.
|
||||
self.in_video = ""
|
||||
self.subjects = {picture.slot: subject_label(picture.subject) for picture in pictures if picture.subject}
|
||||
self.clip_clothes = False # A swap that keeps the clothes of whoever goes.
|
||||
self.appearances = {} # Explicit looks-like lines, by the visible replacement picture slot.
|
||||
@@ -311,6 +419,29 @@ class Cast:
|
||||
self.speaks_as_video = False # With that sound and no words typed: the new person says what the video says.
|
||||
self.typed_lines = False # The script typed words in quotes for someone to say.
|
||||
|
||||
def notice_people(self, text):
|
||||
"""An edit or a move copy with no person picture keeps the video's person only when the lines are about
|
||||
someone, or something is put on them. A clip of an empty hallway gets no made-up person."""
|
||||
if self.video == KEEP:
|
||||
if not self.people and (text or "").strip():
|
||||
self.video_person = bool(NAMES_SOMEONE.search(text))
|
||||
elif self.video == EDIT or self.own_moves:
|
||||
self.video_person = bool(self.of(OUTFIT) or NAMES_SOMEONE.search(text or ""))
|
||||
|
||||
@property
|
||||
def supplies(self):
|
||||
"""What the source video of an edit still gives: a place picture brings the place and its look, a style
|
||||
picture the look."""
|
||||
gone = set()
|
||||
if self.of(PLACE):
|
||||
gone |= {"the place", "the look"}
|
||||
if self.of(STYLE):
|
||||
gone.add("the look")
|
||||
if not self.video_person:
|
||||
gone.add("the person")
|
||||
items = [item for item in EDIT_SUPPLIES if item not in gone]
|
||||
return ", ".join(items[:-1]) + " and " + items[-1]
|
||||
|
||||
def of(self, *jobs):
|
||||
return [picture for picture in self.pictures if picture.job in jobs]
|
||||
|
||||
@@ -356,12 +487,32 @@ class Cast:
|
||||
@property
|
||||
def main(self):
|
||||
"""Who a line is about when it names nobody."""
|
||||
if self.in_video:
|
||||
if self.in_video and self.video_person:
|
||||
return self.in_video
|
||||
if self.people:
|
||||
return subject_label(self.people[0].subject)
|
||||
return next(iter(self.subjects.values()), subject_label(1))
|
||||
|
||||
@property
|
||||
def main_in_shot(self):
|
||||
"""Whether main is a person or thing the clip defines, so "<Subject N> is in the shot" can name it."""
|
||||
if self.in_video and self.video_person and self.main == self.in_video:
|
||||
return True
|
||||
defined = {subject_label(picture.subject) for picture in self.of(*ACTORS, THING, START)}
|
||||
return self.main in defined
|
||||
|
||||
def unclear_speaker(self, moments):
|
||||
"""A refusal when two or more people are connected and a spoken line does not say which one speaks."""
|
||||
if self.video not in ("", MOVES, KEEP) or len(self.people) < 2:
|
||||
return ""
|
||||
people = {picture.slot for picture in self.people}
|
||||
for moment in moments:
|
||||
if moment.speech and not moment.voice and not moment.voiceover:
|
||||
if not any(int(slot) in people for slot in TOKEN.findall(moment.text)):
|
||||
count = "two people" if len(self.people) == 2 else "more than one person"
|
||||
return f'With {count}, name who speaks: @{self.people[1].slot} says "hello".'
|
||||
return ""
|
||||
|
||||
@property
|
||||
def opens(self):
|
||||
return next(iter(self.of(START)), None)
|
||||
@@ -378,9 +529,15 @@ class Cast:
|
||||
if not self.pictures and not self.video:
|
||||
return NOTHING_IN
|
||||
if self.video in NEEDS_A_PERSON and not self.people:
|
||||
if self.of(OUTFIT, THING):
|
||||
if self.of(OUTFIT):
|
||||
return DRESS_THE_VIDEO_PERSON
|
||||
if self.of(THING):
|
||||
return SWAP_NEEDS_PERSON_THING
|
||||
if self.of(PLACE):
|
||||
return SWAP_NEEDS_PERSON_PLACE
|
||||
return NEEDS_A_PERSON[self.video]
|
||||
if self.video == REVOICE and self.of(PERSON, SHEET):
|
||||
return REVOICE_KEEPS_PERSON
|
||||
typed = sorted({int(number) for number in TOKEN.findall(text)} - {0})
|
||||
slots = {picture.slot: picture for picture in self.pictures}
|
||||
for slot in typed:
|
||||
@@ -389,16 +546,23 @@ class Cast:
|
||||
if slots[slot].job == END:
|
||||
return f"Picture {slot} is where the clip ends, so @{slot} can't be in a line. Say what happens on the way there."
|
||||
if typed:
|
||||
for picture in self.of(PERSON, SHEET, THING, OUTFIT):
|
||||
if picture.slot not in typed:
|
||||
return f"Picture {picture.slot} is on, but no line names @{picture.slot}."
|
||||
for picture in self.of(*ACTORS, THING, OUTFIT):
|
||||
if picture.slot in typed:
|
||||
continue
|
||||
# The only person picture is who "He" or "She" means.
|
||||
if picture.job in (PERSON, SHEET) and len(self.of(PERSON, SHEET)) == 1 and HE_SHE.search(text):
|
||||
continue
|
||||
hint = f' Type who wears it, like "He wears @{picture.slot}."' if picture.job == OUTFIT else ""
|
||||
return f"Picture {picture.slot} is on, but no line names @{picture.slot}.{hint}"
|
||||
return ""
|
||||
|
||||
def wearers(self, moments):
|
||||
"""Who wears each outfit: the person named just before it, or else the main person."""
|
||||
found = {}
|
||||
outfits = {subject_label(picture.subject) for picture in self.of(OUTFIT)}
|
||||
default = THE_PERSON if self.main in outfits else self.main # An outfit is never worn by itself.
|
||||
for picture in self.of(OUTFIT):
|
||||
found[picture.slot] = self.main
|
||||
found[picture.slot] = default
|
||||
token = f"@{picture.slot}"
|
||||
for moment in moments:
|
||||
before = moment.text.partition(token)[0]
|
||||
@@ -414,7 +578,9 @@ class Cast:
|
||||
ends = self.ends
|
||||
lines = []
|
||||
if self.video == EDIT:
|
||||
lines.append(EDIT_IS.format(main=self.in_video))
|
||||
lines.append(EDIT_VIDEO.format(supplies=self.supplies))
|
||||
if self.video_person:
|
||||
lines.append(EDIT_IS.format(main=self.in_video))
|
||||
if self.video == SWAP:
|
||||
lines.append(SWAP_VIDEO)
|
||||
lines += [SWAP_IS.format(replaced=gone, who=who) for gone, who, _ in self.swaps]
|
||||
@@ -445,10 +611,17 @@ class Cast:
|
||||
lines.append(FIRST_FRAME.format(picture=picture_label(self.opens.picture)))
|
||||
if ends:
|
||||
lines.append(LAST_FRAME.format(picture=picture_label(ends.picture), last=last))
|
||||
if self.moves:
|
||||
if self.own_moves and not self.video_person:
|
||||
lines.append("<Video 1> provides the camera movement.")
|
||||
elif self.own_moves:
|
||||
clothes = "" if self.of(OUTFIT) else " and clothes,"
|
||||
lines.append(OWN_MOVES_ARE.format(main=self.in_video, clothes=clothes or ","))
|
||||
elif self.moves:
|
||||
lines.append(MOVES_ARE.format(moves=self.moves))
|
||||
if self.video == KEEP:
|
||||
lines.append(KEEP_IS.format(main=self.in_video))
|
||||
lines.append(KEEP_IS)
|
||||
if self.in_video and self.video_person:
|
||||
lines.append(KEEP_MAIN.format(main=self.in_video))
|
||||
if self.video == REVOICE:
|
||||
lines.append(REVOICE_IS.format(main=self.in_video))
|
||||
return "\n".join(lines)
|
||||
@@ -458,7 +631,7 @@ class Cast:
|
||||
subject = subject_label(picture.subject)
|
||||
label = picture_label(picture.picture)
|
||||
wearing = [slot for slot, wearer in wearers.items() if wearer == subject]
|
||||
if self.video == SWAP and picture.job in (PERSON, SHEET):
|
||||
if self.video == SWAP and picture.job in ACTORS:
|
||||
if self.clip_clothes:
|
||||
return CLOTHES_STAY.format(who=self.goes_for(picture), picture=label)
|
||||
return SWAPPED.format(picture=label)
|
||||
@@ -467,9 +640,9 @@ class Cast:
|
||||
elif picture.job == PERSON and wearing:
|
||||
words = DRESSED[1].format(outfit=self.subjects[wearing[0]])
|
||||
else:
|
||||
wearer = wearers.get(picture.slot, self.main)
|
||||
wearer = wearers.get(picture.slot, THE_PERSON if picture.job == OUTFIT else self.main)
|
||||
words = JOB_WORDS[picture.job][1].format(wearer=wearer)
|
||||
if picture.job in (PERSON, SHEET, THING):
|
||||
if picture.job in (*ACTORS, THING):
|
||||
words += " " + BACKGROUND.format(picture=label)
|
||||
return words
|
||||
|
||||
@@ -482,7 +655,9 @@ class Cast:
|
||||
|
||||
lines = []
|
||||
if self.video == EDIT:
|
||||
lines.append(EDIT_KEPT.format(main=self.in_video, shots=shot_list(seen(self.in_video))))
|
||||
lines.append(EDIT_VIDEO_KEPT.format(supplies=self.supplies))
|
||||
if self.video_person:
|
||||
lines.append(EDIT_KEPT.format(main=self.in_video, shots=shot_list(seen(self.in_video))))
|
||||
if self.video == SWAP:
|
||||
lines.append(SWAP_VIDEO_KEPT.format(people="people" if len(self.swaps) > 1 else "person"))
|
||||
lines += [SWAP_KEPT.format(replaced=gone, who=who, main=new) for gone, who, new in self.swaps]
|
||||
@@ -496,10 +671,25 @@ class Cast:
|
||||
lines.append(FIRST_KEPT.format(picture=picture_label(self.opens.picture)))
|
||||
if self.ends:
|
||||
lines.append(LAST_KEPT.format(picture=picture_label(self.ends.picture), last=len(shots)))
|
||||
if self.moves:
|
||||
if self.own_moves and not self.video_person:
|
||||
places = [self.subjects[picture.slot] for picture in self.of(PLACE)]
|
||||
place = OWN_PLACE_FROM.format(place=places[0]) if places else OWN_PLACE_KEPT
|
||||
lines.append(f"<Video 1>: attribute_transfer - apply only its camera movement to the target scene; {place}")
|
||||
elif self.own_moves:
|
||||
outfits = [self.subjects[picture.slot] for picture in self.of(OUTFIT)]
|
||||
kept = (
|
||||
f"partially_preserved - the face, hair, body, moves and timing are retained, and the clothes change to {outfits[0]}."
|
||||
if outfits else "fully_preserved - the face, hair, body, clothes, moves and timing are retained."
|
||||
)
|
||||
places = [self.subjects[picture.slot] for picture in self.of(PLACE)]
|
||||
place = OWN_PLACE_FROM.format(place=places[0]) if places else OWN_PLACE_KEPT
|
||||
lines.append(OWN_MOVES_KEPT.format(main=self.in_video, shots=shot_list(seen(self.in_video)), kept=kept, place=place))
|
||||
elif self.moves:
|
||||
lines.append(MOVES_KEPT.format(moves=self.moves, shots=shot_list(seen(self.main)), main=self.main))
|
||||
if self.video == KEEP:
|
||||
lines.append(KEEP_KEPT.format(main=self.in_video, shots=shot_list(seen(self.in_video))))
|
||||
lines.append(KEEP_KEPT_PLACE if self.of(PLACE) else KEEP_KEPT)
|
||||
if self.in_video and self.video_person:
|
||||
lines.append(KEEP_MAIN_KEPT.format(main=self.in_video, shots=shot_list(seen(self.in_video))))
|
||||
if self.video == REVOICE:
|
||||
lines.append(REVOICE_KEPT.format(main=self.in_video, shots=shot_list(seen(self.in_video))))
|
||||
return "\n".join(lines)
|
||||
|
||||
@@ -13,7 +13,7 @@ import re
|
||||
import numpy as np
|
||||
|
||||
from ._h3_cast_helpers import EDIT, KEEP, NEEDS_NO_WORDS, ONE_GOES, REVOICE, SWAP, Cast, number_pictures, swap_appearances
|
||||
from ._h3_cast_helpers import TOKEN
|
||||
from ._h3_cast_helpers import TOKEN, things_that_perform
|
||||
from ._h3_script_helpers import (
|
||||
ACTION_GOES_ON,
|
||||
PRONOUN,
|
||||
@@ -78,9 +78,10 @@ def one_line(text):
|
||||
|
||||
def clean_words(text):
|
||||
"""Spoken words: one line, no tags, ending the way H3 wants a line to end."""
|
||||
text = one_line(text).replace("<", "").replace(">", "")
|
||||
if text and text[-1] not in ".?!":
|
||||
text += "."
|
||||
# '"Hi," she says' is "Hi.", not "Hi,.". Chinese and Japanese lines end in their own stops: "。", not "。.".
|
||||
text = one_line(text).replace("<", "").replace(">", "").rstrip(" ,;:,、;:")
|
||||
if text and text[-1] not in ".?!。?!…":
|
||||
text += "。" if re.search(r"[\u3040-\u30ff\u4e00-\u9fff]", text) else "."
|
||||
return text
|
||||
|
||||
|
||||
@@ -312,6 +313,7 @@ def write_prompt(script, seconds=15.0, camera="", look="", sound="", language="E
|
||||
longest) puts a question to a small model, if one is connected: it fills in
|
||||
a one-line idea and the sound of the place."""
|
||||
parts = split_sections(script)
|
||||
written = parts is None # Words someone typed in six parts go through as they are.
|
||||
audio = next_label(script, "Audio")
|
||||
speaker = None
|
||||
|
||||
@@ -319,10 +321,13 @@ def write_prompt(script, seconds=15.0, camera="", look="", sound="", language="E
|
||||
jobs = jobs if jobs is not None else {1: "person"}
|
||||
if video == EDIT:
|
||||
script, jobs = put_on_from_pictures(script, jobs)
|
||||
jobs = things_that_perform(script, jobs, video)
|
||||
cast = Cast(number_pictures(jobs, video), video)
|
||||
script, cast.appearances = swap_appearances(script, jobs, video)
|
||||
scene = read_script(script)
|
||||
cast.notice_people(" ".join(moment.text for moment in scene.moments))
|
||||
problem = cast.problem(" ".join(moment.text for moment in scene.moments))
|
||||
problem = problem or cast.unclear_speaker(scene.moments)
|
||||
if problem:
|
||||
raise ValueError(problem)
|
||||
if not scene.moments and video == EDIT:
|
||||
@@ -370,6 +375,8 @@ def write_prompt(script, seconds=15.0, camera="", look="", sound="", language="E
|
||||
scene, seconds, camera=camera, look=look, sound=sound, say=say, cast=cast, sounds=not keeps_song, soundtrack=soundtrack
|
||||
)
|
||||
|
||||
if written and (video == EDIT or (video == SWAP and clip_sound)): # The clip's own sound stays in the result.
|
||||
parts["summary"] = add_task(parts["summary"], "audio reuse")
|
||||
if voice:
|
||||
add_voice(parts, voice_label, speaker)
|
||||
if song_beats is not None and voice:
|
||||
|
||||
+69
-21
@@ -17,15 +17,19 @@ from ._h3_cast_helpers import (
|
||||
MAIN,
|
||||
OUTFIT,
|
||||
PERSON,
|
||||
PERFORMER,
|
||||
PLACE,
|
||||
REVOICE,
|
||||
SHEET,
|
||||
START as START_JOB,
|
||||
END as END_JOB,
|
||||
STYLE,
|
||||
SWAP,
|
||||
SOUND_GOES_ON,
|
||||
SOUND_GOES_ON_KEPT,
|
||||
THING,
|
||||
TOKEN,
|
||||
things_that_perform,
|
||||
ONE_GOES,
|
||||
SPOTS,
|
||||
Cast,
|
||||
@@ -43,7 +47,9 @@ THEN = r"(?:,?\s*(?:and\s+)?then\b|,?\s*and\s+after\s+that\b|,?\s*after\s+that\b
|
||||
# A word that starts a new moment and stays in it.
|
||||
TURN = r"(?=,?\s*\b(?:suddenly|all\s+of\s+a\s+sudden|out\s+of\s+nowhere|finally|at\s+last|(?:hard\s+)?cut\s+to|(?:it\s+|and\s+|(?<!\bit\s))ends?\s+(?:with|on|in|as)|ending\s+(?:with|on|in))\b)"
|
||||
# Where a line breaks into sentences: a full stop that is not a title, the end of a quote, or a semicolon.
|
||||
SENTENCE = r"(?<!\bMr\.)(?<!\bMs\.)(?<!\bDr\.)(?<!\bSt\.)(?<!\bMrs\.)(?<=[.!?])\s+(?=\S)|(?<=\x00)\s+(?=[A-Z])|\s*;\s*"
|
||||
# After a quote, a new sentence starts with a capital or an @: in '"Get a job." @1 looks up' the @1 is a new moment,
|
||||
# or its own words are lost behind the first quote's. So is '"Hi" and @2 says "Bye"': one moment holds one quote.
|
||||
SENTENCE = r"(?<!\bMr\.)(?<!\bMs\.)(?<!\bDr\.)(?<!\bSt\.)(?<!\bMrs\.)(?<=[.!?])\s+(?=\S)|(?<=\x00)\s+(?=[A-Z@])|(?<=\x00),?\s+(?:and|but|while)\s+(?=@\d)|\s*;\s*"
|
||||
CUT_WORDS = re.compile(r"^(?:hard\s+)?(?:cut|cuts|smash\s+cut|jump\s+cut)\s+to\b[:,]?\s*", re.I)
|
||||
NEW_SHOT = re.compile(r"^(?:new\s+shot|next\s+shot|shot\s+\d+)\b[:,.\-]?\s*", re.I)
|
||||
START = re.compile(r"^(?:it\s+|the\s+(?:clip|video|scene|shot)\s+)?(?:starts?|begins?|opens?)(?:\s+(?:with|on|in|at|as)\b[:,]?|\s*:)\s*", re.I)
|
||||
@@ -110,6 +116,30 @@ SOUND_WORDS = 22
|
||||
NAMED = {PLACE: "the place", OUTFIT: "the outfit", THING: "the thing"} # What @2 reads as to the small model.
|
||||
|
||||
WORDS_A_SECOND = 3 # How fast H3 speaks.
|
||||
# Words that trail off ("I never thought...") keep going: across the next cut, or past the end of the clip.
|
||||
TRAILS_OFF = re.compile(r"(?:\.\.\.|\u2026|\u2014|--)\s*$")
|
||||
LINE_CARRIES = "<scenetrans> The line from the previous shot continues seamlessly across the cut, and the words are not repeated."
|
||||
CUT_OFF = "The line is cut off by the end of the video. <cutoff>"
|
||||
|
||||
|
||||
def speech_runs_on(script, seconds):
|
||||
"""(carried, cut_off): the moments whose words go on across the next cut, and the last moment's words if the
|
||||
clip ends mid-line. Words carry on when they trail off with "..." or need more time than their shot has."""
|
||||
starts = timeline(script, seconds)
|
||||
ends = [*starts[1:], seconds]
|
||||
carried, cut_off = set(), None
|
||||
for index, moment in enumerate(script.moments):
|
||||
if not moment.speech:
|
||||
continue
|
||||
trails = bool(TRAILS_OFF.search(moment.speech))
|
||||
long = len(moment.speech.split()) / WORDS_A_SECOND > ends[index] - starts[index] + 0.5
|
||||
following = script.moments[index + 1] if index + 1 < len(script.moments) else None
|
||||
if following is not None and following.cut and not script.one_take and (trails or long):
|
||||
carried.add(index)
|
||||
elif following is None and trails:
|
||||
cut_off = index
|
||||
return carried, cut_off
|
||||
|
||||
HOLD = f"{MAIN} holds still" # What fills the time before a first moment set later.
|
||||
KEEP_LOOK = "The target video keeps the look, the light and the colours of {picture}."
|
||||
KEEP_COLOURS = "The target video keeps the colours and the film grain of {picture}."
|
||||
@@ -130,6 +160,7 @@ OPENS_ON = "The shot begins from {picture}."
|
||||
ENDS_ON = "The shot ends on {picture}."
|
||||
ON_SHEET = "{subject} appears once, without the panels, labels or other views of {picture}."
|
||||
THE_MOVES = "{main} performs the same moves as {moves}, at the same timing."
|
||||
OWN_MOVES = "{main} moves exactly as in <Video 1>, at the same timing."
|
||||
IN_THE_PLACE = "The shot takes place in {place}."
|
||||
WEARS = "{wearer} wears {outfit}."
|
||||
IN_THE_SHOT = "{main} is in the shot."
|
||||
@@ -142,10 +173,10 @@ SAYS_NOTHING = "{main} keeps the lips closed and says nothing the whole time."
|
||||
SPEAKS_AS_VIDEO = "{main} speaks as in <Video 1>, each word landing exactly on the lip movement of <Video 1>."
|
||||
CLIP_SOUND = "The original sound of <Video 1> continues throughout."
|
||||
FOLLOWS_CAMERA = "The camera follows the movement of <Video 1>."
|
||||
REST_AS_VIDEO = "Everything else stays as it is in <Video 1>."
|
||||
SAME_AS_VIDEO = "{main} has the same words, mouth movements and moves as in <Video 1>. Everything else stays as it is in <Video 1>."
|
||||
CARRIES_ON = "The shot carries straight on from the end of <Video 1>."
|
||||
ACTION_GOES_ON = "The action keeps going the way it was heading, and the camera keeps moving the same way."
|
||||
FACES_US = "{main} faces the camera as in <Video 1>."
|
||||
VIDEO_LOOKS = {
|
||||
SWAP: "Retain the look of <Video 1>.",
|
||||
KEEP: "The target video keeps the look, colours and camera of <Video 1>.",
|
||||
@@ -557,12 +588,13 @@ def script_warning(script, seconds, cast=None):
|
||||
if any((moment.at or 0.0) >= seconds for moment in script.moments):
|
||||
return f"A moment starts after the clip ends, at {seconds:g} seconds."
|
||||
starts = timeline(script, seconds)
|
||||
for moment, start, end in zip(script.moments, starts, [*starts[1:], seconds]):
|
||||
carried, cut_off = speech_runs_on(script, seconds)
|
||||
for index, (moment, start, end) in enumerate(zip(script.moments, starts, [*starts[1:], seconds])):
|
||||
unseen = UNSEEN.search(without_speech(moment))
|
||||
if unseen:
|
||||
return f'A camera can\'t see "{unseen.group(0).lower()}". Say what we would see, like "she smiles".'
|
||||
takes = len(moment.speech.split()) / WORDS_A_SECOND
|
||||
if takes > end - start + 0.5:
|
||||
if takes > end - start + 0.5 and index not in carried and index != cut_off:
|
||||
return f"A spoken line takes about {takes:.0f} seconds to say, and its moment has {end - start:.0f}. Give it more room."
|
||||
return ""
|
||||
|
||||
@@ -585,6 +617,7 @@ def script_report(text, seconds, jobs=None, video=""):
|
||||
}
|
||||
for moment, start, end in zip(script.moments, starts, ends)
|
||||
]
|
||||
jobs = things_that_perform(text, jobs, video) if jobs is not None else None
|
||||
cast = Cast(number_pictures(jobs, video), video) if jobs is not None else None
|
||||
return {"moments": moments, "seconds": seconds, "warning": script_warning(script, seconds, cast)}
|
||||
|
||||
@@ -732,6 +765,8 @@ def before_the_action(number, text, cast, wearers):
|
||||
# or for the whole clip at Fast preview; with it the new
|
||||
# person is there from the first frame. An @1 looks like line only adds its own words.
|
||||
looks = (f"has the defined appearance from {picture_label(picture.picture)}: {appearance}" if appearance
|
||||
else f"has the shape, colours and drawing style of the character in {picture_label(picture.picture)}"
|
||||
if picture.job == PERFORMER
|
||||
else f"has the face, hair and clothes of the person in {picture_label(picture.picture)}")
|
||||
notes.append(
|
||||
f"{new} occupies the starting position of {who} and follows the same route, movements, timing and pace. "
|
||||
@@ -749,8 +784,6 @@ def before_the_action(number, text, cast, wearers):
|
||||
notes.append((OWN_LINES_ONLY if f"{new} (S" in text else SAYS_NOTHING).format(main=new))
|
||||
if number == 1 and cast.video == KEEP:
|
||||
notes += [CARRIES_ON]
|
||||
if number == 1 and cast.video == REVOICE:
|
||||
notes += [FACES_US.format(main=cast.main)]
|
||||
places = [subject_label(picture.subject) for picture in cast.of(PLACE)]
|
||||
if places and not any(place in text for place in places):
|
||||
notes.append(IN_THE_PLACE.format(place=places[0]))
|
||||
@@ -760,7 +793,8 @@ def before_the_action(number, text, cast, wearers):
|
||||
notes.append(sentence(", ".join(spots[:-1]) + f" and {spots[-1]} of the frame"))
|
||||
for slot, wearer in wearers.items():
|
||||
outfit = cast.subjects[slot]
|
||||
if outfit not in text and (wearer in people or wearer in text):
|
||||
# An edit has no person picture: the person in the video wears an outfit that no line names.
|
||||
if outfit not in text and (wearer in people or wearer in text or (cast.video == EDIT and wearer == cast.in_video)):
|
||||
notes.append(WEARS.format(wearer=wearer, outfit=outfit))
|
||||
return notes
|
||||
|
||||
@@ -768,10 +802,10 @@ def before_the_action(number, text, cast, wearers):
|
||||
def after_the_action(text, cast):
|
||||
"""What H3 needs to hear about a shot once its action has been said."""
|
||||
notes = []
|
||||
if cast.moves and cast.main in text:
|
||||
notes.append(THE_MOVES.format(main=cast.main, moves=cast.moves))
|
||||
if cast.moves and cast.video_person and cast.main in text:
|
||||
notes.append(OWN_MOVES.format(main=cast.main) if cast.own_moves else THE_MOVES.format(main=cast.main, moves=cast.moves))
|
||||
if cast.video == EDIT:
|
||||
notes.append(SAME_AS_VIDEO.format(main=cast.main))
|
||||
notes.append(SAME_AS_VIDEO.format(main=cast.main) if cast.video_person else REST_AS_VIDEO)
|
||||
if cast.video in (SWAP, EDIT):
|
||||
notes.append(FOLLOWS_CAMERA)
|
||||
for picture in cast.of(SHEET):
|
||||
@@ -799,6 +833,7 @@ def shot_lines(script, seconds, say, cast, wearers, move="", hold="", sounds=Tru
|
||||
talking = speakers(script.moments, cast)
|
||||
quiet = " ".join(QUIET.format(speaker=speaker) for speaker in talking if speaker.startswith("<"))
|
||||
kept = still_true(script.moments)
|
||||
carried, cut_off = speech_runs_on(script, seconds)
|
||||
lines = []
|
||||
for number, shot in enumerate(shots_of(script), 1):
|
||||
shot_camera = script.moments[shot[0]].camera
|
||||
@@ -841,8 +876,17 @@ def shot_lines(script, seconds, say, cast, wearers, move="", hold="", sounds=Tru
|
||||
*([hold] if number > 1 else []),
|
||||
capital(script.moments[first].sound) if script.moments[first].sound and not script.silent else "",
|
||||
]
|
||||
lines.append(f"[Shot {number}] " + " ".join(part for part in body if part))
|
||||
if not any(cast.main in line for line in lines):
|
||||
line = " ".join(part for part in body if part)
|
||||
if shot[0] - 1 in carried:
|
||||
# The speaker is mid-line as the shot opens, so the mouth is not closed here.
|
||||
line = f"{LINE_CARRIES} " + re.sub(r" ?<Subject \d+> stays silent with the lips closed\.", "", line, count=1)
|
||||
if shot[-1] in carried:
|
||||
# The speaker is still talking at the cut, so the mouth does not close here.
|
||||
line = re.sub(r" <Subject \d+> closes the lips\.", "", line) + " <scenetrans>"
|
||||
if shot[-1] == cut_off:
|
||||
line = re.sub(r" <Subject \d+> closes the lips\.", "", line) + f" {CUT_OFF}"
|
||||
lines.append(f"[Shot {number}] " + line)
|
||||
if cast.video_person and cast.main_in_shot and not any(cast.main in line for line in lines):
|
||||
lines[0] = lines[0].replace("[Shot 1] ", f"[Shot 1] {IN_THE_SHOT.format(main=cast.main)} ", 1)
|
||||
return lines
|
||||
|
||||
@@ -881,16 +925,19 @@ def summary_of(script, cast, new_places, soundtrack):
|
||||
return f"[{task}] {changes} Everything else in <Video 1> is kept."
|
||||
if cast.video == KEEP:
|
||||
tag = f"{task} + audio reference" if soundtrack else task
|
||||
return f"[{tag}] The target video continues directly from the end of <Video 1> in the same place."
|
||||
opening = with_labels(without_speech(script.moments[0]), cast) or f"{cast.main} speaks"
|
||||
where = "" if cast.of(PLACE) else " in the same place"
|
||||
return f"[{tag}] The target video continues directly from the end of <Video 1>{where}."
|
||||
talking = [who for who in speakers(script.moments, cast) if who.startswith("<")]
|
||||
who_speaks = f"{' and '.join(talking)} speak" if len(talking) > 1 else f"{cast.main} speaks"
|
||||
opening = with_labels(without_speech(script.moments[0]), cast) or who_speaks
|
||||
later = [with_labels(without_speech(script.moments[shot[0]]), cast) for shot in shots_of(script)[1:]]
|
||||
if cast.opens and cast.ends:
|
||||
moving = f"moving from {picture_label(cast.opens.picture)} to {picture_label(cast.ends.picture)}"
|
||||
return f"[{task}] In the target video, {lower_first(opening.rstrip('.!? '))}, {moving}."
|
||||
summary = f"[{task}] In the target video, {lower_first(sentence(opening))}"
|
||||
summary += "".join(f" {AND_THEN.format(line=lower_first(sentence(line)))}" for line in later if line)
|
||||
if cast.moves:
|
||||
summary += " " + THE_MOVES.format(main=cast.main, moves=cast.moves)
|
||||
if cast.moves and cast.video_person:
|
||||
summary += " " + (OWN_MOVES.format(main=cast.main) if cast.own_moves else THE_MOVES.format(main=cast.main, moves=cast.moves))
|
||||
return f"{summary} {EVERY_PLACE}" if new_places else summary
|
||||
|
||||
|
||||
@@ -916,14 +963,15 @@ def script_parts(script, seconds, camera="", look="", sound="", say=None, cast=N
|
||||
cuts = [script.moments[shot[0]] for shot in shots_of(script)[1:]]
|
||||
moved = any(not FRAME_WORDS.match(without_speech(moment)) for moment in cuts)
|
||||
new_places = last > 1 and not cast.of(PLACE) and moved and all(not FRAME_WORDS.match(without_speech(moment)) for moment in cuts)
|
||||
first = next(iter(cast.of(PLACE) or cast.pictures), None)
|
||||
if not style and cast.video == EDIT:
|
||||
# Only a place, a start frame or a person sets the look; an outfit, a thing or a style never does.
|
||||
first = next(iter(cast.of(PLACE) or cast.of(START_JOB) or cast.of(PERSON, SHEET, PERFORMER, END_JOB)), None)
|
||||
if not style and cast.video == EDIT and not cast.of(PLACE):
|
||||
style = VIDEO_LOOKS[EDIT]
|
||||
if not style and len(cast.of(PLACE)) > 1:
|
||||
style = OWN_COLOURS
|
||||
elif not style and not (first and first.job == THING):
|
||||
elif not style and (first or cast.video in VIDEO_LOOKS):
|
||||
words = KEEP_LOOK if cast.opens else KEEP_COLOURS
|
||||
style = VIDEO_LOOKS.get(cast.video) or words.format(picture=picture_label(first.picture if first else 1))
|
||||
style = (cast.video != EDIT and VIDEO_LOOKS.get(cast.video)) or words.format(picture=picture_label(first.picture if first else 1))
|
||||
takes = [EVERY_PLACE] if new_places else []
|
||||
if last == 1 and (len(script.moments) > 1 or cast.moves or script.one_take):
|
||||
takes = [ONE_SHOT]
|
||||
@@ -947,7 +995,7 @@ def script_parts(script, seconds, camera="", look="", sound="", say=None, cast=N
|
||||
"subject_definitions": subjects,
|
||||
"summary": summary_of(script, cast, new_places, soundtrack),
|
||||
"retention_analysis": kept,
|
||||
"detailed_description": "\n".join([" ".join(part for part in (style, move, *takes) if part), *lines]),
|
||||
"detailed_description": "\n".join([*[" ".join(part for part in (style, move, *takes) if part)] * bool(style or move or takes), *lines]),
|
||||
"overall_soundscape": ambience,
|
||||
"non_diegetic_music": tune,
|
||||
}
|
||||
|
||||
@@ -40,6 +40,9 @@ OUTSIDE = (
|
||||
"Image Folder reads only folders inside ComfyUI's input or output folder. "
|
||||
"Drop your folder on the node, or press Add, and its pictures are copied in."
|
||||
)
|
||||
# A drive ("D:") in any part of a folder name, and control characters.
|
||||
_DRIVE = re.compile(r"^[A-Za-z]:")
|
||||
_CONTROL = re.compile(r"[\x00-\x1f\x7f]")
|
||||
NO_FOLDER = 'Image Folder: there is no folder "{folder}" in ComfyUI\'s {source} folder.'
|
||||
NO_PICTURES = 'Image Folder: no pictures in "{folder}". Add some, or choose another folder.'
|
||||
NONE_LEFT = "Image Folder: none of the picked pictures are in the folder anymore. Pick again on the node."
|
||||
@@ -64,7 +67,9 @@ def clean_folder(folder) -> str:
|
||||
if text.startswith("/") or text.startswith("~") or re.match(r"^[A-Za-z]:", text):
|
||||
raise ValueError(OUTSIDE)
|
||||
parts = [part for part in text.split("/") if part not in ("", ".")]
|
||||
if any(part == ".." for part in parts):
|
||||
# ".." climbs out; a drive in any part ("a/D:/x") jumps to another drive
|
||||
# on Windows; a control character is never part of a folder name.
|
||||
if any(part == ".." or _DRIVE.match(part) for part in parts) or _CONTROL.search(text):
|
||||
raise ValueError(OUTSIDE)
|
||||
return "/".join(parts)
|
||||
|
||||
@@ -82,9 +87,10 @@ def place_inside(folder, roots: dict) -> tuple[str, str] | None:
|
||||
This compares text only. A path that is outside those folders is never
|
||||
looked up on disk, and one on another machine is refused from its text."""
|
||||
text = str(folder or "").strip().strip('"').replace("\\", "/")
|
||||
if not looks_full(text) or text.startswith("//"):
|
||||
# A "~" path is not expanded: only a path written out in full can match.
|
||||
if not looks_full(text) or text.startswith("//") or text.startswith("~"):
|
||||
return None
|
||||
full = os.path.normpath(os.path.expanduser(text))
|
||||
full = os.path.normpath(text)
|
||||
for source, root in roots.items():
|
||||
for base in {os.path.normpath(str(root)), os.path.realpath(str(root))}:
|
||||
if full == base:
|
||||
@@ -94,14 +100,27 @@ def place_inside(folder, roots: dict) -> tuple[str, str] | None:
|
||||
return None
|
||||
|
||||
|
||||
def inside_root(top: Path, relative: str) -> Path:
|
||||
"""`relative` below the resolved root `top`, as a resolved path. It is
|
||||
checked as text before the disk is asked to resolve it, and again after,
|
||||
so a link that leads out of the root is refused too."""
|
||||
if not relative:
|
||||
return top
|
||||
lexical = top.joinpath(*relative.split("/"))
|
||||
if top not in lexical.parents:
|
||||
raise ValueError(OUTSIDE)
|
||||
target = lexical.resolve()
|
||||
if target != top and top not in target.parents:
|
||||
raise ValueError(OUTSIDE)
|
||||
return target
|
||||
|
||||
|
||||
def safe_folder(root, folder, source: str = "input") -> Path:
|
||||
"""The folder as a real path below `root`. A link that leads out of the
|
||||
root is refused like any other way out."""
|
||||
relative = clean_folder(folder)
|
||||
top = Path(root).resolve()
|
||||
target = top.joinpath(*relative.split("/")).resolve() if relative else top
|
||||
if target != top and top not in target.parents:
|
||||
raise ValueError(OUTSIDE)
|
||||
target = inside_root(top, relative)
|
||||
if not target.is_dir():
|
||||
raise ValueError(NO_FOLDER.format(folder=relative, source=source))
|
||||
return target
|
||||
|
||||
@@ -6,18 +6,26 @@ that are wanted: they are copied into the output folder under the names the
|
||||
node would have given them. Everything here works from names this module
|
||||
made itself; the only thing a caller sends is the run's token and which
|
||||
pictures to keep.
|
||||
|
||||
What a run holds (its settings, its count, what was kept) stays in this
|
||||
process's memory, never in a file. ComfyUI's temp folder takes uploads, so a
|
||||
list read back from there could be anyone's. The held pictures themselves
|
||||
are named from the token, their number and one of the node's own formats,
|
||||
and must still be in the held folder when they are copied.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import secrets
|
||||
import shutil
|
||||
import threading
|
||||
|
||||
from ._image_save_helpers import (
|
||||
FORMAT_EXTENSIONS,
|
||||
IMAGE_SAVE_LOCK,
|
||||
existing_action,
|
||||
name_stem,
|
||||
@@ -34,6 +42,14 @@ from ._image_save_helpers import (
|
||||
HELD_FOLDER = "ausboss_held"
|
||||
_TOKEN = re.compile(r"^[0-9a-f]{16}$")
|
||||
GONE = "These pictures are no longer held. Run the workflow again."
|
||||
# The held pictures' formats: the extensions Save Image writes, nothing else.
|
||||
HELD_EXTENSIONS = frozenset(FORMAT_EXTENSIONS.values())
|
||||
# A run holds at most this many pictures, and the server remembers this many
|
||||
# runs; the oldest is forgotten first and then says GONE.
|
||||
MAX_HELD_PICTURES = 10000
|
||||
MAX_HELD_RUNS = 256
|
||||
_RUNS: "OrderedDict[str, dict]" = OrderedDict()
|
||||
_RUNS_LOCK = threading.Lock()
|
||||
|
||||
|
||||
def plan_destinations(settings: dict, count: int, now: datetime, root: Path, output_root: Path, picks=None):
|
||||
@@ -88,15 +104,31 @@ def settle_destinations(planned, has_caption: bool, output_root: Path) -> list[s
|
||||
|
||||
|
||||
def _held_name(token: str, index: int, extension: str) -> str:
|
||||
if not _TOKEN.match(token) or extension not in HELD_EXTENSIONS or not 0 <= index < MAX_HELD_PICTURES:
|
||||
raise ValueError("Save Image: that is not a picture it is holding.")
|
||||
return f"{token}_{index:03d}.{extension}"
|
||||
|
||||
|
||||
def _held_source(folder: Path, token: str, index: int, extension: str) -> Path:
|
||||
"""A held picture's file, which must still sit directly in the held folder."""
|
||||
source = folder / _held_name(token, index, extension)
|
||||
if not source.is_file() or source.is_symlink() or source.resolve().parent != folder.resolve():
|
||||
raise LookupError(GONE)
|
||||
return source
|
||||
|
||||
|
||||
def hold_pictures(temp_root, frames, settings: dict, encode) -> tuple[str, list[dict]]:
|
||||
"""Write a run's pictures to the temp folder and remember how to name them.
|
||||
|
||||
`encode(path, frame)` writes one picture in the run's format. Returns
|
||||
the run's token and the entries the node shows them from.
|
||||
"""
|
||||
frames = list(frames)
|
||||
if len(frames) > MAX_HELD_PICTURES:
|
||||
raise ValueError(
|
||||
f"Save Image: {len(frames)} pictures are too many to hold (at most {MAX_HELD_PICTURES}). "
|
||||
"Turn Auto save on to save them straight away."
|
||||
)
|
||||
folder = Path(temp_root) / HELD_FOLDER
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
token = secrets.token_hex(8)
|
||||
@@ -105,8 +137,10 @@ def hold_pictures(temp_root, frames, settings: dict, encode) -> tuple[str, list[
|
||||
name = _held_name(token, index, settings["extension"])
|
||||
encode(folder / name, frame)
|
||||
previews.append({"filename": name, "subfolder": HELD_FOLDER, "type": "temp"})
|
||||
manifest = dict(settings, count=len(previews), kept={})
|
||||
(folder / f"{token}.json").write_text(json.dumps(manifest), encoding="utf-8")
|
||||
with _RUNS_LOCK:
|
||||
_RUNS[token] = dict(settings, count=len(previews), kept={})
|
||||
while len(_RUNS) > MAX_HELD_RUNS:
|
||||
_RUNS.popitem(last=False)
|
||||
return token, previews
|
||||
|
||||
|
||||
@@ -119,16 +153,18 @@ def keep_pictures(temp_root, output_root, token, picks=None, now: datetime | Non
|
||||
if not isinstance(token, str) or not _TOKEN.match(token):
|
||||
raise ValueError("Save Image: that is not a run it is holding.")
|
||||
folder = Path(temp_root) / HELD_FOLDER
|
||||
manifest_path = folder / f"{token}.json"
|
||||
if not manifest_path.is_file():
|
||||
with _RUNS_LOCK:
|
||||
manifest = _RUNS.get(token)
|
||||
if manifest is None:
|
||||
raise LookupError(GONE)
|
||||
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
||||
count = int(manifest["count"])
|
||||
kept = {int(index): str(path) for index, path in dict(manifest.get("kept") or {}).items()}
|
||||
kept = dict(manifest["kept"])
|
||||
|
||||
if picks is None:
|
||||
wanted = list(range(count))
|
||||
else:
|
||||
if len(picks) > MAX_HELD_PICTURES:
|
||||
raise ValueError("Save Image: that picture is not in this run.")
|
||||
wanted = []
|
||||
for pick in picks:
|
||||
if isinstance(pick, bool) or not isinstance(pick, int) or not 0 <= pick < count:
|
||||
@@ -151,17 +187,14 @@ def keep_pictures(temp_root, output_root, token, picks=None, now: datetime | Non
|
||||
if action == "skip":
|
||||
skipped.append(index)
|
||||
continue
|
||||
source = folder / _held_name(token, index, manifest["extension"])
|
||||
if not source.is_file():
|
||||
raise LookupError(GONE)
|
||||
source = _held_source(folder, token, index, manifest["extension"])
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(source, path)
|
||||
if has_caption:
|
||||
sidecar_path(path).write_text(caption, encoding="utf-8")
|
||||
kept[index] = path.resolve().relative_to(resolved_root).as_posix()
|
||||
saved.append(index)
|
||||
manifest["kept"] = {str(index): path for index, path in kept.items()}
|
||||
manifest_path.write_text(json.dumps(manifest), encoding="utf-8")
|
||||
manifest["kept"] = kept
|
||||
return {
|
||||
"count": count,
|
||||
"saved": [{"index": index, "path": kept[index]} for index in saved],
|
||||
|
||||
@@ -653,10 +653,13 @@ def apply_stitch(
|
||||
exact with the toggle off, since the spread deliberately rewrites the
|
||||
feathered band.
|
||||
|
||||
``color_match`` (0..1) shifts the patch's tone by the offset measured
|
||||
in the feathered band (:func:`estimate_tone_offset`) before blending,
|
||||
so an outpaint whose new bands came out a touch lighter or warmer than
|
||||
the picture lands on the picture's own tone. 0 leaves the patch alone.
|
||||
``color_match`` (0..1) shifts the patch's tone by the measured drift
|
||||
before blending, so a new area that came out a touch lighter or warmer
|
||||
than the picture lands on the picture's own tone. An outpaint is read
|
||||
across its seams (:func:`tone_offset_field`); an inpaint, which has no
|
||||
source rectangle, inside its painted area (:func:`inner_tone_offset`),
|
||||
or in the feathered band (:func:`estimate_tone_offset`) when the
|
||||
painted area holds new content. 0 leaves the patch alone.
|
||||
|
||||
``seam`` "classic" is everything above. "blend in" replaces it on a
|
||||
stitcher that knows where the picture's edge is (Load Image + Pad and
|
||||
@@ -788,7 +791,13 @@ def apply_stitch(
|
||||
# Trimmed like the blend when fewer frames came back.
|
||||
generated = generated[:frames] if generated.shape[0] > frames else generated
|
||||
generated = generated[:, cy : cy + ch, cx : cx + cw].to(out.device)
|
||||
field = tone_offset_field(patch, out[:, cy : cy + ch, cx : cx + cw, :], alpha, bbox, generated)
|
||||
region = out[:, cy : cy + ch, cx : cx + cw, :]
|
||||
field = tone_offset_field(patch, region, alpha, bbox, generated)
|
||||
if bbox is None:
|
||||
# An inpaint has no source rectangle to read a seam across. Its
|
||||
# drift is read just inside the painted area, where it holds.
|
||||
inner, held = inner_tone_offset(patch, region, alpha, came_back)
|
||||
field = torch.where(held.view(-1, 1, 1, 1), inner.view(-1, 1, 1, 3).expand_as(field), field)
|
||||
# Weighted by the blend: a fully generated pixel drifted by the whole
|
||||
# field, a band pixel the sampler mixed at alpha drifted by alpha of
|
||||
# it, and the blend below scales the correction by alpha once more.
|
||||
@@ -841,6 +850,175 @@ def estimate_tone_offset(
|
||||
return torch.where(measured, offset, torch.zeros_like(offset))
|
||||
|
||||
|
||||
# An inpaint's drift is read in the painted area's own rim: this many
|
||||
# pixels in from where the paste becomes whole. The rim is where the new
|
||||
# part most often still shows what was there before (skin beside skin).
|
||||
INNER_RIM_PX = 32
|
||||
|
||||
# Rim pixels within this many LAB units of the rim's median change count as
|
||||
# the same content, drifted. The reading is only used when at least
|
||||
# INNER_MIN_SHARE of the rim agrees and there are INNER_MIN_PIXELS of it.
|
||||
INNER_SAME_CONTENT = 8.0
|
||||
INNER_MIN_SHARE = 0.5
|
||||
INNER_MIN_PIXELS = 64
|
||||
|
||||
# A larger change than this is new content (a jacket over skin), not a
|
||||
# drift: matching it would pull the new thing toward the old colour.
|
||||
INNER_MAX_SHIFT = 20.0
|
||||
|
||||
|
||||
# New content has no "before" in its own place (skin where a shirt was), so
|
||||
# it is read against the untouched picture beside it instead: the painted
|
||||
# area and the picture, each averaged within this many pixels of a point.
|
||||
NEIGHBOUR_REACH_PX = 48
|
||||
|
||||
# A point counts as on the seam when each side fills this much of its reach.
|
||||
NEIGHBOUR_MIN_SIDE = 0.1
|
||||
|
||||
# Seam points within INNER_MAX_SHIFT of each other show the same thing on
|
||||
# both sides (skin beside skin). Fewer than this share of the seam and the
|
||||
# new part is something else all round, so nothing is matched.
|
||||
NEIGHBOUR_MIN_SHARE = 0.25
|
||||
|
||||
|
||||
def _neighbour_offset(
|
||||
new: torch.Tensor, old: torch.Tensor, whole: torch.Tensor, outside: torch.Tensor
|
||||
) -> torch.Tensor | None:
|
||||
"""LAB offset of new content against the untouched picture beside it.
|
||||
|
||||
``new`` and ``old`` are one frame in LAB [H, W, 3]; ``whole`` marks the
|
||||
fully pasted pixels and ``outside`` the untouched ones. Along the seam
|
||||
the painted side's local mean is compared with the picture's. Where the
|
||||
two are alike the model drew more of what is already there, and the gap
|
||||
between them is its drift. None when too little of the seam is alike or
|
||||
the alike part does not agree on one gap.
|
||||
"""
|
||||
size = 2 * NEIGHBOUR_REACH_PX + 1
|
||||
|
||||
def local(values: torch.Tensor, mask: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
weight = mask.to(values.dtype).unsqueeze(-1)
|
||||
stack = torch.cat([values * weight, weight], dim=-1).movedim(-1, 0).unsqueeze(0)
|
||||
stack = functional.avg_pool2d(stack, (1, size), stride=1, padding=(0, NEIGHBOUR_REACH_PX))
|
||||
stack = functional.avg_pool2d(stack, (size, 1), stride=1, padding=(NEIGHBOUR_REACH_PX, 0))[0]
|
||||
return (stack[:3] / stack[3:].clamp_min(1e-6)).movedim(0, -1), stack[3]
|
||||
|
||||
painted, painted_share = local(new, whole)
|
||||
picture, picture_share = local(old, outside)
|
||||
seam = (painted_share >= NEIGHBOUR_MIN_SIDE) & (picture_share >= NEIGHBOUR_MIN_SIDE)
|
||||
gaps = (painted - picture)[seam]
|
||||
if gaps.shape[0] < INNER_MIN_PIXELS:
|
||||
return None
|
||||
alike = gaps.norm(dim=-1) <= INNER_MAX_SHIFT
|
||||
if int(alike.sum()) < INNER_MIN_PIXELS or float(alike.float().mean()) < NEIGHBOUR_MIN_SHARE:
|
||||
return None
|
||||
gaps = gaps[alike]
|
||||
agree = (gaps - gaps.median(dim=0).values).norm(dim=-1) < INNER_SAME_CONTENT
|
||||
if float(agree.float().mean()) < INNER_MIN_SHARE:
|
||||
return None
|
||||
return gaps[agree].median(dim=0).values
|
||||
|
||||
|
||||
def _area_resize(image: torch.Tensor, width: int, height: int) -> torch.Tensor:
|
||||
"""Shrink [B, H, W, C] by averaging the pixels each new one covers."""
|
||||
return functional.interpolate(image.movedim(-1, 1), size=(height, width), mode="area").movedim(1, -1)
|
||||
|
||||
|
||||
def inner_tone_offset(
|
||||
inpainted: torch.Tensor,
|
||||
canvas: torch.Tensor,
|
||||
blend: torch.Tensor,
|
||||
sampled: tuple[int, int] | None = None,
|
||||
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
"""Per-frame LAB drift of an inpaint, read inside the painted area.
|
||||
|
||||
:func:`estimate_tone_offset` reads the feathered band and assumes the
|
||||
sampler mixed original and generated there by ``blend``. A workflow that
|
||||
samples with its own, wider or softer noise mask breaks that: the model
|
||||
leaves the band close to the original and drifts further in, so the band
|
||||
reads a fraction of the drift (issue #361: 0.8 of 2.5 LAB units).
|
||||
|
||||
This reads the same pixels before and after in the rim of the fully
|
||||
pasted area (``blend`` > 0.999, INNER_RIM_PX deep): the median change,
|
||||
then the median again over the pixels that agree with it. Returns the
|
||||
offsets [B, 3] and which frames hold [B]. A frame whose rim mostly
|
||||
disagrees, or changed by more than INNER_MAX_SHIFT, is new content
|
||||
rather than drift. That frame is read against the untouched picture
|
||||
beside it (:func:`_neighbour_offset`), and holds at zero, left as
|
||||
painted, when the picture beside it shows something else. Only a rim too
|
||||
small to judge does not hold, and the caller keeps the band reading for it.
|
||||
|
||||
``sampled`` is the (width, height) the model worked at. A crop from a
|
||||
large picture is pasted back several times that size, and a rim measured
|
||||
in pasted pixels would be a sliver at the very edge of what the model
|
||||
painted, where it drifts least. The reading is taken at the model's
|
||||
size instead, which also keeps its cost the same for any picture.
|
||||
"""
|
||||
from ._color_helpers import rgb_to_lab
|
||||
|
||||
if sampled is not None:
|
||||
width, height = int(sampled[0]), int(sampled[1])
|
||||
if 0 < width < inpainted.shape[2] and 0 < height < inpainted.shape[1]:
|
||||
inpainted = _area_resize(inpainted, width, height)
|
||||
canvas = _area_resize(canvas, width, height)
|
||||
blend = _area_resize(blend.unsqueeze(-1), width, height).squeeze(-1)
|
||||
new = rgb_to_lab(inpainted[..., :3])
|
||||
old = rgb_to_lab(canvas[..., :3])
|
||||
diff = new - old
|
||||
frames = diff.shape[0]
|
||||
whole = (blend > 0.999).to(diff.dtype)
|
||||
size = 2 * INNER_RIM_PX + 1
|
||||
# A pixel is deeper than the rim when nothing within INNER_RIM_PX of it
|
||||
# is outside the whole paste. The crop's own border does not count as
|
||||
# outside: the painted area simply runs off the crop there.
|
||||
# One pass along each axis: the same square reach at a fraction of the cost.
|
||||
outside = (1.0 - whole).unsqueeze(1)
|
||||
outside = functional.max_pool2d(outside, (1, size), stride=1, padding=(0, INNER_RIM_PX))
|
||||
outside = functional.max_pool2d(outside, (size, 1), stride=1, padding=(INNER_RIM_PX, 0))
|
||||
deep = 1.0 - outside.squeeze(1)
|
||||
rim = (whole > 0) & (deep < 0.5)
|
||||
rim = torch.where(rim.flatten(1).any(dim=1).view(-1, 1, 1), rim, whole > 0)
|
||||
pasted = whole > 0
|
||||
untouched = blend < 0.001
|
||||
if rim.shape[0] != frames:
|
||||
rim = rim.expand(frames, -1, -1)
|
||||
pasted = pasted.expand(frames, -1, -1)
|
||||
untouched = untouched.expand(frames, -1, -1)
|
||||
# See-through pixels hold whatever colour sits under the clear part.
|
||||
if inpainted.shape[-1] > 3:
|
||||
rim = rim & (inpainted[..., 3] >= 0.999)
|
||||
pasted = pasted & (inpainted[..., 3] >= 0.999)
|
||||
if canvas.shape[-1] > 3:
|
||||
rim = rim & (canvas[..., 3] >= 0.999)
|
||||
untouched = untouched & (canvas[..., 3] >= 0.999)
|
||||
|
||||
def beside(index: int) -> torch.Tensor:
|
||||
gap = _neighbour_offset(new[index], old[index], pasted[index], untouched[index])
|
||||
return offsets[index] if gap is None else gap
|
||||
|
||||
offsets = torch.zeros((frames, 3), dtype=diff.dtype, device=diff.device)
|
||||
held = torch.zeros((frames,), dtype=torch.bool, device=diff.device)
|
||||
for index in range(frames):
|
||||
changes = diff[index][rim[index]]
|
||||
if changes.shape[0] < INNER_MIN_PIXELS:
|
||||
continue
|
||||
# From here the rim is large enough to judge, so this reading stands
|
||||
# and the band is not asked. New content keeps a zero shift: the band
|
||||
# of a repainted edge reads the new colour itself as drift (a yellow
|
||||
# swimsuit over skin turned the whole patch blue).
|
||||
held[index] = True
|
||||
middle = changes.median(dim=0).values
|
||||
agree = (changes - middle).norm(dim=-1) < INNER_SAME_CONTENT
|
||||
if float(agree.float().mean()) < INNER_MIN_SHARE:
|
||||
offsets[index] = beside(index)
|
||||
continue
|
||||
offset = changes[agree].median(dim=0).values
|
||||
if float(offset.norm()) > INNER_MAX_SHIFT:
|
||||
offsets[index] = beside(index)
|
||||
continue
|
||||
offsets[index] = offset
|
||||
return offsets, held
|
||||
|
||||
|
||||
def _band_weights(blend: torch.Tensor) -> torch.Tensor:
|
||||
return torch.where((blend > 0.001) & (blend < 0.999), blend, torch.zeros_like(blend))
|
||||
|
||||
|
||||
@@ -61,11 +61,8 @@ def list_lama_models() -> list[str]:
|
||||
|
||||
def resolve_lama_model(model_name: str) -> Path:
|
||||
register_lama_model_folder()
|
||||
if folder_paths is None:
|
||||
path = Path(model_name).expanduser().resolve()
|
||||
if path.is_file():
|
||||
return path
|
||||
else:
|
||||
# Only a name from ComfyUI's lama model folder: a typed path is never opened.
|
||||
if folder_paths is not None:
|
||||
resolved = folder_paths.get_full_path(MODEL_FOLDER, model_name)
|
||||
if resolved:
|
||||
return Path(resolved).resolve()
|
||||
|
||||
+23
-19
@@ -13,6 +13,8 @@ from collections import OrderedDict
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from ._route_errors import error_detail
|
||||
|
||||
try:
|
||||
import folder_paths
|
||||
except ImportError: # pragma: no cover - only outside ComfyUI
|
||||
@@ -136,27 +138,29 @@ _remap_noted: set[str] = set()
|
||||
def resolve_lora_path(name: str) -> Path:
|
||||
if folder_paths is None:
|
||||
raise ValueError("folder_paths is unavailable outside ComfyUI.")
|
||||
full = folder_paths.get_full_path("loras", name)
|
||||
if not full:
|
||||
# Only a name on ComfyUI's own LoRA list reaches the disk. A route's
|
||||
# name or a widget value is never joined to a folder as given: it is
|
||||
# matched against the list first, and anything else is refused here.
|
||||
candidate, status = match_lora_name(str(name), list_loras())
|
||||
if status == "remapped":
|
||||
# The saved path is stale; a moved file should just keep working.
|
||||
candidate, status = match_lora_name(str(name), list_loras())
|
||||
if status == "remapped":
|
||||
if name not in _remap_noted:
|
||||
_remap_noted.add(name)
|
||||
print(
|
||||
f"[AusBoss] LoRA Loader: '{name}' is not at its saved "
|
||||
f"path; using '{candidate}'."
|
||||
)
|
||||
full = folder_paths.get_full_path("loras", candidate)
|
||||
elif status == "ambiguous":
|
||||
raise ValueError(
|
||||
f"LoRA name matches several files in models/loras: {name}"
|
||||
if name not in _remap_noted:
|
||||
_remap_noted.add(name)
|
||||
print(
|
||||
f"[AusBoss] LoRA Loader: '{name}' is not at its saved "
|
||||
f"path; using '{candidate}'."
|
||||
)
|
||||
elif status == "ambiguous":
|
||||
raise ValueError(
|
||||
f"LoRA name matches several files in models/loras: {name}"
|
||||
)
|
||||
elif status != "exact":
|
||||
raise ValueError(f"LoRA file not found in models/loras: {name}")
|
||||
full = folder_paths.get_full_path("loras", candidate)
|
||||
if not full:
|
||||
raise ValueError(f"LoRA file not found in models/loras: {name}")
|
||||
# Containment is checked on the path as written, with ".." folded but
|
||||
# links not followed: a LoRA kept on another drive and linked into
|
||||
# models/loras is the user's own choice, and ComfyUI loads it too.
|
||||
# The listed file must also sit below one of the loras folders, read
|
||||
# from the path as ComfyUI built it, with ".." folded.
|
||||
path = Path(os.path.abspath(full))
|
||||
roots = [Path(os.path.abspath(root)) for root in folder_paths.get_folder_paths("loras")]
|
||||
if not any(root in path.parents for root in roots):
|
||||
@@ -388,8 +392,8 @@ def apply_lora_stack(
|
||||
except MemoryError:
|
||||
raise
|
||||
except Exception as exc:
|
||||
# ComfyUI's own message here is PyTorch's and never names the file.
|
||||
detail = f"{type(exc).__name__}: {' '.join(str(exc).split())}"
|
||||
# ComfyUI can add the file's path; error_detail drops words that name one.
|
||||
detail = error_detail(exc)
|
||||
raise ValueError(
|
||||
unreadable_lora_message(row["name"], unreadable_lora_reason(path), detail)
|
||||
) from exc
|
||||
|
||||
@@ -242,13 +242,20 @@ def _locate_comfy_file(text: str, rule: str) -> tuple[str, str, Path]:
|
||||
if (
|
||||
parts[0] == "~"
|
||||
or any(part in ("", ".", "..") for part in parts)
|
||||
or any(re.match(r"[A-Za-z]:", part) for part in parts)
|
||||
or (os.name == "nt" and ":" in inside)
|
||||
or re.search(r"[\x00-\x1f\x7f]", inside)
|
||||
):
|
||||
raise ValueError(rule)
|
||||
root = _server_folders().get(folder)
|
||||
if root is None:
|
||||
raise ValueError(rule)
|
||||
path = root.joinpath(*parts).resolve()
|
||||
# Checked as text before the disk resolves it, and again after, so a
|
||||
# link that leads out of the folder is refused too.
|
||||
lexical = root.joinpath(*parts)
|
||||
if root not in lexical.parents:
|
||||
raise ValueError(rule)
|
||||
path = lexical.resolve()
|
||||
if root not in path.parents:
|
||||
raise ValueError(rule)
|
||||
return folder, inside, path
|
||||
|
||||
+15
-3
@@ -1,11 +1,12 @@
|
||||
"""What a route says back when a request fails."""
|
||||
"""What a route or a node says back when something fails."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
# A whole path: a word that opens with "/", "\" or a drive letter.
|
||||
_SERVER_PATH = re.compile(r"""(?:^|[\s'"(\[=:,;])(?:[A-Za-z]:[\\/]|[\\/])[^\s'"]""")
|
||||
# A whole path: a word that opens with "/", "\", "~/" or a drive letter,
|
||||
# after anything but a letter, digit, "_" or "." ("and/or" and "3/4" stay).
|
||||
_SERVER_PATH = re.compile(r"""(?:^|[^\w.])(?:[A-Za-z]:[\\/]|~[\\/]|[\\/])[^\s'"]""")
|
||||
|
||||
|
||||
def safe_route_error(exc: Exception, fallback: str = "The request failed.") -> str:
|
||||
@@ -16,3 +17,14 @@ def safe_route_error(exc: Exception, fallback: str = "The request failed.") -> s
|
||||
if not text or _SERVER_PATH.search(text):
|
||||
return fallback
|
||||
return text
|
||||
|
||||
|
||||
def error_detail(exc: BaseException) -> str:
|
||||
"""A library's error for a node's message: its kind and its words, or
|
||||
its kind alone when the words name a place on the server's disk. Node
|
||||
errors reach the browser that queued the run and stay in the history."""
|
||||
kind = type(exc).__name__
|
||||
text = " ".join(str(exc).split())
|
||||
if not text or _SERVER_PATH.search(text):
|
||||
return kind
|
||||
return f"{kind}: {text}"
|
||||
|
||||
+19
-11
@@ -480,17 +480,25 @@ def transform_tensor_batch_chunked(
|
||||
return output, mask, geometry
|
||||
|
||||
|
||||
def stable_file_fingerprint(path: str | os.PathLike[str], inputs: dict[str, object]) -> str:
|
||||
normalized_path = str(Path(path).resolve()).casefold()
|
||||
try:
|
||||
stat = os.stat(path)
|
||||
file_state: dict[str, object] = {
|
||||
"path": normalized_path,
|
||||
"mtime_ns": stat.st_mtime_ns,
|
||||
"size": stat.st_size,
|
||||
}
|
||||
except OSError:
|
||||
file_state = {"path": normalized_path, "missing": True}
|
||||
def stable_file_fingerprint(path: Path | None, inputs: dict[str, object]) -> str:
|
||||
"""A key that changes when the inputs or the file do.
|
||||
|
||||
`path` is what resolve_input_path or resolve_video_path returned, or
|
||||
None when they refused the value. Only such a path is ever looked at on
|
||||
disk: a refused value is a string, and a string is only hashed, so a
|
||||
whole path or a network share typed into a widget is never opened."""
|
||||
if isinstance(path, Path):
|
||||
try:
|
||||
stat = os.stat(path)
|
||||
file_state: dict[str, object] = {
|
||||
"path": str(path).casefold(),
|
||||
"mtime_ns": stat.st_mtime_ns,
|
||||
"size": stat.st_size,
|
||||
}
|
||||
except OSError:
|
||||
file_state = {"path": str(path).casefold(), "missing": True}
|
||||
else:
|
||||
file_state = {"unresolved": True}
|
||||
payload = {"file": file_state, "inputs": inputs}
|
||||
encoded = json.dumps(payload, sort_keys=True, separators=(",", ":"), ensure_ascii=True)
|
||||
return hashlib.sha256(encoded.encode("utf-8")).hexdigest()
|
||||
|
||||
@@ -13,6 +13,7 @@ import numpy as np
|
||||
import torch
|
||||
from av.video.reformatter import ColorRange, Colorspace
|
||||
|
||||
from ._route_errors import error_detail
|
||||
from ._execution_helpers import advance_progress, frame_progress, raise_if_interrupted
|
||||
|
||||
AAC_FRAME_SIZE = 1024
|
||||
@@ -363,9 +364,9 @@ def _encoder_start_error(codec: str, exc: Exception) -> RuntimeError:
|
||||
return RuntimeError(
|
||||
"Save Video: the nvenc formats need an NVIDIA GPU with a working "
|
||||
"driver. Pick a software format such as 'mp4 h264' instead. "
|
||||
f"(The '{codec}' encoder said: {exc})"
|
||||
f"(The '{codec}' encoder said: {error_detail(exc)})"
|
||||
)
|
||||
return RuntimeError(f"Save Video could not start the '{codec}' encoder: {exc}.")
|
||||
return RuntimeError(f"Save Video could not start the '{codec}' encoder: {error_detail(exc)}.")
|
||||
|
||||
|
||||
def _add_video_stream(container, spec: VideoFormat, rate, width: int, height: int, crf: int):
|
||||
|
||||
@@ -164,7 +164,7 @@ class AusBossH3PromptWriter:
|
||||
"INT",
|
||||
{
|
||||
"default": 8,
|
||||
"min": 5,
|
||||
"min": 4,
|
||||
"max": 15,
|
||||
"step": 1,
|
||||
"tooltip": "How long the clip is. Plan on about one moment a second at most.",
|
||||
@@ -254,8 +254,8 @@ class AusBossH3PromptWriter:
|
||||
"default": VIDEO_JOBS[0],
|
||||
"tooltip": (
|
||||
"What the video is for: copy its moves, swap the person in it, keep it going, give it "
|
||||
"a new voice, or change something in it and keep the person (a hat, a shirt). Swap, "
|
||||
"new voice and change something ignore Seconds and keep the video's length."
|
||||
"a new voice, or change something in it and keep the person (a hat, a shirt). Copy its "
|
||||
"moves, swap, new voice and change something ignore Seconds and keep the video's length."
|
||||
),
|
||||
},
|
||||
),
|
||||
@@ -393,7 +393,7 @@ def _register_routes():
|
||||
async def read(request):
|
||||
try:
|
||||
body = await request.json()
|
||||
seconds = min(max(int(body.get("seconds", 8)), 5), LONGEST_SECONDS)
|
||||
seconds = min(max(int(body.get("seconds", 8)), 4), LONGEST_SECONDS)
|
||||
jobs = {int(slot): job for slot, job in dict(body.get("jobs") or {}).items() if job in JOBS and int(slot) in PICTURES}
|
||||
video = body.get("video") if body.get("video") in VIDEO_JOBS else ""
|
||||
return web.json_response(script_report(str(body.get("script", ""))[:LONGEST_SCRIPT], seconds, jobs, video))
|
||||
|
||||
@@ -168,7 +168,7 @@ class AusBossImageCropRotatePad:
|
||||
try:
|
||||
path = resolve_input_path(image)
|
||||
except Exception:
|
||||
path = image or ""
|
||||
path = None # refused: hashed by its text only, never opened
|
||||
spec = spec_from_values(**values)
|
||||
# Every widget value is already part of ComfyUI's cache key, so a
|
||||
# changed transform or budget re-runs the node without this; the
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from ._execution_helpers import ignore_extra_inputs
|
||||
@@ -18,6 +20,7 @@ from ._image_folder_helpers import (
|
||||
choose,
|
||||
clean_folder,
|
||||
fingerprint,
|
||||
inside_root,
|
||||
list_folders,
|
||||
list_pictures,
|
||||
load_picture,
|
||||
@@ -69,6 +72,13 @@ def _picked(source, folder, subfolders, sort, pictures) -> list[dict]:
|
||||
return choose(listed, parse_picked(pictures))
|
||||
|
||||
|
||||
def _version_tag(item: dict) -> str:
|
||||
"""A short tag that changes when the picture does, for the browser's
|
||||
thumbnail cache. It carries no file size or time."""
|
||||
seen = f"{item['mtime_ns']}-{item['size']}".encode()
|
||||
return hashlib.sha1(seen, usedforsecurity=False).hexdigest()[:12]
|
||||
|
||||
|
||||
def _register_routes() -> None:
|
||||
"""The gallery's three questions: which folders, which pictures, and a
|
||||
small copy of one. Every path is attacker-controlled; each is resolved
|
||||
@@ -117,7 +127,7 @@ def _register_routes() -> None:
|
||||
"source": source,
|
||||
"folder": shown,
|
||||
"full": len(listed) >= MAX_PICTURES,
|
||||
"pictures": [{"name": item["name"], "v": f"{item['mtime_ns']}-{item['size']}"} for item in listed],
|
||||
"pictures": [{"name": item["name"], "v": _version_tag(item)} for item in listed],
|
||||
})
|
||||
|
||||
@routes.get("/ausboss/image_folder/thumb")
|
||||
@@ -129,8 +139,10 @@ def _register_routes() -> None:
|
||||
base = clean_folder(query(request, "folder"))
|
||||
# The name is a path below the folder; it goes through the same door.
|
||||
relative = clean_folder(f"{base}/{name}" if base else name)
|
||||
path = root.joinpath(*relative.split("/")).resolve()
|
||||
if root not in path.parents or not path.is_file() or not path.name.lower().endswith(IMAGE_EXTENSIONS):
|
||||
if not relative or not relative.lower().endswith(IMAGE_EXTENSIONS):
|
||||
return web.json_response({"error": "no such picture"}, status=404)
|
||||
path = inside_root(root, relative)
|
||||
if not path.is_file() or not path.name.lower().endswith(IMAGE_EXTENSIONS):
|
||||
return web.json_response({"error": "no such picture"}, status=404)
|
||||
try:
|
||||
edge = int(query(request, "size") or 160)
|
||||
|
||||
@@ -15,9 +15,8 @@ class AusBossLoadAudio:
|
||||
"Loads a sound file and hands on only the part you pick. The node shows the "
|
||||
"sound as a wave, so you can see where the loud parts are. Drag the two "
|
||||
"handles to set where it starts and stops, and press play to hear just that "
|
||||
"part. Set Max length to the longest sound the next step takes: anything "
|
||||
"longer shows in red as cut off, so you see exactly what comes out before "
|
||||
"you run anything."
|
||||
"part. Type a Duration to get a sound of an exact length, such as the "
|
||||
"length of the video you are making."
|
||||
)
|
||||
SEARCH_ALIASES = [
|
||||
"load audio",
|
||||
@@ -49,7 +48,7 @@ class AusBossLoadAudio:
|
||||
"min": 0.0,
|
||||
"max": 86400.0,
|
||||
"step": 0.01,
|
||||
"tooltip": "Where the sound starts. Drag the wave's IN handle or type a time.",
|
||||
"tooltip": "Where the sound starts. Drag the wave's left handle or type a Start.",
|
||||
},
|
||||
),
|
||||
"end_seconds": (
|
||||
@@ -59,7 +58,7 @@ class AusBossLoadAudio:
|
||||
"min": 0.0,
|
||||
"max": 86400.0,
|
||||
"step": 0.01,
|
||||
"tooltip": "Where the sound stops. 0 plays to the end. Drag the OUT handle or type a time.",
|
||||
"tooltip": "Where the sound stops. 0 plays to the end. The face sets a Duration instead.",
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -72,8 +71,7 @@ class AusBossLoadAudio:
|
||||
"max": 86400.0,
|
||||
"step": 0.1,
|
||||
"tooltip": (
|
||||
"The longest the sound may be. Anything past it is cut off and shows "
|
||||
"in red. 0 means no limit."
|
||||
"How long the sound is: the Duration box. 0 runs to the end of the file."
|
||||
),
|
||||
},
|
||||
),
|
||||
|
||||
@@ -253,7 +253,7 @@ class AusBossLoadImage:
|
||||
try:
|
||||
path = resolve_input_path(image)
|
||||
except Exception:
|
||||
path = image or ""
|
||||
path = None # refused: hashed by its text only, never opened
|
||||
return stable_file_fingerprint(path, {"image": image, **values})
|
||||
|
||||
|
||||
|
||||
@@ -403,7 +403,7 @@ class AusBossLoadImagePad:
|
||||
try:
|
||||
path = resolve_input_path(image)
|
||||
except Exception:
|
||||
path = image or ""
|
||||
path = None # refused: hashed by its text only, never opened
|
||||
return stable_file_fingerprint(path, {"image": image, **values})
|
||||
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@ class AusBossLoadVideo:
|
||||
CATEGORY = "🆎 AusBoss/Video"
|
||||
DESCRIPTION = (
|
||||
"Loads a video as a BHWC frame batch plus its audio, trimmed to an "
|
||||
"optional start/end window selected on the preview timeline, with frame count, "
|
||||
"optional window set with Start, Duration and Ends at under the player, with frame count, "
|
||||
"fps, size, and duration outputs ready for downstream wiring, plus a lazy "
|
||||
"core VIDEO output for nodes that consume whole videos. every_nth thins "
|
||||
"the batch and max_frames caps it, so long clips load without filling "
|
||||
"memory. single_frame flips the loader into a frame picker that "
|
||||
"returns just the frame at the IN time as a one-image batch."
|
||||
"returns just the frame at the start time as a one-image batch."
|
||||
)
|
||||
SEARCH_ALIASES = [
|
||||
"load video",
|
||||
@@ -53,8 +53,7 @@ class AusBossLoadVideo:
|
||||
"max": 86400.0,
|
||||
"step": 0.01,
|
||||
"tooltip": (
|
||||
"Skip everything before this time. Drag the preview's IN "
|
||||
"handle or type an exact value below the player."
|
||||
"Skip everything before this time. It is the Start box under the player."
|
||||
),
|
||||
},
|
||||
),
|
||||
@@ -66,8 +65,7 @@ class AusBossLoadVideo:
|
||||
"max": 86400.0,
|
||||
"step": 0.01,
|
||||
"tooltip": (
|
||||
"Stop at this time; 0 plays to the end. Drag the preview's "
|
||||
"OUT handle or type an exact value below the player."
|
||||
"Stop at this time; 0 plays to the end. The face sets a Duration instead."
|
||||
),
|
||||
},
|
||||
),
|
||||
@@ -115,8 +113,8 @@ class AusBossLoadVideo:
|
||||
"max": 100000,
|
||||
"step": 1,
|
||||
"tooltip": (
|
||||
"Stop after this many kept frames; 0 loads the "
|
||||
"whole trim window. Caps memory on long clips — "
|
||||
"Stop after this many kept frames: the Duration box. 0 loads the "
|
||||
"whole window. Caps memory on long clips — "
|
||||
"the decode ends early instead of loading and "
|
||||
"discarding."
|
||||
),
|
||||
@@ -127,8 +125,8 @@ class AusBossLoadVideo:
|
||||
{
|
||||
"default": False,
|
||||
"tooltip": (
|
||||
"Load only the frame at the IN time as a "
|
||||
"one-image batch. The preview's trim strip "
|
||||
"Load only the frame at the start time as a "
|
||||
"one-image batch. The timing card "
|
||||
"becomes a frame picker (the FRAME button "
|
||||
"toggles this), and end_seconds, every_nth, "
|
||||
"and max_frames are ignored."
|
||||
|
||||
@@ -6,6 +6,7 @@ import sys
|
||||
|
||||
import torch
|
||||
|
||||
from ._route_errors import error_detail
|
||||
from ._mask_by_name_helpers import (
|
||||
IF_NOTHING,
|
||||
NEEDS_SAM3,
|
||||
@@ -238,7 +239,7 @@ class AusBossMaskByName:
|
||||
raise
|
||||
# A model or text reader that is not SAM 3's fails somewhere
|
||||
# inside; say what to wire instead of showing that.
|
||||
raise RuntimeError(f"{NOT_SAM3} ({type(error).__name__}: {error})") from error
|
||||
raise RuntimeError(f"{NOT_SAM3} ({error_detail(error)})") from error
|
||||
masks, boxes = output.result
|
||||
counts = [len(frame) for frame in boxes]
|
||||
# How sure SAM 3 was of each match in the first picture, best first.
|
||||
|
||||
@@ -15,6 +15,7 @@ import torch
|
||||
import torch.nn.functional as F
|
||||
from PIL import Image
|
||||
|
||||
from ._route_errors import error_detail, safe_route_error
|
||||
from ._execution_helpers import advance_progress, progress_bar, raise_if_interrupted, warn_once
|
||||
from ._fine_edge_helpers import OFF as FINE_OFF
|
||||
from ._fine_edge_helpers import (
|
||||
@@ -485,7 +486,7 @@ class _Session:
|
||||
except Exception as error: # noqa: BLE001 - told apart just below
|
||||
if _stopped_by_user(error) or _out_of_memory(error):
|
||||
raise
|
||||
raise RuntimeError(f"{NOT_SAM3} ({type(error).__name__}: {error})") from error
|
||||
raise RuntimeError(f"{NOT_SAM3} ({error_detail(error)})") from error
|
||||
_WORDS[key] = held
|
||||
while len(_WORDS) > WORDS_KEPT:
|
||||
_WORDS.popitem(last=False)
|
||||
@@ -561,14 +562,14 @@ class _Session:
|
||||
if self._open is None:
|
||||
# A model or a text reader that is not SAM 3's fails
|
||||
# somewhere inside; say what to wire instead of showing that.
|
||||
raise RuntimeError(f"{NOT_SAM3} ({type(error).__name__}: {error})") from error
|
||||
raise RuntimeError(f"{NOT_SAM3} ({error_detail(error)})") from error
|
||||
self.close()
|
||||
try:
|
||||
answer = self._call(kind, frame, what)
|
||||
except Exception as error: # noqa: BLE001
|
||||
if _stopped_by_user(error) or _out_of_memory(error):
|
||||
raise
|
||||
raise RuntimeError(f"{NOT_SAM3} ({type(error).__name__}: {error})") from error
|
||||
raise RuntimeError(f"{NOT_SAM3} ({error_detail(error)})") from error
|
||||
# The plain way answers where the quick way failed.
|
||||
self._distrust("a question failed with it")
|
||||
return answer
|
||||
@@ -1288,7 +1289,7 @@ class AusBossMaskByTouch:
|
||||
if item.kind not in ("subject", "background") or not asked or _stopped_by_user(error):
|
||||
raise
|
||||
area, used, which = None, "none", ()
|
||||
subject_trouble = str(error)
|
||||
subject_trouble = safe_route_error(error, type(error).__name__)
|
||||
if index == 0:
|
||||
share = 0.0 if area is None else round(float(area.sum()) / (height * width), 5)
|
||||
item_notes.append({"ok": used != "none", "share": share, "as": used})
|
||||
@@ -1348,7 +1349,7 @@ class AusBossMaskByTouch:
|
||||
# and the picture says why.
|
||||
if not asked or _stopped_by_user(error):
|
||||
raise
|
||||
fine, fine_trouble = False, str(error)
|
||||
fine, fine_trouble = False, safe_route_error(error, type(error).__name__)
|
||||
if fine and soft:
|
||||
# Where a soft brush had the last word its fade stays as painted.
|
||||
fade = torch.stack(painted) & (raw > 0) & (raw < 1)
|
||||
|
||||
@@ -43,7 +43,7 @@ class AusBossVideoCropRotatePad:
|
||||
required = {
|
||||
"video": (
|
||||
list_input_videos(),
|
||||
{"tooltip": "Choose a video in ComfyUI's input folder or use the upload button."},
|
||||
{"video_upload": True, "tooltip": "Choose a video in ComfyUI's input folder or use the upload button."},
|
||||
),
|
||||
"source_mode": (
|
||||
["input folder", "local path"],
|
||||
@@ -152,7 +152,7 @@ class AusBossVideoCropRotatePad:
|
||||
try:
|
||||
path = resolve_video_path(source_mode, video, local_path)
|
||||
except Exception:
|
||||
path = local_path if source_mode == "local path" else video
|
||||
path = None # refused: hashed by its text only, never opened
|
||||
spec = spec_from_values(**values)
|
||||
resize = {name: values.get(name) for name in resize_inputs()}
|
||||
return stable_file_fingerprint(
|
||||
@@ -160,6 +160,7 @@ class AusBossVideoCropRotatePad:
|
||||
{
|
||||
"video": video,
|
||||
"source_mode": source_mode,
|
||||
"local_path": local_path,
|
||||
"seek_mode": seek_mode,
|
||||
"frame_index": int(frame_index),
|
||||
"frame_time": round(float(frame_time), 6),
|
||||
|
||||
@@ -49,8 +49,8 @@ class AusBossVideoCropRotatePadClip:
|
||||
"mask of the generated area (rotation corners and padding), the audio "
|
||||
"for the same window, the frame count, fps, size, and duration, and a "
|
||||
"stitcher so Stitch Inpaint can paste the source frames back over the "
|
||||
"generated clip. Drag IN and OUT to trim, or turn Length on to set "
|
||||
"the clip by a number of output frames from IN."
|
||||
"generated clip. Set the clip with Start, Duration and Ends at, or drag "
|
||||
"its two handles on the timeline."
|
||||
)
|
||||
SEARCH_ALIASES = [
|
||||
"video crop",
|
||||
@@ -68,7 +68,7 @@ class AusBossVideoCropRotatePadClip:
|
||||
required = {
|
||||
"video": (
|
||||
list_input_videos(),
|
||||
{"tooltip": "Choose a video in ComfyUI's input folder or use the upload button."},
|
||||
{"video_upload": True, "tooltip": "Choose a video in ComfyUI's input folder or use the upload button."},
|
||||
),
|
||||
"source_mode": (
|
||||
["input folder", "local path"],
|
||||
@@ -218,25 +218,25 @@ class AusBossVideoCropRotatePadClip:
|
||||
}),
|
||||
"start_frame": ("INT", {
|
||||
"forceInput": True, "min": 0,
|
||||
"tooltip": "Zero-based source start frame; overrides and locks timeline IN. "
|
||||
"tooltip": "Zero-based source start frame; overrides and locks Start. "
|
||||
"Uses the source frame-rate grid.",
|
||||
}),
|
||||
"end_frame": ("INT", {
|
||||
"forceInput": True, "min": 0,
|
||||
"tooltip": "Exclusive source end frame; 0 means source end. Overrides and "
|
||||
"locks timeline OUT. Uses the source frame-rate grid.",
|
||||
"locks Ends at. Uses the source frame-rate grid.",
|
||||
}),
|
||||
"frame_load_cap": ("INT", {
|
||||
"forceInput": True, "min": 0,
|
||||
"tooltip": "Maximum returned frames after rate conversion and Every nth, "
|
||||
"before Frames for. Overrides and locks Length; 0 means unlimited.",
|
||||
"before Frames for. Overrides and locks Duration; 0 means unlimited.",
|
||||
}),
|
||||
"fixed_frames": ("INT", {
|
||||
"default": 0, "min": 0, "max": 100000,
|
||||
"tooltip": "Exact output frames after rate conversion and Every nth; 0 = off. "
|
||||
"Connected, it sets the length from IN. Overrides OUT/end_frame, Length, "
|
||||
"Connected, it sets the length from Start. Overrides Ends at/end_frame, Duration, "
|
||||
"frame_load_cap and Frames for. Duration = frames / output fps; 120 frames at 24 fps = 5 seconds. "
|
||||
"The source must be long enough. A linked IN anchors the window.",
|
||||
"The source must be long enough. A linked Start anchors the window.",
|
||||
}),
|
||||
"last_seconds": ("FLOAT", {
|
||||
"forceInput": True, "min": 0,
|
||||
@@ -395,7 +395,7 @@ class AusBossVideoCropRotatePadClip:
|
||||
try:
|
||||
path = resolve_video_path(source_mode, video, local_path)
|
||||
except Exception:
|
||||
path = local_path if source_mode == "local path" else video
|
||||
path = None # refused: hashed by its text only, never opened
|
||||
spec = spec_from_values(**values)
|
||||
resize = {name: values.get(name) for name in resize_inputs()}
|
||||
return stable_file_fingerprint(
|
||||
@@ -403,6 +403,7 @@ class AusBossVideoCropRotatePadClip:
|
||||
{
|
||||
"video": video,
|
||||
"source_mode": source_mode,
|
||||
"local_path": local_path,
|
||||
"start_seconds": round(float(start_seconds), 6),
|
||||
"end_seconds": round(float(end_seconds), 6),
|
||||
"every_nth": max(1, int(every_nth)),
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ name = "ausboss-nodes"
|
||||
# Manager/registry search matches against this text, so it names the actual
|
||||
# nodes instead of describing the collection abstractly.
|
||||
description = "ComfyUI-AusBoss (AusBoss nodes): image and video nodes with compact controls: Image and Video Crop + Rotate + Pad (frame or clip), Load Image, Load Image + Pad, Image Folder, Image Resize, Align Image, Image Size, Color Match, Image Compare A/B, Realign to Source (experimental), Save Image (PNG, WebP/JXL, captions), Load Video, Load Audio, Save Video, Select Frame, Frame Interpolate, Mask Refine, Mask by Name and Mask by Touch, LaMa Inpaint, Crop For Inpaint, Stitch Inpaint, Tiled Upscale and Tiled Upscale Stitch, FlashVSR Upscale, Edit Lock and Edit Lock Restore, LoRA Loader, Krea 2 Encode and Outpaint Model Patch, Latent Size, Layout Boxes, Seed, Select Every Nth, Split Batch, Merge Batches, Text, Text Lines, Prompt Variations, H3 Prompt Writer, Integer, Float, Math Expression, Show Text, Free Memory, Workflow Note, Workflow Note Tile, Callout, Callout Tile, Workflow Switches, Run Timer, and Step Preview. Example workflows for Qwen Image 2.1, Krea 2, Klein 9B and LTX 2.3."
|
||||
version = "2.25.2"
|
||||
version = "2.26.3"
|
||||
# comfy-cli serializes this to JSON verbatim, so `file` publishes the literal
|
||||
# string {"file": "LICENSE"} to the registry listing. `text` puts a readable
|
||||
# name there instead. Both forms are supported; the LICENSE file is unchanged.
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
---
|
||||
name: ausboss-workflows
|
||||
description: Write the words for AusBoss ComfyUI video workflows (MiniMax H3 Pika Person Swap and Pika Remix, through the H3 Prompt Writer node), and set up and run those workflows on the person's own computer. Use when someone shares ausboss-examples.vercel.app, asks for a person swap, a video remix or an H3 prompt, or wants an AusBoss workflow installed or run for them.
|
||||
license: MIT
|
||||
compatibility: Writing the words needs nothing. Running needs ComfyUI 0.38 or newer on the person's computer, an 8 GB or larger graphics card, and a browser the agent can drive.
|
||||
metadata:
|
||||
author: AusBoss
|
||||
homepage: https://ausboss-examples.vercel.app/
|
||||
updated: "2026-11-16"
|
||||
---
|
||||
|
||||
# AusBoss workflows
|
||||
|
||||
AusBoss makes a pack of ComfyUI nodes and the workflows built on them. This
|
||||
page is for an AI agent helping someone use those workflows. It covers three
|
||||
jobs, from light to heavy:
|
||||
|
||||
1. **Write the words.** The person says what they want; you write what goes in
|
||||
the workflow's text box and say which settings to pick.
|
||||
2. **Set it up.** Install the node pack and the model files.
|
||||
3. **Run it for them.** Load the workflow in their ComfyUI, put in their files
|
||||
and your words, run it, and hand back the clip.
|
||||
|
||||
Offer the third job when you can run commands on the person's computer. Ask
|
||||
before you start it: it downloads large files (see "Model files") and uses
|
||||
their graphics card for several minutes a clip.
|
||||
|
||||
## Where everything is
|
||||
|
||||
| What | Where |
|
||||
|---|---|
|
||||
| Node pack (source, help pages, issues) | https://github.com/ausboss/ComfyUI-AusBoss |
|
||||
| The pack's own guide for agents (which node does which job) | https://github.com/ausboss/ComfyUI-AusBoss/blob/main/js/docs/agents/README.md |
|
||||
| Workflows | https://civitai.com/user/AusBoss |
|
||||
| Models and LoRAs | https://huggingface.co/ausboss |
|
||||
| Real example runs (this site) | https://ausboss-examples.vercel.app/ |
|
||||
| Help from people, and every workflow file | https://discord.gg/RwVxY9Fuaj |
|
||||
| Video guides | https://www.youtube.com/@ausbossdev |
|
||||
|
||||
The examples on this site are real runs. Each page has a plain-text copy with
|
||||
every script, setting, prompt and file link:
|
||||
|
||||
- Person Swap Examples (4 examples): https://ausboss-examples.vercel.app/person-swap/index.md
|
||||
- Pika Remix Examples (8 examples): https://ausboss-examples.vercel.app/pika-remix/index.md
|
||||
- Fix a Pika Remix or Person Swap Run (a guide): https://ausboss-examples.vercel.app/fix/index.md
|
||||
- Faster Video in ComfyUI (a guide): https://ausboss-examples.vercel.app/speed/index.md
|
||||
|
||||
Read the matching page before you write for a workflow. A real example close
|
||||
to the person's request is the best starting point.
|
||||
|
||||
## The workflows
|
||||
|
||||
| Workflow | What it does | Get it | Real runs |
|
||||
|---|---|---|---|
|
||||
| MiniMax H3 Pika Person Swap | Swaps the person in a clip for the person in one photo. The place, camera, moves and sound stay. | https://civitai.com/models/3040833 | https://ausboss-examples.vercel.app/person-swap/index.md |
|
||||
| MiniMax H3 Pika Remix | Changes, swaps or copies a video using up to four pictures. Also starts a clip from a picture, or goes from one picture to another. | https://civitai.com/models/3050155 | https://ausboss-examples.vercel.app/pika-remix/index.md |
|
||||
|
||||
Both make video with sound, up to 15 seconds, with the MiniMax H3 model and
|
||||
the Pika H3 Flex LoRA. Both have a High VRAM setting (24 GB or more) and a Low
|
||||
VRAM setting (8 to 24 GB; on 8 GB, clips up to 8 seconds and 32 GB of RAM).
|
||||
|
||||
## Write the words
|
||||
|
||||
Both workflows have one text box, on the node titled
|
||||
**H3 Prompt Writer - What happens**. The person types plain lines there and
|
||||
the node writes the model's long prompt itself. So you write short plain
|
||||
lines, never the long prompt. The full rules are on the node's help page:
|
||||
https://github.com/ausboss/ComfyUI-AusBoss/blob/main/js/docs/AUSBOSS_NODES_H3PromptWriter.md
|
||||
If that page and this one disagree, that page is right.
|
||||
|
||||
### The basics
|
||||
|
||||
- One line is one moment. Lines play in order. About one moment a second is
|
||||
the most the model can play.
|
||||
- A blank line cuts to a new place.
|
||||
- `@1` to `@4` name the pictures plugged in. Each picture has a job, picked
|
||||
under the text box.
|
||||
- Say what a camera would see. `She smiles` works; `She feels happy` does not.
|
||||
- Nothing moves or exists unless a line says so.
|
||||
- Say which way people face, and where they end up.
|
||||
- Spoken words go in quotes, with the speaker named: `@1 says "we are late."`
|
||||
- Put the spoken line last. With time left after it, the model keeps talking.
|
||||
|
||||
### Picture jobs
|
||||
|
||||
| Job | Use it for |
|
||||
|---|---|
|
||||
| person | This person goes where the lines say. A clear photo. |
|
||||
| character sheet | One character drawn from several sides. |
|
||||
| place | Where it happens. A picture with nobody in it. |
|
||||
| outfit | Clothes for the person. Best with no head in the picture. |
|
||||
| thing | An object, product, toy or mascot. |
|
||||
| style | Only the look is used, for the whole clip. |
|
||||
| start on it | The clip starts from this picture. |
|
||||
| end on it | The clip lands on this picture. It can't be named with `@`. |
|
||||
|
||||
### Video jobs
|
||||
|
||||
| Job | What happens | What to type |
|
||||
|---|---|---|
|
||||
| swap the person | The pictured person takes over from the one in the video. | Who goes, by what they look like: `Replace the man in the hat with @1.` |
|
||||
| copy its moves | The pictured person does the video's moves somewhere new. | `@1 dances on a rooftop at sunset.` |
|
||||
| change something | The video stays, with one change. | The change, exactly: `She wears a red raincoat.` |
|
||||
| keep going | More of the same clip, from where it ends. | What happens next, or nothing. |
|
||||
| new voice | The same clip with a new voice. | The words, in quotes. Needs a voice clip. |
|
||||
|
||||
For **swap the person**, **change something** and **new voice**, the clip's
|
||||
length comes from the video. To make it shorter, trim the video on its loader.
|
||||
|
||||
### Person swap: the lines that work
|
||||
|
||||
```
|
||||
Replace the man in the suit holding an ice cream with @1.
|
||||
@1 looks like a heavy-set man with round glasses, a white shirt and green trousers.
|
||||
```
|
||||
|
||||
- Line 1 says who goes. Describe them by what is seen in the clip (clothes,
|
||||
hair, position), so the others in the shot are left alone.
|
||||
- Line 2 is optional and describes the new person. Write it from their photo.
|
||||
It helps the look; it does not promise an exact likeness. The Person Swap
|
||||
workflow can write this line itself: the **Describe @1 for me** switch.
|
||||
- If the photo shows only a face, write the clothes too. What the photo does
|
||||
not show, the model makes up.
|
||||
- The face in the clip has to be clear. A small or turned-away face keeps the
|
||||
clip's own person.
|
||||
- **Keep the clip's sound** on: the clip's own voice and music stay and the
|
||||
new mouth follows them. Off, with words in quotes: the model makes a new
|
||||
voice.
|
||||
|
||||
### Other things a line can do
|
||||
|
||||
- A time: start a line with `3s:` and it happens at 3 seconds.
|
||||
- `sound: rain on a tin roof` and `music: slow sad piano`. With no music line
|
||||
there is no music.
|
||||
- `camera: slow push in` and `look: a 1970s film`.
|
||||
- `no cuts` makes blank lines stop being cuts.
|
||||
- `ends on her sitting by the window` sets the last moment.
|
||||
- A sign: `a neon sign reads "OPEN"`.
|
||||
|
||||
### What to hand the person
|
||||
|
||||
When you only write the words, give them:
|
||||
|
||||
1. The lines, in a code block they can paste into the text box.
|
||||
2. Which file goes in which loader (`@1` is Picture 1, and so on).
|
||||
3. The job for each picture and for the video.
|
||||
4. Any switch to change, such as **Keep the clip's sound**.
|
||||
|
||||
A voice clip should be the person's own voice, or one they have permission to
|
||||
use. Only swap a real person into a clip when the person asking has the right
|
||||
to use that photo.
|
||||
|
||||
## Set it up
|
||||
|
||||
Check before you install anything:
|
||||
|
||||
```bash
|
||||
curl -s http://127.0.0.1:8188/system_stats
|
||||
```
|
||||
|
||||
That answers when ComfyUI is running on its usual port, with its version and
|
||||
the graphics card's memory. If nothing answers, ask the person where their
|
||||
ComfyUI is and how they start it. If they have none, the official install
|
||||
guide is https://docs.comfy.org/installation and that choice is theirs.
|
||||
|
||||
### The node pack
|
||||
|
||||
Either of these, then restart ComfyUI:
|
||||
|
||||
```bash
|
||||
comfy node install ausboss-nodes
|
||||
```
|
||||
|
||||
```bash
|
||||
git clone https://github.com/ausboss/ComfyUI-AusBoss.git
|
||||
```
|
||||
|
||||
The first needs comfy-cli. The second runs inside ComfyUI's `custom_nodes`
|
||||
folder. In the ComfyUI window, the person can also open the Manager, search
|
||||
for **AusBoss** and install it there. After the restart this returns the
|
||||
node, which shows the pack loaded:
|
||||
|
||||
```bash
|
||||
curl -s http://127.0.0.1:8188/object_info/AUSBOSS_NODES_H3PromptWriter
|
||||
```
|
||||
|
||||
### Model files
|
||||
|
||||
The files go in ComfyUI's `models` folder, in the subfolder named below. They
|
||||
are large. Tell the person the total and get a yes before you download. Skip
|
||||
any file they already have.
|
||||
|
||||
| File | Folder in `models` | Size | Needed |
|
||||
|---|---|---|---|
|
||||
| [qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors](https://huggingface.co/Comfy-Org/MiniMax-H3/resolve/main/text_encoders/qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors) | `text_encoders` | 15.7 GB | always |
|
||||
| [minimax_h3_audio_vae_fp32.safetensors](https://huggingface.co/Comfy-Org/MiniMax-H3/resolve/main/vae/minimax_h3_audio_vae_fp32.safetensors) | `vae` | 0.6 GB | always |
|
||||
| [pika_h3_flex_ref2va_v1_bf16.safetensors](https://huggingface.co/Comfy-Org/MiniMax-H3/resolve/main/loras/pika_h3_flex_ref2va_v1_bf16.safetensors) | `loras` | 2.0 GB | always |
|
||||
| [minimax_h3_ref2va_pruned_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/MiniMax-H3/resolve/main/diffusion_models/minimax_h3_ref2va_pruned_int8_convrot.safetensors) | `diffusion_models` | 21.0 GB | High VRAM |
|
||||
| [minimax_h3_video_vae_fp16.safetensors](https://huggingface.co/Comfy-Org/MiniMax-H3/resolve/main/vae/minimax_h3_video_vae_fp16.safetensors) | `vae` | 5.2 GB | High VRAM |
|
||||
| [minimax_h3_ref2va_pruned_w6a8.safetensors](https://huggingface.co/Comfy-Org/MiniMax-H3/resolve/main/diffusion_models/minimax_h3_ref2va_pruned_w6a8.safetensors) | `diffusion_models` | 16.0 GB | Low VRAM |
|
||||
| [minimax_h3_video_vae_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/MiniMax-H3/resolve/main/vae/minimax_h3_video_vae_int8_convrot.safetensors) | `vae` | 2.8 GB | Low VRAM |
|
||||
| [flashvsr_v1.1_fp16.safetensors](https://huggingface.co/ausboss/FlashVSR-v1.1-ComfyUI/resolve/main/flashvsr_v1.1_fp16.safetensors) | `diffusion_models` | 3.5 GB | only for Finish: FlashVSR |
|
||||
|
||||
High VRAM needs about 44 GB of files, Low VRAM about 37 GB. The optional switches that write text for you (such as **Describe @1 for me**) use a small Qwen3-VL 8B text model; the workflow's Guide note names that file and where to get it.
|
||||
|
||||
Each workflow opens with a Guide note that lists its files. If the note and
|
||||
this table disagree, the note in the newest workflow is right.
|
||||
|
||||
### Faster runs
|
||||
|
||||
One node or one launch setting makes these workflows about twice as fast on
|
||||
most recent cards: https://ausboss-examples.vercel.app/speed/index.md
|
||||
|
||||
## Run it for them
|
||||
|
||||
### Get the workflow file
|
||||
|
||||
- The newest file is on the workflow's Civitai page (links above). Civitai may
|
||||
ask for a login. If it does, ask the person to download the file and tell
|
||||
you where it is. The same files are in the Discord.
|
||||
- Each Person Swap example on this site also has a zip with the workflow set
|
||||
up exactly as it ran, its input files and its result. Those can be older
|
||||
than the Civitai file. They are good for a first test run: the result is
|
||||
there to compare with.
|
||||
|
||||
### Put the person's files in place
|
||||
|
||||
Copy their clip and pictures into ComfyUI's `input` folder, or upload them:
|
||||
|
||||
```bash
|
||||
curl -s -F "image=@/path/to/photo.jpg" http://127.0.0.1:8188/upload/image
|
||||
```
|
||||
|
||||
The same address takes video and audio files.
|
||||
|
||||
### Load it in ComfyUI's own page and run
|
||||
|
||||
These workflows have switches and grouped parts that only ComfyUI's page
|
||||
turns into a run. So do not rewrite the file into an API prompt by hand:
|
||||
open the page, load the file there, and let the page queue it. Any browser
|
||||
you can drive works, headless or not (Chrome started with
|
||||
`--remote-debugging-port`, Playwright, or a browser tool).
|
||||
|
||||
On the page at `http://127.0.0.1:8188/`, once `window.app.graph` exists:
|
||||
|
||||
```js
|
||||
await app.loadGraphData(workflow); // the parsed workflow file
|
||||
const node = (title) => app.graph.nodes.find((n) => n.title === title);
|
||||
const set = (title, name, value) => {
|
||||
const w = node(title).widgets.find((w) => w.name === name);
|
||||
w.value = value;
|
||||
w.callback?.(value);
|
||||
};
|
||||
set("H3 Prompt Writer - What happens", "script", "Replace the man in the hat with @1.");
|
||||
set("Video - Your clip", "video", "their_clip.mp4");
|
||||
set("Picture 1 - @1", "image", "their_photo.jpg");
|
||||
set("Seed", "seed", 6202);
|
||||
await app.queuePrompt(0);
|
||||
```
|
||||
|
||||
Find a node by its title and a setting by its name. The titles above are the
|
||||
ones in Person Swap; read `app.graph.nodes.map((n) => n.title)` for any other
|
||||
workflow. `await app.graphToPrompt()` shows what would be sent without running
|
||||
anything, which is a cheap check before you queue.
|
||||
|
||||
**Switches** (VRAM, Keep the clip's sound, Describe @1 for me, Finish) are
|
||||
cards on the canvas. To flip one without clicking, change the workflow file
|
||||
before you load it, as the pack's guide describes:
|
||||
https://github.com/ausboss/ComfyUI-AusBoss/blob/main/js/docs/agents/workflow_switches.md
|
||||
With a browser tool that can click, clicking the switch on the card is
|
||||
simpler. Pick **Low VRAM** when the card has less than 24 GB.
|
||||
|
||||
### Wait, then hand back the clip
|
||||
|
||||
`queuePrompt` returns right away. Watch the run with:
|
||||
|
||||
```bash
|
||||
curl -s http://127.0.0.1:8188/queue
|
||||
```
|
||||
|
||||
```bash
|
||||
curl -s http://127.0.0.1:8188/history
|
||||
```
|
||||
|
||||
A clip takes a few minutes; the first run is longer because the models load.
|
||||
The finished clip is in ComfyUI's `output` folder, and the history entry
|
||||
names the file. Tell the person where it is, and show it if you can.
|
||||
|
||||
### If it fails
|
||||
|
||||
- A loader turns red or the run stops on a file name: that model file is
|
||||
missing or has another name. Pick the person's copy in that loader.
|
||||
- Out of memory: pick **Low VRAM**, use a shorter clip, or turn on
|
||||
**Fast preview**.
|
||||
- The swap kept the clip's own person: the face in the clip is too small or
|
||||
turned away, or line 1 did not describe who goes.
|
||||
- A clip came out wrong but ran: run again with a new seed.
|
||||
- Anything else: the pack's issues
|
||||
(https://github.com/ausboss/ComfyUI-AusBoss/issues) and the Discord.
|
||||
|
||||
## About this page
|
||||
|
||||
Everything here is public information from AusBoss about his own nodes and
|
||||
workflows. It gives no instruction to act without the person's say: installs,
|
||||
downloads and runs are theirs to approve.
|
||||
@@ -0,0 +1,71 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { appFields, createAppModeSync, workflowMode } from "../js/shared/app_mode.mjs";
|
||||
import { hideWidget, isWidgetHidden } from "../js/shared/widget_visibility.mjs";
|
||||
|
||||
function graph() {
|
||||
const nodes = new Map();
|
||||
for (const [id, names] of [["256", ["image", "upload"]], ["160", ["script"]]]) {
|
||||
const node = { id, dirty: 0, widgets: names.map((name) => ({ name, value: "" })) };
|
||||
for (const widget of node.widgets) hideWidget(widget);
|
||||
nodes.set(id, node);
|
||||
}
|
||||
const find = (nodeId, name) => {
|
||||
const node = nodes.get(nodeId);
|
||||
const widget = node?.widgets.find((entry) => entry.name === name);
|
||||
return widget ? { node, widget } : null;
|
||||
};
|
||||
return { nodes, find, changed: (node) => { node.dirty += 1; } };
|
||||
}
|
||||
|
||||
const linearData = { inputs: [["256", "image", { description: "One clear photo." }], [160, "script"], ["999", "gone"]], outputs: ["145"] };
|
||||
|
||||
test("fields read both saved shapes and skip broken entries", () => {
|
||||
assert.deepEqual(appFields(linearData), [
|
||||
{ nodeId: "256", widget: "image" }, { nodeId: "160", widget: "script" }, { nodeId: "999", widget: "gone" },
|
||||
]);
|
||||
assert.deepEqual(appFields({ inputs: [null, ["1"], [{}, "x"]] }), []);
|
||||
assert.deepEqual(appFields(undefined), []);
|
||||
});
|
||||
|
||||
test("the mode falls back from the live mode to the saved one", () => {
|
||||
assert.equal(workflowMode({ activeMode: null, initialMode: "app" }), "app");
|
||||
assert.equal(workflowMode({ activeMode: "graph", initialMode: "app" }), "graph");
|
||||
assert.equal(workflowMode(undefined), "graph");
|
||||
});
|
||||
|
||||
test("App mode shows only the listed widgets, the graph hides them again", () => {
|
||||
const g = graph();
|
||||
const sync = createAppModeSync(g);
|
||||
const image = g.find("256", "image").widget;
|
||||
const upload = g.find("256", "upload").widget;
|
||||
assert.equal(sync("app", linearData), 2);
|
||||
assert.equal(isWidgetHidden(image), false);
|
||||
assert.equal(image.options.hidden, false); // written, so the frontend hears it
|
||||
assert.equal(isWidgetHidden(upload), true); // not on the form, left alone
|
||||
assert.equal(g.nodes.get("256").dirty, 1);
|
||||
sync("graph", linearData);
|
||||
assert.equal(isWidgetHidden(image), true);
|
||||
assert.equal(image.options.hidden, true);
|
||||
assert.equal(isWidgetHidden(g.find("160", "script").widget), true);
|
||||
});
|
||||
|
||||
test("a widget a card hides again while in App mode is shown again", () => {
|
||||
const g = graph();
|
||||
const sync = createAppModeSync(g);
|
||||
sync("app", linearData);
|
||||
const image = g.find("256", "image").widget;
|
||||
hideWidget(image); // the card's load-time re-hide
|
||||
sync("app", linearData);
|
||||
assert.equal(isWidgetHidden(image), false);
|
||||
});
|
||||
|
||||
test("builder mode and the graph leave card widgets hidden", () => {
|
||||
const g = graph();
|
||||
const sync = createAppModeSync(g);
|
||||
for (const mode of ["graph", "builder:inputs"]) {
|
||||
assert.equal(sync(mode, linearData), 0);
|
||||
assert.equal(isWidgetHidden(g.find("256", "image").widget), true);
|
||||
}
|
||||
});
|
||||
@@ -102,3 +102,39 @@ test("a server that does not answer keeps the page quiet", async (t) => {
|
||||
await page.serverComesBack("2.7.0");
|
||||
assert.equal(page.toasts.length, 1);
|
||||
});
|
||||
|
||||
// The Manager switches the pack's files on disk, and the server keeps running
|
||||
// the old version until ComfyUI restarts. A reload in between gives the page
|
||||
// the new files: the page is newer than the server, and "press F5" is wrong.
|
||||
test("a page newer than the server says nothing", async (t) => {
|
||||
const page = await openPage(t, { running: "2.26.2", installed: "2.25.2" });
|
||||
assert.deepEqual(page.toasts, []);
|
||||
assert.deepEqual(page.refreshed, []);
|
||||
await page.serverComesBack("2.26.2");
|
||||
assert.deepEqual(page.toasts, [], "after the restart the two match");
|
||||
});
|
||||
|
||||
test("versions compare as numbers, not as text", async (t) => {
|
||||
const older = await openPage(t, { running: "2.25.10", installed: "2.25.9" });
|
||||
assert.deepEqual(older.toasts, [], "2.25.9 is older than 2.25.10");
|
||||
const newer = await openPage(t, { running: "2.25.9", installed: "2.25.10" });
|
||||
assert.equal(newer.toasts.length, 1, "2.25.10 is newer than 2.25.9");
|
||||
assert.match(newer.toasts[0].detail, /v2\.25\.10 is installed/);
|
||||
});
|
||||
|
||||
test("an unknown or odd version says nothing", async (t) => {
|
||||
for (const [running, installed] of [
|
||||
["2.26.2", "unknown"],
|
||||
["2.26.2", "2.27"],
|
||||
["2.26.2", "2.27.0rc1"],
|
||||
["2.26.2", "v2.27.0"],
|
||||
["2.26.2", 3],
|
||||
["unknown", "2.27.0"],
|
||||
["dev", "2.27.0"],
|
||||
[null, "2.27.0"],
|
||||
]) {
|
||||
const page = await openPage(t, { running, installed });
|
||||
assert.deepEqual(page.toasts, [], `page ${running}, server ${installed}`);
|
||||
assert.deepEqual(page.refreshed, [], `page ${running}, server ${installed}`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -142,6 +142,7 @@ test("only the listed parts of the pack listen for the wheel", () => {
|
||||
"image_folder/index.js root", // the copy question, a window over the page
|
||||
"image_folder/index.js root", // the folder list, a window over the page
|
||||
"shared/discard_prompt.mjs backdrop", // the keep or discard question
|
||||
"shared/h3_cast_chips.mjs window", // closes a chip's job list when the graph moves
|
||||
"shared/media_picker.mjs window", // closes its list when the graph moves
|
||||
"shared/transform_editor.mjs canvas", // the full-screen editor zooms its picture
|
||||
"shared/widget_card.mjs area", // a text box scrolls its own text first
|
||||
@@ -262,7 +263,8 @@ test("the fields on a node face pass app shortcuts on", () => {
|
||||
// cursor was in a Text node, a number box or the Seed box (reported on the
|
||||
// Text node). A new field on a node face uses keepKeyInField too.
|
||||
const js = join(dirname(fileURLToPath(import.meta.url)), "..", "js");
|
||||
const fields = ["shared/widget_card.mjs", "shared/scrub_input.mjs", "seed/index.js", "save_image/index.js", "load_video/index.js", "lora_loader/index.js"];
|
||||
// Load Video's typed IN/OUT went; its timing boxes are scrub inputs now.
|
||||
const fields = ["shared/widget_card.mjs", "shared/scrub_input.mjs", "seed/index.js", "save_image/index.js", "lora_loader/index.js"];
|
||||
for (const file of fields) {
|
||||
const source = readFileSync(join(js, file), "utf-8");
|
||||
assert.match(source, /keepKeyInField\(event\)/, `${file}: its field stops every key again`);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { clipOutputRate, inputNumber } from '../js/shared/clip_rate.mjs';
|
||||
import { clipOutputRate, inputNumber, linkOrigin } from '../js/shared/clip_rate.mjs';
|
||||
function linked(type='PrimitiveFloat', value=24) {
|
||||
const source={type,widgets:[{name:'value',value}]};
|
||||
return {inputs:[{name:'force_rate',link:1}],graph:{links:{1:{origin_id:2,origin_slot:0}},getNodeById:()=>source}};
|
||||
@@ -38,3 +38,38 @@ test('reads linked fixed frames from AusBoss numeric cards without evaluating ca
|
||||
node.inputs[0].link=null;
|
||||
assert.equal(inputNumber(node,'fixed_frames',0),0);
|
||||
});
|
||||
|
||||
test('a rate typed inside a subgraph counts as typed (Person Swap: Pick the model files -> video fps 24)', () => {
|
||||
const literal = { id: 222, type: 'AUSBOSS_NODES_Integer', mode: 0, inputs: [{ name: 'value', link: null }], widgets: [{ name: 'value', value: 24 }] };
|
||||
const inner = { links: new Map([[391, { origin_id: 222, origin_slot: 0 }]]), outputs: [{}, {}, { linkIds: [391] }], getNodeById: (id) => (id === 222 ? literal : null) };
|
||||
const box = { id: 146, mode: 0, type: 'subgraph-id', subgraph: inner, isSubgraphNode: () => true };
|
||||
const clip = { inputs: [{ name: 'force_rate', link: 7 }], graph: { links: { 7: { origin_id: 146, origin_slot: 2 } }, getNodeById: (id) => (id === 146 ? box : null) } };
|
||||
assert.equal(inputNumber(clip, 'force_rate', 0), 24);
|
||||
assert.equal(clipOutputRate(clip, 60, 1), 24);
|
||||
// A calculation inside the subgraph stays unknown.
|
||||
literal.type = 'AUSBOSS_NODES_MathExpression';
|
||||
assert.equal(inputNumber(clip, 'force_rate', 0), null);
|
||||
});
|
||||
|
||||
test('an older Primitive node and a Reroute both carry a typed number', () => {
|
||||
const primitive = { id: 5, type: 'PrimitiveNode', mode: 0, widgets: [{ name: 'max_seconds', value: 7.5 }] };
|
||||
const reroute = { id: 6, type: 'Reroute', mode: 0, inputs: [{ link: 2 }] };
|
||||
const graph = { links: { 1: { origin_id: 6, origin_slot: 0 }, 2: { origin_id: 5, origin_slot: 0 } }, getNodeById: (id) => ({ 5: primitive, 6: reroute })[id] ?? null };
|
||||
const audio = { inputs: [{ name: 'max_seconds', widget: { name: 'max_seconds' }, link: 1 }], graph };
|
||||
assert.equal(inputNumber(audio, 'max_seconds', 0), 7.5);
|
||||
assert.deepEqual(linkOrigin(audio, 'max_seconds'), { node: primitive, slot: 0 });
|
||||
// Not linked: the caller's own value. Bypassed: unknown.
|
||||
assert.equal(linkOrigin({ inputs: [{ name: 'max_seconds', link: null }] }, 'max_seconds'), undefined);
|
||||
primitive.mode = 4;
|
||||
assert.equal(inputNumber(audio, 'max_seconds', 0), null);
|
||||
});
|
||||
|
||||
test('Layout Boxes reads a size from inside a subgraph', async () => {
|
||||
const { wiredNumber } = await import('../js/shared/layout_boxes.mjs');
|
||||
const latent = { id: 9, type: 'EmptyLatentImage', mode: 0, outputs: [{ name: 'LATENT' }], widgets: [{ name: 'width', value: 1024 }] };
|
||||
const sizes = { id: 8, type: 'AUSBOSS_NODES_Integer', mode: 0, outputs: [{ name: 'int' }], inputs: [{ name: 'value', link: null }], widgets: [{ name: 'value', value: 832 }] };
|
||||
const inner = { links: new Map([[50, { origin_id: 8, origin_slot: 0 }]]), outputs: [{ linkIds: [50] }], getNodeById: (id) => ({ 8: sizes, 9: latent })[id] ?? null };
|
||||
const box = { id: 3, mode: 0, type: 'subgraph-id', subgraph: inner, isSubgraphNode: () => true };
|
||||
const node = { inputs: [{ name: 'width', link: 4 }], graph: { links: { 4: { origin_id: 3, origin_slot: 0 } }, getNodeById: (id) => (id === 3 ? box : null) } };
|
||||
assert.equal(wiredNumber(node, 'width'), 832);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
const source = readFileSync(new URL("../js/shared/h3_cast_chips.mjs", import.meta.url), "utf-8");
|
||||
|
||||
test("a chip's job list stays open while an item is pressed", () => {
|
||||
// Pressing an item takes focus off the chip's button. A capturing blur
|
||||
// listener heard that and closed the list before the click could pick.
|
||||
const blur = source.match(/addEventListener\("blur",[^\n]*/)?.[0] ?? "";
|
||||
assert.match(blur, /event\.target === window/, "only the window losing focus closes the list");
|
||||
assert.doesNotMatch(blur, /\bon\)/, "the blur listener is not the capturing set");
|
||||
assert.match(source, /menu\.addEventListener\("mousedown", \(event\) => event\.preventDefault\(\)\)/, "a press keeps focus on the button");
|
||||
});
|
||||
@@ -11,10 +11,10 @@ const graphWith = (mode = 0, useMap = false) => {
|
||||
getNodeById:id=>id===150?source:null,
|
||||
} } };
|
||||
};
|
||||
test('only the three backend duration overrides use the clip', () => {
|
||||
test('only the four backend duration overrides use the clip', () => {
|
||||
const {node}=graphWith();
|
||||
for(const job of ['swap the person','new voice','change something']) assert.equal(clipSetsDuration(node,{video_job:job}),true);
|
||||
for(const job of ['copy its moves','keep going','',undefined]) assert.equal(clipSetsDuration(node,{video_job:job}),false);
|
||||
for(const job of ['copy its moves','swap the person','new voice','change something']) assert.equal(clipSetsDuration(node,{video_job:job}),true);
|
||||
for(const job of ['keep going','',undefined]) assert.equal(clipSetsDuration(node,{video_job:job}),false);
|
||||
});
|
||||
test('Full Video OFF/bypassed/missing/disconnected restore seconds; both link stores work', () => {
|
||||
for(const map of [false,true]) {
|
||||
@@ -73,7 +73,7 @@ test('timeline omits guessed duration/retiming and rejects an old async report;
|
||||
const {momentStrip}=await import('data:text/javascript;base64,'+Buffer.from(source).toString('base64'));
|
||||
const {node,source:video}=graphWith();let refreshes=0;node.__ausbossCard={refresh(){refreshes++;}};
|
||||
const panel=momentStrip(node), [ruler,track,note]=panel.element.children;
|
||||
const values={seconds:12,script:'She walks.',video_job:'copy its moves'};
|
||||
const values={seconds:12,script:'She walks.',video_job:'keep going'};
|
||||
panel.sync(values);assert.equal(timers.length,1);timers.shift()();await Promise.resolve();
|
||||
assert.equal(requests[0].seconds,12);
|
||||
panel.sync({...values,video_job:'swap the person'});
|
||||
@@ -114,3 +114,17 @@ test('Length row replaces the whole number+unit, preserves its value, and restor
|
||||
source.mode=0;sync({...values,video_job:'keep going'});assert.equal(scrub.root.style.display,'');
|
||||
assert.equal(node.widgets[0].value,12);assert.equal(node.inputs[0].link,8);
|
||||
});
|
||||
|
||||
test('H3 makes 5 + 17n frames, rounding a clip down (Python video_frames)', async () => {
|
||||
const { h3VideoFrames, clipLengthWords } = await import('../js/shared/h3_duration.mjs');
|
||||
assert.equal(h3VideoFrames(48), 39);
|
||||
assert.equal(h3VideoFrames(39), 39);
|
||||
assert.equal(h3VideoFrames(56), 56);
|
||||
assert.equal(h3VideoFrames(10), 22);
|
||||
assert.equal(h3VideoFrames(1000), 360 - ((360 - 5) % 17));
|
||||
const words = clipLengthWords({ frames: 48, startSeconds: 1, endSeconds: 3, roomFrames: 74 });
|
||||
assert.equal(words.title, "H3 makes 39 of the clip's 48 frames · 1.63 s");
|
||||
assert.match(words.note, /Stops at 2\.63 s.*1\.63 s or 2\.33 s/);
|
||||
assert.equal(clipLengthWords({ frames: 39, startSeconds: 0, endSeconds: 1.625 }).warn, false);
|
||||
assert.equal(clipLengthWords(null), null);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { grabZone, outputSummary, outputWindow, wavePeaks } from "../js/load_audio/audio_window.mjs";
|
||||
import { grabZone, outputWindow, pickWrites, typedPick, wavePeaks } from "../js/load_audio/audio_window.mjs";
|
||||
|
||||
test("the face shows what the node hands on", () => {
|
||||
// Mirrors audio_window in nodes/_audio_trim_helpers.py.
|
||||
@@ -13,11 +13,34 @@ test("the face shows what the node hands on", () => {
|
||||
assert.equal(outputWindow(10, "x", null, NaN).length, 10);
|
||||
});
|
||||
|
||||
test("the line between IN and OUT says how long and what is cut", () => {
|
||||
assert.equal(outputSummary(outputWindow(40, 8, 30, 15)), "15.0 s · cut 7.0 s");
|
||||
assert.equal(outputSummary(outputWindow(200, 0, 0, 0)), "3:20.0");
|
||||
assert.equal(outputSummary(outputWindow(40, 8, 30, 0), { maxFromLink: true }), "22.0 s · max wired");
|
||||
assert.equal(outputSummary(outputWindow(0, 0, 0)), "");
|
||||
test("a pick is stored as a Start and a Duration", () => {
|
||||
// 2 s to 5 s of a 12 s file: Start 2, Duration 3, no end.
|
||||
assert.deepEqual(pickWrites(12, 2, 5), { start: 2, end: 0, max: 3 });
|
||||
// To the end of the file: no Duration, so a longer file later still runs to its end.
|
||||
assert.deepEqual(pickWrites(12, 2, 12), { start: 2, end: 0, max: 0 });
|
||||
// Hundredths, as the boxes show them; the Duration is the difference of the two.
|
||||
assert.deepEqual(pickWrites(12, 1.234, 3.606), { start: 1.23, end: 0, max: 2.38 });
|
||||
// A linked Duration cannot be written: the pick is a start and an end.
|
||||
assert.deepEqual(pickWrites(12, 2, 5, { maxLinked: true }), { start: 2, end: 5 });
|
||||
// A linked end leaves only the start to write.
|
||||
assert.deepEqual(pickWrites(12, 2, 5, { endLinked: true }), { start: 2 });
|
||||
// What it stores comes out as the same pick.
|
||||
const stored = pickWrites(12, 2, 5);
|
||||
assert.equal(outputWindow(12, stored.start, stored.end, stored.max).keepEnd, 5);
|
||||
});
|
||||
|
||||
test("typing in a box: Start keeps the Duration, the other two keep the start", () => {
|
||||
const window = outputWindow(12, 2, 0, 3); // 2 s to 5 s
|
||||
assert.deepEqual(typedPick("start", 4, window, 12), { start: 4, end: 7 });
|
||||
assert.deepEqual(typedPick("start", 11, window, 12), { start: 11, end: 12 }, "less of it is left near the end");
|
||||
assert.deepEqual(typedPick("duration", 6, window, 12), { start: 2, end: 8 });
|
||||
assert.deepEqual(typedPick("end", 9, window, 12), { start: 2, end: 9 });
|
||||
assert.deepEqual(typedPick("end", 1, window, 12), { start: 2, end: 2.1 }, "an end before the start is held just after it");
|
||||
// 0 or an empty Duration, and an empty Ends at, run to the end of the file.
|
||||
assert.deepEqual(typedPick("duration", 0, window, 12), { start: 2, end: 12 });
|
||||
assert.deepEqual(typedPick("duration", null, window, 12), { start: 2, end: 12 });
|
||||
assert.deepEqual(typedPick("end", null, window, 12), { start: 2, end: 12 });
|
||||
assert.deepEqual(typedPick("start", null, window, 12), { start: 0, end: 3 }, "an empty Start is the beginning");
|
||||
});
|
||||
|
||||
test("a press grabs the nearest handle, the middle, or jumps", () => {
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
FILE_WIDGET_PREFIX,
|
||||
coreLoraList,
|
||||
fileChoices,
|
||||
isFileWidget,
|
||||
rowsNeedingFiles,
|
||||
syncFileWidgets,
|
||||
} from "../js/shared/lora_file_widgets.mjs";
|
||||
|
||||
// A node the way LiteGraph hands it over: addWidget appends and returns.
|
||||
function fakeNode() {
|
||||
return {
|
||||
widgets: [{ name: "loras", type: "customtext", value: "[]" }],
|
||||
addWidget(type, name, value, callback, options) {
|
||||
const widget = { type, name, value, callback, options };
|
||||
this.widgets.push(widget);
|
||||
return widget;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const row = (id, name, extra = {}) => ({ id, name, strength: 1, strength_clip: 1, enabled: true, ...extra });
|
||||
const choices = (widget) => widget.options.values(widget);
|
||||
|
||||
test("only rows the server would load need a file", () => {
|
||||
const rows = [
|
||||
row("a", "pika.safetensors"),
|
||||
row("b", ""),
|
||||
row("c", "off.safetensors", { enabled: false }),
|
||||
row("d", "group_off.safetensors", { group: "g", group_off: true }),
|
||||
row("e", "zero.safetensors", { strength: 0, strength_clip: 0 }),
|
||||
row("f", "clip_only.safetensors", { strength: 0, strength_clip: 0.5 }),
|
||||
];
|
||||
assert.deepEqual(rowsNeedingFiles(rows).map((item) => item.id), ["a", "f"]);
|
||||
});
|
||||
|
||||
test("a file the loader would find anyway is not missing", () => {
|
||||
const installed = ["minimax-h3/pika.safetensors", "style.safetensors"];
|
||||
assert.ok(fileChoices("minimax-h3/pika.safetensors", installed).includes("minimax-h3/pika.safetensors"));
|
||||
// saved as a bare name, installed in a subfolder: the loader finds it
|
||||
assert.ok(fileChoices("pika.safetensors", installed).includes("pika.safetensors"));
|
||||
assert.ok(fileChoices("STYLE.safetensors", installed).includes("STYLE.safetensors"));
|
||||
assert.ok(!fileChoices("gone.safetensors", installed).includes("gone.safetensors"));
|
||||
// no list to ask: never a false alarm
|
||||
assert.deepEqual(fileChoices("gone.safetensors", null), ["gone.safetensors"]);
|
||||
});
|
||||
|
||||
test("the install's list comes from ComfyUI's own LoRA loader", () => {
|
||||
assert.deepEqual(coreLoraList({ input: { required: { lora_name: [["a.safetensors"], { tooltip: "x" }] } } }), ["a.safetensors"]);
|
||||
assert.deepEqual(coreLoraList({ input: { required: { lora_name: ["COMBO", { options: ["b.safetensors"] }] } } }), ["b.safetensors"]);
|
||||
assert.equal(coreLoraList(undefined), null);
|
||||
assert.equal(coreLoraList({ input: { required: {} } }), null);
|
||||
});
|
||||
|
||||
test("one hidden list per needed row, out of the save and the prompt", () => {
|
||||
const node = fakeNode();
|
||||
const hidden = [];
|
||||
const changed = syncFileWidgets(node, [row("a", "pika.safetensors"), row("b", "")], {
|
||||
installed: () => [],
|
||||
hide: (widget) => hidden.push(widget),
|
||||
});
|
||||
assert.equal(changed, true);
|
||||
const files = node.widgets.filter(isFileWidget);
|
||||
assert.equal(files.length, 1);
|
||||
const [widget] = files;
|
||||
assert.equal(widget.type, "combo");
|
||||
assert.equal(widget.name, `${FILE_WIDGET_PREFIX}1`);
|
||||
assert.equal(widget.value, "pika.safetensors");
|
||||
assert.equal(widget.serialize, false);
|
||||
assert.equal(widget.options.serialize, false);
|
||||
assert.deepEqual(hidden, [widget]);
|
||||
// ComfyUI's check: a value that is not among the choices is a missing model
|
||||
assert.ok(!choices(widget).includes(widget.value));
|
||||
// the loras text keeps its place in front
|
||||
assert.equal(node.widgets[0].name, "loras");
|
||||
});
|
||||
|
||||
test("the lists follow the rows: renamed, added, removed", () => {
|
||||
const node = fakeNode();
|
||||
const options = { installed: () => ["here.safetensors"], hide: () => {} };
|
||||
syncFileWidgets(node, [row("a", "one.safetensors"), row("b", "two.safetensors")], options);
|
||||
const first = node.widgets.filter(isFileWidget)[0];
|
||||
assert.equal(syncFileWidgets(node, [row("a", "here.safetensors"), row("b", "two.safetensors")], options), false);
|
||||
assert.equal(node.widgets.filter(isFileWidget)[0], first, "the same widget is reused");
|
||||
assert.equal(first.value, "here.safetensors");
|
||||
assert.ok(choices(first).includes("here.safetensors"));
|
||||
assert.equal(syncFileWidgets(node, [row("b", "two.safetensors")], options), true);
|
||||
assert.deepEqual(node.widgets.filter(isFileWidget).map((widget) => [widget.value, widget.ausbossRowId]), [["two.safetensors", "b"]]);
|
||||
syncFileWidgets(node, [], options);
|
||||
assert.equal(node.widgets.filter(isFileWidget).length, 0);
|
||||
assert.deepEqual(node.widgets.map((widget) => widget.name), ["loras"]);
|
||||
});
|
||||
|
||||
test("a replacement put in the list goes to its row", () => {
|
||||
const node = fakeNode();
|
||||
const picks = [];
|
||||
syncFileWidgets(node, [row("a", "one.safetensors"), row("b", "gone.safetensors")], {
|
||||
installed: () => ["new.safetensors"],
|
||||
hide: () => {},
|
||||
onPick: (rowId, name) => picks.push([rowId, name]),
|
||||
});
|
||||
const widget = node.widgets.filter(isFileWidget)[1];
|
||||
// what ComfyUI's Issues panel does: set the value, then call back
|
||||
widget.value = "new.safetensors";
|
||||
widget.callback("new.safetensors");
|
||||
// a call back with the row's own file is no change
|
||||
node.widgets.filter(isFileWidget)[0].callback("one.safetensors");
|
||||
assert.deepEqual(picks, [["b", "new.safetensors"]]);
|
||||
});
|
||||
@@ -24,15 +24,15 @@ test("cuts and speech are marked", () => {
|
||||
|
||||
test("no report and an empty script draw nothing and say what to do", () => {
|
||||
assert.deepEqual(stripRows(null), []);
|
||||
assert.deepEqual(stripCaption(null), { text: "Each line becomes a moment.", warn: false });
|
||||
assert.deepEqual(stripCaption({ moments: [] }), { text: "Each line becomes a moment.", warn: false });
|
||||
assert.deepEqual(stripCaption(null), { text: "Each line becomes a moment. A blank line between lines is a cut.", warn: false });
|
||||
assert.deepEqual(stripCaption({ moments: [] }), { text: "Each line becomes a moment. A blank line between lines is a cut.", warn: false });
|
||||
});
|
||||
|
||||
test("the caption adds the script up", () => {
|
||||
assert.equal(stripCaption({ moments: [row(0, 2.5), row(2.5, 5)] }).text, "2 moments, 2.5 s each, one take.");
|
||||
assert.equal(stripCaption({ moments: [row(0, 8)] }).text, "1 moment, 8 s, one take.");
|
||||
assert.equal(stripCaption({ moments: [row(0, 3), row(3, 8)] }).text, "2 moments, one take.");
|
||||
assert.equal(stripCaption({ moments: [row(0, 3), row(3, 8, { cut: true })] }).text, "2 moments, 1 cut.");
|
||||
assert.equal(stripCaption({ moments: [row(0, 2.5), row(2.5, 5)] }).text, "2 moments, 2.5 s each, one take. Click between two moments to cut there.");
|
||||
assert.equal(stripCaption({ moments: [row(0, 8)] }).text, "1 moment, 8 s, one take. Add a line for the next moment, a blank line to cut.");
|
||||
assert.equal(stripCaption({ moments: [row(0, 3), row(3, 8)] }).text, "2 moments, one take. Click between two moments to cut there.");
|
||||
assert.equal(stripCaption({ moments: [row(0, 3), row(3, 8, { cut: true })] }).text, "2 moments, 1 cut. Click a cut on the bar to join the shots.");
|
||||
});
|
||||
|
||||
test("only connected pictures send their job", () => {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { outlineOf } from "../js/shared/outline.mjs";
|
||||
|
||||
// A frameless tile draws a card inside a transparent node. Snap into line and
|
||||
// Line up must use the card people see, not the node's wider bounds.
|
||||
const canvas = {
|
||||
canvas: { getBoundingClientRect: () => ({ left: 10, top: 20 }) },
|
||||
ds: { scale: 2, offset: [5, 5] },
|
||||
};
|
||||
const card = (rect) => ({ isConnected: true, getBoundingClientRect: () => rect });
|
||||
|
||||
test("a tile's outline is its visible card", () => {
|
||||
const node = {
|
||||
boundingRect: [100, 100, 380, 80],
|
||||
ausbossOutlineElement: card({ left: 10 + 2 * (114 + 5), top: 20 + 2 * (114 + 5), width: 704, height: 100 }),
|
||||
};
|
||||
assert.deepEqual(outlineOf(node, canvas), { x: 114, y: 114, w: 352, h: 50 });
|
||||
});
|
||||
|
||||
test("a collapsed or unshown tile falls back to the node's bounds", () => {
|
||||
const bounds = { x: 100, y: 100, w: 380, h: 80 };
|
||||
const shown = card({ left: 0, top: 0, width: 50, height: 50 });
|
||||
assert.deepEqual(outlineOf({ boundingRect: [100, 100, 380, 80], flags: { collapsed: true }, ausbossOutlineElement: shown }, canvas), bounds);
|
||||
const hidden = card({ left: 0, top: 0, width: 0, height: 0 });
|
||||
assert.deepEqual(outlineOf({ boundingRect: [100, 100, 380, 80], ausbossOutlineElement: hidden }, canvas), bounds);
|
||||
assert.deepEqual(outlineOf({ boundingRect: [100, 100, 380, 80] }, canvas), bounds);
|
||||
});
|
||||
@@ -0,0 +1,108 @@
|
||||
"""A loader's change check never opens a value it refused.
|
||||
|
||||
ComfyUI calls a node's IS_CHANGED with the prompt's widget values before it
|
||||
runs anything, and /prompt needs no login. The picture and video loaders
|
||||
first hand the value to their resolver, which takes only a file named below
|
||||
ComfyUI's input, output or temp folder. When the resolver refuses it, the
|
||||
value is hashed as text and nothing else: on Windows, merely looking up a
|
||||
network path ("//host/share/x.png") contacts that host and hands it the
|
||||
server's login.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
if "nodes" in sys.modules and not hasattr(sys.modules["nodes"], "__path__"):
|
||||
del sys.modules["nodes"]
|
||||
|
||||
from nodes._transform_engine import stable_file_fingerprint # noqa: E402
|
||||
from nodes.node_image_crop_rotate_pad import AusBossImageCropRotatePad # noqa: E402
|
||||
from nodes.node_load_image import AusBossLoadImage # noqa: E402
|
||||
from nodes.node_load_image_pad import AusBossLoadImagePad # noqa: E402
|
||||
from nodes.node_video_crop_rotate_pad import AusBossVideoCropRotatePad # noqa: E402
|
||||
from nodes.node_video_crop_rotate_pad_clip import AusBossVideoCropRotatePadClip # noqa: E402
|
||||
|
||||
REFUSED = [
|
||||
"//evil-host/share/photo.png",
|
||||
"\\\\evil-host\\share\\photo.png",
|
||||
"/evil-host/etc/photo.png",
|
||||
"../../evil-host/photo.png",
|
||||
]
|
||||
|
||||
|
||||
class DiskWatch:
|
||||
"""Records every stat and resolve of a path that names the evil host."""
|
||||
|
||||
def __init__(self):
|
||||
self.touched = []
|
||||
|
||||
def __enter__(self):
|
||||
real_stat, real_resolve = os.stat, Path.resolve
|
||||
watch = self
|
||||
|
||||
def stat(path, *args, **kwargs):
|
||||
if "evil-host" in str(path):
|
||||
watch.touched.append(("stat", str(path)))
|
||||
return real_stat(path, *args, **kwargs)
|
||||
|
||||
def resolve(self, *args, **kwargs):
|
||||
if "evil-host" in str(self):
|
||||
watch.touched.append(("resolve", str(self)))
|
||||
return real_resolve(self, *args, **kwargs)
|
||||
|
||||
self._patches = [patch("os.stat", stat), patch.object(Path, "resolve", resolve)]
|
||||
for item in self._patches:
|
||||
item.start()
|
||||
return self
|
||||
|
||||
def __exit__(self, *exc):
|
||||
for item in reversed(self._patches):
|
||||
item.stop()
|
||||
|
||||
|
||||
class ChangeCheckTests(unittest.TestCase):
|
||||
def assert_off_disk(self, call):
|
||||
for value in REFUSED:
|
||||
with self.subTest(value=value), DiskWatch() as watch:
|
||||
first = call(value)
|
||||
self.assertEqual(watch.touched, [])
|
||||
# The text still counts: another refused value is another key.
|
||||
self.assertNotEqual(first, call(value + "x"))
|
||||
|
||||
def test_picture_loaders(self):
|
||||
for node in (AusBossLoadImage, AusBossLoadImagePad, AusBossImageCropRotatePad):
|
||||
with self.subTest(node=node.__name__):
|
||||
self.assert_off_disk(lambda value, node=node: node.IS_CHANGED(image=value))
|
||||
|
||||
def test_video_crop_nodes(self):
|
||||
for node in (AusBossVideoCropRotatePad, AusBossVideoCropRotatePadClip):
|
||||
for mode in ("input folder", "local path"):
|
||||
with self.subTest(node=node.__name__, mode=mode):
|
||||
self.assert_off_disk(
|
||||
lambda value, node=node, mode=mode: node.IS_CHANGED(
|
||||
video=value if mode == "input folder" else "",
|
||||
source_mode=mode,
|
||||
local_path=value if mode == "local path" else "",
|
||||
seek_mode="frame index",
|
||||
frame_index=0,
|
||||
frame_time=0.0,
|
||||
**({"start_seconds": 0.0, "end_seconds": 0.0} if node is AusBossVideoCropRotatePadClip else {}),
|
||||
)
|
||||
)
|
||||
|
||||
def test_the_fingerprint_opens_only_a_resolved_path(self):
|
||||
with DiskWatch() as watch:
|
||||
stable_file_fingerprint("//evil-host/share/photo.png", {})
|
||||
stable_file_fingerprint(None, {})
|
||||
self.assertEqual(watch.touched, [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -7,6 +7,7 @@ import re
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
@@ -244,6 +245,45 @@ class VersionedServingTests(unittest.TestCase):
|
||||
for path, (_status, body, _headers) in self.fetch(paths).items():
|
||||
self.assertNotIn("?v=tok", body, path)
|
||||
|
||||
def test_an_address_never_reaches_the_disk(self):
|
||||
# The request is unauthenticated: its address is only looked up in
|
||||
# the list of scripts made at startup, never joined to a folder and
|
||||
# resolved. On Windows, resolving "//host/share" contacts that host.
|
||||
web = self.web
|
||||
touched = []
|
||||
|
||||
async def handled(request):
|
||||
return web.Response(text="from the handler", content_type="text/javascript")
|
||||
|
||||
async def run():
|
||||
middleware = make_revalidate_middleware("ausboss-nodes", self.js, "tok")
|
||||
real_resolve, real_stat = Path.resolve, os.stat
|
||||
|
||||
def resolve(path, *args, **kwargs):
|
||||
if "evil-host" in str(path):
|
||||
touched.append(str(path))
|
||||
return real_resolve(path, *args, **kwargs)
|
||||
|
||||
def stat(path, *args, **kwargs):
|
||||
if "evil-host" in str(path):
|
||||
touched.append(str(path))
|
||||
return real_stat(path, *args, **kwargs)
|
||||
|
||||
with patch.object(Path, "resolve", resolve), patch("os.stat", stat):
|
||||
for path in [
|
||||
"/extensions/ausboss-nodes//evil-host/share/x.mjs",
|
||||
"/extensions/ausboss-nodes/%2F%2Fevil-host/share/x.mjs",
|
||||
"/extensions/ausboss-nodes/%5C%5Cevil-host%5Cshare%5Cx.mjs",
|
||||
"/extensions/ausboss-nodes/../../evil-host/x.mjs",
|
||||
"/extensions/ausboss-nodes/%2e%2e/%2e%2e/evil-host/x.js",
|
||||
"/extensions/ausboss-nodes/C:/evil-host/x.mjs",
|
||||
]:
|
||||
response = await middleware(self.make_request("GET", path), handled)
|
||||
self.assertEqual(response.text, "from the handler", path)
|
||||
|
||||
asyncio.run(run())
|
||||
self.assertEqual(touched, [])
|
||||
|
||||
def test_without_a_tag_the_files_are_served_as_before(self):
|
||||
path = "/extensions/ausboss-nodes/shared/b.mjs"
|
||||
status, body, headers = self.fetch([path], token=None)[path]
|
||||
|
||||
@@ -182,6 +182,20 @@ class SplitTests(unittest.TestCase):
|
||||
def test_a_quote_can_end_a_sentence(self):
|
||||
self.assertEqual(moments('A voiceover says "this is how it ended." She walks away.'), ['A voiceover says "this is how it ended."', "She walks away"])
|
||||
|
||||
def test_an_at_after_a_quote_starts_a_new_moment(self):
|
||||
self.assertEqual(moments('@1 says "Hi." @1 waves and says "Bye."'), ['@1 says "Hi."', '@1 waves and says "Bye."'])
|
||||
self.assertEqual(moments('@1 says "Hi" and @2 says "Bye."'), ['@1 says "Hi"', '@2 says "Bye."'])
|
||||
self.assertEqual(moments('"Hi," she says. @1 laughs.'), ['"Hi," she says', "@1 laughs"])
|
||||
|
||||
def test_every_line_in_a_row_is_spoken(self):
|
||||
def said(script, jobs):
|
||||
return re.findall(r"<d>\[English\] (.*?)</d>", write_prompt(script, seconds=8.0, jobs=jobs))
|
||||
|
||||
self.assertEqual(said('@1 says "Hi!" @2 answers "Hello." @1 says "Bye."', {1: "person", 2: "person"}), ["Hi!", "Hello.", "Bye."])
|
||||
self.assertEqual(said('@1 says "Hi" and @2 says "Bye."', {1: "person", 2: "person"}), ["Hi.", "Bye."])
|
||||
self.assertEqual(said('"Hi," @1 says.', {1: "person"}), ["Hi."])
|
||||
self.assertEqual(said('@1 says "我有冰淇淋。" @1 says "好吗?" @1 says "但是,"', {1: "person"}), ["我有冰淇淋。", "好吗?", "但是。"])
|
||||
|
||||
def test_the_timeline_shows_plain_words_for_a_hold(self):
|
||||
self.assertEqual(script_report("3s: she jumps", 8)["moments"][0]["text"], "Holds still")
|
||||
|
||||
@@ -643,7 +657,7 @@ class VideoJobTests(unittest.TestCase):
|
||||
for job in ("outfit", "thing"):
|
||||
text = write_prompt("He wears @1 in place of his blue cap.", seconds=8.0, jobs={1: job}, video="change something")
|
||||
self.assertIn("<Subject 2> is the person in <Video 1>, kept as they are", text)
|
||||
self.assertIn("[video editing] <Subject 2> wears <Subject 1> in place of his blue cap. Everything else in <Video 1> is kept.", text)
|
||||
self.assertIn("[video editing + audio reuse] <Subject 2> wears <Subject 1> in place of his blue cap. Everything else in <Video 1> is kept.", text)
|
||||
self.assertIn("Retain the look of <Video 1>.", text)
|
||||
self.assertIn("<Subject 2> has the same words, mouth movements and moves as in <Video 1>.", text)
|
||||
self.assertIn("The original sound of <Video 1> continues throughout.", text)
|
||||
@@ -659,7 +673,7 @@ class VideoJobTests(unittest.TestCase):
|
||||
self.assertIn("put only this outfit on <Subject 2>", text)
|
||||
self.assertNotIn("<Subject 1> is the person in <Picture 1>", text)
|
||||
text = write_prompt("He wears the propeller hat instead of his cap.", seconds=8.0, jobs={1: "person"}, video="change something")
|
||||
self.assertIn("[video editing] <Subject 2> wears <Subject 1> instead of his cap.", text)
|
||||
self.assertIn("[video editing + audio reuse] <Subject 2> wears <Subject 1> instead of his cap.", text)
|
||||
|
||||
def test_change_something_keeps_a_person_picture_that_is_not_put_on(self):
|
||||
self.assertEqual(put_on_from_pictures("@1 stands next to him.", {1: "person"}), ("@1 stands next to him.", {1: "person"}))
|
||||
@@ -696,9 +710,8 @@ class VideoJobTests(unittest.TestCase):
|
||||
|
||||
def test_a_hat_with_no_person_picture_points_to_change_something(self):
|
||||
for job in ("outfit", "thing"):
|
||||
for video in ("swap the person", "copy its moves"):
|
||||
cast = Cast(number_pictures({1: job}, video), video)
|
||||
self.assertIn('pick the video job "change something"', cast.problem("He wears @1."))
|
||||
cast = Cast(number_pictures({1: job}, "swap the person"), "swap the person")
|
||||
self.assertIn('pick the video job "change something"', cast.problem("He wears @1."))
|
||||
|
||||
def test_copying_moves_keeps_the_performer_out(self):
|
||||
parts = parts_of("@1 dances on a rooftop.", jobs={1: "person"}, video="copy its moves")
|
||||
@@ -710,11 +723,62 @@ class VideoJobTests(unittest.TestCase):
|
||||
|
||||
def test_the_timeline_says_so_when_nothing_is_connected(self):
|
||||
self.assertIn("Connect a picture or a video", script_report("She runs.", 6, {})["warning"])
|
||||
self.assertIn("To copy the moves", script_report("She runs.", 6, {}, "copy its moves")["warning"])
|
||||
self.assertEqual(script_report("She runs.", 6, {}, "copy its moves")["warning"], "")
|
||||
|
||||
def test_copying_moves_with_nobody_to_give_them_to_says_so(self):
|
||||
def test_copying_moves_with_no_person_picture_keeps_the_person_in_the_video(self):
|
||||
cast = Cast(number_pictures({1: "place"}, "copy its moves"), "copy its moves")
|
||||
self.assertIn("To copy the moves", cast.problem("She dances."))
|
||||
self.assertEqual(cast.problem("She dances in @1."), "")
|
||||
parts = parts_of("She dances in @1.", jobs={1: "place"}, video="copy its moves")
|
||||
self.assertIn("<Subject 2> is the person in <Video 1>, with the same face, hair, body and clothes", parts["subject_definitions"])
|
||||
self.assertIn("the background of <Video 1> is not kept, and the place is <Subject 1>", parts["retention_analysis"])
|
||||
self.assertIn("<Subject 2> dances in <Subject 1>. <Subject 2> moves exactly as in <Video 1>", parts["detailed_description"])
|
||||
self.assertNotIn("performs the same moves as", parts["detailed_description"])
|
||||
|
||||
def test_restyling_an_empty_clip_names_no_person_and_drops_the_look(self):
|
||||
parts = parts_of("It looks real, like @1.", jobs={1: "style"}, video="change something")
|
||||
self.assertIn("<Video 1> supplies the place, the action, the timing, the camera movement and the sound.", parts["subject_definitions"])
|
||||
self.assertNotIn("the person in <Video 1>", parts["subject_definitions"])
|
||||
self.assertNotIn("the look", parts["retention_analysis"])
|
||||
self.assertNotIn("Retain the look of <Video 1>", parts["detailed_description"])
|
||||
|
||||
def test_an_edit_with_a_place_picture_takes_the_place_and_look_from_it(self):
|
||||
parts = parts_of("The hallway looks like @1.", jobs={1: "place"}, video="change something")
|
||||
self.assertIn("<Video 1> supplies the action, the timing, the camera movement and the sound.", parts["subject_definitions"])
|
||||
self.assertIn("the colours and the film grain of <Picture 1>", parts["detailed_description"])
|
||||
self.assertNotIn("is in the shot", parts["detailed_description"])
|
||||
|
||||
def test_an_edit_about_someone_still_keeps_them(self):
|
||||
parts = parts_of("She looks real, like @1.", jobs={1: "style"}, video="change something")
|
||||
self.assertIn("is the person in <Video 1>, kept as they are", parts["subject_definitions"])
|
||||
self.assertIn("the person", parts["subject_definitions"].splitlines()[0])
|
||||
|
||||
def test_copying_only_a_camera_move_names_no_person(self):
|
||||
parts = parts_of("The camera glides down @1.", jobs={1: "place"}, video="copy its moves")
|
||||
self.assertNotIn("the person in <Video 1>", parts["subject_definitions"])
|
||||
self.assertIn("apply only its camera movement", parts["retention_analysis"])
|
||||
self.assertNotIn("moves exactly as in", parts["detailed_description"])
|
||||
|
||||
def test_a_thing_that_does_the_action_takes_the_moves(self):
|
||||
parts = parts_of("@1 waves its finger.", jobs={1: "thing"}, video="copy its moves")
|
||||
self.assertIn("<Subject 1> is the character in <Picture 1>, with the same shape, colours and drawing style.", parts["subject_definitions"])
|
||||
self.assertIn("apply only the body motion, choreography and timing to <Subject 1>", parts["retention_analysis"])
|
||||
self.assertIn("<Subject 1> performs the same moves as <Subject 2>", parts["detailed_description"])
|
||||
|
||||
def test_a_thing_can_come_in_for_the_one_in_a_swap(self):
|
||||
parts = parts_of("@1 replaces the yellow hand.", jobs={1: "thing"}, video="swap the person")
|
||||
self.assertIn("<Subject 1> is the yellow hand in <Video 1>, selected for replacement.", parts["subject_definitions"])
|
||||
self.assertIn("has the shape, colours and drawing style of the character in <Picture 1>", parts["detailed_description"])
|
||||
self.assertEqual(script_report("", 6, {1: "thing"}, "swap the person")["warning"], "")
|
||||
|
||||
def test_a_held_thing_stays_a_prop(self):
|
||||
parts = parts_of("He holds @1 and dances.", jobs={1: "thing"}, video="copy its moves")
|
||||
self.assertIn("<Subject 1> is the object in <Picture 1>", parts["subject_definitions"])
|
||||
self.assertIn("<Subject 2> moves exactly as in <Video 1>", parts["detailed_description"])
|
||||
|
||||
def test_copying_moves_with_only_an_outfit_dresses_the_person_in_the_video(self):
|
||||
parts = parts_of("He wears @1.", jobs={1: "outfit"}, video="copy its moves")
|
||||
self.assertIn("the clothes change to <Subject 1>", parts["retention_analysis"])
|
||||
self.assertIn("keep its place unless the script names a new one", parts["retention_analysis"])
|
||||
|
||||
def test_a_swap_with_nobody_to_put_in_says_so(self):
|
||||
with self.assertRaisesRegex(ValueError, "new person"):
|
||||
@@ -755,6 +819,30 @@ class VideoJobTests(unittest.TestCase):
|
||||
self.assertEqual(add_looks("Swap him for @1.", {1: "person"}, lambda slot: said),
|
||||
"Swap him for @1.\n@1 looks like a man with curly brown hair, wearing dark-framed glasses")
|
||||
|
||||
def test_a_swap_reads_the_looks_sentence_on_the_same_line(self):
|
||||
from nodes._h3_cast_helpers import add_looks
|
||||
typed = "replace the girl on the car with @1 .@1 looks like a young woman with long dark hair"
|
||||
text = write_prompt(typed, seconds=8.0, jobs={1: "person"}, video="swap the person")
|
||||
self.assertIn("<Subject 1> is the girl on the car in <Video 1>", text)
|
||||
self.assertIn("this appearance: a young woman with long dark hair.", text)
|
||||
self.assertNotIn("looks like", text)
|
||||
# A typed sentence still wins over the model, wherever it sits on the line.
|
||||
self.assertNotIn("bald", add_looks(typed, {1: "person"}, lambda slot: "a bald man"))
|
||||
# A spoken line that happens to hold the words is left alone.
|
||||
said = 'Replace the guy with @1.\n@1 says: "He said @1 looks like trouble."'
|
||||
self.assertNotIn("this appearance", write_prompt(said, seconds=8.0, jobs={1: "person"}, video="swap the person"))
|
||||
# Only a new sentence is split off: inside a sentence the words are left where they are.
|
||||
from nodes._h3_cast_helpers import looks_on_own_lines
|
||||
self.assertEqual(looks_on_own_lines("Put @1 looks like a friend here."), "Put @1 looks like a friend here.")
|
||||
self.assertEqual(looks_on_own_lines("Swap him for @1! @1 looks like a pilot"), "Swap him for @1!\n@1 looks like a pilot")
|
||||
|
||||
def test_a_swap_reads_clothes_typed_on_their_own_line(self):
|
||||
swap = dict(seconds=8.0, jobs={1: "person"}, video="swap the person")
|
||||
text = write_prompt("Replace the man in the checked shirt with @1.\n@1 is wearing a black suit.", **swap)
|
||||
self.assertIn("this appearance: the same hair, wearing a black suit.", text)
|
||||
both = "Replace the guy with @1.\n@1 looks like a man with short dark hair.\n@1 wears a black suit."
|
||||
self.assertIn("this appearance: a man with short dark hair, wearing a black suit.", write_prompt(both, **swap))
|
||||
|
||||
def test_a_swap_gets_the_firm_wording_without_a_looks_like_line(self):
|
||||
text = write_prompt("Replace the guy with @1.", seconds=8.0, jobs={1: "person"}, video="swap the person")
|
||||
self.assertIn("<Subject 2> has the face, hair and clothes of the person in <Picture 1>", text)
|
||||
@@ -948,6 +1036,30 @@ class VideoJobTests(unittest.TestCase):
|
||||
self.assertIn("each word landing exactly on the lip movement of <Video 1>", parts["detailed_description"])
|
||||
self.assertIn("Quiet room tone", parts["overall_soundscape"])
|
||||
|
||||
def test_a_swap_keeps_every_line_the_new_person_says(self):
|
||||
script = (
|
||||
"Replace the young man in the black t-shirt with @1.\n"
|
||||
'@1 holds a phone up and says: "How do I get rich?" The phone answers: "Get a job." '
|
||||
'@1 looks up, confused, and says: "Bro, what are they talking about?"'
|
||||
)
|
||||
text = write_prompt(script, seconds=8.0, jobs={1: "person"}, video="swap the person")
|
||||
self.assertEqual(re.findall(r"<d>\[English\] (.*?)</d>", text),
|
||||
["How do I get rich?", "Get a job.", "Bro, what are they talking about?"])
|
||||
# With the clip's sound kept, the phone's words come from the clip and only the new person's own lines are written.
|
||||
text = write_prompt(script, seconds=8.0, jobs={1: "person"}, video="swap the person", clip_sound=True)
|
||||
self.assertEqual(re.findall(r"<d>\[English\] (.*?)</d>", text), ["How do I get rich?", "Bro, what are they talking about?"])
|
||||
|
||||
def test_a_looks_line_keeps_only_the_looks(self):
|
||||
script = (
|
||||
"Replace the young man with @1.\n"
|
||||
"@1 looks like a cartoon wooden log, no clothes. The trees behind @1 stay the same."
|
||||
)
|
||||
parts = parts_of(script, jobs={1: "person"}, video="swap the person")
|
||||
self.assertIn("this appearance: a cartoon wooden log, no clothes. The background", parts["subject_definitions"])
|
||||
self.assertNotIn("trees", parts["subject_definitions"])
|
||||
for name, part in parts.items():
|
||||
self.assertNotRegex(part, r"@\d", name)
|
||||
|
||||
def test_a_video_needs_words_unless_it_can_go_without(self):
|
||||
with self.assertRaises(ValueError):
|
||||
write_prompt("", jobs={1: "person"}, video="copy its moves")
|
||||
@@ -1521,5 +1633,110 @@ class ClipSoundTests(unittest.TestCase):
|
||||
self.assertEqual(moves[0], node.write('@1 dances.', 6, picture_1=PICTURE, video=frames, video_sound=sound, video_job="copy its moves")[0])
|
||||
|
||||
|
||||
class PromptBugBatchTests(unittest.TestCase):
|
||||
def test_a_swap_action_line_does_not_name_who_goes(self):
|
||||
for script in ("@1 dances.", "He dances."):
|
||||
text = write_prompt(script, seconds=6, jobs={1: "person"}, video="swap the person")
|
||||
self.assertIn("<Subject 1> is the original person in <Video 1>, selected for replacement.", text)
|
||||
self.assertNotIn("dances", text)
|
||||
|
||||
def test_two_people_need_a_named_speaker(self):
|
||||
jobs = {1: "person", 2: "person"}
|
||||
with self.assertRaisesRegex(ValueError, r"name who speaks: @2 says"):
|
||||
write_prompt('@1 and @2 talk. She says "hi". He says "hello".', seconds=6, jobs=jobs)
|
||||
parts = parts_of('@1 says "hi". @2 says "hello".', seconds=6, jobs=jobs)
|
||||
self.assertIn("<Subject 1> and <Subject 2> speak", parts["summary"])
|
||||
|
||||
def test_keep_going_uses_the_person_picture_as_the_main_person(self):
|
||||
parts = parts_of("He walks.", seconds=6, jobs={1: "person"}, video="keep going")
|
||||
text = join_sections(parts)
|
||||
self.assertNotIn("<Subject 2>", text)
|
||||
self.assertNotIn("main subject in <Video 1>", text)
|
||||
self.assertIn("<Subject 1> walks", parts["detailed_description"])
|
||||
placed = parts_of("He walks in @2.", seconds=6, jobs={1: "person", 2: "place"}, video="keep going")
|
||||
self.assertNotIn("same place", join_sections(placed))
|
||||
empty = parts_of("The room is empty.", seconds=6, jobs={}, video="keep going")
|
||||
self.assertNotIn("is in the shot", join_sections(empty))
|
||||
self.assertNotIn("main subject", join_sections(empty))
|
||||
|
||||
def test_an_outfit_with_no_person_goes_on_the_person_in_the_shot(self):
|
||||
parts = parts_of("He wears @1.", seconds=6, jobs={1: "outfit"})
|
||||
self.assertIn("put only this outfit on the person in the shot", parts["retention_analysis"])
|
||||
self.assertNotIn("on <Subject 1>", parts["retention_analysis"])
|
||||
|
||||
def test_in_the_shot_is_only_for_defined_people_and_things(self):
|
||||
for jobs in ({1: "style"}, {1: "end on it"}, {1: "outfit"}):
|
||||
self.assertNotIn("is in the shot", write_prompt("A calm lake.", seconds=6, jobs=jobs), jobs)
|
||||
self.assertIn("<Subject 1> is in the shot", write_prompt("A calm lake.", seconds=6, jobs={1: "thing"}))
|
||||
|
||||
def test_new_voice_keeps_the_clips_person(self):
|
||||
with self.assertRaisesRegex(ValueError, "swap the person"):
|
||||
write_prompt('She says "hi".', seconds=6, jobs={1: "person"}, video="new voice")
|
||||
text = write_prompt('She says "hi".', seconds=6, jobs={}, video="new voice")
|
||||
self.assertNotIn("faces the camera", text)
|
||||
|
||||
def test_he_or_she_binds_the_only_person_picture(self):
|
||||
parts = parts_of("She walks in @2.", seconds=6, jobs={1: "person", 2: "place"})
|
||||
self.assertIn("<Subject 1> walks in <Subject 2>", parts["detailed_description"])
|
||||
with self.assertRaisesRegex(ValueError, "no line names @1"):
|
||||
write_prompt("A dog sits in @2.", seconds=6, jobs={1: "person", 2: "place"})
|
||||
|
||||
def test_a_swap_with_a_thing_or_place_gets_its_own_advice(self):
|
||||
with self.assertRaisesRegex(ValueError, "He holds @1"):
|
||||
write_prompt("He holds @1.", seconds=6, jobs={1: "thing"}, video="swap the person")
|
||||
with self.assertRaisesRegex(ValueError, "keeps the place"):
|
||||
write_prompt("He dances.", seconds=6, jobs={1: "place"}, video="swap the person")
|
||||
|
||||
def test_the_task_tag_adds_audio_reuse_when_the_clips_sound_stays(self):
|
||||
edit = parts_of("She wears a red coat.", seconds=6, jobs={}, video="change something")["summary"]
|
||||
self.assertTrue(edit.startswith("[video editing + audio reuse]"))
|
||||
kept = parts_of("", seconds=6, jobs={1: "person"}, video="swap the person", clip_sound=True)["summary"]
|
||||
self.assertTrue(kept.startswith("[video editing + audio reuse]"))
|
||||
plain = parts_of("", seconds=6, jobs={1: "person"}, video="swap the person")["summary"]
|
||||
self.assertNotIn("audio reuse", plain)
|
||||
|
||||
def test_only_a_place_or_start_picture_sets_the_look(self):
|
||||
for job in ("outfit", "thing"):
|
||||
self.assertNotIn("film grain", write_prompt("He wears @1.", seconds=6, jobs={1: job}), job)
|
||||
self.assertIn("film grain of <Picture 1>", write_prompt("He sits in @1.", seconds=6, jobs={1: "place"}))
|
||||
|
||||
def test_change_something_puts_an_unnamed_outfit_on_the_video_person(self):
|
||||
parts = parts_of("Add a hat.", seconds=6, jobs={1: "outfit"}, video="change something")
|
||||
self.assertIn("<Subject 2> wears <Subject 1>.", parts["detailed_description"])
|
||||
|
||||
|
||||
|
||||
class SpeechAcrossCutTests(unittest.TestCase):
|
||||
CARRIED = 'She looks out the window. She says "I never thought this would happen..."\n\nA close-up of the road ahead.'
|
||||
|
||||
def test_a_trailing_line_carries_across_the_cut(self):
|
||||
first, second = shots(self.CARRIED, seconds=8)
|
||||
self.assertTrue(first.endswith("<scenetrans>"))
|
||||
self.assertNotIn("closes the lips", first)
|
||||
self.assertIn("<scenetrans> The line from the previous shot continues", second)
|
||||
self.assertNotIn("stays silent", second)
|
||||
self.assertNotIn("<Video 1>", second)
|
||||
self.assertEqual(write_prompt(self.CARRIED, seconds=8).count("I never thought"), 1)
|
||||
|
||||
def test_a_trailing_last_line_is_cut_off(self):
|
||||
(only,) = shots('She says "Wait, I was going to tell you that..."', seconds=4)
|
||||
self.assertTrue(only.endswith("<cutoff>"))
|
||||
self.assertNotIn("closes the lips", only)
|
||||
|
||||
def test_a_carried_line_is_not_warned_about(self):
|
||||
long = 'She says "this is a very long line that would never fit inside two short seconds of video"\n\nA close-up of the road.'
|
||||
self.assertEqual(script_warning(read_script(long), 4), "")
|
||||
self.assertIn("<scenetrans>", write_prompt(long, seconds=4))
|
||||
|
||||
def test_plain_lines_carry_nothing(self):
|
||||
text = write_prompt('She says "hello."\n\nHe waves back.', seconds=6)
|
||||
self.assertNotIn("<scenetrans>", text)
|
||||
self.assertNotIn("<cutoff>", text)
|
||||
|
||||
def test_four_seconds_is_allowed(self):
|
||||
seconds = AusBossH3PromptWriter.INPUT_TYPES()["optional"].get("seconds") or AusBossH3PromptWriter.INPUT_TYPES()["required"]["seconds"]
|
||||
self.assertEqual(seconds[1]["min"], 4)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -127,7 +127,7 @@ class ListingTests(FolderCase):
|
||||
|
||||
def test_no_folder_name_leads_out_of_the_root(self):
|
||||
for bad in ("..", "../private", "people/../../private", "/etc", "~/Pictures", "C:/Windows", "//server/share",
|
||||
"people\\..\\..\\private"):
|
||||
"people\\..\\..\\private", "people/C:/Windows", "people/\x00/x"):
|
||||
with self.assertRaises(ValueError, msg=bad) as refused:
|
||||
safe_folder(self.root, bad)
|
||||
self.assertEqual(str(refused.exception), OUTSIDE, bad)
|
||||
@@ -149,6 +149,11 @@ class ListingTests(FolderCase):
|
||||
self.assertEqual(place_inside(str(self.root) + "/", roots), ("input", ""))
|
||||
self.assertEqual(place_inside(str(roots["output"] / "set"), roots), ("output", "set"))
|
||||
self.assertEqual(place_inside(f'"{self.root / "people"}"', roots), ("input", "people"), "quotes from a copied path")
|
||||
# A "~" path is never expanded into a real one, and no node code does that.
|
||||
self.assertIsNone(place_inside("~/ComfyUI/input/people", roots))
|
||||
nodes_dir = Path(__file__).resolve().parents[1] / "nodes"
|
||||
for source in nodes_dir.glob("*.py"):
|
||||
self.assertNotIn("expanduser", source.read_text(encoding="utf-8"), source.name)
|
||||
|
||||
def test_a_whole_path_anywhere_else_is_not_a_place(self):
|
||||
roots = {"input": self.root, "output": Path(self.temp.name) / "output"}
|
||||
@@ -376,7 +381,13 @@ class RouteTests(FolderCase):
|
||||
("thumb", {"name": "loop/picture.png"})]:
|
||||
with self.subTest(route=route):
|
||||
response = self.request(route, **query)
|
||||
self.assertEqual(response.status, 400)
|
||||
# A looped link is a bad folder to the lists. The thumbnail
|
||||
# answers 400 or 404 depending on whether this Python's
|
||||
# resolve() raises on the loop; neither answer names the path.
|
||||
if route == "thumb":
|
||||
self.assertIn(response.status, (400, 404))
|
||||
else:
|
||||
self.assertEqual(response.status, 400)
|
||||
self.assertNotIn(str(self.root), json.loads(response.text)["error"])
|
||||
|
||||
def test_thumbnail_versions_change_with_subsecond_rewrites_and_size(self):
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
if "nodes" in sys.modules and not hasattr(sys.modules["nodes"], "__path__"):
|
||||
del sys.modules["nodes"]
|
||||
|
||||
from nodes._image_hold_helpers import GONE, HELD_FOLDER, hold_pictures, keep_pictures
|
||||
from nodes import _image_hold_helpers # noqa: E402
|
||||
from nodes._image_hold_helpers import GONE, HELD_FOLDER, hold_pictures, keep_pictures # noqa: E402
|
||||
|
||||
NOW = datetime(2026, 11, 10, 9, 30, 0)
|
||||
|
||||
@@ -99,12 +102,70 @@ class HoldTests(unittest.TestCase):
|
||||
|
||||
def test_a_folder_outside_the_output_folder_is_refused_at_the_click_too(self):
|
||||
token, _ = self.hold(count=1)
|
||||
manifest = self.temp / HELD_FOLDER / f"{token}.json"
|
||||
manifest.write_text(manifest.read_text().replace('"output_dir": ""', '"output_dir": "../elsewhere"'))
|
||||
_image_hold_helpers._RUNS[token]["output_dir"] = "../elsewhere"
|
||||
with self.assertRaises(ValueError):
|
||||
self.keep(token)
|
||||
self.assertFalse((Path(self.box.name) / "elsewhere").exists())
|
||||
|
||||
def test_a_run_planted_in_the_temp_folder_is_not_a_run(self):
|
||||
# ComfyUI's temp folder takes uploads, so a file there can be
|
||||
# anyone's. A planted list naming a server file must copy nothing.
|
||||
secret = Path(self.box.name) / "secret.txt"
|
||||
secret.write_text("server secret")
|
||||
held = self.temp / HELD_FOLDER
|
||||
held.mkdir(exist_ok=True)
|
||||
token = "a" * 16
|
||||
planted = dict(
|
||||
settings(extension="png/../../../secret.txt", output_dir="x/y"), count=1, kept={},
|
||||
)
|
||||
(held / f"{token}.json").write_text(json.dumps(planted))
|
||||
(held / f"{token}_000.png").mkdir() # an upload's subfolder makes the ".." walk work
|
||||
with self.assertRaises(LookupError):
|
||||
self.keep(token)
|
||||
self.assertEqual(list(self.output.rglob("*")), [])
|
||||
|
||||
def test_a_held_picture_is_named_only_from_the_token_number_and_format(self):
|
||||
token, previews = self.hold(count=1)
|
||||
for extension in ["png/../../x", "txt", "", "PNG"]:
|
||||
with self.assertRaises(ValueError):
|
||||
_image_hold_helpers._held_name(token, 0, extension)
|
||||
_image_hold_helpers._RUNS[token]["extension"] = "png/../../../secret.txt"
|
||||
with self.assertRaises(ValueError):
|
||||
self.keep(token)
|
||||
self.assertEqual(list(self.output.iterdir()), [])
|
||||
|
||||
def test_a_picture_swapped_for_a_link_is_not_copied(self):
|
||||
token, previews = self.hold(count=1)
|
||||
secret = Path(self.box.name) / "secret.txt"
|
||||
secret.write_text("server secret")
|
||||
picture = self.temp / HELD_FOLDER / previews[0]["filename"]
|
||||
picture.unlink()
|
||||
try:
|
||||
picture.symlink_to(secret)
|
||||
except (OSError, NotImplementedError):
|
||||
self.skipTest("no symlinks here")
|
||||
with self.assertRaises(LookupError):
|
||||
self.keep(token)
|
||||
self.assertEqual(list(self.output.iterdir()), [])
|
||||
|
||||
def test_counts_are_capped(self):
|
||||
with patch.object(_image_hold_helpers, "MAX_HELD_PICTURES", 4):
|
||||
with self.assertRaises(ValueError):
|
||||
self.hold(count=5)
|
||||
token, _ = self.hold(count=2)
|
||||
with self.assertRaises(ValueError):
|
||||
self.keep(token, [0] * 5)
|
||||
self.assertEqual(list(self.output.iterdir()), [])
|
||||
|
||||
def test_old_runs_are_forgotten_first(self):
|
||||
with patch.object(_image_hold_helpers, "MAX_HELD_RUNS", 2):
|
||||
oldest, _ = self.hold(count=1)
|
||||
self.hold(count=1)
|
||||
newest, _ = self.hold(count=1)
|
||||
with self.assertRaises(LookupError):
|
||||
self.keep(oldest)
|
||||
self.assertEqual(len(self.keep(newest)["saved"]), 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -1148,6 +1148,157 @@ class CanvasStitcherBboxTests(unittest.TestCase):
|
||||
|
||||
|
||||
|
||||
class ToneMatchInpaintTests(unittest.TestCase):
|
||||
"""color_match on a Crop For Inpaint crop: the drift is read inside the
|
||||
painted area, so it holds when the sampler used its own, wider noise
|
||||
mask and left the soft edge close to the original (issue #361)."""
|
||||
|
||||
def _case(self, repaint):
|
||||
generator = torch.Generator().manual_seed(4)
|
||||
rows = torch.linspace(0.0, 1.0, 320).view(1, 320, 1, 1)
|
||||
image = torch.tensor([0.72, 0.55, 0.45]).view(1, 1, 1, 3) - 0.15 * rows
|
||||
image = (image + 0.01 * torch.randn((1, 320, 320, 3), generator=generator)).clamp(0.0, 1.0)
|
||||
mask = torch.zeros((1, 320, 320))
|
||||
mask[:, 110:210, 110:210] = 1.0
|
||||
crop, sampling, stitcher = build_crop(image, mask, 2.0, 16, 16)
|
||||
# The model drifts where it paints, but the workflow's noise mask and
|
||||
# the model itself keep the soft edge on the original: the drift
|
||||
# fades out before the paste's feathered band begins.
|
||||
painted = inpaint_helpers.blur_mask(sampling, 3.0).unsqueeze(-1)
|
||||
patch = crop + painted * (repaint(crop) - crop)
|
||||
cx, cy, cw, ch = stitcher["crop_to_canvas"]
|
||||
ox, oy, ow, oh = stitcher["canvas_to_original"]
|
||||
inside = stitcher["blend"][0, oy : oy + oh, ox : ox + ow] > 0.999
|
||||
return image, patch, stitcher, inside
|
||||
|
||||
def _left_over(self, image, stitched, inside):
|
||||
from nodes._color_helpers import rgb_to_lab
|
||||
return float((rgb_to_lab(stitched) - rgb_to_lab(image))[0][inside].median(dim=0).values.norm())
|
||||
|
||||
def test_a_washed_out_repaint_comes_back_to_the_picture(self):
|
||||
image, patch, stitcher, inside = self._case(lambda crop: crop * 0.85 + 0.11)
|
||||
off = self._left_over(image, apply_stitch(stitcher, patch, color_match=0.0), inside)
|
||||
half = self._left_over(image, apply_stitch(stitcher, patch, color_match=0.5), inside)
|
||||
full = self._left_over(image, apply_stitch(stitcher, patch, color_match=1.0), inside)
|
||||
self.assertGreater(off, 3.0)
|
||||
self.assertLess(half, 0.65 * off)
|
||||
self.assertLess(full, 0.25 * off)
|
||||
|
||||
def test_the_band_alone_read_a_fraction_of_that_drift(self):
|
||||
# What the slider had to work with before: the regression in numbers.
|
||||
image, patch, stitcher, inside = self._case(lambda crop: crop * 0.85 + 0.11)
|
||||
cx, cy, cw, ch = stitcher["crop_to_canvas"]
|
||||
region = stitcher["canvas"][:, cy : cy + ch, cx : cx + cw]
|
||||
alpha = stitcher["blend"][:, cy : cy + ch, cx : cx + cw]
|
||||
band = inpaint_helpers.estimate_tone_offset(patch, region, alpha)
|
||||
inner, held = inpaint_helpers.inner_tone_offset(patch, region, alpha)
|
||||
self.assertTrue(bool(held[0]))
|
||||
self.assertLess(float(band.norm()), 0.5 * float(inner.norm()))
|
||||
|
||||
def test_new_content_is_not_pulled_toward_the_old_colour(self):
|
||||
# A black jacket over skin is a change, not a drift: the reading
|
||||
# holds at zero, so the band is not asked and nothing is shifted.
|
||||
image, patch, stitcher, inside = self._case(lambda crop: torch.full_like(crop, 0.05))
|
||||
cx, cy, cw, ch = stitcher["crop_to_canvas"]
|
||||
region = stitcher["canvas"][:, cy : cy + ch, cx : cx + cw]
|
||||
alpha = stitcher["blend"][:, cy : cy + ch, cx : cx + cw]
|
||||
inner, held = inpaint_helpers.inner_tone_offset(patch, region, alpha)
|
||||
self.assertTrue(bool(held[0]))
|
||||
self.assertEqual(float(inner.abs().max()), 0.0)
|
||||
stitched = apply_stitch(stitcher, patch, color_match=1.0)
|
||||
self.assertLess(float(stitched[0][inside].mean()), 0.12)
|
||||
|
||||
def test_new_content_painted_to_the_edge_is_left_as_painted(self):
|
||||
# A model with no noise mask repaints the soft edge too. The band
|
||||
# then reads the new colour as drift; Tone match must not act on it.
|
||||
def repaint(crop):
|
||||
return torch.tensor([0.85, 0.7, 0.1]).view(1, 1, 1, 3).expand_as(crop).clone()
|
||||
|
||||
image, _patch, stitcher, _inside = self._case(repaint)
|
||||
cx, cy, cw, ch = stitcher["crop_to_canvas"]
|
||||
crop = stitcher["canvas"][:, cy : cy + ch, cx : cx + cw]
|
||||
patch = repaint(crop)
|
||||
plain = apply_stitch(stitcher, patch, color_match=0.0)
|
||||
matched = apply_stitch(stitcher, patch, color_match=1.0)
|
||||
self.assertLess(float((matched - plain).abs().max()), 1.0 / 255)
|
||||
|
||||
def _shirt_case(self, paint):
|
||||
"""Skin with a dark shirt on it. The mask covers the shirt with a
|
||||
thin margin, and the model paints skin there, so the painted area
|
||||
has almost no "before" of its own to be read against."""
|
||||
generator = torch.Generator().manual_seed(7)
|
||||
skin = torch.tensor([0.72, 0.55, 0.45]).view(1, 1, 1, 3)
|
||||
rows = torch.linspace(0.0, 1.0, 320).view(1, 320, 1, 1)
|
||||
clean = (skin - 0.1 * rows + 0.01 * torch.randn((1, 320, 320, 3), generator=generator)).clamp(0.0, 1.0)
|
||||
image = clean.clone()
|
||||
image[:, 104:216, 104:216] = 0.06
|
||||
mask = torch.zeros((1, 320, 320))
|
||||
mask[:, 100:220, 100:220] = 1.0
|
||||
crop, sampling, stitcher = build_crop(image, mask, 2.0, 16, 16)
|
||||
cx, cy, cw, ch = stitcher["crop_to_canvas"]
|
||||
ox, oy, ow, oh = stitcher["canvas_to_original"]
|
||||
wanted = clean[:, oy : oy + oh, ox : ox + ow][:, cy : cy + ch, cx : cx + cw]
|
||||
painted = inpaint_helpers.blur_mask(sampling, 3.0).unsqueeze(-1)
|
||||
patch = crop + painted * (paint(wanted) - crop)
|
||||
inside = stitcher["blend"][0, oy : oy + oh, ox : ox + ow] > 0.999
|
||||
return clean, patch, stitcher, inside
|
||||
|
||||
def test_new_skin_is_matched_to_the_skin_beside_it(self):
|
||||
# Skin where a shirt was, painted paler than the skin around it:
|
||||
# the area's own "before" is the shirt, so it is read against the
|
||||
# untouched skin just outside the paste.
|
||||
clean, patch, stitcher, inside = self._shirt_case(lambda skin: skin * 0.85 + 0.13)
|
||||
off = self._left_over(clean, apply_stitch(stitcher, patch, color_match=0.0), inside)
|
||||
full = self._left_over(clean, apply_stitch(stitcher, patch, color_match=1.0), inside)
|
||||
self.assertGreater(off, 3.0)
|
||||
self.assertLess(full, 0.35 * off)
|
||||
|
||||
def test_new_skin_that_already_matches_is_left_alone(self):
|
||||
clean, patch, stitcher, inside = self._shirt_case(lambda skin: skin)
|
||||
plain = apply_stitch(stitcher, patch, color_match=0.0)
|
||||
matched = apply_stitch(stitcher, patch, color_match=1.0)
|
||||
self.assertLess(float((matched - plain).abs().max()), 2.0 / 255)
|
||||
|
||||
def test_a_mixed_rim_is_not_read_as_drift(self):
|
||||
# Half the painted area turned into something else: too little of
|
||||
# the rim agrees, so nothing inside is trusted.
|
||||
def repaint(crop):
|
||||
out = crop.clone()
|
||||
out[:, :, : crop.shape[2] // 2] = 0.05
|
||||
return out
|
||||
image, patch, stitcher, inside = self._case(repaint)
|
||||
cx, cy, cw, ch = stitcher["crop_to_canvas"]
|
||||
region = stitcher["canvas"][:, cy : cy + ch, cx : cx + cw]
|
||||
alpha = stitcher["blend"][:, cy : cy + ch, cx : cx + cw]
|
||||
offset, held = inpaint_helpers.inner_tone_offset(patch, region, alpha)
|
||||
self.assertLess(float(offset.norm()), 1.0)
|
||||
|
||||
def test_an_unchanged_crop_reads_no_drift(self):
|
||||
image, _patch, stitcher, _inside = self._case(lambda crop: crop)
|
||||
cx, cy, cw, ch = stitcher["crop_to_canvas"]
|
||||
crop = stitcher["canvas"][:, cy : cy + ch, cx : cx + cw]
|
||||
stitched = apply_stitch(stitcher, crop, color_match=1.0)
|
||||
# Nothing to undo; what is left is the colour-space round trip.
|
||||
self.assertLess(float((stitched - image).abs().max()), 0.5 / 255)
|
||||
|
||||
def test_a_large_picture_is_read_at_the_size_the_model_painted(self):
|
||||
_image, patch, stitcher, _inside = self._case(lambda crop: crop * 0.85 + 0.11)
|
||||
cx, cy, cw, ch = stitcher["crop_to_canvas"]
|
||||
canvas = stitcher["canvas"][:, cy : cy + ch, cx : cx + cw]
|
||||
blend = stitcher["blend"][:, cy : cy + ch, cx : cx + cw]
|
||||
small, small_held = inpaint_helpers.inner_tone_offset(patch, canvas, blend)
|
||||
|
||||
def grow(image):
|
||||
return torch.nn.functional.interpolate(image.movedim(-1, 1), scale_factor=4, mode="bilinear").movedim(1, -1)
|
||||
|
||||
big, big_held = inpaint_helpers.inner_tone_offset(
|
||||
grow(patch), grow(canvas), grow(blend.unsqueeze(-1)).squeeze(-1), sampled=(cw, ch)
|
||||
)
|
||||
self.assertTrue(bool(small_held[0]) and bool(big_held[0]))
|
||||
# Pasted back four times larger, the reading is the same one.
|
||||
self.assertLess(float((big - small).norm()), 0.3)
|
||||
|
||||
|
||||
class ToneMatchTests(unittest.TestCase):
|
||||
"""color_match: the drift is read off the feathered band and undone."""
|
||||
|
||||
|
||||
@@ -108,6 +108,15 @@ class _FolderPaths:
|
||||
def get_folder_paths(self, kind: str) -> list[str]:
|
||||
return [str(self.lora_root)] if kind == "loras" else []
|
||||
|
||||
def get_filename_list(self, kind: str) -> list[str]:
|
||||
if kind != "loras":
|
||||
return []
|
||||
return [
|
||||
path.relative_to(self.lora_root).as_posix()
|
||||
for path in self.lora_root.rglob("*")
|
||||
if path.is_file() and path.suffix == ".safetensors"
|
||||
]
|
||||
|
||||
def get_user_directory(self) -> str:
|
||||
return str(self.user_root)
|
||||
|
||||
@@ -605,7 +614,15 @@ class ResolveLoraPathTests(unittest.TestCase):
|
||||
def test_path_outside_the_folders_is_refused(self):
|
||||
self.full_path = lambda kind, name: str(self.root / ".." / "other_drive" / "real.safetensors")
|
||||
with self.assertRaisesRegex(ValueError, "escapes the loras folders"):
|
||||
_lora_helpers.resolve_lora_path("../other_drive/real.safetensors")
|
||||
_lora_helpers.resolve_lora_path("plain.safetensors")
|
||||
|
||||
def test_a_name_off_the_list_never_reaches_the_disk(self):
|
||||
asked = []
|
||||
self.full_path = lambda kind, name: asked.append(name)
|
||||
for name in ("../other_drive/real.safetensors", str(self.outside / "real.safetensors")):
|
||||
with self.assertRaisesRegex(ValueError, "not found"):
|
||||
_lora_helpers.resolve_lora_path(name)
|
||||
self.assertEqual(asked, [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -61,7 +61,7 @@ from nodes._media_helpers import ( # noqa: E402
|
||||
resolve_server_file,
|
||||
resolve_video_path,
|
||||
)
|
||||
from nodes._route_errors import safe_route_error # noqa: E402
|
||||
from nodes._route_errors import error_detail, safe_route_error # noqa: E402
|
||||
|
||||
NETWORK_REFUSAL = "Network source paths are not allowed."
|
||||
WHOLE_PATH_REFUSAL = "A whole path is not read"
|
||||
@@ -425,6 +425,12 @@ class RouteErrorTests(unittest.TestCase):
|
||||
with self.subTest(text=text):
|
||||
self.assertEqual(safe_route_error(ValueError(text)), text)
|
||||
|
||||
def test_a_node_error_keeps_its_words_unless_they_name_a_path(self):
|
||||
self.assertEqual(error_detail(ValueError("bad shape (3, 4)")), "ValueError: bad shape (3, 4)")
|
||||
for text in ("cannot open /home/me/models/x.pt", "Error in `C:\\Comfy\\models\\sam3.pt`", "~/loras/a.safetensors"):
|
||||
with self.subTest(text=text):
|
||||
self.assertEqual(error_detail(OSError(text)), "OSError")
|
||||
|
||||
def test_no_route_sends_a_file_by_its_path(self):
|
||||
for path in sorted((ROOT / "nodes").glob("*.py")):
|
||||
with self.subTest(module=path.name):
|
||||
|
||||
@@ -9,6 +9,13 @@ image and blend_mask with the output the 2.3.0 code gave.
|
||||
The legacy inpaint crop keeps its original geometry here; its expected
|
||||
mask is limited to the paste window. Crop sizing is tested separately.
|
||||
|
||||
A Crop For Inpaint crop with Tone match on is the one case no longer held to
|
||||
2.3.0: that release read the drift in the soft edge, which read a fraction of
|
||||
it when the workflow samples with a wider noise mask, so Tone match hardly
|
||||
did anything (issue #361). It is read inside the painted area now, and
|
||||
ToneMatchInpaintTests in test_inpaint_crop_helpers.py holds that. Its Tone
|
||||
match 0 stitch and its blend mask stay pinned.
|
||||
|
||||
Blend in with Tone match at 0 is pinned the same way, to the 2.4.0 code:
|
||||
the published Qwen Image 2.1 Rotate + Outpaint workflow stitches that way.
|
||||
|
||||
@@ -78,6 +85,11 @@ PINS = {
|
||||
}
|
||||
|
||||
|
||||
# Tone match on an inpaint crop is read inside the painted area since issue
|
||||
# #361, so these two no longer give the 2.3.0 picture. See the docstring.
|
||||
REREAD = {("crop for inpaint", 0.5), ("crop for inpaint", 1.0)}
|
||||
|
||||
|
||||
def picture(width: int, height: int, seed: int) -> Image.Image:
|
||||
"""Smooth colour structure plus fine grain, as 8-bit RGB."""
|
||||
y, x = np.mgrid[0:height, 0:width].astype(np.float32)
|
||||
@@ -207,7 +219,8 @@ class ClassicSeamPinTests(unittest.TestCase):
|
||||
with self.subTest(case=name, color_match=strength):
|
||||
stitcher, patch_image = build()
|
||||
image, blend_mask = stitch(stitcher, patch_image, strength)
|
||||
assert_released_image(image, reference_image(name, strength))
|
||||
if (name, strength) not in REREAD:
|
||||
assert_released_image(image, reference_image(name, strength))
|
||||
expected_mask = reference_mask(name)
|
||||
if name == "crop for inpaint":
|
||||
cx, cy, cw, ch = stitcher["crop_to_canvas"]
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
"""Every video list a node offers from the input folder takes uploads.
|
||||
|
||||
The flag (`video_upload`) is what gives the field an Upload button in
|
||||
ComfyUI's App mode and in Nodes 2.0. Without it the clip field in an App
|
||||
mode form was a bare list with nothing to upload a clip with. Read from the
|
||||
source, so ComfyUI does not have to be importable.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
NODES = Path(__file__).resolve().parent.parent / "nodes"
|
||||
|
||||
|
||||
def video_lists():
|
||||
for path in sorted(NODES.glob("node_*.py")):
|
||||
tree = ast.parse(path.read_text(encoding="utf-8"))
|
||||
for node in ast.walk(tree):
|
||||
if not isinstance(node, ast.Tuple) or not node.elts:
|
||||
continue
|
||||
first = node.elts[0]
|
||||
if isinstance(first, ast.Call) and getattr(first.func, "id", "") == "list_input_videos":
|
||||
options = node.elts[1] if len(node.elts) > 1 and isinstance(node.elts[1], ast.Dict) else None
|
||||
flags = {}
|
||||
if options is not None:
|
||||
for key, value in zip(options.keys, options.values):
|
||||
if isinstance(key, ast.Constant) and isinstance(value, ast.Constant):
|
||||
flags[key.value] = value.value
|
||||
yield path.name, node.lineno, flags
|
||||
|
||||
|
||||
class VideoUploadFlag(unittest.TestCase):
|
||||
def test_every_input_video_list_takes_uploads(self):
|
||||
found = list(video_lists())
|
||||
self.assertGreaterEqual(len(found), 3, "expected Load Video and both video crop nodes")
|
||||
missing = [f"{name}:{line}" for name, line, flags in found if flags.get("video_upload") is not True]
|
||||
self.assertEqual(missing, [], "video lists without video_upload: True")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -43,6 +43,7 @@ function fixture({ size = [300, 80], floor = [210, 94], scale = 1 } = {}) {
|
||||
querySelector() { return this; }
|
||||
setAttribute() {}
|
||||
setPointerCapture() {}
|
||||
closest() { return null; }
|
||||
remove() { this.removed = true; }
|
||||
}
|
||||
const root = new Element();
|
||||
@@ -56,7 +57,7 @@ function fixture({ size = [300, 80], floor = [210, 94], scale = 1 } = {}) {
|
||||
};
|
||||
const source = readFileSync(new URL("../js/shared/tile_face.mjs", import.meta.url), "utf8")
|
||||
.replace(/^import .*;\n/, "").replaceAll("export ", "");
|
||||
const context = vm.createContext({ app, AbortController, document: { createElement: () => new Element() } });
|
||||
const context = vm.createContext({ app, AbortController, CustomEvent, document: { createElement: () => new Element() } });
|
||||
vm.runInContext(source, context);
|
||||
context.setTileFace(node, root, true);
|
||||
const grip = root.children[0];
|
||||
@@ -103,3 +104,25 @@ test("keyboard resize supports fine steps, respects pinning and removes its hand
|
||||
f.disable();
|
||||
assert.equal(f.grip.removed, true);
|
||||
});
|
||||
|
||||
test("a tile drag names its card for snapping and reports each move once placed", () => {
|
||||
const f = fixture();
|
||||
assert.equal(f.node.ausbossOutlineElement, f.root, "Snap into line measures the card, not the transparent node");
|
||||
let stopped = 0;
|
||||
const reports = [];
|
||||
f.root.addEventListener("ausboss-tile-move", (event) => reports.push([...f.node.pos, event.detail.clientX]));
|
||||
const send = (type, values = {}) => {
|
||||
const event = new Event(type, { cancelable: true });
|
||||
Object.assign(event, { button: 0, pointerId: 1, isPrimary: true, clientX: 0, clientY: 0, ...values });
|
||||
if (type === "pointermove") event.stopPropagation = () => stopped++;
|
||||
f.root.dispatchEvent(event);
|
||||
};
|
||||
send("pointerdown", { clientX: 10, clientY: 10 });
|
||||
send("pointermove", { clientX: 60, clientY: 30 });
|
||||
assert.deepEqual([...f.node.pos], [70, 50]);
|
||||
assert.equal(stopped, 1, "the move stays with the tile, or Nodes 2.0 pans the canvas with it");
|
||||
assert.deepEqual(reports, [[70, 50, 60]], "Snap into line hears the move after the tile is placed");
|
||||
send("pointerup");
|
||||
f.disable();
|
||||
assert.equal(f.node.ausbossOutlineElement, undefined);
|
||||
});
|
||||
|
||||
@@ -315,3 +315,19 @@ test("a wired 49-frame selection stops at IN 48 on the 97-frame pier clip", () =
|
||||
assert.equal(clipLengthPlan(info, { ...values, resampled: true, outputFps: 12 }).latestStart, 0);
|
||||
assert.equal(clipLengthPlan(info, { ...values, wired: "fixed_frames", outputFps: 24 }).latestStart, 48);
|
||||
});
|
||||
|
||||
test('a linked 24 fps rate on a 60 fps clip: 48 frames from 1 s end at 3 s', () => {
|
||||
const info = clipInfo({ fps: 60, frame_count: 247, duration: 247 / 60 });
|
||||
const values = { start: 1, end: 0, everyNth: 1, frameSnap: 'free', maxFrames: 48, fixedFrames: 0, wired: null, wiredFrames: null, outputFps: 24, resampled: true };
|
||||
const plan = clipLengthPlan(info, values);
|
||||
assert.equal(plan.frames, 48);
|
||||
assert.equal(plan.endSeconds, 3);
|
||||
assert.equal(plan.last, 177);
|
||||
assert.equal(plan.latestStart, 129);
|
||||
// A 240-frame Length (10 s) only caps a 4.1 s clip: the source ends first.
|
||||
const capped = clipLengthPlan(info, { ...values, maxFrames: 240 });
|
||||
assert.equal(capped.truncated, true);
|
||||
assert.equal(capped.frames, 75);
|
||||
// Still unknown without a rate.
|
||||
assert.equal(clipLengthPlan(info, { ...values, outputFps: null }).last, null);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { COPY_EDITS_SETTING, copyPicture, transformPicture } from "../js/shared/transform_picture.mjs";
|
||||
import { mergeSettings } from "../js/shared/node_settings.mjs";
|
||||
|
||||
function render(values = {}, resize = null, includeEdits = false) {
|
||||
const calls = [];
|
||||
const context = new Proxy({}, { get: (target, name) => name in target ? target[name] : (...args) => calls.push([name, ...args]) });
|
||||
const canvas = { getContext: () => context };
|
||||
const result = transformPicture({
|
||||
sourceWidth: 100, sourceHeight: 60,
|
||||
values: { canvas_multiple: 1, ...values }, resize, includeEdits, fill: "#123456",
|
||||
drawSource: (ctx) => ctx.drawImage("source", -50, -30, 100, 60),
|
||||
createCanvas: () => canvas,
|
||||
});
|
||||
return { result, calls, context };
|
||||
}
|
||||
|
||||
test("default copy uses the original picture, ignoring crop, rotation, padding and resize", () => {
|
||||
const { result, calls } = render({ crop_x: 10, crop_width: 40, rotation_degrees: 90, pad_left: 80, pad_top: 20, canvas_multiple: 64 }, { megapixels: 1, steps: 8 });
|
||||
assert.deepEqual([result.width, result.height], [100, 60]);
|
||||
assert.deepEqual(calls, [
|
||||
["translate", 50, 30], ["drawImage", "source", -50, -30, 100, 60],
|
||||
]);
|
||||
});
|
||||
|
||||
test("the gear preference defaults off for existing browsers and accepts an explicit opt-in", () => {
|
||||
assert.equal(mergeSettings([COPY_EDITS_SETTING], {}).copy_edits, false);
|
||||
assert.equal(mergeSettings([COPY_EDITS_SETTING], { show_mask: true }).copy_edits, false);
|
||||
assert.equal(mergeSettings([COPY_EDITS_SETTING], { copy_edits: "true" }).copy_edits, false);
|
||||
assert.equal(mergeSettings([COPY_EDITS_SETTING], { copy_edits: true }).copy_edits, true);
|
||||
});
|
||||
|
||||
test("opting in includes crop, padding and alignment in the copied bounds and source offset", () => {
|
||||
const { result, calls } = render({ crop_x: 10, crop_y: 5, crop_width: 40, crop_height: 30, pad_left: 8, pad_top: 4, pad_right: 8, pad_bottom: 6, canvas_multiple: 8 }, null, true);
|
||||
assert.deepEqual([result.width, result.height], [56, 40]);
|
||||
assert.ok(calls.some((c) => JSON.stringify(c) === JSON.stringify(["rect", 8, 4, 40, 30])));
|
||||
assert.ok(calls.some((c) => JSON.stringify(c) === JSON.stringify(["translate", 48, 29])));
|
||||
});
|
||||
|
||||
test("opting in applies rotation and resize without copying a screen-sized preview", () => {
|
||||
const { result, calls } = render({ rotation_degrees: 90 }, { megapixels: 0.25, steps: 8 }, true);
|
||||
assert.deepEqual([result.width, result.height], [400, 664]);
|
||||
assert.ok(calls.some((c) => c[0] === "rotate" && c[1] === Math.PI / 2));
|
||||
assert.ok(calls.some((c) => c[0] === "scale" && c[1] === 400 / 60 && c[2] === 664 / 100));
|
||||
});
|
||||
|
||||
test("clipboard write starts before PNG encoding finishes and contains only the clean PNG", async () => {
|
||||
let finish, item, written = false;
|
||||
const canvas = { toBlob: (callback, type) => { assert.equal(type, "image/png"); finish = callback; } };
|
||||
class ClipboardItem { constructor(data) { this.data = data; } }
|
||||
const clipboard = { write: async (items) => { written = true; [item] = items; await item.data["image/png"]; } };
|
||||
const pending = copyPicture(canvas, { clipboard, ClipboardItem });
|
||||
assert.equal(written, true);
|
||||
assert.deepEqual(Object.keys(item.data), ["image/png"]);
|
||||
await Promise.resolve(); await Promise.resolve();
|
||||
const png = new Blob(["picture"], { type: "image/png" });
|
||||
finish(png);
|
||||
await pending;
|
||||
assert.equal(await item.data["image/png"], png);
|
||||
});
|
||||
|
||||
test("clipboard and encoding failures are reported instead of false success", async () => {
|
||||
assert.throws(() => copyPicture({}, { clipboard: null, ClipboardItem: null }), /Open image/);
|
||||
class ClipboardItem { constructor(data) { this.data = data; } }
|
||||
const canvas = { toBlob: (callback) => callback(null) };
|
||||
const clipboard = { write: async ([item]) => await item.data["image/png"] };
|
||||
await assert.rejects(copyPicture(canvas, { clipboard, ClipboardItem }), /could not make/);
|
||||
await assert.rejects(copyPicture({ toBlob: () => {} }, { clipboard: { write: async () => { throw new Error("Denied"); } }, ClipboardItem }), /Denied/);
|
||||
});
|
||||
|
||||
test("both image editing surfaces replace native canvas copying, video is unchanged", () => {
|
||||
const source = readFileSync(new URL("../js/shared/transform_editor.mjs", import.meta.url), "utf8");
|
||||
assert.match(source, /attachStageHandlers\(state, preview, state.panelAbort.signal\)/);
|
||||
assert.match(source, /attachStageHandlers\(state, canvas, abort.signal\)/);
|
||||
assert.match(source, /if \(state.kind === "image"\) \{\s*canvas.addEventListener\("contextmenu"/);
|
||||
assert.match(source, /copyPicture\(picture\)/);
|
||||
});
|
||||
@@ -106,3 +106,14 @@ test("hideInputsInDef never throws on frozen definitions", () => {
|
||||
const frozenAll = Object.freeze({ input: Object.freeze({ required: Object.freeze({ seed: Object.freeze(["INT", Object.freeze({})]) }) }) });
|
||||
assert.equal(hideInputsInDef(frozenAll, ["seed"]), 0);
|
||||
});
|
||||
|
||||
test("show leaves no paint hooks behind that the widget never had", () => {
|
||||
// Left as own `undefined` properties, the frontend took the widget for a
|
||||
// custom-drawn one and App mode drew an empty row for it.
|
||||
const widget = makeWidget();
|
||||
hideWidget(widget);
|
||||
showWidget(widget);
|
||||
for (const key of ["computeSize", "computeLayoutSize", "draw"]) {
|
||||
assert.equal(Object.prototype.hasOwnProperty.call(widget, key), false, key);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
groupModels,
|
||||
hostLabel,
|
||||
matchInstalled,
|
||||
onlyCopy,
|
||||
noteFit,
|
||||
noteIsEmpty,
|
||||
noteShowsTileFace,
|
||||
@@ -332,3 +333,15 @@ test("note panels stand down the frontend image preview", () => {
|
||||
assert.match(source, /import \{ suppressCoreImagePreview \} from "\.\.\/shared\/core_preview\.mjs";/, "the note imports the pack's preview suppression");
|
||||
assert.match(source, /suppressCoreImagePreview\(node\);/, "building a note panel stands the core image preview down");
|
||||
});
|
||||
|
||||
test("onlyCopy picks a file without asking only when there is one copy", () => {
|
||||
const files = ["minimax-h3/model.safetensors", "a/lora.safetensors", "b/lora.safetensors", "vae.safetensors", "a\\Win.safetensors"];
|
||||
assert.equal(onlyCopy("model.safetensors", files), "minimax-h3/model.safetensors");
|
||||
assert.equal(onlyCopy("MODEL.safetensors", files), "minimax-h3/model.safetensors");
|
||||
assert.equal(onlyCopy("lora.safetensors", files), null); // two copies: the user picks
|
||||
assert.equal(onlyCopy("b/lora.safetensors", files), "b/lora.safetensors"); // the exact path wins
|
||||
assert.equal(onlyCopy("vae.safetensors", files), "vae.safetensors");
|
||||
assert.equal(onlyCopy("win.safetensors", files), "a/Win.safetensors");
|
||||
assert.equal(onlyCopy("missing.safetensors", files), null);
|
||||
assert.equal(onlyCopy("model.safetensors", []), null);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user