sgl-project/sglang · error · Error
This browser cannot encode H.264 MP4
Error message
This browser cannot encode H.264 MP4
What it means
Thrown by ngram_corpus Param::parse while parsing a spec-configuration segment. Each segment must split on '|' into exactly two parts: a positional range and a config value. Seeing part's size != 2 means the segment is malformed — missing the '|' separator or containing extra ones.
Source
Thrown at python/sglang/multimodal_gen/apps/realtime_webui/app.js:669
{ codec: "avc1.4d4028", width, height, bitrate, framerate: fps },
{ codec: "avc1.42e028", width, height, bitrate, framerate: fps },
];
let supported = null;
for (const config of configs) {
const candidate = {
...config,
avc: { format: "avc" },
bitrateMode: "variable",
hardwareAcceleration: "prefer-hardware",
latencyMode: "realtime",
};
const result = await VideoEncoder.isConfigSupported(candidate);
if (result.supported) {
supported = result.config;
break;
}
}
if (!supported) throw new Error("This browser cannot encode H.264 MP4");
recordingEncoderConfig = supported;
recordingEncoder = new VideoEncoder({
output: (chunk, metadata) => recordEncodedChunk(chunk, metadata),
error: (error) => {
recordingActive = false;
addHistory(error.message || "recording encoder failed");
updateRecordButton();
},
});
recordingEncoder.configure(supported);
}
function recordEncodedChunk(chunk, metadata) {
if (metadata?.decoderConfig?.description) {
recordingEncoderConfig.description = metadata.decoderConfig.description;
}
const data = new Uint8Array(chunk.byteLength);
chunk.copyTo(data);View on GitHub (pinned to 0132848349)
Solutions
- Fix the config string so every segment is exactly 'L-R|value', e.g. '2-4|8'
- Print/inspect the segments the parser sees (the code already dumps each 'part' to stderr) to find the malformed one
- Validate the config format in Python before passing it into the C++ API
Example fix
# before
param.resetBatchReturnTokenNum("2-4 5-8|3")
# after
param.resetBatchReturnTokenNum("2-4|3 5-8|3") Defensive patterns
Strategy: validation
Validate before calling
import re
SEG = re.compile(r"^\d+-\d+\|\d+$")
assert all(SEG.match(s) for s in cfg.split()), f"bad ngram config segment in {cfg!r}" Type guard
def is_valid_ngram_config(cfg: str) -> bool:
segs = cfg.split()
return bool(segs) and all(re.fullmatch(r"\d+-\d+\|\d+", s) for s in segs) Try / catch
try:
param.resetBatchReturnTokenNum(cfg)
except RuntimeError as e:
if "invalid config" in str(e):
raise ValueError(f"ngram config malformed: {cfg!r} (expected 'L-R|value' segments)") from e
raise Prevention
- Build config strings from structured (L, R, value) tuples via a single formatter f"{L}-{R}|{v}"
- Strip whitespace and trailing separators before passing to C++
- Unit-test the config parser against valid and invalid samples
When it happens
Trigger: resetBatchReturnTokenNum is called with a config string whose pipe-separated segments don't each contain exactly one '|', e.g. "2-4" (no config part), "2-4|8|9" (extra part), or an empty/trailing segment like "2-4|8|".
Common situations: Typos in the speculative n-gram config string passed via CLI/server args, config strings assembled programmatically with a missing or duplicated '|' delimiter, or trailing separators after string joins.
Related errors
- H.264 encoder did not return MP4 decoder config
- delta payload size mismatch: expected ${expectedSize}, got $
- This browser does not support gzip stream decoding
- Unknown match_type: '{match_type}'. Must be 'BFS' or 'PROB'.
- Component residency must use COMPONENT=MODE, got {assignment
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/3188e757d98d56b6.
Report an issue: GitHub.