From 86129589ef262ed5b58d373df8958963b152e9b1 Mon Sep 17 00:00:00 2001 From: gnattu Date: Wed, 22 May 2024 13:35:28 +0800 Subject: [PATCH 1/3] Override too small trickplay image interval Some users may set this value too low, causing the trickplay generation to fail. Reset this interval to the minimum valid value of 1 second when the user-configured value is too small to prevent generation failures. Signed-off-by: gnattu --- .../Trickplay/TrickplayManager.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs b/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs index ccd04612f7..fc43401a56 100644 --- a/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs +++ b/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs @@ -81,6 +81,12 @@ public class TrickplayManager : ITrickplayManager _logger.LogDebug("Trickplay refresh for {ItemId} (replace existing: {Replace})", video.Id, replace); var options = _config.Configuration.TrickplayOptions; + if (options.Interval < 1000) + { + _logger.LogWarning("Trickplay image interval {Interval} is too small, reset to the minimum valid value of 1000", options.Interval); + options.Interval = 1000; + } + foreach (var width in options.WidthResolutions) { cancellationToken.ThrowIfCancellationRequested(); From 447f73caf420880fe4e27d996781df50e52f80bd Mon Sep 17 00:00:00 2001 From: gnattu Date: Wed, 22 May 2024 13:41:54 +0800 Subject: [PATCH 2/3] Fix bitrate calculation accuracy Signed-off-by: gnattu --- Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs b/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs index fc43401a56..f68c4ee09b 100644 --- a/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs +++ b/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs @@ -273,7 +273,7 @@ public class TrickplayManager : ITrickplayManager } // Update bitrate - var bitrate = (int)Math.Ceiling((decimal)new FileInfo(tilePath).Length * 8 / trickplayInfo.TileWidth / trickplayInfo.TileHeight / (trickplayInfo.Interval / 1000)); + var bitrate = (int)Math.Ceiling((decimal)new FileInfo(tilePath).Length * 8 / trickplayInfo.TileWidth / trickplayInfo.TileHeight / ((decimal)trickplayInfo.Interval / 1000)); trickplayInfo.Bandwidth = Math.Max(trickplayInfo.Bandwidth, bitrate); } From fa2bff30f671cb57e23fe19c866d3df43af2bcb3 Mon Sep 17 00:00:00 2001 From: gnattu Date: Wed, 22 May 2024 21:17:00 +0800 Subject: [PATCH 3/3] Explicitly use decimal Co-authored-by: Cody Robibero --- Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs b/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs index f68c4ee09b..30add0dc86 100644 --- a/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs +++ b/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs @@ -273,7 +273,7 @@ public class TrickplayManager : ITrickplayManager } // Update bitrate - var bitrate = (int)Math.Ceiling((decimal)new FileInfo(tilePath).Length * 8 / trickplayInfo.TileWidth / trickplayInfo.TileHeight / ((decimal)trickplayInfo.Interval / 1000)); + var bitrate = (int)Math.Ceiling(new FileInfo(tilePath).Length * 8m / trickplayInfo.TileWidth / trickplayInfo.TileHeight / (trickplayInfo.Interval / 1000m)); trickplayInfo.Bandwidth = Math.Max(trickplayInfo.Bandwidth, bitrate); }