diff --git a/README.md b/README.md index a239d026..a931ce0f 100644 --- a/README.md +++ b/README.md @@ -1428,6 +1428,7 @@ 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. @@ -1587,6 +1588,8 @@ 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: diff --git a/internal/conf/conf_test.go b/internal/conf/conf_test.go index 6b5d2727..0c26086c 100644 --- a/internal/conf/conf_test.go +++ b/internal/conf/conf_test.go @@ -77,7 +77,6 @@ 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) diff --git a/internal/conf/path.go b/internal/conf/path.go index 4c6d9cb9..925f050f 100644 --- a/internal/conf/path.go +++ b/internal/conf/path.go @@ -220,7 +220,6 @@ 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) } diff --git a/mediamtx.yml b/mediamtx.yml index d5efd96f..f936a305 100644 --- a/mediamtx.yml +++ b/mediamtx.yml @@ -615,7 +615,7 @@ pathDefaults: # a regular expression. runOnDemand: # Restart the command if it exits. - runOnDemandRestart: yes + runOnDemandRestart: no # Readers will be put on hold until the runOnDemand command starts publishing # or until this amount of time has passed. runOnDemandStartTimeout: 10s