rename environment variable RTSP_PATH into MTX_PATH (#1967)

This commit is contained in:
Alessandro Ros 2023-06-21 16:08:37 +02:00 committed by GitHub
parent 815fa0586a
commit f79c4783c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 27 additions and 24 deletions

View file

@ -408,7 +408,7 @@ To change the format, codec or compression of a stream, use _FFmpeg_ or _GStream
paths: paths:
all: all:
original: original:
runOnReady: ffmpeg -i rtsp://localhost:$RTSP_PORT/$RTSP_PATH -pix_fmt yuv420p -c:v libx264 -preset ultrafast -b:v 600k -max_muxing_queue_size 1024 -f rtsp rtsp://localhost:$RTSP_PORT/compressed runOnReady: ffmpeg -i rtsp://localhost:$RTSP_PORT/$MTX_PATH -pix_fmt yuv420p -c:v libx264 -preset ultrafast -b:v 600k -max_muxing_queue_size 1024 -f rtsp rtsp://localhost:$RTSP_PORT/compressed
runOnReadyRestart: yes runOnReadyRestart: yes
``` ```
@ -419,7 +419,7 @@ To save available streams to disk, you can use the `runOnReady` parameter and _F
```yml ```yml
paths: paths:
mypath: mypath:
runOnReady: ffmpeg -i rtsp://localhost:$RTSP_PORT/$RTSP_PATH -c copy -f segment -strftime 1 -segment_time 60 -segment_format mpegts saved_%Y-%m-%d_%H-%M-%S.ts runOnReady: ffmpeg -i rtsp://localhost:$RTSP_PORT/$MTX_PATH -c copy -f segment -strftime 1 -segment_time 60 -segment_format mpegts saved_%Y-%m-%d_%H-%M-%S.ts
runOnReadyRestart: yes runOnReadyRestart: yes
``` ```
@ -432,7 +432,7 @@ Edit `mediamtx.yml` and replace everything inside section `paths` with the follo
```yml ```yml
paths: paths:
ondemand: ondemand:
runOnDemand: ffmpeg -re -stream_loop -1 -i file.ts -c copy -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH runOnDemand: ffmpeg -re -stream_loop -1 -i file.ts -c copy -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH
runOnDemandRestart: yes runOnDemandRestart: yes
``` ```
@ -623,7 +623,7 @@ To publish the video stream of a generic webcam to the server, edit `mediamtx.ym
```yml ```yml
paths: paths:
cam: cam:
runOnInit: ffmpeg -f v4l2 -i /dev/video0 -pix_fmt yuv420p -preset ultrafast -b:v 600k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH runOnInit: ffmpeg -f v4l2 -i /dev/video0 -pix_fmt yuv420p -preset ultrafast -b:v 600k -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH
runOnInitRestart: yes runOnInitRestart: yes
``` ```
@ -632,7 +632,7 @@ If the platform is Windows:
```yml ```yml
paths: paths:
cam: cam:
runOnInit: ffmpeg -f dshow -i video="USB2.0 HD UVC WebCam" -pix_fmt yuv420p -c:v libx264 -preset ultrafast -b:v 600k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH runOnInit: ffmpeg -f dshow -i video="USB2.0 HD UVC WebCam" -pix_fmt yuv420p -c:v libx264 -preset ultrafast -b:v 600k -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH
runOnInitRestart: yes runOnInitRestart: yes
``` ```

View file

@ -98,8 +98,8 @@ func TestConfFromFile(t *testing.T) {
} }
func TestConfFromFileAndEnv(t *testing.T) { func TestConfFromFileAndEnv(t *testing.T) {
os.Setenv("RTSP_PATHS_CAM1_SOURCE", "rtsp://testing") os.Setenv("MTX_PATHS_CAM1_SOURCE", "rtsp://testing")
defer os.Unsetenv("RTSP_PATHS_CAM1_SOURCE") defer os.Unsetenv("MTX_PATHS_CAM1_SOURCE")
os.Setenv("RTSP_PROTOCOLS", "tcp") os.Setenv("RTSP_PROTOCOLS", "tcp")
defer os.Unsetenv("RTSP_PROTOCOLS") defer os.Unsetenv("RTSP_PROTOCOLS")
@ -137,8 +137,8 @@ func TestConfFromFileAndEnv(t *testing.T) {
} }
func TestConfFromEnvOnly(t *testing.T) { func TestConfFromEnvOnly(t *testing.T) {
os.Setenv("RTSP_PATHS_CAM1_SOURCE", "rtsp://testing") os.Setenv("MTX_PATHS_CAM1_SOURCE", "rtsp://testing")
defer os.Unsetenv("RTSP_PATHS_CAM1_SOURCE") defer os.Unsetenv("MTX_PATHS_CAM1_SOURCE")
conf, hasFile, err := Load("mediamtx.yml") conf, hasFile, err := Load("mediamtx.yml")
require.NoError(t, err) require.NoError(t, err)

View file

@ -207,7 +207,7 @@ func main() {
source := gortsplib.Client{} source := gortsplib.Client{}
err := source.StartRecording( err := source.StartRecording(
"rtsp://localhost:" + os.Getenv("RTSP_PORT") + "/" + os.Getenv("RTSP_PATH"), "rtsp://localhost:" + os.Getenv("RTSP_PORT") + "/" + os.Getenv("MTX_PATH"),
media.Medias{medi}) media.Medias{medi})
if err != nil { if err != nil {
panic(err) panic(err)

View file

@ -541,7 +541,8 @@ func (pa *path) shouldClose() bool {
func (pa *path) externalCmdEnv() externalcmd.Environment { func (pa *path) externalCmdEnv() externalcmd.Environment {
_, port, _ := net.SplitHostPort(pa.rtspAddress) _, port, _ := net.SplitHostPort(pa.rtspAddress)
env := externalcmd.Environment{ env := externalcmd.Environment{
"RTSP_PATH": pa.name, "MTX_PATH": pa.name,
"RTSP_PATH": pa.name, // deprecated
"RTSP_PORT": port, "RTSP_PORT": port,
} }

View file

@ -296,7 +296,8 @@ func (c *rtmpConn) run() {
c.runOnConnect, c.runOnConnect,
c.runOnConnectRestart, c.runOnConnectRestart,
externalcmd.Environment{ externalcmd.Environment{
"RTSP_PATH": "", "MTX_PATH": "",
"RTSP_PATH": "", // deprecated
"RTSP_PORT": port, "RTSP_PORT": port,
}, },
func(err error) { func(err error) {

View file

@ -77,7 +77,8 @@ func newRTSPConn(
c.runOnConnect, c.runOnConnect,
c.runOnConnectRestart, c.runOnConnectRestart,
externalcmd.Environment{ externalcmd.Environment{
"RTSP_PATH": "", "MTX_PATH": "",
"RTSP_PATH": "", // deprecated
"RTSP_PORT": port, "RTSP_PORT": port,
}, },
func(err error) { func(err error) {

View file

@ -56,7 +56,7 @@ pprofAddress: 127.0.0.1:9999
# Prepend ./ to run an executable in the current folder (example: "./ffmpeg") # Prepend ./ to run an executable in the current folder (example: "./ffmpeg")
# This is terminated with SIGINT when a client disconnects from the server. # This is terminated with SIGINT when a client disconnects from the server.
# The following environment variables are available: # The following environment variables are available:
# * RTSP_PORT: server port # * RTSP_PORT: RTSP server port
runOnConnect: runOnConnect:
# Restart the command if it exits. # Restart the command if it exits.
runOnConnectRestart: no runOnConnectRestart: no
@ -410,8 +410,8 @@ paths:
# Prepend ./ to run an executable in the current folder (example: "./ffmpeg") # Prepend ./ to run an executable in the current folder (example: "./ffmpeg")
# This is terminated with SIGINT when the program closes. # This is terminated with SIGINT when the program closes.
# The following environment variables are available: # The following environment variables are available:
# * RTSP_PATH: path name # * MTX_PATH: path name
# * RTSP_PORT: server port # * RTSP_PORT: RTSP server port
# * G1, G2, ...: regular expression groups, if path name is # * G1, G2, ...: regular expression groups, if path name is
# a regular expression. # a regular expression.
runOnInit: runOnInit:
@ -423,8 +423,8 @@ paths:
# Prepend ./ to run an executable in the current folder (example: "./ffmpeg") # Prepend ./ to run an executable in the current folder (example: "./ffmpeg")
# This is terminated with SIGINT when the path is not requested anymore. # This is terminated with SIGINT when the path is not requested anymore.
# The following environment variables are available: # The following environment variables are available:
# * RTSP_PATH: path name # * MTX_PATH: path name
# * RTSP_PORT: server port # * RTSP_PORT: RTSP server port
# * G1, G2, ...: regular expression groups, if path name is # * G1, G2, ...: regular expression groups, if path name is
# a regular expression. # a regular expression.
runOnDemand: runOnDemand:
@ -442,8 +442,8 @@ paths:
# Prepend ./ to run an executable in the current folder (example: "./ffmpeg") # Prepend ./ to run an executable in the current folder (example: "./ffmpeg")
# This is terminated with SIGINT when the stream is not ready anymore. # This is terminated with SIGINT when the stream is not ready anymore.
# The following environment variables are available: # The following environment variables are available:
# * RTSP_PATH: path name # * MTX_PATH: path name
# * RTSP_PORT: server port # * RTSP_PORT: RTSP server port
# * G1, G2, ...: regular expression groups, if path name is # * G1, G2, ...: regular expression groups, if path name is
# a regular expression. # a regular expression.
runOnReady: runOnReady:
@ -454,8 +454,8 @@ paths:
# Prepend ./ to run an executable in the current folder (example: "./ffmpeg") # Prepend ./ to run an executable in the current folder (example: "./ffmpeg")
# This is terminated with SIGINT when a client stops reading. # This is terminated with SIGINT when a client stops reading.
# The following environment variables are available: # The following environment variables are available:
# * RTSP_PATH: path name # * MTX_PATH: path name
# * RTSP_PORT: server port # * RTSP_PORT: RTSP server port
# * G1, G2, ...: regular expression groups, if path name is # * G1, G2, ...: regular expression groups, if path name is
# a regular expression. # a regular expression.
runOnRead: runOnRead:

View file

@ -21,10 +21,10 @@ define CONFIG_RUN
paths: paths:
all: all:
# runOnReady: ffmpeg -i rtsp://localhost:$$RTSP_PORT/$$RTSP_PATH -c copy -f mpegts myfile_$$RTSP_PATH.ts # runOnReady: ffmpeg -i rtsp://localhost:$$RTSP_PORT/$$MTX_PATH -c copy -f mpegts myfile_$$MTX_PATH.ts
# readUser: test # readUser: test
# readPass: tast # readPass: tast
# runOnDemand: ffmpeg -re -stream_loop -1 -i testimages/ffmpeg/emptyvideo.mkv -c copy -f rtsp rtsp://localhost:$$RTSP_PORT/$$RTSP_PATH # runOnDemand: ffmpeg -re -stream_loop -1 -i testimages/ffmpeg/emptyvideo.mkv -c copy -f rtsp rtsp://localhost:$$RTSP_PORT/$$MTX_PATH
# proxied: # proxied:
# source: rtsp://192.168.2.198:554/stream # source: rtsp://192.168.2.198:554/stream