Add parameters for ffmpeg options

This commit is contained in:
TwistedUmbrellaX 2024-03-02 22:19:51 -05:00
parent 5616c763d6
commit 822bd31c8f
3 changed files with 27 additions and 4 deletions

View File

@ -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.
/// </summary>
public string AutoSkipNotificationText { get; set; } = "Intro skipped";
/// <summary>
/// Gets or sets the number of threads for an ffmpeg process.
/// </summary>
public int ProcessThreads { get; set; } = 0;
/// <summary>
/// Gets or sets the relative priority for an ffmpeg process.
/// </summary>
public ProcessPriorityClass ProcessPriority { get; set; } = ProcessPriorityClass.BelowNormal;
}

View File

@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>ConfusedPolarBear.Plugin.IntroSkipper</RootNamespace>
<AssemblyVersion>0.1.14.0</AssemblyVersion>
<FileVersion>0.1.14.0</FileVersion>
<AssemblyVersion>0.1.15.0</AssemblyVersion>
<FileVersion>0.1.15.0</FileVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>

View File

@ -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];