RTSP source should support filtering media types before SETUP, like FFmpeg `-allowed_media_types video`
Describe the feature
Hi,
I’d like to report a compatibility gap in the RTSP source handling.
When MediaMTX connects to an RTSP source that exposes multiple media types in its SDP, it currently sends SETUP for all advertised tracks, including audio, application, and metadata tracks such as vnd.onvif.metadata.
This is a problem for some sources because it creates unnecessary or unwanted SETUP requests for non-video tracks, and in some cases those tracks should be ignored entirely.
Example
A source may return SDP like:
m=video
a=control:stream=0
m=application
a=rtpmap:107 vnd.onvif.metadata/90000
a=control:stream=1Current MediaMTX behavior:
DESCRIBE
SETUP stream=0
SETUP stream=1
PLAYWhat we need is behavior equivalent to FFmpeg:
ffmpeg -allowed_media_types video ...which results in only:
DESCRIBE
SETUP stream=0
PLAYand ignores:
m=audiom=applicationvnd.onvif.metadata- any non-video media
Why this matters
This is important for RTSP interoperability with devices and servers that expose auxiliary tracks but are intended to be consumed as video-only sources.
A video-only selection mode would:
- avoid unnecessary
SETUPrequests - prevent issues with unsupported or noisy metadata tracks
- align MediaMTX behavior more closely with FFmpeg’s RTSP client behavior
- improve compatibility with RTSP cameras and servers that expose extra media streams
Suggested solution
It would be very useful to add a configuration option such as:
allowedMediaTypes:
- videoor a simpler shortcut like:
videoOnly: trueThis should be applied before track setup, so that non-video tracks are never SETUP at all.
Expected behavior
When video-only filtering is enabled, MediaMTX should:
- parse the SDP as usual
- inspect the available media tracks
- only issue
SETUPfor video tracks - ignore all other media types completely
Additional note
This feature would be particularly valuable for RTSP sources that include ONVIF metadata or other auxiliary application streams, where only the video track is actually needed.
Thanks for considering this improvement.
Source: bluenviron/mediamtx