moeru-ai/airi · error · Error
Unsupported AVIF speed "${argv[avifSpeedFlagIndex + 1] ?? av
Error message
Unsupported AVIF speed "${argv[avifSpeedFlagIndex + 1] ?? avifSpeed}". Expected a number between 1 and 10. What it means
The value of --avif-speed is coerced with Number() (capture.ts:28) and must be a finite number in the 1-10 range (capture.ts:99) before being handed to @napi-rs/image Transformer.avif({ speed }) (capture.ts:43-46). This error fires on NaN, values below 1, or values above 10; note this is the encoder speed scale (1 = slowest/best, 10 = fastest), not a percentage.
Source
Thrown at packages/scenarios-stage-tamagotchi-browser/scripts/capture.ts:99
if (avifSpeedFlagIndex >= 0 && !argv[avifSpeedFlagIndex + 1]) {
throw new Error('Missing value for --avif-speed.')
}
if (!Number.isFinite(settleMs) || settleMs < 0) {
throw new Error(`Unsupported settle delay "${argv[settleMsFlagIndex + 1] ?? settleMs}". Expected a number >= 0.`)
}
if (!Number.isFinite(avifMaxWidth) || avifMaxWidth < 1) {
throw new Error(`Unsupported AVIF max width "${argv[avifMaxWidthFlagIndex + 1] ?? avifMaxWidth}". Expected a number >= 1.`)
}
if (!Number.isFinite(avifQuality) || avifQuality < 0 || avifQuality > 100) {
throw new Error(`Unsupported AVIF quality "${argv[avifQualityFlagIndex + 1] ?? avifQuality}". Expected a number between 0 and 100.`)
}
if (!Number.isFinite(avifSpeed) || avifSpeed < 1 || avifSpeed > 10) {
throw new Error(`Unsupported AVIF speed "${argv[avifSpeedFlagIndex + 1] ?? avifSpeed}". Expected a number between 1 and 10.`)
}
await captureBrowserRoots({
imageTransformers: requestedFormat === 'avif'
? [avifTransformer]
: undefined,
sceneAppRoot,
routePath,
outputDir,
settleMs,
viewport: {
width: 1920,
height: 1080,
deviceScaleFactor: 2,
},
})
View on GitHub (pinned to 677329427f)
Solutions
- Pass an integer 1-10: `--avif-speed 6`
- Map qualitative presets yourself (fast=8, balanced=6, best=2) instead of words
- Validate the value in the caller before building the command line
Example fix
// before pnpm capture --format avif --avif-speed 100 // after pnpm capture --format avif --avif-speed 6
Defensive patterns
Strategy: validation
Validate before calling
function parseAvifSpeed(raw: string | undefined): number {
const value = raw === undefined ? 6 : Number(raw)
if (!Number.isFinite(value) || value < 1 || value > 10)
throw new Error(`Unsupported AVIF speed "${raw}". Expected a number between 1 and 10.`)
return value
} Type guard
const isEncoderSpeed = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v) && v >= 1 && v <= 10
Prevention
- The napi-rs AVIF speed range is 1-10 (1 slowest/best, 10 fastest)
- Do not reuse speed scales from other encoders
- Fail fast on NaN in pipeline config validation
When it happens
Trigger: Passing `--avif-speed fast`, `--avif-speed 0`, `--avif-speed 11`, or `--avif-speed 100` (percentage-style input). A dangling flag token in the value slot also produces NaN.
Common situations: Assuming speed is 0-1 or 0-100 like other tools, or copying speed values from ffmpeg/cavif presets whose scales differ.
Related errors
- Unsupported AVIF quality "${argv[avifQualityFlagIndex + 1] ?
- Unsupported AVIF max width "${argv[avifMaxWidthFlagIndex + 1
- Missing value for --avif-max-width.
- Missing value for --avif-quality.
- Missing value for --avif-speed.
AI-assisted analysis of moeru-ai/airi@677329427f (2026-08-18).
Data as JSON: /api/errors/88234412932e742c.
Report an issue: GitHub.