Add CreateTiles to ITrickplayManager
This commit is contained in:
parent
6d9e43cfe0
commit
0e1ae2def2
|
@ -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<JellyfinDbContext> _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
|
|||
/// <param name="config">The server configuration manager.</param>
|
||||
/// <param name="imageEncoder">The image encoder.</param>
|
||||
/// <param name="dbProvider">The database provider.</param>
|
||||
/// <param name="appPaths">The application paths.</param>
|
||||
public TrickplayManager(
|
||||
ILogger<TrickplayManager> logger,
|
||||
IMediaEncoder mediaEncoder,
|
||||
|
@ -57,7 +60,8 @@ public class TrickplayManager : ITrickplayManager
|
|||
ILibraryManager libraryManager,
|
||||
IServerConfigurationManager config,
|
||||
IImageEncoder imageEncoder,
|
||||
IDbContextFactory<JellyfinDbContext> dbProvider)
|
||||
IDbContextFactory<JellyfinDbContext> dbProvider,
|
||||
IApplicationPaths appPaths)
|
||||
{
|
||||
_logger = logger;
|
||||
_mediaEncoder = mediaEncoder;
|
||||
|
@ -67,6 +71,7 @@ public class TrickplayManager : ITrickplayManager
|
|||
_config = config;
|
||||
_imageEncoder = imageEncoder;
|
||||
_dbProvider = dbProvider;
|
||||
_appPaths = appPaths;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -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<string> images, int width, TrickplayOptions options, string workDir, string outputDir)
|
||||
/// <inheritdoc />
|
||||
public TrickplayInfo CreateTiles(List<string> 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
|
||||
|
|
|
@ -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
|
|||
/// <returns>Task.</returns>
|
||||
Task RefreshTrickplayDataAsync(Video video, bool replace, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Creates trickplay tiles out of individual thumbnails.
|
||||
/// </summary>
|
||||
/// <param name="images">Ordered file paths of the thumbnails to be used.</param>
|
||||
/// <param name="width">The width of a single thumbnail.</param>
|
||||
/// <param name="options">The trickplay options.</param>
|
||||
/// <param name="outputDir">The output directory.</param>
|
||||
/// <returns>The associated trickplay information.</returns>
|
||||
/// <remarks>
|
||||
/// The output directory will be DELETED and replaced if it already exists.
|
||||
/// </remarks>
|
||||
TrickplayInfo CreateTiles(List<string> images, int width, TrickplayOptions options, string outputDir);
|
||||
|
||||
/// <summary>
|
||||
/// Get available trickplay resolutions and corresponding info.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user