mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
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;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Data.Entities;
|
using Jellyfin.Data.Entities;
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Drawing;
|
using MediaBrowser.Controller.Drawing;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
@ -34,6 +35,7 @@ public class TrickplayManager : ITrickplayManager
|
|||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly IImageEncoder _imageEncoder;
|
private readonly IImageEncoder _imageEncoder;
|
||||||
private readonly IDbContextFactory<JellyfinDbContext> _dbProvider;
|
private readonly IDbContextFactory<JellyfinDbContext> _dbProvider;
|
||||||
|
private readonly IApplicationPaths _appPaths;
|
||||||
|
|
||||||
private static readonly SemaphoreSlim _resourcePool = new(1, 1);
|
private static readonly SemaphoreSlim _resourcePool = new(1, 1);
|
||||||
private static readonly string[] _trickplayImgExtensions = { ".jpg" };
|
private static readonly string[] _trickplayImgExtensions = { ".jpg" };
|
||||||
@ -49,6 +51,7 @@ public class TrickplayManager : ITrickplayManager
|
|||||||
/// <param name="config">The server configuration manager.</param>
|
/// <param name="config">The server configuration manager.</param>
|
||||||
/// <param name="imageEncoder">The image encoder.</param>
|
/// <param name="imageEncoder">The image encoder.</param>
|
||||||
/// <param name="dbProvider">The database provider.</param>
|
/// <param name="dbProvider">The database provider.</param>
|
||||||
|
/// <param name="appPaths">The application paths.</param>
|
||||||
public TrickplayManager(
|
public TrickplayManager(
|
||||||
ILogger<TrickplayManager> logger,
|
ILogger<TrickplayManager> logger,
|
||||||
IMediaEncoder mediaEncoder,
|
IMediaEncoder mediaEncoder,
|
||||||
@ -57,7 +60,8 @@ public class TrickplayManager : ITrickplayManager
|
|||||||
ILibraryManager libraryManager,
|
ILibraryManager libraryManager,
|
||||||
IServerConfigurationManager config,
|
IServerConfigurationManager config,
|
||||||
IImageEncoder imageEncoder,
|
IImageEncoder imageEncoder,
|
||||||
IDbContextFactory<JellyfinDbContext> dbProvider)
|
IDbContextFactory<JellyfinDbContext> dbProvider,
|
||||||
|
IApplicationPaths appPaths)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_mediaEncoder = mediaEncoder;
|
_mediaEncoder = mediaEncoder;
|
||||||
@ -67,6 +71,7 @@ public class TrickplayManager : ITrickplayManager
|
|||||||
_config = config;
|
_config = config;
|
||||||
_imageEncoder = imageEncoder;
|
_imageEncoder = imageEncoder;
|
||||||
_dbProvider = dbProvider;
|
_dbProvider = dbProvider;
|
||||||
|
_appPaths = appPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -152,8 +157,7 @@ public class TrickplayManager : ITrickplayManager
|
|||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// Create tiles
|
// Create tiles
|
||||||
var tilesTempDir = Path.Combine(imgTempDir, Guid.NewGuid().ToString("N"));
|
var trickplayInfo = CreateTiles(images, width, options, outputDir);
|
||||||
var trickplayInfo = CreateTiles(images, width, options, tilesTempDir, outputDir);
|
|
||||||
|
|
||||||
// Save tiles info
|
// Save tiles info
|
||||||
try
|
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)
|
if (images.Count == 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Can't create trickplay from 0 images.");
|
throw new ArgumentException("Can't create trickplay from 0 images.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var workDir = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N"));
|
||||||
Directory.CreateDirectory(workDir);
|
Directory.CreateDirectory(workDir);
|
||||||
|
|
||||||
var trickplayInfo = new TrickplayInfo
|
var trickplayInfo = new TrickplayInfo
|
||||||
|
@ -4,6 +4,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Data.Entities;
|
using Jellyfin.Data.Entities;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Model.Configuration;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Trickplay;
|
namespace MediaBrowser.Controller.Trickplay;
|
||||||
|
|
||||||
@ -21,6 +22,19 @@ public interface ITrickplayManager
|
|||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
Task RefreshTrickplayDataAsync(Video video, bool replace, CancellationToken cancellationToken);
|
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>
|
/// <summary>
|
||||||
/// Get available trickplay resolutions and corresponding info.
|
/// Get available trickplay resolutions and corresponding info.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user