From 8a675d9a0d75929356ec5ff20eb69acd7a968014 Mon Sep 17 00:00:00 2001 From: Thomas Goodwin Date: Fri, 27 Feb 2026 07:29:58 -0500 Subject: [PATCH 1/2] fix(exec): address concurrency of multiple exec -> single RTSP If the stream configuration has an RTSP stream as well as multiple exec instances (or ffmpeg, which are wrapped in exec) referring to that same RTSP stream, a concurrency issue can sometimes be observed if two or more of those exec streams are requested at the same time. --- internal/exec/exec.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/exec/exec.go b/internal/exec/exec.go index e428aefbe..d56b1d3b5 100644 --- a/internal/exec/exec.go +++ b/internal/exec/exec.go @@ -23,6 +23,7 @@ import ( "github.com/AlexxIT/go2rtc/pkg/pcm" pkg "github.com/AlexxIT/go2rtc/pkg/rtsp" "github.com/AlexxIT/go2rtc/pkg/shell" + "github.com/google/uuid" "github.com/rs/zerolog" ) @@ -76,8 +77,11 @@ func execHandle(rawURL string) (prod core.Producer, err error) { return nil, errors.New("exec: rtsp module disabled") } + // Insert a UUID into the path to make it unique for this exec instance. + // This allows for multiple exec instances referring to the same RTSP + // stream to work without interfering with each other. sum := md5.Sum([]byte(rawURL)) - path = "/" + hex.EncodeToString(sum[:]) + path = "/" + hex.EncodeToString(sum[:]) + "-" + uuid.NewString() rawURL = rawURL[:i] + "rtsp://127.0.0.1:" + rtsp.Port + path + rawURL[i+8:] } From bb69cbf9c0bf3c63fa9b1696480a381072626074 Mon Sep 17 00:00:00 2001 From: Thomas Goodwin Date: Tue, 3 Mar 2026 07:05:25 -0500 Subject: [PATCH 2/2] fix(exec): move uuid randomization into md5.sum() Per PR comment, moving the randomization into the md5.sum calculation rather than having it be appended to the path as a suffix. --- internal/exec/exec.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/exec/exec.go b/internal/exec/exec.go index d56b1d3b5..300fc836f 100644 --- a/internal/exec/exec.go +++ b/internal/exec/exec.go @@ -77,11 +77,11 @@ func execHandle(rawURL string) (prod core.Producer, err error) { return nil, errors.New("exec: rtsp module disabled") } - // Insert a UUID into the path to make it unique for this exec instance. + // Insert a UUID into the sum to make it unique for this exec instance. // This allows for multiple exec instances referring to the same RTSP // stream to work without interfering with each other. - sum := md5.Sum([]byte(rawURL)) - path = "/" + hex.EncodeToString(sum[:]) + "-" + uuid.NewString() + sum := md5.Sum([]byte(rawURL + uuid.NewString())) + path = "/" + hex.EncodeToString(sum[:]) rawURL = rawURL[:i] + "rtsp://127.0.0.1:" + rtsp.Port + path + rawURL[i+8:] }