New features
API
- Add forwardDestCount to paths. The paths endpoints now return the number of forward destinations, so it can be read without calling /forward-dests/list. (#6499)
- Add search parameter to path and user lists. /paths/list, /config/internal-users/list and /config/paths/list accept a "search=TEXT" parameter that filters items without downloading every page. (#6498)
- Add endpoints to list and get path readers. New /path/readers/list and /path/readers/get endpoints return the readers of a path on demand and in a paginated way. The "reader" field of /paths/list and /paths/get is deprecated, and a "readerCount" field is added to both. (#6500)
- Support kicking RTSP connections through the API. RTSP connections can now be kicked with an API request. (#6545)
- Add recording to path status. The path status returned by the API now reports whether the path is being recorded. (#6557)
RTSP
- Support kicking RTSP connections through the API. RTSP connections can now be kicked with an API request. (#6545)
RTSP (from gortsplib)
- Send path and query over the RTSP WebSocket tunnel and add a hook for tunnel HTTP requests. The WebSocket tunnel now requests the stream's path and query, as the HTTP tunnel already did, instead of always requesting "/". This fixes RTSP sources that use the WebSocket tunnel with a path or query. The client also gains
OnHTTPRequest, which receives each HTTP request that opens a tunnel so a caller can change it, for example to add headers needed by a proxy or load balancer. (bluenviron/gortsplib#1222) (bluenviron/gortsplib#1228)
HLS
- Use hls:// and hlss:// schemes in sources. HLS sources can now be declared with hls:// and hlss:// URLs, since HTTP is no longer tied to HLS. The previous schemes still work. (#6591)
SRT
- Support dumping unencrypted SRT content. When dumpPackets is enabled, the unencrypted SRT content is dumped to disk. (#6526)
Fixes and improvements
General
- Allow requests without Origin when all origins are allowed. HTTP requests that carry no Origin header are no longer rejected when all origins are allowed. (#6497)
- Log every hook command consistently. The disconnect, unread, on-demand, unavailable, offline and record-segment hooks now log failures. "command started", "command stopped" and "command exited with error" are printed automatically for every kind of hook. (#6259) (#6502)
- Sanitize the Location header further. Control characters are now trimmed from the Location header, which prevents open redirect attacks. (#6520)
- Include RTP header extensions in the packet size limit. The maximum payload size is now computed per stream and takes RTP header extensions into account, instead of being a constant. (#6517) (#6524)
- Do not set path.stream when stream initialization fails. A failed stream initialization no longer leaves a half-initialized stream on the path. (#6529)
- Fix routine leak when alwaysAvailable fails. When the offline sub-stream fails to start, the inboundFramesInError routine is now stopped and tracked. (#6530)
- Prevent loading NaN and Inf values from environment variables. Environment parsing now discards these values, as JSON and YAML already do. (#6533)
- Validate alwaysAvailableTracks loaded through environment variables. Values set this way were not validated before. (#6532)
- Stop producing armv6 Docker images. Docker no longer supports armv6. (#6510)
- Deprecate the "id" metrics label. Metrics are meant to provide aggregate statistics, so use the API for specific details. (#6538)
- Rename metrics "tags" into "labels". The terminology in the metrics output and documentation now says "labels". (#6539)
- Deprecate apiAllowOrigins, metricsAllowOrigins and pprofAllowOrigins. These options could expose sensitive information or allow control of the server when misconfigured. To reach the API, metrics or pprof from a browser, use a reverse proxy. (#6528)
- Stop playback /get and /list when the client disconnects. Previously a disconnection was not detected until all parts had been read from disk. (#6564)
- Limit parallel segment reads in playback /list. At most 16 segments are read at once, and the remaining ones are skipped when the request is cancelled. This avoids "thread exhaustion" crashes on slow storage. (#6446) (#6447)
- Validate pathDefaults. Most values in pathDefaults are now validated, so rules are enforced consistently. (#6586)
- Prevent sourceRedirect and fallback from containing credentials. This avoids passing plain credentials to users, since they are currently unredacted in the API. (#6585)
- Fix panic when the scheme of a forward URL is not lowercase. Redirect URLs are also checked for lowercase schemes to prevent similar issues. (#6588)
- Allow colons in the password passed in Authorization Bearer. Passwords containing colons now work with Bearer authentication. (#6597)
- Prevent credential bypass with legacy credentials. When readUser, readPass, publishUser or publishPass are in use, a catch-all regexp path can no longer generate empty credentials that replace the intended ones. (#6578)
General (from mediacommon)
- Fix MPEG-TS support for several AC-3 / EAC-3 frames in a PES packet. The MPEG-TS parser assumed one frame per PES packet, but a PES packet can hold several AC-3 / EAC-3 frames. It now handles that case, so MPEG-TS streams with such audio are read correctly. (bluenviron/mediacommon#412)
- Reject zero sample rates in audio parsers. MPEG-4 audio AudioSpecificConfig, FLAC StreamInfo and MP4 parsing now refuse a zero clock rate or sample rate. Such values caused problems in downstream components when MediaMTX read streams with malformed audio configurations. (bluenviron/mediacommon#414) (bluenviron/mediacommon#415) (bluenviron/mediacommon#416)
- Fix DTS extraction for interlaced H264 frame pictures. With
frame_mbs_only_flag = 0the DTS extractor returned DTS = PTS, so DTS went backwards on streams with B-frames, for example interlaced x264 streams using MBAFF. Readers such as RTMP, SRT and the HLS muxer then failed with "DTS is not monotonically increasing". The slice header parser now readsfield_pic_flag,bottom_field_flagandcolour_plane_id, and treats frame pictures like progressive ones. Field pictures (PAFF) keep the previous behavior. (bluenviron/mediacommon#413) - Reject empty payloads when decoding JPEG, LATM and ADTS data. Decoding a JPEG DefineQuantizationTable, an AudioSyncStream or an ADTS frame without a payload now returns an error, and AudioMuxElement no longer returns empty payloads. This stops malformed input from producing empty frames downstream. (bluenviron/mediacommon#426) (bluenviron/mediacommon#425) (bluenviron/mediacommon#424) (bluenviron/mediacommon#423)
- Reduce copies when writing fMP4 parts. Part samples and data offsets are now written without extra copies, which lowers CPU and memory use when MediaMTX muxes fMP4 for HLS and for recordings. (bluenviron/mediacommon#417)
API
- Rename RTSP fields in the API. The transport and profile fields are renamed to transportProtocol and transportProfile. (#6501)
- Fix documented API response codes. The undocumented code 401 is added, code 400 is removed from two endpoints where it was wrongly documented, and the definitions of 500, 401 and 400 are shared. (#6546)
- Fix openapi.yaml generation. Deprecated fields such as serverKey and serverCert are now present, and every field is written whether it is omitted or deprecated. (#6562) (#6563)
- Fix restoring redacted readPass and publishPass. When either is set to "" through the API, its original value is now restored. (#6581)
Media-over-QUIC
- Prevent AAC tracks from having a zero sample rate. AAC tracks with a zero sample rate are now rejected. (#6531)
- Add read and write deadlines. MoQ connections now use read and write deadlines. (#6536)
- Fix crash when reloading the configuration of a path with a MoQ source. Reloading no longer crashes the server. (#6567)
RTSP
- Rename RTSP fields in the API. The transport and profile fields are renamed to transportProtocol and transportProfile. (#6501)
- Remove the reader from the path when a SETUP request is rejected. A reader whose SETUP request was rejected is no longer left on the path. (#6568)
- Fix crash when rtspUDPSourcePortRange does not contain 2 values. This misconfiguration no longer crashes the server. (#6587)
- Fix disconnect detection and freeze in rtspDemuxMpegts mode. Disconnects and timeouts are now detected in MPEG-TS demux mode. The demuxer pipe is closed when the demuxer exits, so a blocked RTP callback can no longer freeze the source and stop it from reconnecting. (#6595) (#6598)
RTSP (from gortsplib)
- Accept RTSP PLAY requests sent to the media URL. Some clients send PLAY to the media URL used in SETUP (
rtsp://host/path/trackID=0) instead of the aggregate URL. SETUP stripped the/trackID=Nsuffix but PLAY did not, so the server rejected these requests with "path has changed". The server now strips the suffix in PLAY too and accepts them. (#6264) (bluenviron/gortsplib#1223) - Support colons in Basic authentication passwords. The
Authorizationheader parser split the decoded credentials on every colon, so passwords containing ":" were rejected. It now splits only on the first colon, as RFC 7617 requires. This lets MediaMTX's RTSP server authenticate users whose passwords contain colons. (bluenviron/gortsplib#1243) - Split H265 units by timestamp. The H265 RTP decoder now separates access units by RTP timestamp, as the H264 decoder already did. This fixes support for some thermal cameras. (#6512) (bluenviron/gortsplib#1227)
- Improve performance of H264, H265 and MJPEG RTP encoders. The H264 encoder now allocates all fragments of a NALU at once, and the same technique is applied to the H265 and MJPEG encoders. This reduces allocations when MediaMTX re-packetizes these codecs. (bluenviron/gortsplib#1234) (bluenviron/gortsplib#1247)
- Fix RTSP HTTP tunnel when the POST arrives before the GET. The server previously handled the tunnel incorrectly when the client's POST connection came before its GET connection. It now supports either order. (bluenviron/gortsplib#1238) (bluenviron/gortsplib#1239) (bluenviron/gortsplib#1249)
RTMP (from gortmplib)
- Fix stack overflow when decoding AMF0 data. The AMF0 decoder now limits the nesting depth, so a maliciously crafted RTMP message with deeply nested objects can no longer crash the server through a stack overflow. (bluenviron/gortmplib#165)
- Fix encrypted RTMP writer modifying the input buffer. The RC4 read/writer used for encrypted RTMP connections (RTMPE) now follows the
io.Writercontract and never changes the buffer passed by the caller. (bluenviron/gortmplib#167)
HLS
- Retire the automatic HLS muxer before replacing a ready path. During a config reload, HLS is told the path is no longer ready before the path is removed. A replacement path with the same name can then create its own muxer immediately. (#6505)
HLS (from gohlslib)
- Fix partial writes when storing HLS parts on disk. The writer that saves HLS parts to both disk and memory now follows the
io.Writercontract. It returns the number of bytes actually written and mirrors only those bytes into the in-memory copy. Before, a failed or partial disk write could leave the disk and memory copies out of sync. This affects MediaMTX when HLS segments are stored on disk through the muxerDirectoryoption. (bluenviron/gohlslib#428)
WebRTC
- Limit reordering of audio tracks. Reordering and buffering of audio tracks is now strongly limited, since it only helps with packet inversion and audio has no NACK/RTX. (#6329)
- Close the peer on write errors. Write errors used to be ignored and now close the peer, which should prevent stuck connections. (#6521)
- Strip extensions from RTP packets. RTP extensions are not supported, because their meaning differs between RTSP and WebRTC and they might push the packet over the payload size limit. (#6523)
Dependencies
- code.cloudfoundry.org/bytefmt updated from v0.98.0 to v0.100.0
- github.com/MicahParks/jwkset updated from v0.11.4 to v0.12.0
- github.com/MicahParks/keyfunc/v3 updated from v3.9.1 to v3.9.2
- github.com/bluenviron/gohlslib/v2 updated from v2.4.8 to v2.4.9
- github.com/bluenviron/gortmplib updated from v1.0.6 to v1.0.7
- github.com/bluenviron/gortsplib/v5 updated from v5.7.0 to v5.7.1
- github.com/bluenviron/mediacommon/v2 updated from v2.10.0 to v2.10.1
- github.com/matthewhartstonge/argon2 updated from v1.6.4 to v1.6.5
- github.com/pion/datachannel updated from v1.6.3 to v1.6.4
- github.com/pion/dtls/v3 updated from v3.1.15 to v3.1.16
- github.com/pion/sctp updated from v1.12.0 to v1.12.1
- github.com/pion/transport/v5 updated from v5.1.5 to v5.1.6
- github.com/pion/webrtc/v4 updated from v4.2.26 to v4.2.29
- github.com/quic-go/quic-go updated from v0.64.1 to v0.66.0
- golang.org/x/crypto updated from v0.58.0 to v0.59.0
- golang.org/x/net updated from v0.62.0 to v0.63.0
Security of released binaries
Binaries are compiled from source code by the Release workflow, which is a fully-visible process that prevents any change or external interference in produced artifacts.
Checksums of binaries are published in a public blockchain by using GitHub Attestations and can be verified by running:
ls mediamtx_* | xargs -L1 gh attestation verify --repo bluenviron/mediamtx