Files
openclaw/packages/media-understanding-common/src/video.ts
Vincent Koc d3cfef3bd8 fix(media-understanding): align video base64 byte limits (#96519)
Merged via squash.

Prepared head SHA: e37e577cd4
Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com>
Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com>
Reviewed-by: @vincentkoc
2026-06-25 02:02:59 +08:00

16 lines
598 B
TypeScript

// Media Understanding Common module implements video behavior.
import { DEFAULT_VIDEO_MAX_BASE64_BYTES } from "./defaults.js";
// Video payload size helpers for base64-expanded request bodies.
/** Estimate base64 size for a byte count. */
export function estimateBase64Size(bytes: number): number {
return Math.ceil(bytes / 3) * 4;
}
/** Resolve video base64 byte limit from raw byte limit and global cap. */
export function resolveVideoMaxBase64Bytes(maxBytes: number): number {
const expanded = estimateBase64Size(maxBytes);
return Math.min(expanded, DEFAULT_VIDEO_MAX_BASE64_BYTES);
}