pion/webrtc · error

incomplete frame data

Error message

incomplete frame data

What it means

Returned by IVFReader.ParseNextFrame when the frame header was read successfully but io.ReadFull hit io.ErrUnexpectedEOF while reading the frame's payload bytes, meaning the stream ended before the declared frame size was fully available.

Source

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

package ivfreader

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

View on GitHub (pinned to 8c25dc09fa)

Solutions

  1. Verify and re-acquire the source IVF file (complete download, valid size).
  2. Catch this error specifically to treat truncation as a graceful end-of-stream if partial data is acceptable.
  3. Sanitize frame-size fields if the file comes from an untrusted producer.

Example fix

// before
payload, _, err := reader.ParseNextFrame()
if err != nil { return err }
// after
payload, _, err := reader.ParseNextFrame()
if err == ivfreader.ErrIncompleteFrameData {
    log.Warn("frame payload truncated at end of file")
    return nil
} else if err != nil {
    return err
}
Defensive patterns

Strategy: try-catch

Validate before calling

if fi.Size() < int64(32+12) {
    return errors.New("file too small to contain frame data")
}

Try / catch

frame, hdr, err := reader.ParseNextFrame()
if err == ivfreader.ErrIncompleteFrameData {
    log.Warn("frame payload truncated at end of IVF stream")
    return nil
} else if err != nil {
    return err
}

Prevention

When it happens

Trigger: ParseNextFrame where the payload (per the 12-byte frame header's size field) extends beyond the end of the stream.

Common situations: Truncated or partially downloaded IVF files, corrupt frame-size fields, reading a file mid-write, piping a stream that closed early.

Related errors


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