Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change name of configuration file #1640

Merged
merged 1 commit into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
21 changes: 18 additions & 3 deletions internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/conf/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions internal/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions scripts/binaries.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/run.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down