From e48459f49db25b5f1b125336ed687bdc257cc7b2 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Sat, 15 Jul 2023 14:41:28 +0300 Subject: [PATCH] Add channels and sample rate params to ALSA --- internal/ffmpeg/device/device_linux.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/ffmpeg/device/device_linux.go b/internal/ffmpeg/device/device_linux.go index 1dd8bd74..46d869c1 100644 --- a/internal/ffmpeg/device/device_linux.go +++ b/internal/ffmpeg/device/device_linux.go @@ -1,13 +1,14 @@ package device import ( - "github.com/AlexxIT/go2rtc/internal/api" - "github.com/AlexxIT/go2rtc/pkg/core" "net/url" "os" "os/exec" "regexp" "strings" + + "github.com/AlexxIT/go2rtc/internal/api" + "github.com/AlexxIT/go2rtc/pkg/core" ) func queryToInput(query url.Values) string { @@ -28,8 +29,16 @@ func queryToInput(query url.Values) string { } if audio := query.Get("audio"); audio != "" { + // https://trac.ffmpeg.org/wiki/Capture/ALSA input := "-f alsa" + for key, value := range query { + switch key { + case "channels", "sample_rate": + input += " -" + key + " " + value[0] + } + } + return input + " -i " + indexToItem(audios, audio) }