enable runOnDemandRestart by default (#3605)

This commit is contained in:
Alessandro Ros 2024-08-03 20:51:54 +02:00 committed by GitHub
parent 012cc6c701
commit 547e56e82b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 3 additions and 4 deletions

View File

@ -1428,7 +1428,6 @@ Edit `mediamtx.yml` and replace everything inside section `paths` with the follo
paths:
ondemand:
runOnDemand: ffmpeg -re -stream_loop -1 -i file.ts -c copy -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH
runOnDemandRestart: yes
```
The command inserted into `runOnDemand` will start only when a client requests the path `ondemand`, therefore the file will start streaming only when requested.
@ -1588,8 +1587,6 @@ pathDefaults:
# * G1, G2, ...: regular expression groups, if path name is
# a regular expression.
runOnDemand: ffmpeg -i my_file.mp4 -c copy -f rtsp rtsp://localhost:8554/mypath
# Restart the command if it exits.
runOnDemandRestart: no
```
`runOnUnDemand` allows to run a command when there are no readers anymore:

View File

@ -77,6 +77,7 @@ func TestConfFromFile(t *testing.T) {
RPICameraAfRange: "normal",
RPICameraAfSpeed: "normal",
RPICameraTextOverlay: "%Y-%m-%d %H:%M:%S - MediaMTX",
RunOnDemandRestart: true,
RunOnDemandStartTimeout: 5 * StringDuration(time.Second),
RunOnDemandCloseAfter: 10 * StringDuration(time.Second),
}, pa)

View File

@ -220,6 +220,7 @@ func (pconf *Path) setDefaults() {
pconf.RPICameraTextOverlay = "%Y-%m-%d %H:%M:%S - MediaMTX"
// Hooks
pconf.RunOnDemandRestart = true
pconf.RunOnDemandStartTimeout = 10 * StringDuration(time.Second)
pconf.RunOnDemandCloseAfter = 10 * StringDuration(time.Second)
}

View File

@ -615,7 +615,7 @@ pathDefaults:
# a regular expression.
runOnDemand:
# Restart the command if it exits.
runOnDemandRestart: no
runOnDemandRestart: yes
# Readers will be put on hold until the runOnDemand command starts publishing
# or until this amount of time has passed.
runOnDemandStartTimeout: 10s