AlexxIT/go2rtc · error
stream not found
Error message
stream not found
What it means
outputFLV serves an FLV stream by looking it up with streams.Get(src); when no stream is registered under that name the handler returns the api.StreamNotFound message with HTTP 404. The library throws this because it cannot output a stream that does not exist in its in-memory stream registry.
Solutions
- Check that a stream with exactly that name exists in the streams config section
- Use the /api/streams endpoint to list actual stream names
- Create the stream first (config or POST /api/streams?src=...) before consuming
- Fix the URL's src query parameter spelling/case
Example fix
// before http://host:1984/api/stream.flv?src=cameara1 // after http://host:1984/api/stream.flv?src=camera1
Defensive patterns
Strategy: validation
Validate before calling
const streams = await (await fetch('/api/streams')).json();
if (!streams.some(s => s.name === src)) throw new Error(`stream '${src}' not configured`); Try / catch
const res = await fetch(`/api/stream.flv?src=${encodeURIComponent(src)}`);
if (res.status === 404) { /* stream missing: create it or fix the name */ }
else if (!res.ok) throw new Error(await res.text()); Prevention
- Keep stream names in one shared constant/config to avoid typos
- List /api/streams before consuming to confirm the name exists
- Remember dynamic streams disappear after restart — recreate on boot
- Case-sensitive: match stream names exactly
When it happens
Trigger: HTTP GET to the FLV output endpoint with a `src` query parameter naming a stream that was never created, was removed, or is spelled differently from the configured stream name.
Common situations: Typo in the src name; stream defined in a different config section (streams vs mp4/rtsp naming); stream not yet started so Get returns nil; consumer requests a stream after go2rtc restart wiped dynamic streams.
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
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/6ef3f45e6e36a69b.
Report an issue: GitHub.
Appendix: source
Thrown at internal/rtmp/rtmp.go:158
_, err = cons.WriteTo(wr)
}
return cons, run, nil
}
func apiHandle(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
outputFLV(w, r)
} else {
inputFLV(w, r)
}
}
func outputFLV(w http.ResponseWriter, r *http.Request) {
src := r.URL.Query().Get("src")
stream := streams.Get(src)
if stream == nil {
http.Error(w, api.StreamNotFound, http.StatusNotFound)
return
}
cons := flv.NewConsumer()
cons.WithRequest(r)
if err := stream.AddConsumer(cons); err != nil {
log.Error().Err(err).Caller().Send()
return
}
h := w.Header()
h.Set("Content-Type", "video/x-flv")
_, _ = cons.WriteTo(w)
stream.RemoveConsumer(cons)
}View on GitHub (pinned to c245815e75)