Compile from source
Standard procedure
Install git and Go ≥ 1.25.
Clone the repository, enter into the folder and start the building process:
git clone https://github.com/bluenviron/mediamtx cd mediamtx go generate ./... CGO_ENABLED=0 go build .This will produce the
mediamtxbinary.
Custom libcamera
If you need to use a custom or external libcamera to interact with some Raspberry Pi Camera model that requires it, additional steps are required:
Download mediamtx-rpicamera source code and compile it against the external libcamera. Instructions are in the repository.
Install git and Go ≥ 1.25.
Clone the MediaMTX repository:
git clone https://github.com/bluenviron/mediamtxInside the MediaMTX folder, run:
go generate ./...Copy
build/mtxrpicam_32and/orbuild/mtxrpicam_64(depending on the architecture) frommediamtx-rpicameratomediamtx, inside folderinternal/staticsources/rpicamera/, overriding existing folders.Compile:
go run .This will produce the
mediamtxbinary.
Cross compile
Cross compilation allows to build an executable for a target machine from another machine with different operating system or architecture. This is useful in case the target machine doesn’t have enough resources for compilation or if you don’t want to install the compilation dependencies on it.
On the machine you want to use to compile, install git and Go ≥ 1.25.
Clone the repository, enter into the folder and start the building process:
git clone https://github.com/bluenviron/mediamtx cd mediamtx go generate ./... CGO_ENABLED=0 GOOS=my_os GOARCH=my_arch go build .Replace
my_osandmy_archwith the operating system and architecture of your target machine. A list of all supported combinations can be obtained with:go tool dist listFor instance:
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build .In case of the
armarchitecture, there’s an additional flag available,GOARM, that allows to set the ARM version:CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GOARM=7 go build .In case of the
mipsarchitecture, there’s an additional flag available,GOMIPS, that allows to set additional parameters:CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build .The command will produce the
mediamtxbinary.
Compile for all supported platforms
Install Docker and launch:
make binariesThe command will produce tarballs in folder binaries/.
Docker image
The official Docker image can be recompiled by following these steps:
Build binaries for all supported platforms:
make binariesBuild the image by using one of the Dockerfiles inside the
docker/folder:docker build . -f docker/standard.Dockerfile -t my-mediamtxThis will produce the
my-mediamtximage.A Dockerfile is available for each image variant (
standard.Dockerfile,ffmpeg.Dockerfile,rpi.Dockerfile,ffmpeg-rpi.Dockerfile).