From b45c22092d6d4db406c8ce003d88afac7ba1ce19 Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Sun, 30 Nov 2025 06:26:57 -0600 Subject: [PATCH] fix startup on systems unsupported by nvencsharp (#2678) --- CHANGELOG.md | 2 ++ .../Capabilities/HardwareCapabilitiesFactory.cs | 8 ++++++++ .../Capabilities/Nvidia/NvEncSharpRedirector.cs | 4 ++++ ErsatzTV.Scanner.Tests/Core/FFmpeg/TranscodingTests.cs | 4 ++++ ErsatzTV/Services/RunOnce/PlatformSettingsService.cs | 4 ++++ 5 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c6077afa..f47548082 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Fixed +- Fix startup on systems unsupported by NvEncSharp ## [25.9.0] - 2025-11-29 ### Added diff --git a/ErsatzTV.FFmpeg/Capabilities/HardwareCapabilitiesFactory.cs b/ErsatzTV.FFmpeg/Capabilities/HardwareCapabilitiesFactory.cs index fce8e934a..150ef1f7b 100644 --- a/ErsatzTV.FFmpeg/Capabilities/HardwareCapabilitiesFactory.cs +++ b/ErsatzTV.FFmpeg/Capabilities/HardwareCapabilitiesFactory.cs @@ -151,6 +151,10 @@ public partial class HardwareCapabilitiesFactory( { // do nothing } + catch (TypeInitializationException) + { + // do nothing + } // if we don't have a list of cuda devices, fall back to ffmpeg check @@ -644,6 +648,10 @@ public partial class HardwareCapabilitiesFactory( { // do nothing } + catch (TypeInitializationException) + { + // do nothing + } logger.LogWarning( "Error detecting NVIDIA GPU capabilities; some hardware accelerated features will be unavailable"); diff --git a/ErsatzTV.FFmpeg/Capabilities/Nvidia/NvEncSharpRedirector.cs b/ErsatzTV.FFmpeg/Capabilities/Nvidia/NvEncSharpRedirector.cs index fc1ac7967..db82f986b 100644 --- a/ErsatzTV.FFmpeg/Capabilities/Nvidia/NvEncSharpRedirector.cs +++ b/ErsatzTV.FFmpeg/Capabilities/Nvidia/NvEncSharpRedirector.cs @@ -16,6 +16,10 @@ public static class NvEncSharpRedirector { CudaHelper.IsLoaded = false; } + catch (TypeInitializationException) + { + CudaHelper.IsLoaded = false; + } } private static IntPtr Resolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) diff --git a/ErsatzTV.Scanner.Tests/Core/FFmpeg/TranscodingTests.cs b/ErsatzTV.Scanner.Tests/Core/FFmpeg/TranscodingTests.cs index fe4661657..7e14380ba 100644 --- a/ErsatzTV.Scanner.Tests/Core/FFmpeg/TranscodingTests.cs +++ b/ErsatzTV.Scanner.Tests/Core/FFmpeg/TranscodingTests.cs @@ -463,6 +463,10 @@ public class TranscodingTests { // do nothing } + catch (TypeInitializationException) + { + // do nothing + } var localFileSystem = new LocalFileSystem( new MockFileSystem(), diff --git a/ErsatzTV/Services/RunOnce/PlatformSettingsService.cs b/ErsatzTV/Services/RunOnce/PlatformSettingsService.cs index e0af3cd92..2f5b02956 100644 --- a/ErsatzTV/Services/RunOnce/PlatformSettingsService.cs +++ b/ErsatzTV/Services/RunOnce/PlatformSettingsService.cs @@ -27,6 +27,10 @@ public class PlatformSettingsService(IServiceScopeFactory serviceScopeFactory) : { // do nothing } + catch (TypeInitializationException) + { + // do nothing + } } if (runtimeInfo.IsOSPlatform(OSPlatform.Linux))