{"record":{"id":"edff92457186ae59","repo":"heygen-com/hyperframes","slug":"audio-file-too-large-for-headless-analysis-mb-m","errorCode":null,"errorMessage":"Audio file too large for headless analysis (${mb}MB > ${MAX_AUDIO_BYTES / 1e6}MB).","messagePattern":"Audio file too large for headless analysis \\((.+?)MB > (.+?)MB\\)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/beats/headlessAnalyzer.ts","lineNumber":133,"sourceCode":"  });\n  page.on(\"console\", (m) => {\n    if (m.type() === \"error\") pageErrors.push(m.text());\n  });\n  await page.setContent(\"<!doctype html><html><body></body></html>\");\n  await page.addScriptTag({ content: bundle });\n  try {\n    return (await page.evaluate(inPageAnalyze, b64)) as HeadlessBeatResult;\n  } catch (err) {\n    const detail = pageErrors.length ? ` (${pageErrors.join(\"; \")})` : \"\";\n    throw new Error(`${err instanceof Error ? err.message : String(err)}${detail}`);\n  }\n}\n\n/** Decode + analyze the given audio bytes in headless Chrome. */\nexport async function analyzeBeatsHeadless(audioBytes: Buffer): Promise<HeadlessBeatResult> {\n  if (audioBytes.length > MAX_AUDIO_BYTES) {\n    const mb = Math.round(audioBytes.length / 1e6);\n    throw new Error(\n      `Audio file too large for headless analysis (${mb}MB > ${MAX_AUDIO_BYTES / 1e6}MB).`,\n    );\n  }\n  const bundle = await buildAnalyzerBundle();\n  const { ensureBrowser } = await import(\"../browser/manager.js\");\n  const puppeteer = await import(\"puppeteer-core\");\n  const browser = await ensureBrowser();\n  const chrome: Browser = await puppeteer.default.launch({\n    headless: true,\n    executablePath: browser.executablePath,\n    args: [\"--no-sandbox\", \"--disable-dev-shm-usage\", \"--autoplay-policy=no-user-gesture-required\"],\n  });\n  try {\n    const page = await chrome.newPage();\n    return await detectOnPage(page, bundle, audioBytes.toString(\"base64\"));\n  } finally {\n    await chrome.close();\n  }","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/cli/src/beats/headlessAnalyzer.ts#L115-L151","documentation":"Thrown by analyzeBeatsHeadless() before any browser work when audioBytes.length exceeds MAX_AUDIO_BYTES (80 MiB). The guard exists because the audio is base64-encoded (+33% size) and shipped to the headless page over CDP; a very large file would blow CDP message limits and stall. The message reports the actual size in MB and the cap (80MB).","triggerScenarios":"Calling analyzeBeatsHeadless(buf) where buf is a Buffer longer than 83,886,080 bytes (80*1024*1024). Typical with long mixes, podcast episodes, or lossless files (FLAC/WAV) of a few minutes.","commonSituations":"User runs the beats command on a 2-hour podcast WAV; a lossless FLAC that is large per minute; a full album rip passed as one file.","solutions":["Trim the audio to the section you need: `ffmpeg -i in.flac -t 180 -c:a libmp3lame -q:a 2 clip.mp3` (first 180s).","Downsample/compress to MP3 or AAC to shrink the byte size while keeping beat-detection-relevant frequencies.","If you need beats for a long track, analyze a representative segment and extrapolate, or raise the cap locally by editing MAX_AUDIO_BYTES if you control memory."],"exampleFix":"# before — 200MB FLAC rejected\n$ bunx hyperframes beats album.flac\n# trim and compress\n$ ffmpeg -i album.flac -t 300 -c:a libmp3lame -b:a 192k clip.mp3\n$ bunx hyperframes beats clip.mp3","handlingStrategy":"validation","validationCode":"const MAX = 80 * 1024 * 1024;\nif (audioBytes.length > MAX) {\n  throw new Error(`Audio too large (${Math.round(audioBytes.length / 1e6)}MB). Trim or compress to <= 80MB.`);\n}\nawait analyzeBeatsHeadless(audioBytes);","typeGuard":"function audioWithinLimit(bytes: Buffer): boolean {\n  return bytes.length <= 80 * 1024 * 1024;\n}","tryCatchPattern":null,"preventionTips":["Trim long audio to the section you need before analysis.","Compress lossless sources (FLAC/WAV) to MP3/AAC to reduce byte size.","Check Buffer.byteLength before calling analyzeBeatsHeadless."],"tags":["beats","size-limit","audio","validation","pre-io"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}