{"record":{"id":"d4558721c569a081","repo":"remotion-dev/remotion","slug":"only-h264-is-supported-as-a-stream-type-in-avi-g","errorCode":null,"errorMessage":"Only H264 is supported as a stream type in .avi, got ${handler}","messagePattern":"Only H264 is supported as a stream type in \\.avi, got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/riff/parse-strh.ts","lineNumber":23,"sourceCode":"export const parseStrh = ({\n\titerator,\n\tsize,\n}: {\n\titerator: BufferIterator;\n\tsize: number;\n}): RiffBox => {\n\tconst box = iterator.startBox(size);\n\tconst fccType = iterator.getByteString(4, false);\n\tif (fccType !== 'vids' && fccType !== 'auds') {\n\t\tthrow new Error('Expected AVI handler to be vids / auds');\n\t}\n\n\tconst handler =\n\t\tfccType === 'vids'\n\t\t\t? iterator.getByteString(4, false)\n\t\t\t: iterator.getUint32Le();\n\tif (typeof handler === 'string' && handler !== 'H264') {\n\t\tthrow new Error(\n\t\t\t`Only H264 is supported as a stream type in .avi, got ${handler}`,\n\t\t);\n\t}\n\n\tif (fccType === 'auds' && handler !== 1) {\n\t\tthrow new Error(\n\t\t\t`Only \"1\" is supported as a stream type in .avi, got ${handler}`,\n\t\t);\n\t}\n\n\tconst flags = iterator.getUint32Le();\n\tconst priority = iterator.getUint16Le();\n\tconst language = iterator.getUint16Le();\n\tconst initialFrames = iterator.getUint32Le();\n\tconst scale = iterator.getUint32Le();\n\tconst rate = iterator.getUint32Le();\n\tconst start = iterator.getUint32Le();\n\tconst length = iterator.getUint32Le();","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/riff/parse-strh.ts#L5-L41","documentation":"Thrown by parseStrh() for a 'vids' stream when the handler FourCC (the 4 bytes after 'vids') is not exactly 'H264'. This is the stream-header-level guard that mirrors error 1389 in track construction. Any other video codec FourCC (XVID, DX50, MJPG, FMP4, etc.) trips it.","triggerScenarios":"An AVI video stream with a non-H.264 codec FourCC. The handler is read as a 4-byte ASCII string for vids streams and compared to 'H264'.","commonSituations":"Legacy AVI files encoded with Xvid/DivX/MPEG-4 Part 2; Motion-JPEG AVIs from cameras; any modern re-encode that did not use H.264.","solutions":["Transcode the video to H.264: ffmpeg -i in.avi -c:v libx264 -pix_fmt yuv420p -c:a aac out.avi","If only audio is needed, drop the video stream.","Pre-inspect with ffprobe -show_streams and reject non-H.264 AVIs before parsing."],"exampleFix":"// before\nawait parseMediaStream({src: 'divx.avi'});\n\n// after\n// ffmpeg -i divx.avi -c:v libx264 -pix_fmt yuv420p -c:a aac out.avi\nawait parseMediaStream({src: 'out.avi'});","handlingStrategy":"validation","validationCode":"// Pre-check the AVI video FourCC with ffprobe before parsing.\n// ffprobe -v error -select_streams v -show_entries stream=codec_name -of csv in.avi\n// Expect: h264","typeGuard":"function isH264FourCC(handler: string): boolean {\n  return handler === 'H264';\n}","tryCatchPattern":"try {\n  await parseMediaStream({src: 'in.avi'});\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Only H264 is supported')) {\n    // transcode video to H.264: ffmpeg -i in.avi -c:v libx264 -pix_fmt yuv420p -c:a aac out.avi\n  } else throw err;\n}","preventionTips":["Encode AVI video with the 'H264' FourCC.","Reject non-H.264 AVIs at ingest via ffprobe.","Prefer MP4 for broad codec support."],"tags":["riff","avi","video-codec","h264","fourcc","media-parser"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}