diff --git a/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs b/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs index 34b27e21a8..e3bfdd50d6 100644 --- a/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs +++ b/Jellyfin.Server.Implementations/Trickplay/TrickplayManager.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using Jellyfin.Data.Entities; +using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Entities; @@ -34,6 +35,7 @@ public class TrickplayManager : ITrickplayManager private readonly IServerConfigurationManager _config; private readonly IImageEncoder _imageEncoder; private readonly IDbContextFactory _dbProvider; + private readonly IApplicationPaths _appPaths; private static readonly SemaphoreSlim _resourcePool = new(1, 1); private static readonly string[] _trickplayImgExtensions = { ".jpg" }; @@ -49,6 +51,7 @@ public class TrickplayManager : ITrickplayManager /// The server configuration manager. /// The image encoder. /// The database provider. + /// The application paths. public TrickplayManager( ILogger logger, IMediaEncoder mediaEncoder, @@ -57,7 +60,8 @@ public class TrickplayManager : ITrickplayManager ILibraryManager libraryManager, IServerConfigurationManager config, IImageEncoder imageEncoder, - IDbContextFactory dbProvider) + IDbContextFactory dbProvider, + IApplicationPaths appPaths) { _logger = logger; _mediaEncoder = mediaEncoder; @@ -67,6 +71,7 @@ public class TrickplayManager : ITrickplayManager _config = config; _imageEncoder = imageEncoder; _dbProvider = dbProvider; + _appPaths = appPaths; } /// @@ -152,8 +157,7 @@ public class TrickplayManager : ITrickplayManager .ToList(); // Create tiles - var tilesTempDir = Path.Combine(imgTempDir, Guid.NewGuid().ToString("N")); - var trickplayInfo = CreateTiles(images, width, options, tilesTempDir, outputDir); + var trickplayInfo = CreateTiles(images, width, options, outputDir); // Save tiles info try @@ -194,13 +198,15 @@ public class TrickplayManager : ITrickplayManager } } - private TrickplayInfo CreateTiles(List images, int width, TrickplayOptions options, string workDir, string outputDir) + /// + public TrickplayInfo CreateTiles(List images, int width, TrickplayOptions options, string outputDir) { if (images.Count == 0) { throw new ArgumentException("Can't create trickplay from 0 images."); } + var workDir = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")); Directory.CreateDirectory(workDir); var trickplayInfo = new TrickplayInfo diff --git a/MediaBrowser.Controller/Trickplay/ITrickplayManager.cs b/MediaBrowser.Controller/Trickplay/ITrickplayManager.cs index 0a1e780b2e..7bea54fbab 100644 --- a/MediaBrowser.Controller/Trickplay/ITrickplayManager.cs +++ b/MediaBrowser.Controller/Trickplay/ITrickplayManager.cs @@ -4,6 +4,7 @@ using System.Threading; using System.Threading.Tasks; using Jellyfin.Data.Entities; using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Controller.Trickplay; @@ -21,6 +22,19 @@ public interface ITrickplayManager /// Task. Task RefreshTrickplayDataAsync(Video video, bool replace, CancellationToken cancellationToken); + /// + /// Creates trickplay tiles out of individual thumbnails. + /// + /// Ordered file paths of the thumbnails to be used. + /// The width of a single thumbnail. + /// The trickplay options. + /// The output directory. + /// The associated trickplay information. + /// + /// The output directory will be DELETED and replaced if it already exists. + /// + TrickplayInfo CreateTiles(List images, int width, TrickplayOptions options, string outputDir); + /// /// Get available trickplay resolutions and corresponding info. ///