From 547e56e82b81fce123cd9082e1cec6cf47477a24 Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Sat, 3 Aug 2024 20:51:54 +0200 Subject: [PATCH] enable runOnDemandRestart by default (#3605) --- README.md | 3 --- internal/conf/conf_test.go | 1 + internal/conf/path.go | 1 + mediamtx.yml | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3e09e429..ef349d4f 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/internal/conf/conf_test.go b/internal/conf/conf_test.go index 0c26086c..6b5d2727 100644 --- a/internal/conf/conf_test.go +++ b/internal/conf/conf_test.go @@ -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) diff --git a/internal/conf/path.go b/internal/conf/path.go index 925f050f..4c6d9cb9 100644 --- a/internal/conf/path.go +++ b/internal/conf/path.go @@ -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) } diff --git a/mediamtx.yml b/mediamtx.yml index f936a305..d5efd96f 100644 --- a/mediamtx.yml +++ b/mediamtx.yml @@ -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