CoachBate Video Prompt From Metadata
Reuse the prompt your clip was made with, read straight out of the mp4
- prompt
- info
- found
The prompt is in the file. Use it.
ComfyUI writes the workflow and the API prompt into every file it saves, and for a video that means the mp4 you're looking at already knows the exact prompt that made it. That's not trivia - it's the difference between opening a refine pass and having to paste a 400-word prompt back in by hand, and getting it slightly wrong because you don't remember which of the three draft prompts you actually queued.
CoachBate Video Prompt From Metadata takes a video path (the same string you gave VHS Load Video
(Path)) and returns the recovered prompt, plus an info string and a found boolean. It exists
for the "refine an existing clip" workflow: the clip arrives, this node reads its own prompt, and
the second pass reuses it instead of you retyping it.
It follows the graph, which is the hard part
Reading a string out of an mp4 is easy. Working out which string was the positive prompt is not,
because the prompt you typed is usually several hops from the save node: through a text encoder,
maybe through a switch or a concatenate, maybe assembled from primitives. This node walks the API
prompt graph backwards from the save node to the sampler to the encoder, following links through
switches, concatenations and primitives - and it prefers the workflow JSON's widget values where
the API snapshot is known to be stale, which is the case whenever the frontend has edited a widget
without re-queueing.
Encoder text fields are matched by a priority list covering the common families - text for a
plain CLIPTextEncode, prompt for the Qwen-ish nodes, positive_prompt for Wan,
text_g/text_l for core SDXL, plus the timeline-style global_prompt/local_prompts used by
prompt-relay encoders. Negative fields are deliberately absent from that list, so a negative prompt
can never be returned as your positive by accident.
Getting the metadata out is a three-tier fallback: ffprobe first if it's on your PATH, then the
bundled ffmpeg's ffmetadata dump, then mutagen - which is the tier that reads the mp4 tags
when neither ffmpeg binary is available, identifying workflow and prompt payloads by their content
since its keys come back unnamed. One more nicety: an A1111-style parameters tag is understood
too, so a clip that came out of a webui-side tool still yields the text before the
Negative prompt: line.
fallback is the string used when the file carries nothing. Leave it empty and you get an empty
prompt, which is the honest answer; put your usual boilerplate there and a metadata-less clip still
renders something sensible.
Inputs and outputs
Required: fallback (STRING, multiline) and video (STRING - the path, quotes stripped, env vars
and ~ expanded). Outputs: prompt (STRING), info (STRING, a human-readable reason like
"prompt from clip.mp4: <how it was found>"), found (BOOLEAN).
The input order is deliberate, and it's a nice detail you'd never notice: fallback is first
because when the node is bypassed, ComfyUI's frontend routes output slot N to input slot N for
any-typed consumers like the pack's own Text Preview and Edit. With the path first, bypassing
pushed the path out of prompt and over whatever you'd typed downstream. With the normally
unlinked fallback widget at slot 0, a bypassed node emits nothing on prompt and the downstream
input reads as unconnected, which is what you expect a bypass to do.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/CoachBate/ComfyUI-CoachBate.git
Or ComfyUI Manager → search "CoachBate" → restart. Category CoachBate / H3. No pip dependencies: ffmpeg is used if it's around, and mutagen is optional - without both, you're down to whatever ffmpeg binary ComfyUI itself bundles.
Where people get burned
foundis false on a file you made in ComfyUI. The metadata is gone: you screenshotted it, re-encoded it in an editor, or the saving instance had "Disable saving prompt metadata" on (or--disable-metadata/ an API client that strips it). Metadata is not part of the pixels; it lives and dies with the container.- A prompt comes back that you don't recognise. You're reading the prompt of the last save in that file's graph, and a refine pass saves a graph whose sampler is fed by a second generation node. The node has an H3-specific last-resort path for exactly this, but if a clip has two encoders and one of them is empty, the answer can be the other one.
- Empty prompt downstream.
fallbackis empty and no metadata was found - that's the designed behaviour, not a bug. Set a fallback if a blank prompt breaks your workflow.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| fallback | STRING | Used as the prompt when the file carries none. Leave empty to output an empty prompt in that case. | |
| video | STRING | Path to the mp4 (the same value as VHS Load Video (Path)). Surrounding quotes are stripped. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |
| info | STRING | — |
| found | BOOLEAN | — |