Skip to content

fix(console): 视频输入上限按字段拆分并限制参考图生视频时长 - #909

Merged
chenyme merged 2 commits into
chenyme:mainfrom
741075810:pr/console-video-input-limits
Aug 13, 2026
Merged

fix(console): 视频输入上限按字段拆分并限制参考图生视频时长#909
chenyme merged 2 commits into
chenyme:mainfrom
741075810:pr/console-video-input-limits

Conversation

@741075810

Copy link
Copy Markdown
Contributor

背景

在生产环境对 Console POST /v1/videos/generations 做了黑盒实测(grok-imagine-videogrok-imagine-video-1.5 分别验证),发现两处本地守卫与上游实际行为不一致。#885 已把 image / reference_images 的互斥语义修好,本 PR 只补这两处数值与分档,不改字段语义、不改前端。

改动 1:输入上限按字段拆分,不再求和

现状 consoleMaxVideoImages = mediadomain.MaxInputImages(= 8),且 consoleVideoImageCountimagereference_images 合计计数。

上游按字段各自设限:

  • reference_images 上限 7,8 张回 400 Too many reference images: 8. Maximum allowed is 7.(两个模型分别实测)
  • image 是单数字段,上限 1

有了互斥校验之后合计口径不再致命,但 off-by-one 还在:8 张参考图能通过本地守卫,然后吃上游 400。

改为 consoleMaxVideoFirstFrames = 1 / consoleMaxVideoReferenceImages = 7 分别校验,consoleVideoImageCount 改成 consoleVideoImageCounts 分字段返回。

改动 2:reference-to-video 在基础模型上限 10 秒

现状生成一律放行 1–15s。上游有两个互斥的图片入口,走哪个字段决定时长上限:

模式 grok-imagine-video grok-imagine-video-1.5
纯文本 T2V ≤15s ≤15s
image(image-to-video) 15s 15s
reference_images(reference-to-video) ≤10s ≤15s

v1 + reference_images + 15s 的上游报错原文:

400 Duration 15s exceeds the maximum allowed for reference-to-video, which is 10s.

新增的守卫只拦 grok-imagine-video + 有 reference_images + duration > 10 这一种组合,image-to-video 与 1.5 都保持 15s 不受影响。

一点补充:/v1/videos/generations 是异步接口,create 入队即 200 + request_id,上游的参数拒绝只在轮询 GET /v1/videos/{id}status:failed 里体现。我们 E2E 实跑过 v1 双图 15s,结果是任务 failed 且不扣额度,所以在本地拦掉比放过去更好。

测试

  • 新增 TestConsoleVideoRejectsLongReferenceDurationOnBaseModel:v1 + 参考图 + 15s 被本地拒绝
  • 新增 TestConsoleVideo15AllowsLongReferenceDuration:同样的请求在 1.5 上正常发到上游
  • TestConsoleVideoRejectsTooManyReferenceImages / TestConsoleVideoRejectsTooManyCombinedImages 改引用新常量,断言不变
  • 既有的 TestConsoleVideoRejectsImageWithReferencesTestConsoleVideoPostsSingleReferenceImageTestConsoleVideo15Rejects1080pReferenceMode 未改动且通过

本地:gofmt clean、go build ./...go vet ./... 通过;go test ./... 全绿;console 包 15 个 Video 用例全部 PASS。

说明

两个上限值都直接来自上游报错文案,注释里写了报错原文和测法,便于以后上游调整时核对。

顺带一条复测提醒:Console 团队级限频较紧(实测约 60 RPM,grok-imagine-video-1.5 另有约 2 RPS),而且 429 的优先级高于图片数量校验(实测顺序:422 反序列化 → 404 模型不存在 → 429 配额 → 400 图片数量 → 400 图片元素 → 400 prompt 为空)。连发用例容易把配额错误误读成接口契约,建议每个用例换一个满额账号、间隔 ≥25 秒。

…to-video duration

Upstream enforces the two video image inputs separately: image is a single
first frame (image-to-video) and reference_images holds up to 7 references
(reference-to-video). The combined ceiling of MaxInputImages (8) let 8
references pass the local guard and take a 400 from upstream instead:
"Too many reference images: 8. Maximum allowed is 7."

Generation also allowed 1-15s for every mode, but reference-to-video on
grok-imagine-video caps at 10s upstream: "Duration 15s exceeds the maximum
allowed for reference-to-video, which is 10s." image-to-video and
grok-imagine-video-1.5 keep 15s, so the new guard keys on reference_images
plus the base model rather than on duration alone.

Both limits come straight from upstream error text, quoted in comments so
future changes can be checked against them.
@chenyme
chenyme merged commit 297c277 into chenyme:main Aug 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants