{"record":{"id":"91c229122a2b6466","repo":"remotion-dev/remotion","slug":"audio-track-cannot-be-decoded","errorCode":null,"errorMessage":"Audio track cannot be decoded","messagePattern":"Audio track cannot be decoded","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-utils/src/use-windowed-audio-data.ts","lineNumber":153,"sourceCode":"\n\t\t\t\tif (await audioTrack.isLive()) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Live streams are not currently supported by Remotion. Sorry! Source: ' +\n\t\t\t\t\t\t\tsrc,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (await audioTrack.isRelativeToUnixEpoch()) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Streams with UNIX timestamps are not currently supported by Remotion. Sorry! Source: ' +\n\t\t\t\t\t\t\tsrc,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst canDecode = await audioTrack.canDecode();\n\n\t\t\t\tif (!canDecode) {\n\t\t\t\t\tthrow new Error('Audio track cannot be decoded');\n\t\t\t\t}\n\n\t\t\t\tif (channelIndex >= audioTrack.numberOfChannels || channelIndex < 0) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Invalid channel index ${channelIndex} for audio with ${audioTrack.numberOfChannels} channels`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst numberOfChannels = await audioTrack.getNumberOfChannels();\n\t\t\t\tconst sampleRate = await audioTrack.getSampleRate();\n\n\t\t\t\tconst format = await input.getFormat();\n\n\t\t\t\tconst isMatroska = format === MATROSKA || format === WEBM;\n\n\t\t\t\tif (isMounted.current) {\n\t\t\t\t\tsetAudioUtils({\n\t\t\t\t\t\tinput,","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-utils/src/use-windowed-audio-data.ts#L135-L171","documentation":"Thrown inside useWindowedAudioData() when mediabunny reports audioTrack.canDecode() === false (line 150-154). The container has an audio track but the codec/sample-format is not decodable in the current environment, so windowing waveforms is impossible. Forwarded to cancelRender().","triggerScenarios":"Audio encoded in a codec the runtime cannot decode (e.g. ALAC, AC-3, DTS, E-AC-3, TrueHD, Opus-in-MP4 on some browsers, or an obscure FourCC); partial/truncated file where the codec init data is missing; DRM-protected audio; an audio track that is metadata-only.","commonSituations":"Using broadcast AC-3 audio from .ts/.mkv captures; Opus audio inside an MP4 container in older Chromium; ALAC from iTunes; MP4 with custom FourCC after a bad transcode; file truncated during upload so decoder setup fails.","solutions":["Transcode the audio to a widely supported codec: ffmpeg -i in.mp4 -c:v copy -c:a aac -b:a 192k out.mp4.","If you need Opus, keep it in a WebM/Matroska container rather than MP4 for broader decoder support.","Verify with ffprobe that the audio codec is one Chromium decodes (AAC, MP3, Opus-in-WebM, FLAC, Vorbis, WAV/PCM).","Re-download the asset if you suspect truncation (compare file size to the source)."],"exampleFix":"// before (AC-3 audio Chromium cannot decode -> 'Audio track cannot be decoded')\nuseWindowedAudioData({src: staticFile('capture-ac3.mkv'), ...});\n\n// after (re-encode audio to AAC)\n// ffmpeg -i capture-ac3.mkv -c:v copy -c:a aac -b:a 192k capture-aac.mp4\nuseWindowedAudioData({src: staticFile('capture-aac.mp4'), ...});","handlingStrategy":"validation","validationCode":"// Probe audio codec and reject ones Chromium does not decode\nimport {execFileSync} from 'child_process';\n\nconst SUPPORTED = new Set(['aac', 'mp3', 'opus', 'vorbis', 'flac', 'pcm_s16le', 'pcm_s24le']);\n\nfunction isDecodableAudio(file: string): boolean {\n  const codec = execFileSync('ffprobe', ['-v', 'error', '-select_streams', 'a:0', '-show_entries', 'stream=codec_name', '-of', 'csv=p=0', file], {encoding: 'utf8'}).trim();\n  return SUPPORTED.has(codec);\n}\n\nif (!isDecodableAudio(file)) {\n  // re-encode to AAC before rendering\n}","typeGuard":"async function canDecodeMediabunny(src: string): Promise<boolean> {\n  const {Input} = await import('mediabunny');\n  const input = new Input({source: src});\n  try {\n    const track = await input.getPrimaryAudioTrack();\n    return track ? await track.canDecode() : false;\n  } finally {\n    input.dispose();\n  }\n}","tryCatchPattern":"// Forwarded to cancelRender(); wrap an ErrorBoundary and fall back to a re-encoded asset:\n// <ErrorBoundary fallback={<Waveform src={staticFile('audio-aac.mp4')} ... />}>\n//   <WindowedWaveform src={src} ... />\n// </ErrorBoundary>","preventionTips":["Prefer AAC or MP3 for audio inside Remotion assets.","If you must use Opus, keep it inside a WebM/Matroska container rather than MP4.","Run ffprobe -show_entries stream=codec_name on new assets before wiring them in.","Re-download truncated assets if decoder setup fails; compare sizes against the source."],"tags":["audio","codec","unsupported-format","mediabunny","render-failure"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}