change name of configuration file (#1640)

This commit is contained in:
Alessandro Ros 2023-04-01 19:32:10 +02:00 committed by GitHub
parent aae8eb943e
commit f5fd89d3b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 30 deletions

View File

@ -212,17 +212,17 @@ Please keep in mind that the Docker image doesn't include _FFmpeg_. if you need
### Configuration
All the configuration parameters are listed and commented in the [configuration file](rtsp-simple-server.yml).
All the configuration parameters are listed and commented in the [configuration file](mediamtx.yml).
There are 3 ways to change the configuration:
1. By editing the `rtsp-simple-server.yml` file, that is
1. By editing the `mediamtx.yml` file, that is
* included into the release bundle
* available in the root folder of the Docker image (`/rtsp-simple-server.yml`); it can be overridden in this way:
* 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/rtsp-simple-server.yml:/rtsp-simple-server.yml aler9/rtsp-simple-server
docker run --rm -it --network=host -v $PWD/mediamtx.yml:/mediamtx.yml aler9/rtsp-simple-server
```
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.
@ -254,7 +254,7 @@ There are 3 ways to change the configuration:
### Authentication
Edit `rtsp-simple-server.yml` and replace everything inside section `paths` with the following content:
Edit `mediamtx.yml` and replace everything inside section `paths` with the following content:
```yml
paths:
@ -359,7 +359,7 @@ _rtsp-simple-server_ is also a proxy, that is usually deployed in one of these s
* when there are multiple users that are reading a stream and the bandwidth is limited; the proxy is used to receive the stream once. Users can then connect to the proxy instead of the original source.
* when there's a NAT / firewall between a stream and the users; the proxy is installed on the NAT and makes the stream available to the outside world.
Edit `rtsp-simple-server.yml` and replace everything inside section `paths` with the following content:
Edit `mediamtx.yml` and replace everything inside section `paths` with the following content:
```yml
paths:
@ -390,7 +390,7 @@ paths:
### Remuxing, re-encoding, compression
To change the format, codec or compression of a stream, use _FFmpeg_ or _GStreamer_ together with _rtsp-simple-server_. For instance, to re-encode an existing stream, that is available in the `/original` path, and publish the resulting stream in the `/compressed` path, edit `rtsp-simple-server.yml` and replace everything inside section `paths` with the following content:
To change the format, codec or compression of a stream, use _FFmpeg_ or _GStreamer_ together with _rtsp-simple-server_. For instance, to re-encode an existing stream, that is available in the `/original` path, and publish the resulting stream in the `/compressed` path, edit `mediamtx.yml` and replace everything inside section `paths` with the following content:
```yml
paths:
@ -415,7 +415,7 @@ In the configuratio above, streams are saved into TS files, that can be read eve
### On-demand publishing
Edit `rtsp-simple-server.yml` and replace everything inside section `paths` with the following content:
Edit `mediamtx.yml` and replace everything inside section `paths` with the following content:
```yml
paths:
@ -436,7 +436,7 @@ Download a release bundle from the [release page](https://github.com/aler9/rtsp-
```
sudo mv rtsp-simple-server /usr/local/bin/
sudo mv rtsp-simple-server.yml /usr/local/etc/
sudo mv mediamtx.yml /usr/local/etc/
```
Create the service:
@ -446,7 +446,7 @@ sudo tee /etc/systemd/system/rtsp-simple-server.service >/dev/null << EOF
[Unit]
Wants=network.target
[Service]
ExecStart=/usr/local/bin/rtsp-simple-server /usr/local/etc/rtsp-simple-server.yml
ExecStart=/usr/local/bin/rtsp-simple-server /usr/local/etc/mediamtx.yml
[Install]
WantedBy=multi-user.target
EOF
@ -606,7 +606,7 @@ The command will produce tarballs in folder `binaries/`.
### From a webcam
To publish the video stream of a generic webcam to the server, edit `rtsp-simple-server.yml` and replace everything inside section `paths` with the following content:
To publish the video stream of a generic webcam to the server, edit `mediamtx.yml` and replace everything inside section `paths` with the following content:
```yml
paths:
@ -649,7 +649,7 @@ If you want to run the standard (non-containerized) version of the server:
2. download the server executable. If you're using 64-bit version of the operative system, make sure to pick the `arm64` variant.
3. edit `rtsp-simple-server.yml` and replace everything inside section `paths` with the following content:
3. edit `mediamtx.yml` and replace everything inside section `paths` with the following content:
```yml
paths:
@ -681,7 +681,7 @@ paths:
rpiCameraHeight: 1080
```
All available parameters are listed in the [sample configuration file](https://github.com/aler9/rtsp-simple-server/blob/master/rtsp-simple-server.yml#L230).
All available parameters are listed in the [sample configuration file](https://github.com/aler9/rtsp-simple-server/blob/master/mediamtx.yml#L230).
### From OBS Studio
@ -774,7 +774,7 @@ videotestsrc ! video/x-raw,width=1280,height=720 ! x264enc speed-preset=ultrafas
audiotestsrc ! audioconvert ! avenc_aac ! mux.
```
Edit `rtsp-simple-server.yml` and replace everything inside section `paths` with the following content:
Edit `mediamtx.yml` and replace everything inside section `paths` with the following content:
```yml
paths:
@ -878,7 +878,7 @@ openssl genrsa -out server.key 2048
openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
```
Edit `rtsp-simple-server.yml`, and set the `protocols`, `encryption`, `serverKey` and `serverCert` parameters:
Edit `mediamtx.yml`, and set the `protocols`, `encryption`, `serverKey` and `serverCert` parameters:
```yml
protocols: [tcp]
@ -992,7 +992,7 @@ openssl genrsa -out server.key 2048
openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
```
Edit `rtsp-simple-server.yml`, and set the `rtmpEncryption`, `rtmpServerKey` and `rtmpServerCert` parameters:
Edit `mediamtx.yml`, and set the `rtmpEncryption`, `rtmpServerKey` and `rtmpServerCert` parameters:
```yml
rtmpEncryption: optional

View File

@ -40,9 +40,17 @@ func decrypt(key string, byts []byte) ([]byte, error) {
}
func loadFromFile(fpath string, conf *Conf) (bool, error) {
// rtsp-simple-server.yml is optional
if fpath == "mediamtx.yml" {
// give priority to the legacy configuration file, in order not to break
// existing setups
if _, err := os.Stat("rtsp-simple-server.yml"); err == nil {
fpath = "rtsp-simple-server.yml"
}
}
// mediamtx.yml is optional
// other configuration files are not
if fpath == "rtsp-simple-server.yml" {
if fpath == "mediamtx.yml" || fpath == "rtsp-simple-server.yml" {
if _, err := os.Stat(fpath); err != nil {
return false, nil
}
@ -53,7 +61,14 @@ func loadFromFile(fpath string, conf *Conf) (bool, error) {
return true, err
}
if key, ok := os.LookupEnv("RTSP_CONFKEY"); ok {
if key, ok := os.LookupEnv("RTSP_CONFKEY"); ok { // legacy format
byts, err = decrypt(key, byts)
if err != nil {
return true, err
}
}
if key, ok := os.LookupEnv("MTX_CONFKEY"); ok {
byts, err = decrypt(key, byts)
if err != nil {
return true, err

View File

@ -118,7 +118,7 @@ func TestConfFromEnvOnly(t *testing.T) {
os.Setenv("RTSP_PATHS_CAM1_SOURCE", "rtsp://testing")
defer os.Unsetenv("RTSP_PATHS_CAM1_SOURCE")
conf, hasFile, err := Load("rtsp-simple-server.yml")
conf, hasFile, err := Load("mediamtx.yml")
require.NoError(t, err)
require.Equal(t, false, hasFile)

View File

@ -52,7 +52,7 @@ type Core struct {
var cli struct {
Version bool `help:"print version"`
Confpath string `arg:"" default:"rtsp-simple-server.yml"`
Confpath string `arg:"" default:"mediamtx.yml"`
}
// New allocates a core.
@ -63,7 +63,7 @@ func New(args []string) (*Core, bool) {
kong.ValueFormatter(func(value *kong.Value) string {
switch value.Name {
case "confpath":
return "path to a config file. The default is rtsp-simple-server.yml."
return "path to a config file. The default is mediamtx.yml."
default:
return kong.DefaultHelpValueFormatter(value)

View File

@ -24,30 +24,30 @@ ENV VERSION $(shell git describe --tags)
ENV CGO_ENABLED 0
RUN rm -rf binaries
RUN mkdir tmp binaries
RUN cp rtsp-simple-server.yml LICENSE tmp/
RUN cp mediamtx.yml LICENSE tmp/
RUN GOOS=windows GOARCH=amd64 go build -ldflags "-X github.com/aler9/rtsp-simple-server/internal/core.version=$$VERSION" -o tmp/rtsp-simple-server.exe
RUN cd tmp && zip -q ../binaries/rtsp-simple-server_$${VERSION}_windows_amd64.zip rtsp-simple-server.exe rtsp-simple-server.yml LICENSE
RUN cd tmp && zip -q ../binaries/rtsp-simple-server_$${VERSION}_windows_amd64.zip rtsp-simple-server.exe mediamtx.yml LICENSE
RUN GOOS=linux GOARCH=amd64 go build -ldflags "-X github.com/aler9/rtsp-simple-server/internal/core.version=$$VERSION" -o tmp/rtsp-simple-server
RUN tar -C tmp -czf binaries/rtsp-simple-server_$${VERSION}_linux_amd64.tar.gz --owner=0 --group=0 rtsp-simple-server rtsp-simple-server.yml LICENSE
RUN tar -C tmp -czf binaries/rtsp-simple-server_$${VERSION}_linux_amd64.tar.gz --owner=0 --group=0 rtsp-simple-server mediamtx.yml LICENSE
RUN GOOS=darwin GOARCH=amd64 go build -ldflags "-X github.com/aler9/rtsp-simple-server/internal/core.version=$$VERSION" -o tmp/rtsp-simple-server
RUN tar -C tmp -czf binaries/rtsp-simple-server_$${VERSION}_darwin_amd64.tar.gz --owner=0 --group=0 rtsp-simple-server rtsp-simple-server.yml LICENSE
RUN tar -C tmp -czf binaries/rtsp-simple-server_$${VERSION}_darwin_amd64.tar.gz --owner=0 --group=0 rtsp-simple-server mediamtx.yml LICENSE
COPY --from=rpicamera32 /s/internal/rpicamera/exe/exe internal/rpicamera/exe/
RUN GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "-X github.com/aler9/rtsp-simple-server/internal/core.version=$$VERSION" -o tmp/rtsp-simple-server -tags rpicamera
RUN tar -C tmp -czf binaries/rtsp-simple-server_$${VERSION}_linux_armv6.tar.gz --owner=0 --group=0 rtsp-simple-server rtsp-simple-server.yml LICENSE
RUN tar -C tmp -czf binaries/rtsp-simple-server_$${VERSION}_linux_armv6.tar.gz --owner=0 --group=0 rtsp-simple-server mediamtx.yml LICENSE
RUN rm internal/rpicamera/exe/exe
COPY --from=rpicamera32 /s/internal/rpicamera/exe/exe internal/rpicamera/exe/
RUN GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-X github.com/aler9/rtsp-simple-server/internal/core.version=$$VERSION" -o tmp/rtsp-simple-server -tags rpicamera
RUN tar -C tmp -czf binaries/rtsp-simple-server_$${VERSION}_linux_armv7.tar.gz --owner=0 --group=0 rtsp-simple-server rtsp-simple-server.yml LICENSE
RUN tar -C tmp -czf binaries/rtsp-simple-server_$${VERSION}_linux_armv7.tar.gz --owner=0 --group=0 rtsp-simple-server mediamtx.yml LICENSE
RUN rm internal/rpicamera/exe/exe
COPY --from=rpicamera64 /s/internal/rpicamera/exe/exe internal/rpicamera/exe/
RUN GOOS=linux GOARCH=arm64 go build -ldflags "-X github.com/aler9/rtsp-simple-server/internal/core.version=$$VERSION" -o tmp/rtsp-simple-server -tags rpicamera
RUN tar -C tmp -czf binaries/rtsp-simple-server_$${VERSION}_linux_arm64v8.tar.gz --owner=0 --group=0 rtsp-simple-server rtsp-simple-server.yml LICENSE
RUN tar -C tmp -czf binaries/rtsp-simple-server_$${VERSION}_linux_arm64v8.tar.gz --owner=0 --group=0 rtsp-simple-server mediamtx.yml LICENSE
RUN rm internal/rpicamera/exe/exe
endef
export DOCKERFILE_BINARIES

View File

@ -8,7 +8,7 @@ COPY . ./
RUN go build -o /out .
WORKDIR /
ARG CONFIG_RUN
RUN echo "$$CONFIG_RUN" > rtsp-simple-server.yml
RUN echo "$$CONFIG_RUN" > mediamtx.yml
endef
export DOCKERFILE_RUN