pion/webrtc · error

incomplete file header

Error message

incomplete file header

What it means

Returned by parseFileHeader when io.ReadFull gets io.ErrUnexpectedEOF while reading the 32-byte IVF file header, meaning the stream is shorter than a full IVF header. Such data cannot be an IVF file at all.

Source

Thrown at pkg/media/ivfreader/ivfreader.go:24

import (
	"encoding/binary"
	"errors"
	"fmt"
	"io"
)

const (
	ivfFileHeaderSignature = "DKIF"
	ivfFileHeaderSize      = 32
	ivfFrameHeaderSize     = 12
)

var (
	errNilStream             = errors.New("stream is nil")
	errIncompleteFrameHeader = errors.New("incomplete frame header")
	errIncompleteFrameData   = errors.New("incomplete frame data")
	errIncompleteFileHeader  = errors.New("incomplete file header")
	errSignatureMismatch     = errors.New("IVF signature mismatch")
	errUnknownIVFVersion     = errors.New("IVF version unknown, parser may not parse correctly")
	errInvalidMediaTimebase  = errors.New("invalid media timebase")
)

// IVFFileHeader 32-byte header for IVF files
// https://wiki.multimedia.cx/index.php/IVF
type IVFFileHeader struct {
	signature           string // 0-3
	version             uint16 // 4-5
	headerSize          uint16 // 6-7
	FourCC              string // 8-11
	Width               uint16 // 12-13
	Height              uint16 // 14-15
	TimebaseDenominator uint32 // 16-19
	TimebaseNumerator   uint32 // 20-23
	NumFrames           uint32 // 24-27
	unused              uint32 // 28-31

View on GitHub (pinned to 8c25dc09fa)

Solutions

  1. Check the file size is at least 32 bytes before parsing.
  2. Confirm you're passing an actual IVF (DKIF) file and not another format.
  3. Re-download/restore the file if it was truncated.

Example fix

// before
f, _ := os.Open(path)
r, hdr, _ := ivfreader.NewWith(f)
// after
fi, err := f.Stat()
if err != nil || fi.Size() < 32 {
    return fmt.Errorf("%s is too small to be an IVF file", path)
}
r, hdr, err := ivfreader.NewWith(f)
Defensive patterns

Strategy: validation

Validate before calling

fi, err := f.Stat()
if err != nil {
    return err
}
if fi.Size() < 32 {
    return fmt.Errorf("%s: too small to be an IVF file (<32 bytes)", path)
}

Try / catch

if err == ivfreader.ErrIncompleteFileHeader {
    return fmt.Errorf("input too short to be an IVF file: %w", err)
}

Prevention

When it happens

Trigger: First parse on a stream with fewer than 32 bytes total (NewWith reads the file header immediately).

Common situations: Empty files, wrong file passed (a few-byte text file), severely truncated downloads, misconfigured paths pointing at the wrong artifact.

Related errors


AI-assisted analysis of pion/webrtc@8c25dc09fa (2026-09-03). Data as JSON: /api/errors/32a2aee4359a2e02. Report an issue: GitHub.