增加即梦图片5.0和视频2.5的能力
This commit is contained in:
1 parent
542246e4ce
commit
88a4268d40
55 files changed
+1412
-200
No files matched your search
+37
-3
@@ -1,6 +1,7 @@
|
||||
export const VIDEO_DURATION_AUTO = -1;
|
||||
export const VIDEO_DURATION_MIN = 4;
|
||||
export const VIDEO_DURATION_MAX = 15;
|
||||
export const VIDEO_DURATION_MAX_SEEDANCE_25 = 30;
|
||||
export const VIDEO_DURATION_DEFAULT = 5;
|
||||
export const VIDEO_DURATION_OPTIONS = Array.from(
|
||||
{ length: VIDEO_DURATION_MAX - VIDEO_DURATION_MIN + 1 },
|
||||
@@ -14,8 +15,18 @@ export const VIDEO_RESOLUTION_DEFAULT = "720p";
|
||||
export const VIDEO_RESOLUTIONS = ["720p", "1080p", "480p"] as const;
|
||||
export const VIDEO_FAST_RESOLUTIONS = ["720p", "480p"] as const;
|
||||
|
||||
export const SEEDANCE_20_MODEL = "doubao-seedance-2-0-260128";
|
||||
export const SEEDANCE_25_MODEL = "doubao-seedance-2-5-260628";
|
||||
export const SEEDANCE_MODELS = [
|
||||
{ id: SEEDANCE_20_MODEL, label: "Seedance 2.0" },
|
||||
{ id: SEEDANCE_25_MODEL, label: "Seedance 2.5" }
|
||||
] as const;
|
||||
|
||||
export type SeedanceModel = (typeof SEEDANCE_MODELS)[number]["id"];
|
||||
|
||||
type VideoDurationOptions = {
|
||||
allowAuto?: boolean;
|
||||
model?: string;
|
||||
};
|
||||
|
||||
export function clampVideoDuration(
|
||||
@@ -27,12 +38,35 @@ export function clampVideoDuration(
|
||||
if (!Number.isFinite(duration)) return fallback;
|
||||
const rounded = Math.round(duration);
|
||||
if (options.allowAuto !== false && rounded === VIDEO_DURATION_AUTO) return VIDEO_DURATION_AUTO;
|
||||
return Math.min(VIDEO_DURATION_MAX, Math.max(VIDEO_DURATION_MIN, rounded));
|
||||
return Math.min(seedanceMaximumOutputDuration(options.model), Math.max(VIDEO_DURATION_MIN, rounded));
|
||||
}
|
||||
|
||||
export function normalizeVideoDuration(value: unknown) {
|
||||
export function normalizeVideoDuration(value: unknown, model?: string) {
|
||||
if (value === undefined || value === null || value === "") return undefined;
|
||||
return clampVideoDuration(value);
|
||||
return clampVideoDuration(value, VIDEO_DURATION_DEFAULT, { model });
|
||||
}
|
||||
|
||||
export function seedanceMaximumOutputDuration(model?: string) {
|
||||
return isSeedance25Model(model) ? VIDEO_DURATION_MAX_SEEDANCE_25 : VIDEO_DURATION_MAX;
|
||||
}
|
||||
|
||||
export function seedanceDurationOptions(model?: string) {
|
||||
const maximum = seedanceMaximumOutputDuration(model);
|
||||
return Array.from({ length: maximum - VIDEO_DURATION_MIN + 1 }, (_, index) => VIDEO_DURATION_MIN + index);
|
||||
}
|
||||
|
||||
export function normalizeSeedanceModel(value: unknown, fallback: SeedanceModel = SEEDANCE_20_MODEL): SeedanceModel {
|
||||
const normalized = String(value || "").trim();
|
||||
return isSupportedSeedanceModel(normalized) ? normalized : fallback;
|
||||
}
|
||||
|
||||
export function isSupportedSeedanceModel(value: unknown): value is SeedanceModel {
|
||||
const normalized = String(value || "").trim();
|
||||
return SEEDANCE_MODELS.some((model) => model.id === normalized);
|
||||
}
|
||||
|
||||
export function isSeedance25Model(model?: string) {
|
||||
return String(model || "").trim() === SEEDANCE_25_MODEL;
|
||||
}
|
||||
|
||||
export function normalizeVideoRatio(value: unknown, fallback = VIDEO_RATIO_DEFAULT) {
|
||||
|
||||
Reference in new issue
Block a user