kling3: support 'shot 1 | 4 seconds | prompt' multi-shot format

This commit is contained in:
Dreaming Computers
2026-02-11 11:06:30 +07:00
parent bedb0146ae
commit 5d52abe853
4 changed files with 34 additions and 27 deletions
+16 -11
View File
@@ -58,21 +58,26 @@ def _parse_multi_prompt_text(shots_text: str) -> list[dict[str, Any]]:
shots: list[dict[str, Any]] = []
for idx, line in enumerate(lines, start=1):
parts = [part.strip() for part in line.split("|")]
if len(parts) == 2:
duration_str, prompt = parts
elif len(parts) >= 3:
duration_str, prompt = parts[1], "|".join(parts[2:]).strip()
else:
if len(parts) < 3:
raise _validation_error(
f"Invalid shots_text format on line {idx}. "
"Use 'duration | prompt' or 'label | duration | prompt'. "
"Example: '3 | A dog runs through fog' or 'shot1 | 3 | A dog runs through fog'."
"Use 'shot_label | duration | prompt'. "
"Example: 'shot 1 | 3 seconds | A dog runs through fog'."
)
shot_label = parts[0]
duration_str = parts[1]
prompt = "|".join(parts[2:]).strip()
try:
duration = int(duration_str)
except ValueError as exc:
raise _validation_error(f"Invalid shot duration '{duration_str}' on line {idx}.") from exc
if not shot_label:
raise _validation_error(f"Missing shot label on line {idx}.")
duration_match = re.match(r"^(\\d+)(?:\\s*seconds?)?$", duration_str, flags=re.IGNORECASE)
if not duration_match:
raise _validation_error(
f"Invalid shot duration '{duration_str}' on line {idx}. "
"Use values like '4' or '4 seconds'."
)
duration = int(duration_match.group(1))
if duration < MULTI_SHOT_MIN or duration > MULTI_SHOT_MAX:
raise _validation_error(
+10 -9
View File
@@ -775,9 +775,8 @@ Inputs:
- multi_shots: enable multi-shot mode
- prompt: Used in single-shot mode
- shots_text: Used in multi-shot mode, format:
duration | prompt
or
label | duration | prompt
shot_label | duration | prompt
duration can be like: 4 or 4 seconds
- first_frame: Optional start frame image
- last_frame: Optional end frame image (single-shot only)
- sound: Single-shot only
@@ -796,9 +795,10 @@ Outputs:
- VIDEO: ComfyUI video output compatible with SaveVideo
"""
SHOTS_TEXT_PLACEHOLDER = (
"shot1 | 4 | Wide cinematic opening with @element_name\n"
"shot2 | 3 | Medium tracking shot with @element_name\n"
"shot3 | 3 | Close-up emotional finale with @element_name"
"multi-prompt section:\n"
"shot 1 | 4 seconds | Wide cinematic opening with @element_name\n"
"shot 2 | 3 seconds | Medium tracking shot with @element_name\n"
"shot 3 | 3 seconds | Close-up emotional finale with @element_name"
)
@classmethod
@@ -908,9 +908,10 @@ Outputs:
- STRING: notes
"""
SHOTS_TEXT_PLACEHOLDER = (
"shot1 | 4 | Wide cinematic opening with @element_name\n"
"shot2 | 3 | Medium tracking shot with @element_name\n"
"shot3 | 3 | Close-up emotional finale with @element_name"
"multi-prompt section:\n"
"shot 1 | 4 seconds | Wide cinematic opening with @element_name\n"
"shot 2 | 3 seconds | Medium tracking shot with @element_name\n"
"shot 3 | 3 seconds | Close-up emotional finale with @element_name"
)
@classmethod
+1
View File
@@ -20,6 +20,7 @@ Validate Kling 3.0 inputs and build the exact payload JSON without submitting a
## Notes
- This node still uploads required input media to produce valid URLs in payload.
- In multi-shot mode, duration is auto-calculated from shot durations.
- Multi-shot `shots_text` must use: `shot_label | duration | prompt` (duration supports `4` or `4 seconds`).
- `notes` returns a `VALID` summary when checks pass, including:
- mode, single/multi-shot status, resolved duration
- frame count and aspect-ratio handling
+7 -7
View File
@@ -12,8 +12,8 @@ Generate Kling 3.0 videos in single-shot or multi-shot mode.
- `multi_shots` (BOOLEAN): enables multi-shot mode
- `prompt` (STRING): single-shot prompt
- `shots_text` (STRING, optional): multi-shot lines:
- `duration | prompt`
- or `label | duration | prompt`
- `shot_label | duration | prompt`
- duration accepts `4` or `4 seconds`
- `first_frame` (IMAGE, optional): start frame
- `last_frame` (IMAGE, optional): end frame (single-shot only)
- `sound` (BOOLEAN, optional): single-shot only
@@ -37,12 +37,12 @@ Generate Kling 3.0 videos in single-shot or multi-shot mode.
- Single-shot (`multi_shots=false`): use `prompt`.
- Multi-shot (`multi_shots=true`): use `shots_text` only.
- `shots_text` format:
- `duration | prompt`
- or `label | duration | prompt`
- `shot_label | duration | prompt`
- duration accepts `4` or `4 seconds`
- Example:
- `shot1 | 4 | A woman exits a spaceship with @dog`
- `shot2 | 3 | Medium tracking shot of @dog running`
- `shot3 | 3 | Emotional close-up of @dog and @old_woman`
- `shot 1 | 4 seconds | A woman exits a spaceship with @dog`
- `shot 2 | 3 seconds | Medium tracking shot of @dog running`
- `shot 3 | 3 seconds | Emotional close-up of @dog and @old_woman`
## Element Naming and References
- Define elements upstream with `KIE Kling Elements`.