{"record":{"id":"7134aa9ff4eb480f","repo":"pion/webrtc","slug":"invalid-media-timebase-7134aa","errorCode":null,"errorMessage":"invalid media timebase","messagePattern":"invalid media timebase","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/media/ivfwriter/ivfwriter.go","lineNumber":24,"sourceCode":"\nimport (\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"io\"\n\t\"os\"\n\n\t\"github.com/pion/rtp\"\n\t\"github.com/pion/rtp/codecs\"\n\t\"github.com/pion/rtp/codecs/av1/obu\"\n)\n\nvar (\n\terrFileNotOpened        = errors.New(\"file not opened\")\n\terrInvalidNilPacket     = errors.New(\"invalid nil packet\")\n\terrCodecUnset           = errors.New(\"codec is unset\")\n\terrCodecAlreadySet      = errors.New(\"codec is already set\")\n\terrNoSuchCodec          = errors.New(\"no codec for this MimeType\")\n\terrInvalidMediaTimebase = errors.New(\"invalid media timebase\")\n)\n\ntype (\n\tcodec int\n\n\t// IVFWriter is used to take RTP packets and write them to an IVF on disk.\n\tIVFWriter struct {\n\t\tioWriter     io.Writer\n\t\tcount        uint64\n\t\tseenKeyFrame bool\n\n\t\tcodec codec\n\n\t\ttimebaseDenominator uint32\n\t\ttimebaseNumerator   uint32\n\t\tfirstFrameTimestamp uint32\n\t\tclockRate           uint64\n\t\tvideoWidth          uint16","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/pion/webrtc/blob/8c25dc09fa9e7c09aac4309ead88093d760432b0/pkg/media/ivfwriter/ivfwriter.go#L6-L42","documentation":"errInvalidMediaTimebase is returned when an IVF file header declares a zero timebase numerator or denominator. The timebase converts the header's timebase to presentation timestamps, so a zero value would cause division by zero and meaningless timestamps. The reader refuses to parse such files. It indicates a corrupt, truncated, or badly generated IVF file.","triggerScenarios":"Calling ivfreader.NewWith / ParseNextHeader on an IVF stream whose 32-byte header has TimebaseNumerator == 0 or TimebaseDenominator == 0.","commonSituations":"Files produced by a broken encoder, hand-crafted test fixtures with zeroed header fields, files truncated before the timebase fields were filled, or buffers not yet fully read when the header is parsed.","solutions":["Regenerate or fix the IVF file so the timebase numerator/denominator are non-zero (commonly 1/1000)","Validate header fields before feeding the stream to the reader","If you control the writing side, use ivfwriter to produce a spec-compliant header","Check that the file/buffer was fully populated before parsing (truncated writes)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var h ivfreader.IVFFileHeader\n// after parsing the header yourself or from ParseNextHeader result:\nif h.TimebaseNumerator == 0 || h.TimebaseDenominator == 0 {\n    return errors.New(\"ivf header has zero timebase\")\n}","typeGuard":"func hasValidTimebase(h *ivfreader.IVFFileHeader) bool {\n    return h != nil && h.TimebaseNumerator != 0 && h.TimebaseDenominator != 0\n}","tryCatchPattern":"r, h, err := ivfreader.NewWith(f)\nif err != nil {\n    if errors.Is(err, ivfreader.ErrInvalidMediaTimebase) { // or the package-exported sentinel\n        return fmt.Errorf(\"corrupt IVF file: %w\", err)\n    }\n    return err\n}","preventionTips":["Validate IVF header fields before parsing packets","Generate IVF files with ivfwriter or a known-good muxer","Reject zeroed headers early when ingesting untrusted files","Check for truncated writes that leave header fields zero"],"tags":["go","media","ivf","corrupt-file"],"backgroundTag":"invalid-media-header","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"}