新增 MiniMax H3 Highspeed/Lite 与 Seedance 2.5 Flash,兼容视频参数和旧工作流

This commit is contained in:
Jony
2026-11-17 15:44:20 +08:00
parent af300996b9
commit 209100ecde
16 changed files with 598 additions and 70 deletions
+63 -6
View File
@@ -3,19 +3,67 @@ import { app } from "../../../scripts/app.js";
const NODE_TYPE = "MiniMaxH3Video";
const MODEL_H3 = "MiniMax-H3";
const MODEL_MAX = "MiniMax-H3-MAX";
const MODEL_HIGHSPEED = "MiniMax-H3-Highspeed";
const MODEL_LITE = "MiniMax-H3-Lite";
const MODE_TEXT = "文生视频";
const MODE_REFERENCE = "参考素材生视频";
const MODE_REFERENCE = "多模态生视频";
const MODE_LAST = "尾帧图生视频";
const MODE_FIRST_LAST = "首尾帧生视频";
const FIXED_RATIOS = ["16:9", "21:9", "4:3", "1:1", "3:4", "9:16"];
const RESOLUTIONS = {
[MODEL_H3]: ["2K", "768P"],
[MODEL_MAX]: ["768P", "480P"],
[MODEL_HIGHSPEED]: ["768P", "480P"],
[MODEL_LITE]: ["768P", "480P"],
};
const MIN_DURATION = {
[MODEL_H3]: 4,
[MODEL_MAX]: 5,
[MODEL_HIGHSPEED]: 4,
[MODEL_LITE]: 4,
};
function findWidget(node, name) {
return node.widgets?.find((widget) => widget.name === name);
for (const widget of node.widgets || node.childWidgets || []) {
if (widget.name === name || widget.name?.endsWith(`.${name}`)) return widget;
const nested = findWidget(widget, name);
if (nested) return nested;
}
}
function selectedModel(node) {
const value = findWidget(node, "模型")?.value;
return Object.hasOwn(RESOLUTIONS, value) ? value : MODEL_H3;
}
function allowedRatios(node) {
return findWidget(node, "生成模式")?.value === MODE_REFERENCE
&& selectedModel(node) !== MODEL_LITE
? ["adaptive", ...FIXED_RATIOS] : FIXED_RATIOS;
}
function updateRatio(node, silent) {
const widget = findWidget(node, "宽高比");
if (!widget) return;
widget.options ??= {};
widget.options.values = allowedRatios(node);
if (!widget.__o1keyMiniMaxRatioGuard) {
widget.__o1keyMiniMaxRatioGuard = true;
const originalCallback = widget.callback;
widget.callback = function (value, ...args) {
const allowed = allowedRatios(node);
const next = allowed.includes(value) ? value : allowed[0];
if (next !== value) {
widget.value = next;
notify(`${selectedModel(node)} 当前模式须使用具体比例,已切换为 ${next}。`);
}
return originalCallback?.call(this, next, ...args);
};
}
if (!widget.options.values.includes(widget.value)) {
setWidgetValue(widget, widget.options.values[0]);
if (!silent) notify(`${selectedModel(node)} 当前模式须使用具体比例,已切换为 ${widget.value}。`);
}
}
function notify(detail) {
@@ -40,7 +88,7 @@ function updateParameters(node, silent = false) {
const durationWidget = findWidget(node, "时长");
if (!modelWidget || !modeWidget || !resolutionWidget || !durationWidget) return;
const model = modelWidget.value === MODEL_MAX ? MODEL_MAX : MODEL_H3;
const model = selectedModel(node);
const allowedResolutions = RESOLUTIONS[model];
resolutionWidget.options ??= {};
resolutionWidget.options.values = [...allowedResolutions];
@@ -64,6 +112,13 @@ function updateParameters(node, silent = false) {
if (!silent) notify("MiniMax-H3-MAX 不支持参考素材模式,已切换为文生视频。");
}
if ([MODEL_HIGHSPEED, MODEL_LITE].includes(model) && modeWidget.value === MODE_LAST) {
setWidgetValue(modeWidget, MODE_FIRST_LAST);
if (!silent) notify(`${model} 使用尾帧时须同时提供首帧,已切换为首尾帧生视频。`);
}
updateRatio(node, silent);
node.setDirtyCanvas?.(true, true);
}
@@ -92,12 +147,14 @@ function guardNode(node) {
node.setDirtyCanvas?.(true, true);
return originalModeCallback?.call(this, MODE_TEXT);
}
return originalModeCallback?.apply(this, arguments);
const result = originalModeCallback?.apply(this, arguments);
updateParameters(node);
return result;
};
const originalResolutionCallback = resolutionWidget.callback;
resolutionWidget.callback = function (value) {
const model = modelWidget.value === MODEL_MAX ? MODEL_MAX : MODEL_H3;
const model = selectedModel(node);
if (!RESOLUTIONS[model].includes(value)) {
resolutionWidget.value = "768P";
notify(`${model} 不支持 ${value},已切换为 768P。`);
@@ -109,7 +166,7 @@ function guardNode(node) {
const originalDurationCallback = durationWidget.callback;
durationWidget.callback = function (value) {
const model = modelWidget.value === MODEL_MAX ? MODEL_MAX : MODEL_H3;
const model = selectedModel(node);
const minimum = MIN_DURATION[model];
const duration = Number(value);
if (Number.isFinite(duration) && duration < minimum) {