github bluenviron/mediamtx v1.21.3

2 hours ago

Fixes and improvements

General

  • http: restore support for HTTP2 requests (#6320) The server was not advertising the HTTP2 protocol in TLS ALPN anymore. Fix this.
  • forward: match destinations by configuration when reloading (#6299) ReloadConf compared the old and new destination lists by position, so removing a destination from the middle of the list shifted all the following ones, which were therefore considered changed and restarted (dropping and re-establishing their connections). Match destinations by their configuration instead: adding, removing or reordering destinations only starts or stops the affected ones, and the others keep running. The position reported by the API and used in logs is updated for the destinations that are kept.
  • avoid forward destination overlapping (#6324) When the configuration changes and forward destinations are changed, create new forward destinations only after closing existing ones, avoiding double publishers.
  • http: log outbound requests (#6325) log outbound HTTP requests with logLevel debug, in the same way as HTTP inbound requests are already logged.
  • fix race condition during logger recreation (#6206) (#6326) The logger can be dynamically recreated (for instance, this happens when changing the logLevel), but some components always need it, in particular hooks, which are not shut down unless the entire server is shutting down. Fix this issue by safely reloading the logger configuration without destroying it.
  • document link-local IPv6 zone encoding (#6327)
  • recorder: fix different time zones in record segment name (#5451) (#6333) Absolute timestamps of frames can have different time zones, in particular, timestamps from HLS sources arrive with their original time zone. When an absolute timestamp is not available, gohlslib uses time.Now(), which has the local time zone, resulting in streams with timestamps with different time zones. Timestamps are used in names of record segments, but they were not normalized and were written with their original time zone, causing confusion and errors in particular when the '%z' placeholder is not used. Fix the issue by normalizing every incoming date to the local time zone before using it as name of a segment.
  • add timezone to default recordPath and warn when not present (#6334) recordPath without %z causes segments to be overwritten or placed at wrong time during daylight saving time switches.
  • rtmp, recorder, stream: treat H264 recovery point SEI as random access (#6349) Streams without IDR frames use I slices with a recovery point SEI as random access points. The RTMP reader output and the fMP4 recorder only accepted IDR, and the unit remuxer only prepended SPS and PPS on IDR, so the DTS extractor never received an SPS. Use h264.IsRandomAccess, as the MPEG-TS outputs already do.
  • mpegts, rtmp: stop silently skipping H264 units without IDR and without non-IDR (#6354)
  • recorder: fix height of VP9 tracks in fMP4 recordings (#6359) The fMP4 recorder took the height of a VP9 track from the width in the key frame header, so the init segment declared a square size, for example 1920x1920 instead of 1920x804. Use the height instead.
  • docs: suggest to run MediaMTX in a writable folder (#6369) * when running in Docker, use /etc/mediamtx * when running in host Linux, use /usr/local/etc/mediamtx
  • recorder: fix timestamps of MPEG-1/2 Audio tracks in fMP4 recordings (#6361) The DTS of every sample was computed as the unit PTS plus the unit PTS, so sample durations in the recording were twice the real ones, and the frames of a unit that holds several of them got the same timestamp. Advance the PTS by the duration of each frame instead, and move the NTP of each frame by the same offset, as the Opus, MPEG-4 Audio and AC-3 cases do.
  • recorder: prevent a stream-time discontinuity from inflating fMP4 segment duration (#5984) When an RTP timestamp discontinuity occurs (e.g. after a burst of packet loss), the gap between two consecutive samples can be enormous. In the fMP4 recorder that gap is written as the preceding sample's duration (sample.Duration = nextSample.dts - sample.dts), which pushes the segment's endDTS -- and therefore the duration stamped into the mvhd header and reported to runOnRecordSegmentComplete -- forward by the size of the gap. The existing NTP-vs-stream-time drift detector (added in #5239) only fires on the next sample, by which point the inflated segment has already been flushed and reported (a ~1-minute clip reported as multiple hours). Detect the discontinuity one sample earlier: when the next sample's stream time has drifted from absolute time beyond the tolerance, zero the current sample's duration so the segment is not inflated. The drift detector then resets the recording on the following sample as before. mpegts is unaffected (it checks drift against the current sample before touching the segment). Complements #5126 (negative diff) and #5239 (drift reset).
  • close sessions when their JWT expires (#4300) (#5813) (#6389)
  • allow HTTP authentication to set a session expiration date (#6391)
  • record: fix segments never deleted when the configuration is reloaded often (#6256)
  • exit in case of fatal listening errors (#6415)
  • stream: fix 8-channel AAC always-available tracks refusing 7.1 publishers (#6414) With an always-available MPEG4Audio track of channelCount 8, a 7.1 AAC publisher is refused with "MPEG-4 audio configuration does not match". The track uses channel configuration 8, which is reserved, while the publisher's configuration is 7. Channel configuration 7 stands for 8 channels. Use configuration 7 for an 8-channel track. Other channel counts are unchanged.
  • fix routine leak in CertLoader (#6261) (#6417) make CertLoader.Close() to wait for CertLoader.watch()
  • mpegts: fix reading tracks with big video frames (bluenviron/mediacommon#393) (#4791) Big video frames delay audio packets, which are needed to parse tracks. Increase maximum buffer size to account for that.
  • mpegts: stop validating AC-3 / EAC-3 frames (bluenviron/mediacommon#395) Validating AC-3 / EAC-3 frames is not important for the MPEG-TS parser to work and decreases performance.

API

  • add endpoints to manage internal users (#6293) Add dedicated endpoints to manage specific users without the need of calling config/global/patch with the entire user list, in particular: /v3/config/internal-users/list /v3/config/internal-users/get/{id} /v3/config/internal-users/add /v3/config/internal-users/patch/{id} /v3/config/internal-users/replace/{id} /v3/config/internal-users/delete/{id}
  • prevent using internal-users/list with deprecated credentials (#6368)
  • fix global/patch with webrtcICEServers or credentials (#6362) (#6365) When the deprecated webrtcICEServers parameter is set, webrtcICEServers2 is filled automatically, but the latter prevents the former from being set through global/patch. Fix this. The same applies to deprecated credentials (readUser, readPass, publishUser, publishPass) and authInternalUsers.
  • expose users of MoQ sessions (#6390)
  • fix channel count of 8-channel MPEG-4 Audio tracks (#6405) When a path carries an MPEG-4 Audio track with channel configuration 7, for instance AAC in the 7.1 layout, the track is listed with "channelCount": 7 in the codecProps of the tracks2 field of the path API, while it has 8 channels. Tracks with 1 to 6 channels are listed correctly. Channel configuration 7 stands for 8 channels, while the values 1 to 6 are equal to the channel count. Report 8 for configuration 7.
  • add duration to fmp4 record segments (#6412)

Media-Over-QUIC

  • send client SETUP without waiting for server one (#6396)
  • log every inbound and outbound message (#6404)
  • fix channel count of 8-channel MPEG-4 Audio tracks (#6406) A MoQ client reading a 7.1 AAC path gets "channels": 7 in the catalog, while the track has 8 channels. A MoQ source or publisher sending "channels": 8 gets channel configuration 8, which is reserved. Channel configuration 7 stands for 8 channels. Report 8 for configuration 7 and use configuration 7 for 8 channels, so a relay of a 7.1 track keeps configuration 7. Other values are unchanged.
  • support draft-22, draft-21, draft-20 (#6403)

RTMP

  • preserve tcURL query when appending stream key (bluenviron/gortmplib#133) Parse the tcURL and stream key separately before joining their paths so existing tcURL query parameters remain attached to the final URL. Merge stream-key query parameters, preserve escaped paths, and avoid populating RawPath when no custom escaping is required.
  • support leading question mark in stream key (bluenviron/gortmplib#141)
  • Expose ErrReaderUnpublish to handle graceful shutdown on MediaMTX (bluenviron/gortmplib#139) * Expose ErrReaderUnpublish to handle graceful shutdown on MediaMTX * Add patch coverage to ErrReaderUnpublished

HLS

  • fix MPEG-TS variant failing on streams with Opus tracks (#6387) With hlsVariant set to mpegts, a stream that carries an Opus track, for instance H264 and Opus published through WebRTC, could not be read through HLS. The muxer failed to start with "the MPEG-TS variant of HLS supports MPEG-4 Audio only" and playlist requests got a 500 error, so the video was unreadable too, while other tracks that HLS cannot carry are skipped with a warning. Skip the audio tracks that are not MPEG-4 Audio when the variant is MPEG-TS, as setupDataTracks already does for KLV tracks. A stream whose only track is such an audio track now returns ErrNoSupportedCodecs instead of failing when the muxer starts.
  • fix MPEG-TS variant failing on streams with several audio tracks (#6394) With hlsVariant set to mpegts, a stream that carries two MPEG-4 Audio tracks, for instance H264 and two AAC tracks received through MPEG-TS over SRT, could not be read through HLS. The muxer failed to start with "the MPEG-TS variant of HLS supports a single audio track only" and playlist requests got a 500 error, so the video was unreadable too, while other tracks that HLS cannot carry are skipped with a warning. Skip the MPEG-4 Audio tracks that follow the first one when the variant is MPEG-TS, like the audio tracks of other codecs that this variant cannot carry.
  • muxer: support H264 recovery points (bluenviron/gohlslib#403)
  • muxer: stop silently skipping H264 units without IDR and without non-IDR (bluenviron/gohlslib#405)
  • add AI warning (bluenviron/gohlslib#406)

WebRTC

  • prevent using webrtcICEServers and webrtcICEServers2 together (#6367)

UDP

  • support interface=all for multicast sources (#6253) restore support for listening for UDP multicast packets on all multicast-capable network interfaces. To do so, add the interface=all parameter to the end of a UDP multicast URL when configuring the source.

RPI Camera

Dependencies

  • code.cloudfoundry.org/bytefmt updated from v0.92.0 to v0.95.0
  • github.com/bluenviron/gohlslib/v2 updated from v2.4.6 to v2.4.7
  • github.com/bluenviron/gortmplib updated from v1.0.4 to v1.0.5
  • github.com/bluenviron/mediacommon/v2 updated from v2.9.6 to v2.9.7
  • github.com/gookit/color updated from v1.6.1 to v1.6.3
  • github.com/matthewhartstonge/argon2 updated from v1.6.3 to v1.6.4
  • github.com/pion/ice/v4 updated from v4.4.5 to v4.4.8
  • github.com/pion/webrtc/v4 updated from v4.2.22 to v4.2.24
  • github.com/pires/go-proxyproto updated from v0.15.0 to v0.16.0
  • github.com/quic-go/quic-go updated from v0.63.0 to v0.64.1
  • golang.org/x/crypto updated from v0.57.0 to v0.58.0
  • golang.org/x/sync updated from v0.23.0 to v0.24.0
  • golang.org/x/sys updated from v0.48.0 to v0.49.0
  • golang.org/x/term updated from v0.46.0 to v0.47.0
  • github.com/pion/dtls/v3 updated from v3.1.9 to v3.1.13
  • github.com/pion/sctp updated from v1.11.3 to v1.12.0
  • golang.org/x/net updated from v0.59.0 to v0.61.0
  • golang.org/x/text updated from v0.42.0 to v0.43.0
  • github.com/bluenviron/mediamtx-rpicamera updated from v2.9.0 to v2.9.1

Security

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 also published in a public blockchain by using GitHub Attestations, and they can be verified by running:

ls mediamtx_* | xargs -L1 gh attestation verify --repo bluenviron/mediamtx

You can verify checksums of binaries by downloading checksums.sha256 and running:

cat checksums.sha256 | grep "$(ls mediamtx_*)" | sha256sum --check

Don't miss a new mediamtx release

NewReleases is sending notifications on new releases.