AlexxIT/go2rtc · error

streams: codecs not matched:

Error message

streams: codecs not matched: 

What it means

formatError in AddConsumer builds this error when SDP negotiation between the producer's recvonly codecs and the consumer's sendonly codecs finds no intersection. The message appends both codec lists ('kind:codec' joined per media) so the mismatch is visible: producer offers X, consumer demands Y. It fires when the two sides of a stream share no common codec for any media kind.

Solutions

  1. Compare the two codec lists in the message and reconfigure either the producer source or the consumer to use a shared codec (e.g. H264 vs H265 mismatch)
  2. Enable transcoding so codecs on both sides can be bridged
  3. If the consumer side is empty, verify the consumer actually offered sendonly medias with codecs
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/streams/add_consumer.go:151 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07). Data as JSON: /api/errors/dcedcec00fc9d77c. Report an issue: GitHub.

Appendix: source

Thrown at internal/streams/add_consumer.go:151

		var prod, cons string

		for _, media := range prodMedias {
			if media.Direction == core.DirectionRecvonly {
				for _, codec := range media.Codecs {
					prod = appendString(prod, media.Kind+":"+codec.PrintName())
				}
			}
		}

		for _, media := range consMedias {
			if media.Direction == core.DirectionSendonly {
				for _, codec := range media.Codecs {
					cons = appendString(cons, media.Kind+":"+codec.PrintName())
				}
			}
		}

		return errors.New("streams: codecs not matched: " + prod + " => " + cons)
	}

	// 3. Return unknown error
	return errors.New("streams: unknown error")
}

func appendString(s, elem string) string {
	if strings.Contains(s, elem) {
		return s
	}
	if len(s) == 0 {
		return elem
	}
	return s + ", " + elem
}

View on GitHub (pinned to c245815e75)