From 822bd31c8fc84a44a6c7ac9c2de41c310b559e37 Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX Date: Sat, 2 Mar 2024 22:19:51 -0500 Subject: [PATCH 1/8] Add parameters for ffmpeg options --- .../Configuration/PluginConfiguration.cs | 11 +++++++++++ .../ConfusedPolarBear.Plugin.IntroSkipper.csproj | 4 ++-- .../FFmpegWrapper.cs | 16 ++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) 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]; From 01c5c1df51ec0353fc34af69c8370ef386dbeb05 Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX Date: Sun, 3 Mar 2024 08:08:55 -0500 Subject: [PATCH 2/8] Support modifying ffmpeg priority --- .../Configuration/configPage.html | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html index 0475d82..f79761b 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html @@ -59,6 +59,41 @@ +
+ + + +
+ Sets the relative priority of the ffmpeg process during detection
+ If you notice excessive RAM usage, try setting a lower value
+ If you would like to speed up detection, increase this value +
+
+
-
- - - -
- Sets the relative priority of the ffmpeg process during detection
- If you notice excessive RAM usage, try setting a lower value
- If you would like to speed up detection, increase this value -
-
- -
- - -
- If checked, episode fingerprints will be cached to the filesystem -
- WARNING: Disabling cache may result in lengthy detection -
-
-
-
- EDL file generation + EDL File Generation
@@ -164,7 +115,7 @@
- Modify introduction requirements + Modify Intro Requirements
@@ -229,7 +180,7 @@
- Silence detection options + Silence Detection Options
@@ -254,6 +205,74 @@
+ +
+ Task Configuration + +
+
+ + +
+ If checked, episode fingerprints will be saved on the filesystem to improve analysis speed. +
+ WARNING: May result in lengthy detection! Not recommended for large libraries! +
+
+
+ +
+ + + +
+ Sets the relative priority of the analysis ffmpeg process to other parallel operations + (ie. transcoding, chapter detection, etc). +
+
+ +
+ + +
+ Number of simultaneous processes to use for ffmpeg operations. +
+ This value is most often defined as 1 thread per CPU core, + but setting a value of 0 (default) will use the maximum threads available. +
+
+ +
@@ -521,12 +540,13 @@ // analysis "MaxParallelism", "SelectedLibraries", - "ProcessPriority", "AnalysisPercent", "AnalysisLengthLimit", "MinimumIntroDuration", "MaximumIntroDuration", "EdlAction", + "ProcessPriority", + "ProcessThreads", // playback "ShowPromptAdjustment", "HidePromptAdjustment", @@ -542,8 +562,8 @@ var booleanConfigurationFields = [ "AnalyzeSeasonZero", - "CacheFingerprints", "RegenerateEdlFiles", + "CacheFingerprints", "AutoSkip", "SkipFirstEpisode", "PersistSkipButton", From 8e8a6207a5cf7c0a29d10b6a3ed724e66d88881a Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX Date: Sun, 3 Mar 2024 21:46:52 -0500 Subject: [PATCH 4/8] Update StyleCop and address warnings --- .gitignore | 4 ++++ .../Analyzers/ChapterAnalyzer.cs | 2 +- .../Analyzers/ChromaprintAnalyzer.cs | 4 ++-- .../ConfusedPolarBear.Plugin.IntroSkipper.csproj | 8 ++------ .../GlobalSuppressions.cs | 10 ++++++++++ ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs | 2 +- 6 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 ConfusedPolarBear.Plugin.IntroSkipper/GlobalSuppressions.cs diff --git a/.gitignore b/.gitignore index 295855b..6908286 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ BenchmarkDotNet.Artifacts/ # Ignore pre compiled web interface docker/dist + +# Visual Studio +.vs/ +UpgradeLog*.htm diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs index b22e428..763d461 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs @@ -7,8 +7,8 @@ using System.Globalization; using System.Linq; using System.Text.RegularExpressions; using System.Threading; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Entities; +using Microsoft.Extensions.Logging; /// /// Chapter name analyzer. diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs index c230c1b..2a03321 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs @@ -275,10 +275,10 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer { var modifiedPoint = (uint)(originalPoint + i); - if (rhsIndex.ContainsKey(modifiedPoint)) + if (rhsIndex.TryGetValue(modifiedPoint, out var value)) { var lhsFirst = (int)lhsIndex[originalPoint]; - var rhsFirst = (int)rhsIndex[modifiedPoint]; + var rhsFirst = (int)value; indexShifts.Add(rhsFirst - lhsFirst); } } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj b/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj index 3970a4e..1f3c386 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj +++ b/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj @@ -1,5 +1,4 @@ - net6.0 ConfusedPolarBear.Plugin.IntroSkipper @@ -11,15 +10,13 @@ AllEnabledByDefault ../jellyfin.ruleset - - + - @@ -27,5 +24,4 @@ - - + \ No newline at end of file diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/GlobalSuppressions.cs b/ConfusedPolarBear.Plugin.IntroSkipper/GlobalSuppressions.cs new file mode 100644 index 0000000..2967ca7 --- /dev/null +++ b/ConfusedPolarBear.Plugin.IntroSkipper/GlobalSuppressions.cs @@ -0,0 +1,10 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name should match first type name", Justification = "Legacy TODO", Scope = "type", Target = "~T:ConfusedPolarBear.Plugin.IntroSkipper.WarningManager")] +[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Legacy TODO", Scope = "type", Target = "~T:ConfusedPolarBear.Plugin.IntroSkipper.IntroWithMetadata")] +[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Legacy TODO", Scope = "type", Target = "~T:ConfusedPolarBear.Plugin.IntroSkipper.TimeRangeHelpers")] diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs index 7f57af8..5fd0b8d 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs @@ -331,7 +331,7 @@ public class Plugin : BasePlugin, IHasWebPages private void InjectSkipButton(string indexPath) { // Parts of this code are based off of JellyScrub's script injection code. - // https://github.com/nicknsy/jellyscrub/blob/4ce806f602988a662cfe3cdbaac35ee8046b7ec4/Nick.Plugin.Jellyscrub/JellyscrubPlugin.cs + // https://github.com/nicknsy/jellyscrub/blob/main/Nick.Plugin.Jellyscrub/JellyscrubPlugin.cs#L38 _logger.LogDebug("Reading index.html from {Path}", indexPath); var contents = File.ReadAllText(indexPath); From f626595cb1ffb1d92728cf892ee047c52daced69 Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX Date: Mon, 4 Mar 2024 07:08:11 -0500 Subject: [PATCH 5/8] Disconnect erase from editor window --- .../Configuration/configPage.html | 129 +++++++++--------- manifest.json | 2 +- 2 files changed, 66 insertions(+), 65 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html index ed3e867..39f8699 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html @@ -59,61 +59,6 @@ -
- EDL File Generation - -
-
- - - -
- If set to a value other than None, specifies which action to write to - MPlayer compatible EDL files - alongside your episode files.
- - If this value is changed after EDL files are generated, you must check the - "Regenerate EDL files" checkbox below. -
-
- -
- - -
- If checked, the plugin will overwrite all EDL files associated with - your episodes with the currently discovered introduction timestamps and EDL action. -
-
-
-
Modify Intro Requirements @@ -179,6 +124,61 @@

+
+ EDL File Generation + +
+
+ + + +
+ If set to a value other than None, specifies which action to write to + MPlayer compatible EDL files + alongside your episode files.
+ + If this value is changed after EDL files are generated, you must check the + "Regenerate EDL files" checkbox below. +
+
+ +
+ + +
+ If checked, the plugin will overwrite all EDL files associated with + your episodes with the currently discovered introduction timestamps and EDL action. +
+
+
+
Silence Detection Options @@ -207,7 +207,7 @@
- Task Configuration + Process Configuration
@@ -271,7 +271,6 @@ but setting a value of 0 (default) will use the maximum threads available.
-
@@ -322,7 +321,7 @@
- If checked, skip button will appear through entire intro (offset and timeout are ignored).
+ If checked, skip button will appear throughout entire intro (offset and timeout are ignored).
@@ -442,13 +441,13 @@

- - -
+ +
+ @@ -674,6 +673,7 @@ // show changed, populate seasons async function showChanged() { clearSelect(selectSeason); + btnSeasonEraseTimestamps.style.display = "none"; // add all seasons from this show to the season select for (var season of shows[selectShow.value]) { @@ -690,6 +690,7 @@ clearSelect(selectEpisode1); clearSelect(selectEpisode2); + btnSeasonEraseTimestamps.style.display = "block"; let i = 1; for (let episode of episodes) { @@ -770,7 +771,7 @@ // make an authenticated GET to the server and parse the response as JSON async function getJson(url) { - return await fetchWithAuth(url, "GET").then(r => { return r.json(); }); + return await fetchWithAuth(url, "GET").then(r => { return r.json(); }).catch(err => { console.debug(err) }); } // make an authenticated fetch to the server diff --git a/manifest.json b/manifest.json index d23259b..d7ab2fd 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "Intro Skipper", "overview": "Automatically detect and skip intros in television episodes", "description": "Analyzes the audio of television episodes and detects introduction sequences.", - "owner": "ConfusedPolarBear", + "owner": "jumoog (forked from ConfusedPolarBear)", "category": "General", "imageUrl": "https://raw.githubusercontent.com/jumoog/intro-skipper/master/images/logo.png", "versions": [ From 0107c92d0f105e05239a66ec2c74199dd86dbde3 Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX Date: Mon, 4 Mar 2024 08:20:46 -0500 Subject: [PATCH 6/8] Stop calling optional items "required" --- .../Configuration/configPage.html | 2 +- README.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html index 39f8699..151a77d 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/configPage.html @@ -60,7 +60,7 @@
- Modify Intro Requirements + Modify Intro Parameters
diff --git a/README.md b/README.md index 7048bf4..d7ed50c 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,14 @@ This fork doesn't ship the custom web interface on your server. So the plugin ne * Debian Linux based native installs: provided by the `jellyfin-ffmpeg5` package * MacOS native installs: build ffmpeg with chromaprint support ([instructions](#installation-instructions-for-macos)) -## Introduction requirements +## Introduction parameters -Show introductions will only be detected if they are: +Show introductions will be detected if they are: -* Located within the first 25% of an episode, or the first 10 minutes, whichever is smaller +* Located within the first 25% of an episode or the first 10 minutes, whichever is smaller * Between 15 seconds and 2 minutes long -Ending credits will only be detected if they are shorter than 4 minutes. +Ending credits will be detected if they are shorter than 4 minutes. All of these requirements can be customized as needed. From 31365442b181a3a359e2afca8d47dd900f94ac6f Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX Date: Mon, 4 Mar 2024 08:58:15 -0500 Subject: [PATCH 7/8] Chromaprint is for scan, not config --- ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs | 7 ------- .../ScheduledTasks/BaseItemAnalyzerTask.cs | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs index 30239a4..c27ff62 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/QueueManager.cs @@ -43,13 +43,6 @@ public class QueueManager /// Queued media items. public ReadOnlyDictionary> GetMediaItems() { - // Assert that ffmpeg with chromaprint is installed - if (!FFmpegWrapper.CheckFFmpegVersion()) - { - throw new FingerprintException( - "ffmpeg with chromaprint is not installed on this system - episodes will not be analyzed. If Jellyfin is running natively, install jellyfin-ffmpeg5. If Jellyfin is running in a container, upgrade it to the latest version of 10.8.0."); - } - Plugin.Instance!.TotalQueued = 0; LoadAnalysisSettings(); diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs index 940e0a0..ca72342 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/ScheduledTasks/BaseItemAnalyzerTask.cs @@ -53,6 +53,13 @@ public class BaseItemAnalyzerTask IProgress progress, CancellationToken cancellationToken) { + // Assert that ffmpeg with chromaprint is installed + if (!FFmpegWrapper.CheckFFmpegVersion()) + { + throw new FingerprintException( + "ffmpeg with chromaprint is not installed on this system - episodes will not be analyzed. If Jellyfin is running natively, install jellyfin-ffmpeg5. If Jellyfin is running in a container, upgrade it to the latest version of 10.8.0."); + } + var queueManager = new QueueManager( _loggerFactory.CreateLogger(), _libraryManager); From ad8677dc2913087aaa35ddc9626abb826118d4da Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX Date: Mon, 4 Mar 2024 09:15:29 -0500 Subject: [PATCH 8/8] v0.1.15.0 --- manifest.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index d7ab2fd..9dde9b2 100644 --- a/manifest.json +++ b/manifest.json @@ -4,10 +4,18 @@ "name": "Intro Skipper", "overview": "Automatically detect and skip intros in television episodes", "description": "Analyzes the audio of television episodes and detects introduction sequences.", - "owner": "jumoog (forked from ConfusedPolarBear)", + "owner": "jumoog, AbandonedCart (forked from ConfusedPolarBear)", "category": "General", "imageUrl": "https://raw.githubusercontent.com/jumoog/intro-skipper/master/images/logo.png", "versions": [ + { + "version": "0.1.15.0", + "changelog": "- See the full changelog at [GitHub](https://github.com/jumoog/intro-skipper/blob/master/CHANGELOG.md)\n", + "targetAbi": "10.8.4.0", + "sourceUrl": "https://github.com/jumoog/intro-skipper/releases/download/v0.1.15/intro-skipper-v0.1.15.zip", + "checksum": "cf05593afbb2be39b8de31dcb7fd8a50", + "timestamp": "2024-03-03T09:08:10Z" + }, { "version": "0.1.14.0", "changelog": "- See the full changelog at [GitHub](https://github.com/jumoog/intro-skipper/blob/master/CHANGELOG.md)\n",