diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs index 294f565..0d4407e 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs @@ -1,3 +1,4 @@ +using System.Diagnostics; using MediaBrowser.Model.Plugins; namespace ConfusedPolarBear.Plugin.IntroSkipper.Configuration; @@ -181,4 +182,14 @@ public class PluginConfiguration : BasePluginConfiguration /// Gets or sets the notification text sent after automatically skipping an introduction. /// public string AutoSkipNotificationText { get; set; } = "Intro skipped"; + + /// + /// Gets or sets the number of threads for an ffmpeg process. + /// + public int ProcessThreads { get; set; } = 0; + + /// + /// Gets or sets the relative priority for an ffmpeg process. + /// + public ProcessPriorityClass ProcessPriority { get; set; } = ProcessPriorityClass.BelowNormal; } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj b/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj index 51ee209..3970a4e 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj +++ b/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj @@ -3,8 +3,8 @@ net6.0 ConfusedPolarBear.Plugin.IntroSkipper - 0.1.14.0 - 0.1.14.0 + 0.1.15.0 + 0.1.15.0 true true enable diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/FFmpegWrapper.cs b/ConfusedPolarBear.Plugin.IntroSkipper/FFmpegWrapper.cs index fc0c9d4..95779e6 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/FFmpegWrapper.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/FFmpegWrapper.cs @@ -400,8 +400,9 @@ public static class FFmpegWrapper // for each file that is fingerprinted. var prependArgument = string.Format( CultureInfo.InvariantCulture, - "-hide_banner -loglevel {0} ", - logLevel); + "-hide_banner -loglevel {0} -threads {1} ", + logLevel, + Plugin.Instance?.Configuration.ProcessThreads ?? 0); var info = new ProcessStartInfo(ffmpegPath, args.Insert(0, prependArgument)) { @@ -425,6 +426,17 @@ public static class FFmpegWrapper ffmpeg.Start(); + try + { + ffmpeg.PriorityClass = Plugin.Instance?.Configuration.ProcessPriority ?? ProcessPriorityClass.BelowNormal; + } + catch (Exception e) + { + Logger?.LogDebug( + "ffmpeg priority could not be modified. {Message}", + e.Message); + } + using (MemoryStream ms = new MemoryStream()) { var buf = new byte[4096];