Skip to content

Unrestricted Open-source alternative to AI video platforms — Free AI image & video generation studio with 600+ models (Flux, Midjourney, Kling, Sora, Veo). No content filters. Self-hosted, MIT licensed.

feat(studio): simplify Vidu model selection

antilya5bc5ded144ce
diff --git a/packages/studio/src/components/VideoStudio.jsx b/packages/studio/src/components/VideoStudio.jsx
index 7aa0821d..c2fcd020 100644
--- a/packages/studio/src/components/VideoStudio.jsx
+++ b/packages/studio/src/components/VideoStudio.jsx
@@ -900,6 +900,7 @@ export default function VideoStudio({
workflowMediaDraftsRef.current = workflowMediaDrafts;
const commonParameterValuesRef = useRef(null);
commonParameterValuesRef.current = {
+ ...modelParameterValues,
aspectRatio: selectedAr,
duration: selectedDuration,
resolution: selectedResolution,
@@ -923,9 +924,7 @@ export default function VideoStudio({
const getCurrentAspectRatios = useCallback(
(id) =>
- getGroupedVideoConfiguration(id)
- ? getVideoCommonOptions(videoModelCatalog.variantById.get(id)?.model).aspectRatios
- : imageMode
+ imageMode
? getAspectRatiosForI2VModel(id)
: getAspectRatiosForVideoModel(id),
[imageMode],
@@ -933,9 +932,7 @@ export default function VideoStudio({
const getCurrentDurations = useCallback(
(id) =>
- getGroupedVideoConfiguration(id)
- ? getVideoCommonOptions(videoModelCatalog.variantById.get(id)?.model).durations
- : imageMode ? getDurationsForI2VModel(id) : getDurationsForModel(id),
+ imageMode ? getDurationsForI2VModel(id) : getDurationsForModel(id),
[imageMode],
);
@@ -966,7 +963,7 @@ export default function VideoStudio({
(modelId, isImageMode, isV2vMode) => {
if (getGroupedVideoConfiguration(modelId)) {
const model = videoModelCatalog.variantById.get(modelId)?.model;
- const options = getVideoCommonOptions(model);
+ const options = getVideoCommonOptions(model, commonParameterValuesRef.current);
const values = getVideoCommonValues(model, commonParameterValuesRef.current);
setShowAr(options.aspectRatios.length > 0);
setShowDuration(options.durations.length > 0);
@@ -1103,11 +1100,12 @@ export default function VideoStudio({
currentModelId: selectedModel,
nativeResolution: selectedResolution,
commonValues: {
+ ...modelParameterValues,
aspectRatio: selectedAr, duration: selectedDuration,
quality: selectedQuality,
},
...options,
- }), [selectedFamilyId, selectedWorkflowId, selectedModel, selectedResolution, selectedAr, selectedDuration, selectedQuality, activeWorkflowMediaDraft]);
+ }), [selectedFamilyId, selectedWorkflowId, selectedModel, selectedResolution, selectedAr, selectedDuration, selectedQuality, modelParameterValues, activeWorkflowMediaDraft]);
const describeSelectionAdjustments = useCallback((adjustments) => {
const valueLabel = (key, value) => {
if (key === "duration") return getVideoDurationLabel(value, groupCopy);
@@ -1151,15 +1149,18 @@ export default function VideoStudio({
const adjustments = option.disabled ? [] : getGroupedVideoSelectionAdjustments({
currentModelId: selectedModel, nativeResolution: selectedResolution,
currentWorkflowId: selectedWorkflowId, media: activeWorkflowMediaDraft,
- commonValues: { aspectRatio: selectedAr, duration: selectedDuration, quality: selectedQuality },
+ commonValues: { ...modelParameterValues, aspectRatio: selectedAr, duration: selectedDuration, quality: selectedQuality },
selection: option, changes: { resolution: option.value },
});
return { ...option, adjustmentDescription: describeSelectionAdjustments(adjustments) };
}),
};
- }, [groupedConfiguration, selectedFamilyId, selectedWorkflowId, selectedModel, selectedResolution, selectedAr, selectedDuration, selectedQuality, describeSelectionAdjustments, groupCopy, groupCopyKey, activeWorkflowMediaDraft]);
+ }, [groupedConfiguration, selectedFamilyId, selectedWorkflowId, selectedModel, selectedResolution, selectedAr, selectedDuration, selectedQuality, modelParameterValues, describeSelectionAdjustments, groupCopy, groupCopyKey, activeWorkflowMediaDraft]);
const commonOptions = useMemo(
- () => getVideoCommonOptions(selectedVariant?.model), [selectedVariant],
+ () => getVideoCommonOptions(selectedVariant?.model, {
+ ...modelParameterValues, aspectRatio: selectedAr, duration: selectedDuration,
+ resolution: selectedResolution, quality: selectedQuality,
+ }), [selectedVariant, modelParameterValues, selectedAr, selectedDuration, selectedResolution, selectedQuality],
);
const groupedModes = useMemo(() => groupedConfiguration && workflowFamily
? [...(workflowFamily.hasBase ? [{ id: null }] : []), ...workflowFamily.workflows].map((workflow) => {
@@ -1194,6 +1195,7 @@ export default function VideoStudio({
? inputs.filter(({ key }) => key !== "omni_reference_task_type").map(({ key, schema }) => ({
key, schema: {
...schema, ...groupCopy.fields[key],
+ ...(schema.descriptionKey ? { description: groupCopy[schema.descriptionKey] } : {}),
...(key === "generate_audio" && selectedWorkflowId === "edit_video" ? groupCopy.editAudio : {}),
},
}))
@@ -1202,7 +1204,11 @@ export default function VideoStudio({
);
const handleModelParameterChange = useCallback((key, value) => {
setModelParameterValues((values) => ({ ...values, [key]: value }));
- }, []);
+ if (selectedVariant?.model.commonParameterRules) {
+ commonParameterValuesRef.current = { ...commonParameterValuesRef.current, [key]: value };
+ applyControlsForModel(selectedModel, imageMode, v2vMode);
+ }
+ }, [selectedVariant, selectedModel, imageMode, v2vMode, applyControlsForModel]);
const applySelectedVariant = useCallback(
(variant, mode, family, workflowId = null) => {
@@ -1369,6 +1375,7 @@ export default function VideoStudio({
// Update control visibility based on restored model/mode
commonParameterValuesRef.current = {
+ ...data.modelParameterValues,
aspectRatio: data.selectedAr,
duration: data.selectedDuration,
resolution: restoredResolution,
@@ -1923,6 +1930,9 @@ export default function VideoStudio({
}
const { selection, adjustments } = plan;
const target = videoModelCatalog.variantById.get(selection.modelId);
+ if (selection.resolution !== undefined) {
+ commonParameterValuesRef.current = { ...commonParameterValuesRef.current, resolution: selection.resolution };
+ }
applyUserSelectedVariant(target, target.mode, family, workflowId);
if (selection.resolution !== undefined) setSelectedResolution(selection.resolution);
if (adjustments.length) {
@@ -2076,6 +2086,7 @@ export default function VideoStudio({
: activeParameterValues;
const commonParams = grouped
? buildVideoCommonPayload(currentModel, {
+ ...generationParameterValues,
aspectRatio: selectedAr, duration: selectedDuration,
resolution: selectedResolution, quality: selectedQuality,
})
@@ -3168,7 +3179,7 @@ export default function VideoStudio({
{copy.dropdowns.aspectRatio}
</PromptPopoverHeader>
<PromptMenuList>
- {getCurrentAspectRatios(selectedModel).map((r) => (
+ {(groupedConfiguration ? commonOptions.aspectRatios : getCurrentAspectRatios(selectedModel)).map((r) => (
<PromptMenuItem
key={r}
selected={selectedAr === r}
diff --git a/packages/studio/src/groupedVideoModels.js b/packages/studio/src/groupedVideoModels.js
index 858192db..bb4e2ba2 100644
--- a/packages/studio/src/groupedVideoModels.js
+++ b/packages/studio/src/groupedVideoModels.js
@@ -4,8 +4,9 @@ import { MINIMAX_MODEL_GROUP } from "./minimaxModels.js";
import { ALIBABA_MODEL_GROUP } from "./alibabaModels.js";
import { HAPPY_HORSE_MODEL_GROUP } from "./happyHorseModels.js";
import { KLING_MODEL_GROUP } from "./klingModels.js";
+import { VIDU_MODEL_GROUP } from "./viduModels.js";
-const groups = [SEEDANCE_MODEL_GROUP, VEO_MODEL_GROUP, MINIMAX_MODEL_GROUP, ALIBABA_MODEL_GROUP, HAPPY_HORSE_MODEL_GROUP, KLING_MODEL_GROUP];
+const groups = [SEEDANCE_MODEL_GROUP, VEO_MODEL_GROUP, MINIMAX_MODEL_GROUP, ALIBABA_MODEL_GROUP, HAPPY_HORSE_MODEL_GROUP, KLING_MODEL_GROUP, VIDU_MODEL_GROUP];
const groupByFamilyId = new Map();
const configurationByModelId = new Map();
const familyNames = {};
diff --git a/packages/studio/src/groupedVideoParameters.js b/packages/studio/src/groupedVideoParameters.js
index f31c1c95..985c1c6e 100644
--- a/packages/studio/src/groupedVideoParameters.js
+++ b/packages/studio/src/groupedVideoParameters.js
@@ -12,6 +12,8 @@ import { HAPPY_HORSE_MODEL_GROUP } from "./happyHorseModels.js";
import { happyHorseParameters } from "./happyHorseParameters.js";
import { KLING_MODEL_GROUP } from "./klingModels.js";
import { klingParameters } from "./klingParameters.js";
+import { VIDU_MODEL_GROUP } from "./viduModels.js";
+import { viduParameters } from "./viduParameters.js";
import {
getMiniMaxResolutionOptions,
getMiniMaxSelectionAdjustments,
@@ -27,6 +29,7 @@ import {
} from "./veoParameters.js";
const groups = [
+ { familyNames: VIDU_MODEL_GROUP.familyNames, ...viduParameters },
{ familyNames: KLING_MODEL_GROUP.familyNames, ...klingParameters },
{ familyNames: HAPPY_HORSE_MODEL_GROUP.familyNames, ...happyHorseParameters },
{ familyNames: ALIBABA_MODEL_GROUP.familyNames, ...alibabaParameters },
diff --git a/packages/studio/src/messages/en/videoStudio.json b/packages/studio/src/messages/en/videoStudio.json
index c4a277f5..72028e9a 100644
--- a/packages/studio/src/messages/en/videoStudio.json
+++ b/packages/studio/src/messages/en/videoStudio.json
@@ -425,5 +425,37 @@
}
}
}
+ },
+ "vidu": {
+ "speed": "Speed",
+ "speeds": {
+ "standard": "Standard speed",
+ "fast": "Fast"
+ },
+ "speedDescriptions": {
+ "standard": "",
+ "fast": "Faster generation."
+ },
+ "fields": {
+ "audio": {
+ "title": "Generate audio",
+ "description": ""
+ },
+ "bgm": {
+ "title": "Background music",
+ "description": ""
+ },
+ "movement_amplitude": {
+ "title": "Motion",
+ "description": "How much subjects move.",
+ "optionLabels": {
+ "auto": "Let model choose",
+ "small": "Subtle",
+ "medium": "Moderate",
+ "large": "Strong"
+ }
+ }
+ },
+ "musicDuration": "Sets duration to 4 seconds."
}
}
diff --git a/packages/studio/src/messages/zh/videoStudio.json b/packages/studio/src/messages/zh/videoStudio.json
index 79f627eb..198eaa02 100644
--- a/packages/studio/src/messages/zh/videoStudio.json
+++ b/packages/studio/src/messages/zh/videoStudio.json
@@ -425,5 +425,37 @@
}
}
}
+ },
+ "vidu": {
+ "speed": "速度",
+ "speeds": {
+ "standard": "标准速度",
+ "fast": "快速"
+ },
+ "speedDescriptions": {
+ "standard": "",
+ "fast": "更快生成。"
+ },
+ "fields": {
+ "audio": {
+ "title": "生成音频",
+ "description": ""
+ },
+ "bgm": {
+ "title": "背景音乐",
+ "description": ""
+ },
+ "movement_amplitude": {
+ "title": "动作幅度",
+ "description": "主体的动作幅度。",
+ "optionLabels": {
+ "auto": "由模型选择",
+ "small": "轻微",
+ "medium": "适中",
+ "large": "强烈"
+ }
+ }
+ },
+ "musicDuration": "时长设为 4 秒。"
}
}
diff --git a/packages/studio/src/models.js b/packages/studio/src/models.js
index 4155967a..eebea5c2 100644
--- a/packages/studio/src/models.js
+++ b/packages/studio/src/models.js
@@ -143,6 +143,23 @@ const KLING_OMNI_REFERENCE_INPUT = Object.freeze({
name: "images_list", minItems: 1, maxItems: 4,
});
+const VIDU_REFERENCE_INPUT = Object.freeze({
+ type: "array", items: { type: "string" }, title: "Reference images",
+ name: "images_list", minItems: 1,
+});
+const VIDU_Q2_MUSIC_INPUT = Object.freeze({
+ type: "boolean", title: "Background music", name: "bgm", default: false,
+ description: "Sets duration to 4 seconds.", descriptionKey: "musicDuration",
+});
+// Q2 music requires four seconds only on the regular text/image routes.
+const VIDU_Q2_MUSIC_RULES = Object.freeze([
+ { when: { bgm: [true] }, options: { durations: [4] } },
+]);
+const VIDU_2_FORMAT_RULES = Object.freeze([
+ { when: { resolution: ["360p", "720p"] }, options: { aspectRatios: ["16:9"] } },
+ { when: { resolution: ["1080p"] }, options: { aspectRatios: ["1:1"] } },
+]);
+
export const t2iModels = [
{
"id": "nano-banana",
@@ -6918,6 +6935,7 @@ export const t2vModels = [
"id": "vidu-q2-pro-text-to-video",
"name": "Vidu Q2 Pro",
"endpoint": "vidu-q2-pro-text-to-video",
+ "commonParameterRules": VIDU_Q2_MUSIC_RULES,
"inputs": {
"prompt": {
"examples": [
@@ -6961,13 +6979,7 @@ export const t2vModels = [
"maxValue": 8,
"step": 1
},
- "bgm": {
- "type": "boolean",
- "title": "Bgm",
- "name": "bgm",
- "description": "Add background music to the output. When enabled, duration must be exactly 4 seconds.",
- "default": false
- },
+ "bgm": VIDU_Q2_MUSIC_INPUT,
"movement_amplitude": {
"enum": [
"auto",
@@ -6989,6 +7001,7 @@ export const t2vModels = [
"id": "vidu-q2-turbo-text-to-video",
"name": "Vidu Q2 Turbo",
"endpoint": "vidu-q2-turbo-text-to-video",
+ "commonParameterRules": VIDU_Q2_MUSIC_RULES,
"inputs": {
"prompt": {
"examples": [
@@ -7032,13 +7045,7 @@ export const t2vModels = [
"maxValue": 8,
"step": 1
},
- "bgm": {
- "type": "boolean",
- "title": "Bgm",
- "name": "bgm",
- "description": "Add background music to the output. When enabled, duration must be exactly 4 seconds.",
- "default": false
- },
+ "bgm": VIDU_Q2_MUSIC_INPUT,
"movement_amplitude": {
"enum": [
"auto",
@@ -13723,10 +13730,12 @@ export const i2vModels = [
"id": "vidu-v2.0-i2v",
"name": "Vidu v2.0 I2V",
"endpoint": "vidu-v2.0-i2v",
+ "commonParameterRules": VIDU_2_FORMAT_RULES,
"family": "vidu-v2",
"imageField": "images_list",
"lastImageField": "images_list",
"hasPrompt": true,
+ "promptRequired": true,
"inputs": {
"prompt": {
"type": "string",
@@ -13781,8 +13790,10 @@ export const i2vModels = [
"family": "vidu-q1",
"imageField": "images_list",
"hasPrompt": true,
+ "promptRequired": true,
"maxImages": 7,
"inputs": {
+ "images_list": VIDU_REFERENCE_INPUT,
"prompt": {
"type": "string",
"title": "Prompt",
@@ -14874,6 +14885,7 @@ export const i2vModels = [
"promptRequired": true,
"maxImages": 7,
"inputs": {
+ "images_list": VIDU_REFERENCE_INPUT,
"prompt": {
"type": "string",
"title": "Prompt",
@@ -15026,6 +15038,7 @@ export const i2vModels = [
"name": "resolution",
"description": "The resolution of the generated video.",
"enum": [
+ "540p",
"720p",
"1080p"
],
@@ -15037,7 +15050,7 @@ export const i2vModels = [
"name": "duration",
"description": "The duration of the generated video in seconds",
"default": 5,
- "minValue": 2,
+ "minValue": 1,
"maxValue": 8,
"step": 1
},
@@ -18791,6 +18804,7 @@ export const i2vModels = [
"id": "vidu-q2-pro-image-to-video",
"name": "Vidu Q2 Pro",
"endpoint": "vidu-q2-pro-image-to-video",
+ "commonParameterRules": VIDU_Q2_MUSIC_RULES,
"family": "vidu-q2",
"imageField": "image_url",
"hasPrompt": true,
@@ -18848,13 +18862,7 @@ export const i2vModels = [
"maxValue": 8,
"step": 1
},
- "bgm": {
- "type": "boolean",
- "title": "Bgm",
- "name": "bgm",
- "description": "Add background music to the output. When enabled, duration must be exactly 4 seconds.",
- "default": false
- },
+ "bgm": VIDU_Q2_MUSIC_INPUT,
"movement_amplitude": {
"enum": [
"auto",
@@ -18876,6 +18884,7 @@ export const i2vModels = [
"id": "vidu-q2-turbo-image-to-video",
"name": "Vidu Q2 Turbo",
"endpoint": "vidu-q2-turbo-image-to-video",
+ "commonParameterRules": VIDU_Q2_MUSIC_RULES,
"family": "vidu-q2",
"imageField": "image_url",
"hasPrompt": true,
@@ -18933,13 +18942,7 @@ export const i2vModels = [
"maxValue": 8,
"step": 1
},
- "bgm": {
- "type": "boolean",
- "title": "Bgm",
- "name": "bgm",
- "description": "Add background music to the output. When enabled, duration must be exactly 4 seconds.",
- "default": false
- },
+ "bgm": VIDU_Q2_MUSIC_INPUT,
"movement_amplitude": {
"enum": [
"auto",
diff --git a/packages/studio/src/videoModelParameters.js b/packages/studio/src/videoModelParameters.js
index ae5859e2..b3beb8d2 100644
--- a/packages/studio/src/videoModelParameters.js
+++ b/packages/studio/src/videoModelParameters.js
@@ -46,7 +46,7 @@ function nearestDuration(options, value) {
return nearest;
}
-export function getVideoCommonOptions(model) {
+function getBaseOptions(model) {
if (!model) return EMPTY_OPTIONS;
const cached = optionsByModel.get(model);
if (cached) return cached;
@@ -60,8 +60,7 @@ export function getVideoCommonOptions(model) {
return options;
}
-export function getVideoCommonValues(model, previous = {}) {
- const options = getVideoCommonOptions(model);
+function resolveValues(model, options, previous) {
return Object.fromEntries(COMMON_FIELDS.map(([key, field, optionsKey]) => {
const allowed = options[optionsKey];
const value = matchingVideoParameterValue(allowed, previous[key]) ??
@@ -71,10 +70,29 @@ export function getVideoCommonValues(model, previous = {}) {
}));
}
+export function getVideoCommonOptions(model, values = {}) {
+ const base = getBaseOptions(model);
+ if (!model?.commonParameterRules) return base;
+ const current = { ...values, ...resolveValues(model, base, values) };
+ const options = { ...base };
+ for (const rule of model.commonParameterRules) {
+ if (Object.entries(rule.when).every(([key, allowed]) =>
+ allowed.includes(current[key] ?? model.inputs?.[key]?.default))) {
+ Object.assign(options, rule.options);
+ }
+ }
+ return options;
+}
+
+export function getVideoCommonValues(model, previous = {}) {
+ return resolveValues(model, getVideoCommonOptions(model, previous), previous);
+}
+
export function buildVideoCommonPayload(model, values = {}) {
- const options = getVideoCommonOptions(model);
+ const options = getVideoCommonOptions(model, values);
+ const resolved = model?.commonParameterRules ? resolveValues(model, options, values) : values;
return Object.fromEntries(COMMON_FIELDS.flatMap(([key, field, optionsKey]) => {
- const value = matchingVideoParameterValue(options[optionsKey], values[key]);
+ const value = matchingVideoParameterValue(options[optionsKey], resolved[key]);
return value === undefined || !model.inputs?.[field] ? [] : [[field, value]];
}));
}
diff --git a/packages/studio/src/videoWorkflows.js b/packages/studio/src/videoWorkflows.js
index f7ef72f8..5362135a 100644
--- a/packages/studio/src/videoWorkflows.js
+++ b/packages/studio/src/videoWorkflows.js
@@ -62,15 +62,6 @@ export const VIDEO_WORKFLOW_VARIANTS = Object.freeze({
animate_image: ["grok-imagine-video-1-5-preview"],
references: ["grok-imagine-image-to-video"],
},
- "vidu-q3": {
- animate_image: ["vidu-q3-turbo-image-to-video", "vidu-q3-pro-image-to-video"],
- keyframes: ["vidu-q3-turbo-first-last-frames", "vidu-q3-pro-first-last-frames"],
- },
- "vidu-q2": {
- animate_image: ["vidu-q2-turbo-image-to-video", "vidu-q2-pro-image-to-video"],
- keyframes: ["vidu-q2-pro-start-end-video", "vidu-q2-turbo-start-end-video"],
- references: ["vidu-q2-reference"],
- },
"pixverse-6": {
animate_image: ["pixverse-v6-i2v"],
keyframes: ["pixverse-v6-transition"],
diff --git a/packages/studio/src/viduModels.js b/packages/studio/src/viduModels.js
new file mode 100644
index 00000000..3851184e
--- /dev/null
+++ b/packages/studio/src/viduModels.js
@@ -0,0 +1,48 @@
+import { createGroupedVideoRegistry } from "./groupedVideoRegistry.js";
+
+export const VIDU_FAMILY_NAMES = Object.freeze({
+ "vidu-q3": "Vidu Q3",
+ "vidu-q2": "Vidu Q2",
+ "vidu-q1": "Vidu Q1",
+ "vidu-2": "Vidu 2.0",
+});
+
+const registry = createGroupedVideoRegistry({
+ facetOptions: {
+ speed: [
+ { value: "standard", label: "Standard speed" },
+ { value: "fast", label: "Fast" },
+ ],
+ },
+ facetLabels: { speed: "Speed" },
+ registerVariants(register) {
+ for (const version of ["q3", "q2"]) {
+ const familyId = `vidu-${version}`;
+ for (const [service, speed] of [["pro", "standard"], ["turbo", "fast"]]) {
+ const stem = `${familyId}-${service}`;
+ register(`${stem}-text-to-video`, familyId, [null], { speed });
+ register(`${stem}-image-to-video`, familyId, ["animate_image"], { speed });
+ register(`${stem}-${version === "q3" ? "first-last-frames" : "start-end-video"}`,
+ familyId, ["keyframes"], { speed });
+ }
+ }
+ register("vidu-q2-reference", "vidu-q2", ["references"]);
+ register("vidu-q1-reference", "vidu-q1", ["references"]);
+ register("vidu-v2.0-t2v", "vidu-2", [null]);
+ register("vidu-v2.0-i2v", "vidu-2", ["animate_image", "keyframes"]);
+ },
+});
+
+export const {
+ getConfiguration: getViduConfiguration,
+ resolveVariant: resolveViduVariant,
+} = registry;
+
+export const VIDU_MODEL_GROUP = Object.freeze({
+ copyKey: "vidu",
+ familyNames: VIDU_FAMILY_NAMES,
+ configurations: registry.configurations,
+ workflowVariants: registry.workflowVariants,
+ resolveVariant: resolveViduVariant,
+ getVariantOptions: registry.getVariantOptions,
+});
diff --git a/packages/studio/src/viduParameters.js b/packages/studio/src/viduParameters.js
new file mode 100644
index 00000000..b8f9b426
--- /dev/null
+++ b/packages/studio/src/viduParameters.js
@@ -0,0 +1,7 @@
+import { createNativeVideoParameters } from "./nativeVideoParameters.js";
+import { getViduConfiguration, resolveViduVariant } from "./viduModels.js";
+
+export const viduParameters = createNativeVideoParameters({
+ getConfiguration: getViduConfiguration,
+ resolveVariant: resolveViduVariant,
+});