Support Regex Capture Groups in source for Dynamic RTSP Routing (original) (raw)
Describe the feature
Hi,
I would like to request support for using regex capture groups in the source field for dynamic RTSP routing in MediaMTX.
Current Behavior
Path regex matching currently works as expected, for example:
~^mycam/([^/]+)/([^/]+)/(.+)$
However, it is not possible to reuse the captured groups inside the source URL.
Example:
The values are interpreted literally, which results in errors such as DNS lookup failures for $1.
Expected Behavior
It would be very useful to support dynamic source definitions like:
Where:
$1= host$2= port$3= stream path
Example
Incoming request:
rtsp://proxy:8555/mycam/10.0.0.15/8554/stream1
Expected resolved source:
rtsp://10.0.0.15:8554/stream1
Why This Would Be Useful
This feature would:
- Enable dynamic RTSP proxying
- Remove the need for static configuration per camera
- Simplify large-scale CCTV / IoT deployments
- Avoid relying on external routing/proxy services
Workarounds Considered
Current alternatives are possible but not ideal:
- Static configuration per camera (not scalable)
- Regex path matching (works, but capture groups are not reusable in
source) - External proxy/resolver services (adds complexity)
Thanks for your work on MediaMTX.