docs/2-features/05-configuration.md
MediaMTX can be configured through parameters that are listed and commented in the configuration file (mediamtx.yml).
There are several ways to change configuration parameters:
Edit the configuration file, that is
included into the release bundle
available in the root folder of the Docker image (/mediamtx.yml); it can be overridden in this way:
docker run --rm -it --network=host -v "$PWD/mediamtx.yml:/mediamtx.yml:ro" bluenviron/mediamtx:1
The configuration can be changed dynamically when the server is running (hot reloading) by writing to the configuration file. Changes are detected and applied without disconnecting existing clients, whenever it's possible.
Use environment variables, in the format MTX_PARAMNAME, where PARAMNAME is the uppercase name of a parameter. For instance, the rtspAddress parameter can be overridden in the following way:
MTX_RTSPADDRESS="127.0.0.1:8554" ./mediamtx
Parameters 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 ./mediamtx
Parameters 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=password
This method is particularly useful when using Docker; any configuration parameter can be changed by passing environment variables with the -e flag:
docker run --rm -it --network=host -e MTX_PATHS_TEST_SOURCE=rtsp://myurl bluenviron/mediamtx:1
Use the Control API.
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