pyronear / pyronear/pyro-engine
stream: quality is hardcoded, no way to adapt bitrate to network capacity
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 19
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
Problem
Stream quality (640x360, 10 fps, 700k) is effectively hardcoded. When the uplink can't sustain the bitrate, SRT drops late packets and the viewer gets artifacts or freezes. There is no graceful degradation and no way to configure a lighter profile for sites on weak 4G links.
Two related findings:
- Latent config bug:
start_streamreadswidth,height,fps,conffromSTREAMS[camera_ip](routes_stream.py:77-80), butSTREAMSis built inconfig.pywith onlyinput_urlandoutput_url. These keys can never be set, so the defaults always apply. Per-camera quality config silently doesn't exist. - SRT latency unit: ffmpeg's
latencyoption is in microseconds, soSRT_LATENCY = 50means 50 µs (rounded to 0, libsrt falls back to its 120 ms default). The intended value was presumably 50 ms, which would be too low anyway for 4G links (rule of thumb: 3-4x RTT).
Proposal
- Propagate quality keys (
width,height,fps,bitrate) fromcredentials.jsonintoSTREAMSso per-camera profiles work. - Accept optional quality overrides on
POST /stream/start_stream(e.g.bitrate,fps, or aprofile=low|highshortcut) so the platform can pick per session. - Fix
SRT_LATENCYto an explicit microsecond value (~300000). - Optional follow-up: switch restream mode to
-c:v copy(camera already outputs H.264, re-encoding wastes Pi CPU) and control bitrate at the source via the camera API.
Out of scope: automatic ABR (HLS ladder or congestion-based encoder restart). Can be discussed later if static profiles prove insufficient.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in routes_stream.py around lines 77-80 and compare the expected quality keys with STREAMS construction in config.py and the credentials.json flow. Trace POST /stream/start_stream and the SRT latency setting, then verify that per-camera and request-level quality profiles are propagated and that the configured latency uses microseconds without implementing automatic ABR.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, audio-video-rtc, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100