{"record":{"id":"7fb034f2a87f208e","repo":"AlexxIT/go2rtc","slug":"pcm-unsupported-audio-format-audio","errorCode":null,"errorMessage":"pcm: unsupported audio format: ${audio}","messagePattern":"pcm: unsupported audio format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/pcm/backchannel.go","lineNumber":23,"sourceCode":"\n\t\"github.com/AlexxIT/go2rtc/pkg/core\"\n\t\"github.com/AlexxIT/go2rtc/pkg/shell\"\n\t\"github.com/pion/rtp\"\n)\n\ntype Backchannel struct {\n\tcore.Connection\n\tcmd *shell.Command\n}\n\nfunc NewBackchannel(cmd *shell.Command, audio string) (core.Producer, error) {\n\tvar codec *core.Codec\n\n\tif audio == \"\" {\n\t\t// default codec\n\t\tcodec = &core.Codec{Name: core.CodecPCML, ClockRate: 16000}\n\t} else if codec = core.ParseCodecString(audio); codec == nil {\n\t\treturn nil, errors.New(\"pcm: unsupported audio format: \" + audio)\n\t}\n\n\tmedias := []*core.Media{\n\t\t{\n\t\t\tKind:      core.KindAudio,\n\t\t\tDirection: core.DirectionSendonly,\n\t\t\tCodecs:    []*core.Codec{codec},\n\t\t},\n\t}\n\n\treturn &Backchannel{\n\t\tConnection: core.Connection{\n\t\t\tID:         core.NewID(),\n\t\t\tFormatName: \"pcm\",\n\t\t\tProtocol:   \"pipe\",\n\t\t\tMedias:     medias,\n\t\t\tTransport:  cmd,\n\t\t},","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/pcm/backchannel.go#L5-L41","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nbc, err := NewBackchannel(\"pcm_l16\")\n// after\nbc, err := NewBackchannel(\"pcml/16000\") // or NewBackchannel(\"\") for the default","handlingStrategy":"validation","validationCode":"if audio != \"\" && core.ParseCodecString(audio) == nil {\n    return fmt.Errorf(\"unsupported audio format %q; use pcml/pcma or empty for default\", audio)\n}\nbc, err := NewBackchannel(audio)","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"unsupported audio format\") {\n        bc, err = NewBackchannel(\"\") // fall back to default codec\n    }\n}","preventionTips":["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"],"tags":["audio","codec","invalid-argument-value"],"backgroundTag":"invalid-argument-value","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}