AlexxIT/go2rtc · error
pcm: unsupported audio format
Error message
pcm: unsupported audio format: ${audio} What it means
NewBackchannel builds a PCM backchannel and needs a codec. It takes the audio format string, tries core.ParseCodecString on it, and throws this error when the string cannot be parsed into a known codec (and the caller did not leave it empty to get the default 16kHz PCML codec).
Solutions
- Check the audio string against the formats core.ParseCodecString accepts (e.g. "pcml/16000", "pcma/8000")
- Pass an empty string to get the default codec (PCML, 16000 Hz)
- Log the exact value of the audio parameter coming from your caller/config and fix the typo
Example fix
// before
bc, err := NewBackchannel("pcm_l16")
// after
bc, err := NewBackchannel("pcml/16000") // or NewBackchannel("") for the default Defensive patterns
Strategy: validation
Validate before calling
if audio != "" && core.ParseCodecString(audio) == nil {
return fmt.Errorf("unsupported audio format %q; use pcml/pcma or empty for default", audio)
}
bc, err := NewBackchannel(audio) Try / catch
if err != nil {
if strings.Contains(err.Error(), "unsupported audio format") {
bc, err = NewBackchannel("") // fall back to default codec
}
} Prevention
- Whitelist allowed codec strings in your config layer before passing them in
- Use the empty-string default when unsure of the exact format
- Unit-test any codec string that comes from user input
When it happens
Trigger: Calling NewBackchannel (via execHandle) with a non-empty `audio` string that core.ParseCodecString cannot parse, e.g. "pcm-ulaw" or a misspelled codec name like "pcml " or "opus/48000/2" if unsupported.
Common situations: Typo in codec name in config or URL query parameter; passing an SDP-format codec string when a simple name is expected; assuming formats like opus are supported when only PCM variants are.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- waw: unsupported codec
- unsupported iso audio
- kasa: unsupported type:
- mp4: unsupported codec:
- av server not ready
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/7fb034f2a87f208e.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/pcm/backchannel.go:23
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/shell"
"github.com/pion/rtp"
)
type Backchannel struct {
core.Connection
cmd *shell.Command
}
func NewBackchannel(cmd *shell.Command, audio string) (core.Producer, error) {
var codec *core.Codec
if audio == "" {
// default codec
codec = &core.Codec{Name: core.CodecPCML, ClockRate: 16000}
} else if codec = core.ParseCodecString(audio); codec == nil {
return nil, errors.New("pcm: unsupported audio format: " + audio)
}
medias := []*core.Media{
{
Kind: core.KindAudio,
Direction: core.DirectionSendonly,
Codecs: []*core.Codec{codec},
},
}
return &Backchannel{
Connection: core.Connection{
ID: core.NewID(),
FormatName: "pcm",
Protocol: "pipe",
Medias: medias,
Transport: cmd,
},View on GitHub (pinned to c245815e75)