Configuration
MediaMTX can be configured through parameters that are listed and commented in the configuration file (mediamtx.yml).
Change the configuration
There are several ways to change configuration parameters:
Edit the configuration file.
When installing the server as a standalone binary, the configuration file is included into the release bundle.
When installing the server as a Docker container, you need to download the configuration file in a local folder, mount the folder and point
MediaMTXto the file in the folder:mkdir config wget https://raw.githubusercontent.com/bluenviron/mediamtx/v1.21.0/mediamtx.yml -O config/mediamtx.yml docker run --rm -it \ -p 8554:8554 \ -p 1935:1935 \ -p 8888:8888 \ -p 8889:8889 \ -p 8892:8892 \ -p 8890:8890/udp \ -p 8189:8189/udp \ -p 8892:8892/udp \ -p 8893:8893/udp \ -v "$PWD/config:/config" \ -w /config \ bluenviron/mediamtx:1 ./mediamtx.ymlYou can edit the configuration file when the server is running (hot reloading). Changes are detected and applied without disconnecting existing clients, whenever it’s possible.
Use environment variables, in the format
MTX_PARAMNAME, wherePARAMNAMEis the uppercase name of a parameter. For instance, thertspAddressparameter can be overridden in the following way:MTX_RTSPADDRESS="127.0.0.1:8554" ./mediamtxParameters that have array as value can be overridden by setting a comma-separated list. For example:
MTX_RTSPTRANSPORTS="tcp,udp"Parameters in maps can be overridden by using underscores, in the following way:
MTX_PATHS_TEST_SOURCE=rtsp://myurl ./mediamtxParameters in lists can be overridden in the same way as parameters in maps, using their position like an additional key. This is particularly useful if you want to use internal users but define credentials through environment variables:
MTX_AUTHINTERNALUSERS_0_USER=username MTX_AUTHINTERNALUSERS_0_PASS=passwordThis method is particularly useful when using Docker; any configuration parameter can be changed by passing environment variables with the
-eflag:docker run --rm -it \ --network=host \ -e MTX_PATHS_TEST_SOURCE=rtsp://myurl \ bluenviron/mediamtx:1Use the Control API.
Validate the configuration
You can validate a configuration file without starting the server:
./mediamtx --validate-conf=/path/to/mediamtx.ymlEncrypt the configuration
The configuration file can be entirely encrypted for security purposes by using the crypto_secretbox function of the NaCL library. An online tool for performing this operation is available here.
After performing the encryption, put the base64-encoded result into the configuration file, and launch the server with the MTX_CONFKEY variable:
MTX_CONFKEY=mykey ./mediamtx