Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(macos): resolve Chromium USB microphone labels
Crnobog952713e3a38b5f5c
diff --git a/electron/native/screencapturekit/Sources/OpenScreenCaptureCore/MicrophoneDeviceSelection.swift b/electron/native/screencapturekit/Sources/OpenScreenCaptureCore/MicrophoneDeviceSelection.swiftnew file mode 100644index 000000000..d3d9a0b3d--- /dev/null+++ b/electron/native/screencapturekit/Sources/OpenScreenCaptureCore/MicrophoneDeviceSelection.swift@@ -0,0 +1,27 @@+import Foundation++/// Chromium decorates USB labels with a vendor/product suffix; AVFoundation does not.+/// Resolve IDs first and only accept unambiguous names, never a substring match.+public func resolveMicrophoneDeviceID(+ deviceID: String?,+ deviceName: String?,+ devices: [(id: String, name: String)]+) -> String? {+ if let id = deviceID?.trimmingCharacters(in: .whitespacesAndNewlines),+ devices.contains(where: { $0.id == id }) {+ return id+ }+ guard let name = deviceName?.trimmingCharacters(in: .whitespacesAndNewlines),+ !name.isEmpty else { return nil }+ let exact = devices.filter { $0.name == name }+ if exact.count == 1 { return exact[0].id }+ if !exact.isEmpty { return nil }+ let normalized = name.replacingOccurrences(+ of: #" \([0-9a-fA-F]{4}:[0-9a-fA-F]{4}\)$"#,+ with: "",+ options: .regularExpression+ )+ guard normalized != name else { return nil }+ let matches = devices.filter { $0.name == normalized }+ return matches.count == 1 ? matches[0].id : nil+}diff --git a/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/ScreenCaptureRecorder.swift b/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/ScreenCaptureRecorder.swiftindex 6bb6d9461..00706a9f9 100644--- a/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/ScreenCaptureRecorder.swift+++ b/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/ScreenCaptureRecorder.swift@@ -828,23 +828,13 @@ final class ScreenCaptureRecorder: NSObject, SCStreamOutput, SCStreamDelegate {}private func resolveMicrophoneCaptureDeviceID() -> String? {- let devices = AVCaptureDevice.devices(for: .audio)-- if let deviceName = request.audio.microphone.deviceName?.trimmingCharacters(in: .whitespacesAndNewlines),- !deviceName.isEmpty,- let device = devices.first(where: { $0.localizedName == deviceName })- {- return device.uniqueID- }-- if let deviceId = request.audio.microphone.deviceId?.trimmingCharacters(in: .whitespacesAndNewlines),- !deviceId.isEmpty,- devices.contains(where: { $0.uniqueID == deviceId })- {- return deviceId- }-- return nil+ resolveMicrophoneDeviceID(+ deviceID: request.audio.microphone.deviceId,+ deviceName: request.audio.microphone.deviceName,+ devices: AVCaptureDevice.devices(for: .audio).map {+ (id: $0.uniqueID, name: $0.localizedName)+ }+ )}}diff --git a/electron/native/screencapturekit/Tests/OpenScreenCaptureCoreTests/MicrophoneDeviceSelectionTests.swift b/electron/native/screencapturekit/Tests/OpenScreenCaptureCoreTests/MicrophoneDeviceSelectionTests.swiftnew file mode 100644index 000000000..093ffe21a--- /dev/null+++ b/electron/native/screencapturekit/Tests/OpenScreenCaptureCoreTests/MicrophoneDeviceSelectionTests.swift@@ -0,0 +1,37 @@+import XCTest+import OpenScreenCaptureCore++final class MicrophoneDeviceSelectionTests: XCTestCase {+ private let devices = [(id: "studio", name: "Studio Display"), (id: "mv7", name: "Shure MV7")]++ func testChromiumUSBLabelResolvesToSelectedMicrophone() {+ XCTAssertEqual(resolveMicrophoneDeviceID(deviceID: "browser-hash", deviceName: "Shure MV7 (14ed:1012)", devices: devices), "mv7")+ }++ func testNativeIDTakesPrecedenceOverStaleName() {+ XCTAssertEqual(resolveMicrophoneDeviceID(deviceID: "mv7", deviceName: "Studio Display", devices: devices), "mv7")+ }++ func testExactNameAndWhitespace() {+ XCTAssertEqual(resolveMicrophoneDeviceID(deviceID: nil, deviceName: " Shure MV7 ", devices: devices), "mv7")+ }++ func testDoesNotGuessMissingOrPartialNames() {+ for name in [nil, "", "Shure", "Shure MV7 (Virtual)", "Shure MV7 (14ed:1012) extra"] as [String?] {+ XCTAssertNil(resolveMicrophoneDeviceID(deviceID: "browser-hash", deviceName: name, devices: devices))+ }+ }++ func testAmbiguousNamesDoNotPickFirstDevice() {+ let duplicates = devices + [(id: "other", name: "Shure MV7")]+ for name in ["Shure MV7", "Shure MV7 (14ED:1012)"] {+ XCTAssertNil(resolveMicrophoneDeviceID(deviceID: nil, deviceName: name, devices: duplicates))+ }+ XCTAssertEqual(resolveMicrophoneDeviceID(deviceID: "other", deviceName: "Shure MV7", devices: duplicates), "other")+ }++ func testExactDecoratedDeviceNameIsPreserved() {+ let decorated = devices + [(id: "literal", name: "Shure MV7 (14ed:1012)")]+ XCTAssertEqual(resolveMicrophoneDeviceID(deviceID: nil, deviceName: "Shure MV7 (14ed:1012)", devices: decorated), "literal")+ }+}diff --git a/technical-documentation/testing/manual-e2e-checklist.md b/technical-documentation/testing/manual-e2e-checklist.mdindex 3921c7477..0f41860da 100644--- a/technical-documentation/testing/manual-e2e-checklist.md+++ b/technical-documentation/testing/manual-e2e-checklist.md@@ -621,3 +621,5 @@ The mask comes from the native compositor (ONNX Runtime + the vendored selfie-se| | | | | || | | | | || 2026-09-05 | Windows single-frame decoder ownership follow-up; source SHA-256 `FAF87561...87117`, bundled addon `94bc16d7...43a2c`, app.asar `8063a377...96f04` | Windows 11 build 26340; packaged Electron 41.2.1 | Scoped pass: nonzero AV1 seek and cross-clip playback | Fresh package, unique profile, no addon override; all 15 packaged native files hash-match staging (the existing packaging filter excludes standalone `ffmpeg.exe`). Native keyboard opened Studio after HUD pointer targeting failed; Studio seek/play/close used native input. AV1 at timeline 1.500 s/source 0.400 s rendered red `[255,24,0,255]` with a retained screenshot. During native playback from the first H.264 clip, read-only CDP samples observed blue followed by third-clip green `[0,216,0,255]` at 1.571 s; native logs confirm the malformed AV1 and following H.264 sources. PID 35472 exited 0 through window Close. An earlier sandboxed launch failed during Chromium GPU startup and is excluded from this pass. Limits: synthetic media, two native playback attempts in one successful session, no repeated stability or reporter-file claim; capture/webcam/tray/export not run. Exact-endpoint 4.540 s and one subsequent seek showed first-clip blue after native free-run wrapped: unchanged clip-identity synchronization paths, outside this resource/preflight follow-up; endpoint correctness is not claimed. Historical A/B rows remain separate. |++| 2026-09-13 | `6862a380` + microphone USB-label resolver patch; rebuilt release helpers | macOS 26.6.2, Apple Silicon, Shure MV7 | Partial | Real desktop HUD: selected explicit `Shure MV7 (14ed:1012)`, microphone on, system audio/camera off; started/stopped capture and reached saved editor (16.1 s). Logs confirm the rebuilt helper path and decorated label. Raw AAC is non-silent (mean -37.4 dBFS, peak -13.3 dBFS). Separately, the resolver matched the decorated label to the real AVFoundation MV7 ID. Default input was also MV7, so audio alone does not prove non-default routing. Listening, mixed/system audio, export, non-default-input recording and other platforms were not run; this is not full acceptance. |