@@ -30,6 +30,8 @@ const DEFAULT_TIMEOUT_MS = 120_000;
|
30 | 30 | const POLL_INTERVAL_MS = 5_000; |
31 | 31 | const MAX_POLL_ATTEMPTS = 120; |
32 | 32 | const BYTEPLUS_SEED_MAX = 2_147_483_647; |
| 33 | +const BYTEPLUS_MIN_DURATION_SECONDS = 2; |
| 34 | +const BYTEPLUS_MAX_DURATION_SECONDS = 12; |
33 | 35 | |
34 | 36 | type BytePlusTaskCreateResponse = { |
35 | 37 | id?: unknown; |
@@ -125,6 +127,16 @@ function resolveBytePlusSeed(value: unknown): number | undefined {
|
125 | 127 | return asSafeIntegerInRange(value, { min: -1, max: BYTEPLUS_SEED_MAX }); |
126 | 128 | } |
127 | 129 | |
| 130 | +function resolveBytePlusDurationSeconds(value: unknown): number | undefined { |
| 131 | +if (typeof value !== "number" || !Number.isFinite(value)) { |
| 132 | +return undefined; |
| 133 | +} |
| 134 | +return asSafeIntegerInRange(Math.round(value), { |
| 135 | +min: BYTEPLUS_MIN_DURATION_SECONDS, |
| 136 | +max: BYTEPLUS_MAX_DURATION_SECONDS, |
| 137 | +}); |
| 138 | +} |
| 139 | + |
128 | 140 | async function pollBytePlusTask(params: { |
129 | 141 | taskId: string; |
130 | 142 | headers: Headers; |
@@ -306,8 +318,9 @@ export function buildBytePlusVideoGenerationProvider(): VideoGenerationProvider
|
306 | 318 | if (resolution) { |
307 | 319 | body.resolution = resolution; |
308 | 320 | } |
309 | | -if (typeof req.durationSeconds === "number" && Number.isFinite(req.durationSeconds)) { |
310 | | -body.duration = Math.max(1, Math.round(req.durationSeconds)); |
| 321 | +const duration = resolveBytePlusDurationSeconds(req.durationSeconds); |
| 322 | +if (duration !== undefined) { |
| 323 | +body.duration = duration; |
311 | 324 | } |
312 | 325 | if (typeof req.audio === "boolean") { |
313 | 326 | body.generate_audio = req.audio; |
|