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
feat(wgc-capture): fall back to software H.264 encoder
My-Denia59383ce9bdee
diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.tsindex ae8f5525d..b3b2d81ce 100644--- a/electron/ipc/handlers.ts+++ b/electron/ipc/handlers.ts@@ -1621,9 +1621,17 @@ export function registerIpcHandlers(: null;const cursorCaptureMode =normalizeCursorCaptureMode(request.cursor?.mode) ?? "editable-overlay";+ const envPreferSoftwareEncoder = (+ process.env.OPENSCREEN_WGC_PREFER_SOFTWARE_ENCODER ?? ""+ ).toLowerCase();+ const preferSoftwareEncoder =+ request.preferSoftwareEncoder === true ||+ envPreferSoftwareEncoder === "true" ||+ envPreferSoftwareEncoder === "1";const config = {schemaVersion: 2,recordingId,+ preferSoftwareEncoder,outputPath,sourceType: request.source.type,sourceId: request.source.sourceId,@@ -1665,6 +1673,9 @@ export function registerIpcHandlers(video: request.video,audio: request.audio,webcam: request.webcam,+ encoder: {+ preferSoftwareEncoder,+ },cursor: {mode: cursorCaptureMode,},@@ -1675,6 +1686,7 @@ export function registerIpcHandlers(source: request.source,audio: request.audio,webcam: request.webcam,+ encoder: { preferSoftwareEncoder },cursor: { mode: cursorCaptureMode },bounds,sourceId: selectedSource?.id ?? null,diff --git a/electron/native/README.md b/electron/native/README.mdindex cda6c9f55..8306a2458 100644--- a/electron/native/README.md+++ b/electron/native/README.md@@ -64,6 +64,7 @@ Current V2 JSON shape:"videoWidth": 1920,"videoHeight": 1080,"fps": 60,+ "preferSoftwareEncoder": false,"captureSystemAudio": false,"captureMic": false,"microphoneDeviceId": "default",@@ -83,12 +84,15 @@ Current V2 JSON shape:The current helper implementation supports display/window video capture, system audio loopback, selected-microphone capture, Media Foundation webcam capture, and a DirectShow webcam fallback for virtual cameras that are not exposed through Media Foundation. Webcam frames are currently composed into the primary MP4 as a bottom-right picture-in-picture overlay. Browser `deviceId` values do not always map to Media Foundation symbolic links or WASAPI endpoint IDs, so the renderer passes both browser IDs and user-visible device names. For microphones, the helper tries the requested WASAPI endpoint ID first, then resolves an active capture endpoint by `microphoneDeviceName`, then falls back to the default endpoint. For webcams, Electron resolves a matching DirectShow filter CLSID for the selected label; the helper uses Media Foundation first, then that exact DirectShow filter when the requested camera is absent from Media Foundation.-Encoder diagnostic on sink-writer failure: when `MFCreateSinkWriterFromURL` fails, the helper logs the registered H.264 video encoder MFT count (via `MFTEnumEx`), the registered AAC encoder count when audio was requested, and the hex HRESULT. If no H.264 encoder is registered, it additionally emits the four-bullet actionable error (missing Media Feature Pack / GPU driver registration / empty `HKLM:\SOFTWARE\Microsoft\Windows Media Foundation\Transforms` / reboot). If an H.264 encoder IS registered but the sink writer still failed, it logs a hint pointing at invalid output path, missing MP4 mux, or GPU driver incompatibility. The diagnostic runs only on the failure path — there is no pre-flight gating check, because `MFTEnumEx` and `MFCreateSinkWriterFromURL` can disagree about which H.264 encoders are "available" in non-interactive / Session 0 contexts, and a pre-flight zero-count would block a recording the sink writer can otherwise complete.+Encoder selection: by default the helper keeps the existing sink-writer path first. If that path fails while setting up H.264, it retries with the Microsoft software H.264 encoder (`mfh264enc.dll`) registered locally in the helper process and hardware transforms disabled for that retry. Set `preferSoftwareEncoder: true` in the helper JSON, or set `OPENSCREEN_WGC_PREFER_SOFTWARE_ENCODER=true` before launching Electron, to force the software path from the first attempt.++Encoder diagnostic on final sink-writer failure: when the final `MFCreateSinkWriterFromURL` attempt fails, the helper logs the registered H.264 video encoder MFT count (via `MFTEnumEx`), the registered AAC encoder count when audio was requested, and the hex HRESULT. If no H.264 encoder is registered, it additionally emits the four-bullet actionable error (missing Media Feature Pack / GPU driver registration / empty `HKLM:\SOFTWARE\Microsoft\Windows Media Foundation\Transforms` / reboot). If an H.264 encoder IS registered but the sink writer still failed, it logs a hint pointing at invalid output path, missing MP4 mux, or GPU driver incompatibility. There is still no fail-fast pre-flight gate because `MFTEnumEx` and `MFCreateSinkWriterFromURL` can disagree about which H.264 encoders are available in non-interactive / Session 0 contexts.Smoke-test the helper with:```powershellnpm run test:wgc-helper:win+npm run test:wgc-helper:win -- --software-encodernpm run test:wgc-window:winnpm run test:wgc-audio:winnpm run test:wgc-mic:windiff --git a/electron/native/wgc-capture/src/main.cpp b/electron/native/wgc-capture/src/main.cppindex af73b26fc..95d9dcc74 100644--- a/electron/native/wgc-capture/src/main.cpp+++ b/electron/native/wgc-capture/src/main.cpp@@ -40,6 +40,7 @@ struct CaptureConfig {bool captureMic = false;bool captureCursor = false;bool webcamEnabled = false;+ bool preferSoftwareEncoder = false;std::string microphoneDeviceId;std::string microphoneDeviceName;double microphoneGain = 1.0;@@ -338,6 +339,7 @@ bool parseConfig(const std::string& json, CaptureConfig& config) {config.captureMic = findBool(json, "captureMic", false);config.captureCursor = findBool(json, "captureCursor", false);config.webcamEnabled = findBool(json, "webcamEnabled", false);+ config.preferSoftwareEncoder = findBool(json, "preferSoftwareEncoder", false);config.microphoneDeviceId = findString(json, "microphoneDeviceId");config.microphoneDeviceName = findString(json, "microphoneDeviceName");config.microphoneGain = findDouble(json, "microphoneGain", 1.0);@@ -502,6 +504,9 @@ int main(int argc, char* argv[]) {<< "}" << std::endl;}+ MFEncoderOptions encoderOptions{};+ encoderOptions.preferSoftwareEncoder = config.preferSoftwareEncoder;+MFEncoder encoder;if (!encoder.initialize(utf8ToWide(config.outputPath),@@ -511,11 +516,16 @@ int main(int argc, char* argv[]) {bitrate,session.device(),session.context(),- audioFormat ? &encoderAudioFormat : nullptr)) {+ audioFormat ? &encoderAudioFormat : nullptr,+ encoderOptions)) {std::cerr << "ERROR: Failed to initialize Media Foundation encoder" << std::endl;return 1;}-+ std::cout << "{\"event\":\"encoder-selection\",\"schemaVersion\":2,\"video\":\""+ << encoder.videoEncoderSelection()+ << "\",\"preferSoftwareEncoder\":"+ << (config.preferSoftwareEncoder ? "true" : "false")+ << "}" << std::endl;MFEncoder webcamEncoder;if (writeSeparateWebcam) {const int webcamPixels = std::max(1, webcamCapture.width()) * std::max(1, webcamCapture.height());@@ -528,7 +538,8 @@ int main(int argc, char* argv[]) {webcamBitrate,session.device(),session.context(),- nullptr)) {+ nullptr,+ encoderOptions)) {std::cerr << "ERROR: Failed to initialize native webcam encoder" << std::endl;return 1;}diff --git a/electron/native/wgc-capture/src/mf_encoder.cpp b/electron/native/wgc-capture/src/mf_encoder.cppindex 738a29b58..d1c779b96 100644--- a/electron/native/wgc-capture/src/mf_encoder.cpp+++ b/electron/native/wgc-capture/src/mf_encoder.cpp@@ -123,6 +123,99 @@ void logMissingH264EncoderError() {<< std::endl;}+constexpr const char* kVideoEncoderSelectionDefault = "default";+constexpr const char* kVideoEncoderSelectionSoftwarePreferred = "software-preferred";+constexpr const char* kVideoEncoderSelectionSoftwareFallback = "software-fallback";++HRESULT ensureSoftwareH264EncoderRegisteredForProcess() {+ static std::mutex registrationMutex;+ static bool attempted = false;+ static HRESULT result = E_FAIL;++ std::scoped_lock lock(registrationMutex);+ if (attempted) {+ return result;+ }+ attempted = true;++ MFT_REGISTER_TYPE_INFO inputType{};+ inputType.guidMajorType = MFMediaType_Video;+ inputType.guidSubtype = GUID_NULL;++ MFT_REGISTER_TYPE_INFO outputType{};+ outputType.guidMajorType = MFMediaType_Video;+ outputType.guidSubtype = MFVideoFormat_H264;++ result = MFTRegisterLocalByCLSID(+ CLSID_MSH264EncoderMFT,+ MFT_CATEGORY_VIDEO_ENCODER,+ L"Microsoft H.264 Encoder MFT (software)",+ MFT_ENUM_FLAG_SYNCMFT,+ 1,+ &inputType,+ 1,+ &outputType);+ if (FAILED(result)) {+ std::cerr << "ERROR: MFTRegisterLocalByCLSID(CLSID_MSH264EncoderMFT) failed (hr=0x"+ << std::hex << result << std::dec << ")" << std::endl;+ }+ return result;+}++HRESULT createSinkWriterFromUrl(+ const std::wstring& outputPath,+ bool forceSoftwareEncoder,+ Microsoft::WRL::ComPtr<IMFSinkWriter>& sinkWriter) {+ Microsoft::WRL::ComPtr<IMFAttributes> attributes;+ if (forceSoftwareEncoder) {+ const HRESULT registerHr = ensureSoftwareH264EncoderRegisteredForProcess();+ if (FAILED(registerHr)) {+ return registerHr;+ }++ HRESULT hr = MFCreateAttributes(&attributes, 1);+ if (FAILED(hr)) {+ std::cerr << "ERROR: MFCreateAttributes(sink writer) failed (hr=0x"+ << std::hex << hr << std::dec << ")" << std::endl;+ return hr;+ }+ hr = attributes->SetUINT32(MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, FALSE);+ if (FAILED(hr)) {+ std::cerr << "ERROR: Set MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS failed (hr=0x"+ << std::hex << hr << std::dec << ")" << std::endl;+ return hr;+ }+ }++ return MFCreateSinkWriterFromURL(+ outputPath.c_str(), nullptr, attributes.Get(), &sinkWriter);+}++void logSinkWriterCreateFailure(HRESULT sinkWriterHr, const AudioInputFormat* audioFormat) {+ const UINT32 h264EncoderCount = countRegisteredH264VideoEncoders();+ const UINT32 aacEncoderCount = (audioFormat != nullptr)+ ? countRegisteredAacAudioEncoders()+ : 0;+ std::cerr << "ERROR: MFCreateSinkWriterFromURL failed (hr=0x"+ << std::hex << sinkWriterHr << std::dec << ")" << std::endl;+ std::cerr << " Registered H.264 video encoder MFTs: " << h264EncoderCount+ << std::endl;+ if (audioFormat != nullptr) {+ std::cerr << " Registered AAC audio encoder MFTs: " << aacEncoderCount+ << std::endl;+ }+ if (h264EncoderCount == 0) {+ logMissingH264EncoderError();+ } else {+ std::cerr+ << " An H.264 encoder MFT is registered but the sink writer "+ << "still failed. Possible causes: invalid output path or "+ << "permissions, no MP4 mux configured, or GPU driver "+ << "incompatibility with this Media Foundation build."+ << std::endl;+ }+}+void setFrameSize(IMFMediaType* type, UINT32 width, UINT32 height) {MFSetAttributeSize(type, MF_MT_FRAME_SIZE, width, height);}@@ -184,6 +277,10 @@ MFEncoder::~MFEncoder() {finalize();}+const char* MFEncoder::videoEncoderSelection() const {+ return videoEncoderSelection_;+}+bool MFEncoder::initialize(const std::wstring& outputPath,int width,@@ -192,21 +289,14 @@ bool MFEncoder::initialize(int bitrate,ID3D11Device* device,ID3D11DeviceContext* context,- const AudioInputFormat* audioFormat) {+ const AudioInputFormat* audioFormat,+ MFEncoderOptions options) {width_ = (std::max(2, width) / 2) * 2;height_ = (std::max(2, height) / 2) * 2;fps_ = std::max(1, fps);device_ = device;context_ = context;-- // No H.264 encoder pre-flight check here. MFTEnumEx and- // MFCreateSinkWriterFromURL can disagree about which H.264 encoders are- // "available" in non-interactive / Session 0 contexts (NVENC et al. are- // registered but their COM server may not fully activate from a service- // session). A pre-flight that fails fast on a zero MFTEnumEx count would- // therefore break a recording that the sink writer can complete- // successfully. The diagnostic dump below runs only on the failure path,- // so a healthy MFTEnumEx result never blocks a working recording.+ videoEncoderSelection_ = kVideoEncoderSelectionDefault;if (!succeeded(MFStartup(MF_VERSION), "MFStartup")) {return false;@@ -224,47 +314,6 @@ bool MFEncoder::initialize(setFrameRate(outputType.Get(), static_cast<UINT32>(fps_));setPixelAspectRatio(outputType.Get());- HRESULT sinkWriterHr = MFCreateSinkWriterFromURL(- outputPath.c_str(), nullptr, nullptr, &sinkWriter_);- if (FAILED(sinkWriterHr)) {- // The HRESULT alone is not actionable. Tell the user whether an H.264- // encoder is registered at all (no H.264 == the MFP missing-MFT path),- // whether AAC is registered (only when audio is requested), and the- // hex HRESULT so the exact failure is greppable. Encoder counts are- // computed lazily here, only on the failure path, so a healthy- // recording does not pay for an MFTEnumEx call.- const UINT32 h264EncoderCount = countRegisteredH264VideoEncoders();- const UINT32 aacEncoderCount = (audioFormat != nullptr)- ? countRegisteredAacAudioEncoders()- : 0;- std::cerr << "ERROR: MFCreateSinkWriterFromURL failed (hr=0x"- << std::hex << sinkWriterHr << std::dec << ")" << std::endl;- std::cerr << " Registered H.264 video encoder MFTs: " << h264EncoderCount- << std::endl;- if (audioFormat != nullptr) {- std::cerr << " Registered AAC audio encoder MFTs: " << aacEncoderCount- << std::endl;- }- if (h264EncoderCount == 0) {- logMissingH264EncoderError();- } else {- std::cerr- << " An H.264 encoder MFT is registered but the sink writer "- << "still failed. Possible causes: invalid output path or "- << "permissions, no MP4 mux configured, or GPU driver "- << "incompatibility with this Media Foundation build."- << std::endl;- }- return false;- }- if (!succeeded(sinkWriter_->AddStream(outputType.Get(), &videoStreamIndex_), "AddStream")) {- return false;- }-- if (audioFormat && !configureAudioStream(*audioFormat)) {- return false;- }-Microsoft::WRL::ComPtr<IMFMediaType> inputType;if (!succeeded(MFCreateMediaType(&inputType), "MFCreateMediaType(input)")) {return false;@@ -277,15 +326,72 @@ bool MFEncoder::initialize(setFrameRate(inputType.Get(), static_cast<UINT32>(fps_));setPixelAspectRatio(inputType.Get());- if (!succeeded(sinkWriter_->SetInputMediaType(videoStreamIndex_, inputType.Get(), nullptr),- "SetInputMediaType")) {- return false;+ auto resetSinkWriterAttempt = [&]() {+ sinkWriter_.Reset();+ videoStreamIndex_ = 0;+ audioStreamIndex_ = 0;+ hasAudioStream_ = false;+ videoEncoderSelection_ = kVideoEncoderSelectionDefault;+ };++ auto configureSinkWriterAttempt = [&, audioFormat](+ bool forceSoftwareEncoder,+ const char* selection,+ bool logCreateFailure) {+ resetSinkWriterAttempt();++ const HRESULT sinkWriterHr = createSinkWriterFromUrl(+ outputPath,+ forceSoftwareEncoder,+ sinkWriter_);+ if (FAILED(sinkWriterHr)) {+ if (logCreateFailure) {+ logSinkWriterCreateFailure(sinkWriterHr, audioFormat);+ } else {+ std::cerr << "WARNING: Default MFCreateSinkWriterFromURL failed (hr=0x"+ << std::hex << sinkWriterHr << std::dec << ")" << std::endl;+ }+ return false;+ }+ if (!succeeded(sinkWriter_->AddStream(outputType.Get(), &videoStreamIndex_), "AddStream")) {+ return false;+ }++ if (audioFormat && !configureAudioStream(*audioFormat)) {+ return false;+ }++ if (!succeeded(sinkWriter_->SetInputMediaType(videoStreamIndex_, inputType.Get(), nullptr),+ "SetInputMediaType")) {+ return false;+ }+ if (!succeeded(sinkWriter_->BeginWriting(), "BeginWriting")) {+ return false;+ }++ videoEncoderSelection_ = selection;+ return true;+ };++ if (options.preferSoftwareEncoder) {+ return configureSinkWriterAttempt(+ true,+ kVideoEncoderSelectionSoftwarePreferred,+ true);}- if (!succeeded(sinkWriter_->BeginWriting(), "BeginWriting")) {- return false;++ if (configureSinkWriterAttempt(false, kVideoEncoderSelectionDefault, false)) {+ return true;}- return true;+ std::cerr+ << "WARNING: Default Media Foundation H.264 encoder setup failed; "+ << "retrying with the Microsoft software H.264 encoder."+ << std::endl;+ return configureSinkWriterAttempt(+ true,+ kVideoEncoderSelectionSoftwareFallback,+ true);}bool MFEncoder::configureAudioStream(const AudioInputFormat& audioFormat) {diff --git a/electron/native/wgc-capture/src/mf_encoder.h b/electron/native/wgc-capture/src/mf_encoder.hindex e7821e910..22d676bb9 100644--- a/electron/native/wgc-capture/src/mf_encoder.h+++ b/electron/native/wgc-capture/src/mf_encoder.h@@ -26,6 +26,10 @@ struct AudioInputFormat {UINT32 avgBytesPerSec = 0;};+struct MFEncoderOptions {+ bool preferSoftwareEncoder = false;+};+class MFEncoder {public:MFEncoder() = default;@@ -42,11 +46,13 @@ public:int bitrate,ID3D11Device* device,ID3D11DeviceContext* context,- const AudioInputFormat* audioFormat = nullptr);+ const AudioInputFormat* audioFormat = nullptr,+ MFEncoderOptions options = {});bool writeFrame(ID3D11Texture2D* texture, int64_t timestampHns, const BgraFrameView* webcamFrame = nullptr);bool writeBgraFrame(const BgraFrameView& frame, int64_t timestampHns);bool writeAudio(const BYTE* data, DWORD byteCount, int64_t timestampHns, int64_t durationHns);bool finalize();+ const char* videoEncoderSelection() const;private:bool ensureStagingTexture(ID3D11Texture2D* texture);@@ -72,4 +78,5 @@ private:int64_t firstTimestampHns_ = -1;int64_t lastTimestampHns_ = -1;bool finalized_ = false;+ const char* videoEncoderSelection_ = "default";};diff --git a/scripts/test-windows-wgc-helper.mjs b/scripts/test-windows-wgc-helper.mjsindex 5dd2dccf2..d5ba55409 100644--- a/scripts/test-windows-wgc-helper.mjs+++ b/scripts/test-windows-wgc-helper.mjs@@ -26,6 +26,9 @@ const WITH_WEBCAM =const CAPTURE_CURSOR =process.env.OPENSCREEN_WGC_TEST_CAPTURE_CURSOR === "true" ||process.argv.includes("--capture-cursor");+const WITH_SOFTWARE_ENCODER =+ process.env.OPENSCREEN_WGC_TEST_SOFTWARE_ENCODER === "true" ||+ process.argv.includes("--software-encoder");function runHelper(config) {return new Promise((resolve, reject) => {@@ -237,6 +240,7 @@ const fixtureWindow = WITH_WINDOW ? await startFixtureWindow() : null;const config = {schemaVersion: 2,recordingId: Date.now(),+ preferSoftwareEncoder: WITH_SOFTWARE_ENCODER,outputPath,sourceType: fixtureWindow ? "window" : "display",sourceId: fixtureWindow ? fixtureWindow.sourceId : "screen:0:0",@@ -314,6 +318,10 @@ const cursorCaptureLine = result.stdout.split(/\r?\n/).find((line) => line.includes('"event":"cursor-capture"'));const cursorCapture = cursorCaptureLine ? JSON.parse(cursorCaptureLine) : null;+const encoderSelectionLine = result.stdout+ .split(/\r?\n/)+ .find((line) => line.includes('"event":"encoder-selection"'));+const encoderSelection = encoderSelectionLine ? JSON.parse(encoderSelectionLine) : null;const nativeWebcamDiagnostics = result.stderr.split(/\r?\n/).filter((line) => line.includes("Native webcam candidate"));@@ -339,6 +347,14 @@ if (`WGC helper did not apply requested cursor capture mode (${CAPTURE_CURSOR}): ${result.stdout}`,);}+if (+ WITH_SOFTWARE_ENCODER &&+ (!encoderSelection ||+ typeof encoderSelection.video !== "string" ||+ !encoderSelection.video.startsWith("software"))+) {+ throw new Error(`WGC helper did not use the requested software encoder path: ${result.stdout}`);+}if ((WITH_SYSTEM_AUDIO || WITH_MICROPHONE) && !hasAudio) {throw new Error(`WGC helper output has no audio stream: ${outputPath}`);}@@ -375,6 +391,7 @@ console.log(duration: stream.duration,})),cursorCapture,+ encoderSelection,selectedMicrophoneDeviceName: audioFormat?.microphoneDeviceName,selectedWebcamDeviceName: webcamFormat?.deviceName,nativeMicrophoneDiagnostics,diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.tsindex 72ddc529b..8f266c4e7 100644--- a/src/hooks/useScreenRecorder.ts+++ b/src/hooks/useScreenRecorder.ts@@ -13,6 +13,7 @@ import {} from "@/lib/nativeWindowsRecording";import type { CursorCaptureMode, RecordedVideoAssetInput } from "@/lib/recordingSession";import { requestCameraAccess } from "@/lib/requestCameraAccess";+import { loadUserPreferences } from "@/lib/userPreferences";import { createRecorderHandle, type RecorderHandle } from "./recorderHandle";const TARGET_FRAME_RATE = 60;@@ -844,6 +845,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn {}const request: NativeWindowsRecordingRequest = {recordingId: activeRecordingId,+ preferSoftwareEncoder: loadUserPreferences().preferSoftwareEncoder,source: {type: sourceType,sourceId: selectedSource.id,diff --git a/src/lib/nativeWindowsRecording.ts b/src/lib/nativeWindowsRecording.tsindex 5e0685171..dd668b010 100644--- a/src/lib/nativeWindowsRecording.ts+++ b/src/lib/nativeWindowsRecording.ts@@ -2,6 +2,7 @@ export type NativeWindowsSourceType = "display" | "window";export type NativeWindowsRecordingRequest = {recordingId?: number;+ preferSoftwareEncoder?: boolean;source: {type: NativeWindowsSourceType;sourceId: string;diff --git a/src/lib/userPreferences.test.ts b/src/lib/userPreferences.test.tsindex 8a64295c5..ac3d901a9 100644--- a/src/lib/userPreferences.test.ts+++ b/src/lib/userPreferences.test.ts@@ -103,4 +103,19 @@ describe("user preferences", () => {expect(loadUserPreferences().trayLayout).toBe("horizontal");});++ it("persists the software encoder preference", () => {+ saveUserPreferences({ preferSoftwareEncoder: true });++ expect(loadUserPreferences().preferSoftwareEncoder).toBe(true);+ });++ it("falls back to the default software encoder preference for invalid stored values", () => {+ localStorage.setItem(+ "openscreen_user_preferences",+ JSON.stringify({ preferSoftwareEncoder: "yes" }),+ );++ expect(loadUserPreferences().preferSoftwareEncoder).toBe(false);+ });});diff --git a/src/lib/userPreferences.ts b/src/lib/userPreferences.tsindex 66c5a66a4..09860bd3f 100644--- a/src/lib/userPreferences.ts+++ b/src/lib/userPreferences.ts@@ -33,6 +33,8 @@ export interface UserPreferences {projectFolder: string | null;/** Recording HUD control layout */trayLayout: "horizontal" | "vertical";+ /** Force the Windows native recorder to use the software H.264 encoder */+ preferSoftwareEncoder: boolean;}export const DEFAULT_PREFS: UserPreferences = {@@ -43,6 +45,7 @@ export const DEFAULT_PREFS: UserPreferences = {exportFolder: null,projectFolder: null,trayLayout: "horizontal",+ preferSoftwareEncoder: false,};/** Parses stored preferences without throwing on malformed JSON. */@@ -99,6 +102,10 @@ export function loadUserPreferences(): UserPreferences {raw.trayLayout === "horizontal" || raw.trayLayout === "vertical"? raw.trayLayout: DEFAULT_PREFS.trayLayout,+ preferSoftwareEncoder:+ typeof raw.preferSoftwareEncoder === "boolean"+ ? raw.preferSoftwareEncoder+ : DEFAULT_PREFS.preferSoftwareEncoder,};}