diff --git a/internal/ffmpeg/device/device_windows.go b/internal/ffmpeg/device/device_windows.go index e522a482..c14630d3 100644 --- a/internal/ffmpeg/device/device_windows.go +++ b/internal/ffmpeg/device/device_windows.go @@ -45,30 +45,20 @@ func queryToInput(query url.Values) string { } if video != "" { - input += ` -i video="` + video + `"` + input += ` -i "video=` + video if audio != "" { - input += `:audio="` + audio + `"` + input += `:audio=` + audio } + + input += `"` } else { - input += ` -i audio="` + audio + `"` + input += ` -i "audio=` + audio + `"` } return input } -func deviceInputSuffix(video, audio string) string { - switch { - case video != "" && audio != "": - return `video="` + video + `":audio=` + audio + `"` - case video != "": - return `video="` + video + `"` - case audio != "": - return `audio="` + audio + `"` - } - return "" -} - func initDevices() { cmd := exec.Command( Bin, "-hide_banner", "-list_devices", "true", "-f", "dshow", "-i", "", diff --git a/internal/ffmpeg/ffmpeg_test.go b/internal/ffmpeg/ffmpeg_test.go index b5d3e5ed..2493bace 100644 --- a/internal/ffmpeg/ffmpeg_test.go +++ b/internal/ffmpeg/ffmpeg_test.go @@ -35,12 +35,15 @@ func TestParseArgsFile(t *testing.T) { func TestParseArgsDevice(t *testing.T) { // [DEVICE] video will be output for MJPEG to pipe, with size 1920x1080 args := parseArgs("device?video=0&video_size=1920x1080") - require.Equal(t, `ffmpeg -hide_banner -f dshow -video_size 1920x1080 -i video="0" -c copy -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}`, args.String()) + require.Equal(t, `ffmpeg -hide_banner -f dshow -video_size 1920x1080 -i "video=0" -c copy -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}`, args.String()) // [DEVICE] video will be transcoded to H265 with framerate 20, audio will be skipped //args = parseArgs("device?video=0&video_size=1280x720&framerate=20#video=h265#audio=pcma") - args = parseArgs("device?video=0&framerate=20#video=h265#audio=pcma") - require.Equal(t, `ffmpeg -hide_banner -f dshow -framerate 20 -i video="0" -c:v libx265 -g 50 -profile:v main -level:v 5.1 -preset:v superfast -tune:v zerolatency -c:a pcm_alaw -ar:a 8000 -ac:a 1 -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}`, args.String()) + args = parseArgs("device?video=0&framerate=20#video=h265") + require.Equal(t, `ffmpeg -hide_banner -f dshow -framerate 20 -i "video=0" -c:v libx265 -g 50 -profile:v main -level:v 5.1 -preset:v superfast -tune:v zerolatency -an -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}`, args.String()) + + args = parseArgs("device?video=FaceTime HD Camera&audio=Microphone (High Definition Audio Device)") + require.Equal(t, `ffmpeg -hide_banner -f dshow -i "video=FaceTime HD Camera:audio=Microphone (High Definition Audio Device)" -c copy -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}`, args.String()) } func TestParseArgsIpCam(t *testing.T) { diff --git a/pkg/shell/shell_test.go b/pkg/shell/shell_test.go index e3481eb0..09102701 100644 --- a/pkg/shell/shell_test.go +++ b/pkg/shell/shell_test.go @@ -13,6 +13,6 @@ print("time", time.time())' ` require.Equal(t, []string{"python", "-c", "import time\nprint(\"time\", time.time())"}, QuoteSplit(s)) - s = `ffmpeg -i video="0" -i "DeckLink SDI (2)"` - require.Equal(t, []string{"ffmpeg", "-i", "video=\"0\"", "-i", "DeckLink SDI (2)"}, QuoteSplit(s)) + s = `ffmpeg -i "video=FaceTime HD Camera" -i "DeckLink SDI (2)"` + require.Equal(t, []string{"ffmpeg", "-i", `video=FaceTime HD Camera`, "-i", "DeckLink SDI (2)"}, QuoteSplit(s)) }