{"record":{"id":"f3a453860e262070","repo":"pion/webrtc","slug":"ivf-version-unknown-parser-may-not-parse-correctl","errorCode":null,"errorMessage":"IVF version unknown, parser may not parse correctly","messagePattern":"IVF version unknown, parser may not parse correctly","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/media/ivfreader/ivfreader.go","lineNumber":26,"sourceCode":"\t\"encoding/binary\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n)\n\nconst (\n\tivfFileHeaderSignature = \"DKIF\"\n\tivfFileHeaderSize      = 32\n\tivfFrameHeaderSize     = 12\n)\n\nvar (\n\terrNilStream             = errors.New(\"stream is nil\")\n\terrIncompleteFrameHeader = errors.New(\"incomplete frame header\")\n\terrIncompleteFrameData   = errors.New(\"incomplete frame data\")\n\terrIncompleteFileHeader  = errors.New(\"incomplete file header\")\n\terrSignatureMismatch     = errors.New(\"IVF signature mismatch\")\n\terrUnknownIVFVersion     = errors.New(\"IVF version unknown, parser may not parse correctly\")\n\terrInvalidMediaTimebase  = errors.New(\"invalid media timebase\")\n)\n\n// IVFFileHeader 32-byte header for IVF files\n// https://wiki.multimedia.cx/index.php/IVF\ntype IVFFileHeader struct {\n\tsignature           string // 0-3\n\tversion             uint16 // 4-5\n\theaderSize          uint16 // 6-7\n\tFourCC              string // 8-11\n\tWidth               uint16 // 12-13\n\tHeight              uint16 // 14-15\n\tTimebaseDenominator uint32 // 16-19\n\tTimebaseNumerator   uint32 // 20-23\n\tNumFrames           uint32 // 24-27\n\tunused              uint32 // 28-31\n}\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/pion/webrtc/blob/8c25dc09fa9e7c09aac4309ead88093d760432b0/pkg/media/ivfreader/ivfreader.go#L8-L44","documentation":"Returned by parseFileHeader (wrapped with fmt.Errorf %w plus expected/got values) when the IVF header signature is valid but the version field is not 0, the only version this parser understands. Parsing may not work correctly for unknown versions.","triggerScenarios":"parseFileHeader encounters header.version != 0 after a successful DKIF signature check; the error text includes the actual version number.","commonSituations":"IVF files produced by newer or nonstandard encoders/muxers setting a nonzero version field; corrupted version bytes; hand-crafted or fuzzed headers.","solutions":["Inspect the reported version in the error message; if the file is nonstandard, re-mux it with a standard tool (ffmpeg -c copy) to produce version-0 IVF.","Use errors.Is so the wrapped sentinel matches, and decide whether to proceed at your own risk or reject the file.","Check the producing encoder's output settings for a version/profile flag."],"exampleFix":"// before\nif err != nil { return err }\n// after\nif err != nil {\n    if errors.Is(err, ivfErrUnknownIVFVersion) {\n        log.Warn(\"nonzero IVF version, attempting best-effort parse\")\n    } else {\n        return err\n    }\n}","handlingStrategy":"type-guard","validationCode":"hdrBytes := make([]byte, 32)\nio.ReadFull(f, hdrBytes)\nversion := binary.LittleEndian.Uint16(hdrBytes[4:6])\nif version != 0 {\n    log.Warnf(\"IVF version %d is nonstandard; parser may misbehave\", version)\n}\nf.Seek(0, io.SeekStart)","typeGuard":"func isKnownIVFVersion(v uint16) bool { return v == 0 }","tryCatchPattern":"if err != nil && errors.Is(err, ivfErrUnknownIVFVersion) {\n    log.Warn(\"nonstandard IVF version; continuing best-effort\")\n} else if err != nil {\n    return err\n}","preventionTips":["Prefer errors.Is over equality since this error is wrapped with fmt.Errorf %w.","Log the embedded expected/got version details when triaging producer issues.","Re-mux nonstandard files with a standard muxer to produce version-0 IVF."],"tags":["go","media","ivf","version-mismatch","format-version"],"backgroundTag":"unsupported-format-version","analyzedSha":"8c25dc09fa9e7c09aac4309ead88093d760432b0","analyzedAt":"2026-09-03T21:56:56.182Z","contentChangedAt":"2026-09-03T21:56:56.182Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}