pion/webrtc · error

file not opened

Error message

file not opened

What it means

Sentinel error returned in two generic nil guards: ivfwriter.NewWith when the io.Writer argument is nil, and IVFWriter.WriteRTP when the writer's internal ioWriter is nil (e.g. after Close or when the writer was constructed improperly). It means there is no valid output destination to write IVF data to.

Source

Thrown at pkg/media/ivfwriter/ivfwriter.go:19

func NewWith(out io.Writer, opts ...Option) (*IVFWriter, error) {
	if out == nil {
		return nil, errFileNotOpened
	}

	writer := &IVFWriter{
		ioWriter:            out,
		seenKeyFrame:        false,
		timebaseDenominator: 30,
		timebaseNumerator:   1,
		clockRate:           90000,
		videoWidth:          640,
		videoHeight:         480,
	}

	for _, o := range opts {
		if err := o(writer); err != nil {
			return nil, err
		}
	}

View on GitHub (pinned to 8c25dc09fa)

Solutions

  1. Pass a non-nil io.Writer to NewWith, e.g. a value from os.Create or a bytes.Buffer
  2. Do not call WriteRTP after Close; reuse requires creating a new writer
  3. Check that a constructed writer is non-nil before using it (NewWith returns an error alongside the nil writer)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/media/ivfwriter/ivfwriter.go:19 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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