AlexxIT/go2rtc · error
ErrCantGetTrack
ErrCantGetTrack
Error message
can't get track
What it means
core.ErrCantGetTrack ("can't get track", pkg/core/track.go:10) is the sentinel returned when a media producer cannot supply a Receiver for the requested Media/Codec combination. Several backends (e.g. pkg/alsa/playback_linux.go GetTrack, pkg/doorbird/backchannel.go GetTrack) unconditionally return it because they simply do not support producing a track. It signals an unsupported/unavailable media track, not a transport failure.
Solutions
- Check support with errors.Is(err, core.ErrCantGetTrack) and skip/disable that track in your application instead of retrying.
- Pick a backend/device that supports the requested direction (e.g. use a speaker-capable integration for backchannel).
- Request only tracks the device actually produces (inspect Media/Codec from GetMedias first).
- Implement the track in the backend if you own the driver code; the stub returns nil, ErrCantGetTrack by design.
Example fix
// before
track, err := producer.GetTrack(media, codec)
if err != nil {
return err // aborts whole pipeline on unsupported backchannel
}
// after
track, err := producer.GetTrack(media, codec)
if errors.Is(err, core.ErrCantGetTrack) {
return nil // no track available; continue without it
} Defensive patterns
Strategy: type-guard
Validate before calling
// check the device offers the media before asking for a track
if len(media.GetVideo()) == 0 && isVideoRequest {
return nil // nothing to request
} Type guard
func trackAvailable(err error) bool {
return !errors.Is(err, core.ErrCantGetTrack)
} Try / catch
track, err := producer.GetTrack(media, codec)
if errors.Is(err, core.ErrCantGetTrack) {
log.Info("track not supported by backend; continuing without it")
return nil
} Prevention
- Always compare with errors.Is against the sentinel
- Enumerate the device's advertised medias before GetTrack
- Document which backends are stubs (ALSA playback, Doorbird backchannel)
- Design pipelines that tolerate missing tracks
When it happens
Trigger: Calling GetTrack(media, codec) on a backend that has no track for the given media/codec — including ALSA playback and Doorbird backchannel, which always return ErrCantGetTrack.
Common situations: Requesting two-way audio (backchannel) from a Doorbird camera whose integration doesn't support it; requesting a track from a sink that only consumes (ALSA playback); asking for a codec the device doesn't emit; consumer code not checking for the sentinel and treating it as transient.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- ErrRead
- probe reader overflow
- dvrip: can't probe medias
- kasa: unsupported type:
- webrtc: can't get track
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/cda2fe99a053e84c.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/core/track.go:10
package core
import (
"encoding/json"
"errors"
"github.com/pion/rtp"
)
var ErrCantGetTrack = errors.New("can't get track")
type Receiver struct {
Node
// Deprecated: should be removed
Media *Media `json:"-"`
// Deprecated: should be removed
ID byte `json:"-"` // Channel for RTSP, PayloadType for MPEG-TS
Bytes int `json:"bytes,omitempty"`
Packets int `json:"packets,omitempty"`
}
func NewReceiver(media *Media, codec *Codec) *Receiver {
r := &Receiver{
Node: Node{id: NewID(), Codec: codec},
Media: media,
}View on GitHub (pinned to c245815e75)