aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-02-20 11:37:41 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-02-20 11:37:41 -0500
commit888b8d619aec031f57cfd03410ccda52edcca958 (patch)
tree143080937fb8811d107c610507a15376d6761955
parent160d14208809a13791e34530a3758b079d6b9638 (diff)
added encoding manager interface
-rw-r--r--MediaBrowser.Api/MediaBrowser.Api.csproj1
-rw-r--r--MediaBrowser.Api/Playback/BaseStreamingService.cs12
-rw-r--r--MediaBrowser.Api/Playback/Hls/AudioHlsService.cs119
-rw-r--r--MediaBrowser.Api/Playback/Hls/BaseHlsService.cs5
-rw-r--r--MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs5
-rw-r--r--MediaBrowser.Api/Playback/Hls/VideoHlsService.cs5
-rw-r--r--MediaBrowser.Api/Playback/Progressive/AudioService.cs5
-rw-r--r--MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs10
-rw-r--r--MediaBrowser.Api/Playback/Progressive/VideoService.cs5
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj9
-rw-r--r--MediaBrowser.Controller/MediaEncoding/ChapterImageRefreshOptions.cs17
-rw-r--r--MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs33
-rw-r--r--MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs (renamed from MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs)2
-rw-r--r--MediaBrowser.Controller/MediaEncoding/InternalMediaInfoResult.cs (renamed from MediaBrowser.Controller/MediaInfo/InternalMediaInfoResult.cs)6
-rw-r--r--MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs (renamed from MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs)8
-rw-r--r--MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs2
-rw-r--r--MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs2
-rw-r--r--MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs2
-rw-r--r--MediaBrowser.Providers/MediaInfo/FFProbeHelpers.cs2
-rw-r--r--MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs7
-rw-r--r--MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs15
-rw-r--r--MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs2
-rw-r--r--MediaBrowser.Providers/Omdb/OmdbProvider.cs3
-rw-r--r--MediaBrowser.Providers/TV/MovieDbSeriesProvider.cs2
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs2
-rw-r--r--MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj1
-rw-r--r--MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs (renamed from MediaBrowser.Controller/MediaInfo/FFMpegManager.cs)177
-rw-r--r--MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs2
-rw-r--r--MediaBrowser.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs33
-rw-r--r--MediaBrowser.ServerApplication/ApplicationHost.cs19
30 files changed, 223 insertions, 290 deletions
diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj
index e62ed3e25..f8d0ed125 100644
--- a/MediaBrowser.Api/MediaBrowser.Api.csproj
+++ b/MediaBrowser.Api/MediaBrowser.Api.csproj
@@ -96,7 +96,6 @@
<Compile Include="PackageReviewService.cs" />
<Compile Include="PackageService.cs" />
<Compile Include="Playback\EndlessStreamCopy.cs" />
- <Compile Include="Playback\Hls\AudioHlsService.cs" />
<Compile Include="Playback\Hls\BaseHlsService.cs" />
<Compile Include="Playback\Hls\DynamicHlsService.cs" />
<Compile Include="Playback\Hls\HlsSegmentService.cs" />
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index 5705d4cd8..da3f9be17 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -5,7 +5,7 @@ using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Drawing;
@@ -58,6 +58,7 @@ namespace MediaBrowser.Api.Playback
/// </summary>
/// <value>The media encoder.</value>
protected IMediaEncoder MediaEncoder { get; private set; }
+ protected IEncodingManager EncodingManager { get; private set; }
protected IDtoService DtoService { get; private set; }
protected IFileSystem FileSystem { get; private set; }
@@ -76,8 +77,9 @@ namespace MediaBrowser.Api.Playback
/// <param name="dtoService">The dto service.</param>
/// <param name="fileSystem">The file system.</param>
/// <param name="itemRepository">The item repository.</param>
- protected BaseStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager)
+ protected BaseStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager, IEncodingManager encodingManager)
{
+ EncodingManager = encodingManager;
LiveTvManager = liveTvManager;
ItemRepository = itemRepository;
FileSystem = fileSystem;
@@ -589,8 +591,8 @@ namespace MediaBrowser.Api.Playback
/// <returns>System.String.</returns>
private string GetExtractedAssPath(StreamState state, bool performConversion)
{
- var path = FFMpegManager.Instance.GetSubtitleCachePath(state.MediaPath, state.SubtitleStream, ".ass");
-
+ var path = EncodingManager.GetSubtitleCachePath(state.MediaPath, state.SubtitleStream.Index, ".ass");
+
if (performConversion)
{
InputType type;
@@ -629,7 +631,7 @@ namespace MediaBrowser.Api.Playback
/// <returns>System.String.</returns>
private string GetConvertedAssPath(string mediaPath, MediaStream subtitleStream, bool performConversion)
{
- var path = FFMpegManager.Instance.GetSubtitleCachePath(mediaPath, subtitleStream, ".ass");
+ var path = EncodingManager.GetSubtitleCachePath(subtitleStream.Path, ".ass");
if (performConversion)
{
diff --git a/MediaBrowser.Api/Playback/Hls/AudioHlsService.cs b/MediaBrowser.Api/Playback/Hls/AudioHlsService.cs
deleted file mode 100644
index a64cdb119..000000000
--- a/MediaBrowser.Api/Playback/Hls/AudioHlsService.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Dto;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Controller.MediaInfo;
-using MediaBrowser.Controller.Persistence;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.IO;
-using ServiceStack;
-using System;
-
-namespace MediaBrowser.Api.Playback.Hls
-{
- /// <summary>
- /// Class GetHlsAudioStream
- /// </summary>
- [Route("/Audio/{Id}/stream.m3u8", "GET")]
- [Api(Description = "Gets an audio stream using HTTP live streaming.")]
- public class GetHlsAudioStream : StreamRequest
- {
-
- }
-
- /// <summary>
- /// Class AudioHlsService
- /// </summary>
- public class AudioHlsService : BaseHlsService
- {
- public AudioHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager)
- : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager)
- {
- }
-
- /// <summary>
- /// Gets the specified request.
- /// </summary>
- /// <param name="request">The request.</param>
- /// <returns>System.Object.</returns>
- public object Get(GetHlsAudioStream request)
- {
- return ProcessRequest(request);
- }
-
- /// <summary>
- /// Gets the audio arguments.
- /// </summary>
- /// <param name="state">The state.</param>
- /// <returns>System.String.</returns>
- protected override string GetAudioArguments(StreamState state)
- {
- var codec = GetAudioCodec(state.Request);
-
- var args = "-codec:a " + codec;
-
- var channels = GetNumAudioChannelsParam(state.Request, state.AudioStream);
-
- if (channels.HasValue)
- {
- args += " -ac " + channels.Value;
- }
-
- if (state.Request.AudioSampleRate.HasValue)
- {
- args += " -ar " + state.Request.AudioSampleRate.Value;
- }
-
- if (state.Request.AudioBitRate.HasValue)
- {
- args += " -ab " + state.Request.AudioBitRate.Value;
- }
-
- return args;
- }
-
- /// <summary>
- /// Gets the video arguments.
- /// </summary>
- /// <param name="state">The state.</param>
- /// <param name="performSubtitleConversion">if set to <c>true</c> [perform subtitle conversion].</param>
- /// <returns>System.String.</returns>
- protected override string GetVideoArguments(StreamState state, bool performSubtitleConversion)
- {
- // No video
- return string.Empty;
- }
-
- /// <summary>
- /// Gets the segment file extension.
- /// </summary>
- /// <param name="state">The state.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentException">Must specify either aac or mp3 audio codec.</exception>
- /// <exception cref="System.InvalidOperationException">Only aac and mp3 audio codecs are supported.</exception>
- protected override string GetSegmentFileExtension(StreamState state)
- {
- if (state.Request.AudioCodec == AudioCodecs.Aac)
- {
- return ".aac";
- }
- if (state.Request.AudioCodec == AudioCodecs.Mp3)
- {
- return ".mp3";
- }
-
- throw new ArgumentException("Must specify either aac or mp3 audio codec.");
- }
-
- /// <summary>
- /// Gets the map args.
- /// </summary>
- /// <param name="state">The state.</param>
- /// <returns>System.String.</returns>
- protected override string GetMapArgs(StreamState state)
- {
- return string.Format("-map 0:{0}", state.AudioStream.Index);
- }
- }
-}
diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
index 35a418ba7..c6055ed51 100644
--- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
@@ -5,7 +5,7 @@ using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dto;
@@ -24,8 +24,7 @@ namespace MediaBrowser.Api.Playback.Hls
/// </summary>
public abstract class BaseHlsService : BaseStreamingService
{
- protected BaseHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager)
- : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager)
+ protected BaseHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager, IEncodingManager encodingManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager, encodingManager)
{
}
diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
index e04fc3b14..121957ecc 100644
--- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
@@ -4,7 +4,7 @@ using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.IO;
@@ -60,8 +60,7 @@ namespace MediaBrowser.Api.Playback.Hls
public class DynamicHlsService : BaseHlsService
{
- public DynamicHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager)
- : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager)
+ public DynamicHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager, IEncodingManager encodingManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager, encodingManager)
{
}
diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
index f8a674f05..ca598c275 100644
--- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
@@ -3,7 +3,7 @@ using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.IO;
using ServiceStack;
@@ -52,8 +52,7 @@ namespace MediaBrowser.Api.Playback.Hls
/// </summary>
public class VideoHlsService : BaseHlsService
{
- public VideoHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager)
- : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager)
+ public VideoHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager, IEncodingManager encodingManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager, encodingManager)
{
}
diff --git a/MediaBrowser.Api/Playback/Progressive/AudioService.cs b/MediaBrowser.Api/Playback/Progressive/AudioService.cs
index 5ce2eeece..909dd0f40 100644
--- a/MediaBrowser.Api/Playback/Progressive/AudioService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/AudioService.cs
@@ -5,7 +5,7 @@ using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.IO;
using ServiceStack;
@@ -43,8 +43,7 @@ namespace MediaBrowser.Api.Playback.Progressive
/// </summary>
public class AudioService : BaseProgressiveStreamingService
{
- public AudioService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager, IImageProcessor imageProcessor, IHttpClient httpClient)
- : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager, imageProcessor, httpClient)
+ public AudioService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager, IEncodingManager encodingManager, IHttpClient httpClient, IImageProcessor imageProcessor) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager, encodingManager, httpClient, imageProcessor)
{
}
diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
index 960424373..023c59730 100644
--- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
@@ -5,16 +5,16 @@ using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.IO;
+using ServiceStack.Web;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
-using ServiceStack.Web;
namespace MediaBrowser.Api.Playback.Progressive
{
@@ -26,11 +26,11 @@ namespace MediaBrowser.Api.Playback.Progressive
protected readonly IImageProcessor ImageProcessor;
protected readonly IHttpClient HttpClient;
- protected BaseProgressiveStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager, IImageProcessor imageProcessor, IHttpClient httpClient)
- : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager)
+ protected BaseProgressiveStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager, IEncodingManager encodingManager, IHttpClient httpClient, IImageProcessor imageProcessor)
+ : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager, encodingManager)
{
- ImageProcessor = imageProcessor;
HttpClient = httpClient;
+ ImageProcessor = imageProcessor;
}
/// <summary>
diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs
index 4bd8c351c..6deea4ffc 100644
--- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs
@@ -5,7 +5,7 @@ using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.IO;
using ServiceStack;
@@ -58,8 +58,7 @@ namespace MediaBrowser.Api.Playback.Progressive
/// </summary>
public class VideoService : BaseProgressiveStreamingService
{
- public VideoService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager, IImageProcessor imageProcessor, IHttpClient httpClient)
- : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager, imageProcessor, httpClient)
+ public VideoService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem, IItemRepository itemRepository, ILiveTvManager liveTvManager, IEncodingManager encodingManager, IHttpClient httpClient, IImageProcessor imageProcessor) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem, itemRepository, liveTvManager, encodingManager, httpClient, imageProcessor)
{
}
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index c88164897..ab1c012a8 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -135,8 +135,10 @@
<Compile Include="LiveTv\SeriesTimerInfo.cs" />
<Compile Include="LiveTv\TimerInfo.cs" />
<Compile Include="Localization\ILocalizationManager.cs" />
- <Compile Include="MediaInfo\IMediaEncoder.cs" />
- <Compile Include="MediaInfo\InternalMediaInfoResult.cs" />
+ <Compile Include="MediaEncoding\ChapterImageRefreshOptions.cs" />
+ <Compile Include="MediaEncoding\IEncodingManager.cs" />
+ <Compile Include="MediaEncoding\IMediaEncoder.cs" />
+ <Compile Include="MediaEncoding\InternalMediaInfoResult.cs" />
<Compile Include="Net\IHasResultFactory.cs" />
<Compile Include="Net\IHttpResultFactory.cs" />
<Compile Include="Net\IHttpServer.cs" />
@@ -198,7 +200,7 @@
<Compile Include="IServerApplicationPaths.cs" />
<Compile Include="Library\SearchHintInfo.cs" />
<Compile Include="Providers\IProviderManager.cs" />
- <Compile Include="MediaInfo\MediaEncoderHelpers.cs" />
+ <Compile Include="MediaEncoding\MediaEncoderHelpers.cs" />
<Compile Include="Providers\MetadataProviderPriority.cs" />
<Compile Include="Resolvers\BaseItemResolver.cs" />
<Compile Include="Resolvers\BaseVideoResolver.cs" />
@@ -209,7 +211,6 @@
<Compile Include="Localization\BaseStrings.cs" />
<Compile Include="Localization\LocalizedStringData.cs" />
<Compile Include="Localization\LocalizedStrings.cs" />
- <Compile Include="MediaInfo\FFMpegManager.cs" />
<Compile Include="Persistence\IDisplayPreferencesRepository.cs" />
<Compile Include="Persistence\IItemRepository.cs" />
<Compile Include="Persistence\IRepository.cs" />
diff --git a/MediaBrowser.Controller/MediaEncoding/ChapterImageRefreshOptions.cs b/MediaBrowser.Controller/MediaEncoding/ChapterImageRefreshOptions.cs
new file mode 100644
index 000000000..e11bd6cdf
--- /dev/null
+++ b/MediaBrowser.Controller/MediaEncoding/ChapterImageRefreshOptions.cs
@@ -0,0 +1,17 @@
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Model.Entities;
+using System.Collections.Generic;
+
+namespace MediaBrowser.Controller.MediaEncoding
+{
+ public class ChapterImageRefreshOptions
+ {
+ public Video Video { get; set; }
+
+ public List<ChapterInfo> Chapters { get; set; }
+
+ public bool SaveChapters { get; set; }
+
+ public bool ExtractImages { get; set; }
+ }
+}
diff --git a/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs b/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs
new file mode 100644
index 000000000..d1e40e3f0
--- /dev/null
+++ b/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs
@@ -0,0 +1,33 @@
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Controller.MediaEncoding
+{
+ public interface IEncodingManager
+ {
+ /// <summary>
+ /// Gets the subtitle cache path.
+ /// </summary>
+ /// <param name="originalSubtitlePath">The original subtitle path.</param>
+ /// <param name="outputSubtitleExtension">The output subtitle extension.</param>
+ /// <returns>System.String.</returns>
+ string GetSubtitleCachePath(string originalSubtitlePath, string outputSubtitleExtension);
+
+ /// <summary>
+ /// Gets the subtitle cache path.
+ /// </summary>
+ /// <param name="mediaPath">The media path.</param>
+ /// <param name="subtitleStreamIndex">Index of the subtitle stream.</param>
+ /// <param name="outputSubtitleExtension">The output subtitle extension.</param>
+ /// <returns>System.String.</returns>
+ string GetSubtitleCachePath(string mediaPath, int subtitleStreamIndex, string outputSubtitleExtension);
+
+ /// <summary>
+ /// Refreshes the chapter images.
+ /// </summary>
+ /// <param name="options">The options.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task{System.Boolean}.</returns>
+ Task<bool> RefreshChapterImages(ChapterImageRefreshOptions options, CancellationToken cancellationToken);
+ }
+}
diff --git a/MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
index d8cad48b3..119688fa7 100644
--- a/MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs
+++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
@@ -4,7 +4,7 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
-namespace MediaBrowser.Controller.MediaInfo
+namespace MediaBrowser.Controller.MediaEncoding
{
/// <summary>
/// Interface IMediaEncoder
diff --git a/MediaBrowser.Controller/MediaInfo/InternalMediaInfoResult.cs b/MediaBrowser.Controller/MediaEncoding/InternalMediaInfoResult.cs
index 3ceec1b90..e113521ec 100644
--- a/MediaBrowser.Controller/MediaInfo/InternalMediaInfoResult.cs
+++ b/MediaBrowser.Controller/MediaEncoding/InternalMediaInfoResult.cs
@@ -1,7 +1,7 @@
-using System.Collections.Generic;
-using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Entities;
+using System.Collections.Generic;
-namespace MediaBrowser.Controller.MediaInfo
+namespace MediaBrowser.Controller.MediaEncoding
{
/// <summary>
/// Class MediaInfoResult
diff --git a/MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs
index 300071b7b..b2b9e2af3 100644
--- a/MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs
+++ b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs
@@ -1,12 +1,12 @@
-using System;
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.IO;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
-using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.IO;
-namespace MediaBrowser.Controller.MediaInfo
+namespace MediaBrowser.Controller.MediaEncoding
{
/// <summary>
/// Class MediaEncoderHelpers
diff --git a/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs b/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs
index bc29bad34..09939f2d6 100644
--- a/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs
+++ b/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs
@@ -236,7 +236,7 @@ namespace MediaBrowser.Providers.BoxSets
private static string GetCollectionsDataPath(IApplicationPaths appPaths)
{
- var dataPath = Path.Combine(appPaths.DataPath, "tmdb-collections");
+ var dataPath = Path.Combine(appPaths.CachePath, "tmdb-collections");
return dataPath;
}
diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
index 7d9e3e315..b3c3f278e 100644
--- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs
@@ -3,7 +3,7 @@ using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs
index ebb2f13d1..e79fa65fb 100644
--- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs
+++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs
@@ -3,7 +3,7 @@ using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Serialization;
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeHelpers.cs b/MediaBrowser.Providers/MediaInfo/FFProbeHelpers.cs
index 5a4b2beb2..49c7ebec8 100644
--- a/MediaBrowser.Providers/MediaInfo/FFProbeHelpers.cs
+++ b/MediaBrowser.Providers/MediaInfo/FFProbeHelpers.cs
@@ -1,4 +1,4 @@
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using System;
using System.Collections.Generic;
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs
index 161532fd3..ed324ede8 100644
--- a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs
@@ -6,7 +6,7 @@ using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Localization;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
@@ -42,6 +42,7 @@ namespace MediaBrowser.Providers.MediaInfo
private readonly ILocalizationManager _localization;
private readonly IApplicationPaths _appPaths;
private readonly IJsonSerializer _json;
+ private readonly IEncodingManager _encodingManager;
public string Name
{
@@ -124,7 +125,7 @@ namespace MediaBrowser.Providers.MediaInfo
return _cachedTask;
}
- var prober = new FFProbeVideoInfo(_logger, _isoManager, _mediaEncoder, _itemRepo, _blurayExaminer, _localization, _appPaths, _json);
+ var prober = new FFProbeVideoInfo(_logger, _isoManager, _mediaEncoder, _itemRepo, _blurayExaminer, _localization, _appPaths, _json, _encodingManager);
return prober.ProbeVideo(item, directoryService, cancellationToken);
}
@@ -155,7 +156,7 @@ namespace MediaBrowser.Providers.MediaInfo
if (video != null)
{
- var prober = new FFProbeVideoInfo(_logger, _isoManager, _mediaEncoder, _itemRepo, _blurayExaminer, _localization, _appPaths, _json);
+ var prober = new FFProbeVideoInfo(_logger, _isoManager, _mediaEncoder, _itemRepo, _blurayExaminer, _localization, _appPaths, _json, _encodingManager);
return !video.SubtitleFiles.SequenceEqual(prober.GetSubtitleFiles(video, directoryService).Select(i => i.FullName).OrderBy(i => i), StringComparer.OrdinalIgnoreCase);
}
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
index 074bcfdff..f55fc4cf5 100644
--- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
+++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
@@ -3,7 +3,7 @@ using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
@@ -31,10 +31,11 @@ namespace MediaBrowser.Providers.MediaInfo
private readonly ILocalizationManager _localization;
private readonly IApplicationPaths _appPaths;
private readonly IJsonSerializer _json;
+ private readonly IEncodingManager _encodingManager;
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
- public FFProbeVideoInfo(ILogger logger, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo, IBlurayExaminer blurayExaminer, ILocalizationManager localization, IApplicationPaths appPaths, IJsonSerializer json)
+ public FFProbeVideoInfo(ILogger logger, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo, IBlurayExaminer blurayExaminer, ILocalizationManager localization, IApplicationPaths appPaths, IJsonSerializer json, IEncodingManager encodingManager)
{
_logger = logger;
_isoManager = isoManager;
@@ -44,6 +45,7 @@ namespace MediaBrowser.Providers.MediaInfo
_localization = localization;
_appPaths = appPaths;
_json = json;
+ _encodingManager = encodingManager;
}
public async Task<ItemUpdateType> ProbeVideo<T>(T item, IDirectoryService directoryService, CancellationToken cancellationToken)
@@ -167,7 +169,14 @@ namespace MediaBrowser.Providers.MediaInfo
video.HasSubtitles = mediaStreams.Any(i => i.Type == MediaStreamType.Subtitle);
- await FFMpegManager.Instance.PopulateChapterImages(video, chapters, false, false, cancellationToken).ConfigureAwait(false);
+ await _encodingManager.RefreshChapterImages(new ChapterImageRefreshOptions
+ {
+ Chapters = chapters,
+ Video = video,
+ ExtractImages = false,
+ SaveChapters = false
+
+ }, cancellationToken).ConfigureAwait(false);
await _itemRepo.SaveMediaStreams(video.Id, mediaStreams, cancellationToken).ConfigureAwait(false);
diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
index 03cdc3e72..68216c6e1 100644
--- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
@@ -1,7 +1,7 @@
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
diff --git a/MediaBrowser.Providers/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Omdb/OmdbProvider.cs
index 38f555133..07fee988c 100644
--- a/MediaBrowser.Providers/Omdb/OmdbProvider.cs
+++ b/MediaBrowser.Providers/Omdb/OmdbProvider.cs
@@ -1,8 +1,5 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Entities.Movies;
-using MediaBrowser.Controller.Entities.TV;
-using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Serialization;
using System;
using System.Globalization;
diff --git a/MediaBrowser.Providers/TV/MovieDbSeriesProvider.cs b/MediaBrowser.Providers/TV/MovieDbSeriesProvider.cs
index 165f901ea..b46336e90 100644
--- a/MediaBrowser.Providers/TV/MovieDbSeriesProvider.cs
+++ b/MediaBrowser.Providers/TV/MovieDbSeriesProvider.cs
@@ -202,7 +202,7 @@ namespace MediaBrowser.Providers.TV
internal static string GetSeriesDataPath(IApplicationPaths appPaths)
{
- var dataPath = Path.Combine(appPaths.DataPath, "tmdb-tv");
+ var dataPath = Path.Combine(appPaths.CachePath, "tmdb-tv");
return dataPath;
}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index 989ed3c35..110e6377a 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -7,7 +7,7 @@ using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Sorting;
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index 5060dbed3..9417eb191 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
@@ -179,6 +179,7 @@
<Compile Include="LiveTv\RecordingImageProvider.cs" />
<Compile Include="LiveTv\RefreshChannelsScheduledTask.cs" />
<Compile Include="Localization\LocalizationManager.cs" />
+ <Compile Include="MediaEncoder\EncodingManager.cs" />
<Compile Include="MediaEncoder\MediaEncoder.cs" />
<Compile Include="News\NewsEntryPoint.cs" />
<Compile Include="News\NewsService.cs" />
diff --git a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs b/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs
index e3604eb0e..6f4b7a8a7 100644
--- a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
+++ b/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs
@@ -4,6 +4,7 @@ using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
@@ -15,63 +16,65 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-namespace MediaBrowser.Controller.MediaInfo
+namespace MediaBrowser.Server.Implementations.MediaEncoder
{
- /// <summary>
- /// Class FFMpegManager
- /// </summary>
- public class FFMpegManager
+ public class EncodingManager : IEncodingManager
{
private readonly IServerConfigurationManager _config;
- private readonly IMediaEncoder _encoder;
+ private readonly CultureInfo _usCulture = new CultureInfo("en-US");
+ private readonly IFileSystem _fileSystem;
private readonly ILogger _logger;
private readonly IItemRepository _itemRepo;
+ private readonly IMediaEncoder _encoder;
- private readonly IFileSystem _fileSystem;
-
- public static FFMpegManager Instance { get; private set; }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="FFMpegManager" /> class.
- /// </summary>
- /// <param name="encoder">The encoder.</param>
- /// <param name="logger">The logger.</param>
- /// <param name="itemRepo">The item repo.</param>
- /// <exception cref="System.ArgumentNullException">zipClient</exception>
- public FFMpegManager(IMediaEncoder encoder, ILogger logger, IItemRepository itemRepo, IFileSystem fileSystem, IServerConfigurationManager config)
+ public EncodingManager(IServerConfigurationManager config, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IMediaEncoder encoder)
{
- _encoder = encoder;
+ _config = config;
+ _fileSystem = fileSystem;
_logger = logger;
_itemRepo = itemRepo;
- _fileSystem = fileSystem;
- _config = config;
-
- // TODO: Remove this static instance
- Instance = this;
+ _encoder = encoder;
}
- /// <summary>
- /// Gets the chapter images data path.
- /// </summary>
- /// <value>The chapter images data path.</value>
- public string ChapterImagesPath
+ private string SubtitleCachePath
{
get
{
- return Path.Combine(_config.ApplicationPaths.DataPath, "chapter-images");
+ return Path.Combine(_config.ApplicationPaths.CachePath, "subtitles");
}
}
+
+ public string GetSubtitleCachePath(string originalSubtitlePath, string outputSubtitleExtension)
+ {
+ var ticksParam = _fileSystem.GetLastWriteTimeUtc(originalSubtitlePath).Ticks;
+
+ var filename = (originalSubtitlePath + ticksParam).GetMD5() + outputSubtitleExtension;
+
+ var prefix = filename.Substring(0, 1);
+
+ return Path.Combine(SubtitleCachePath, prefix, filename);
+ }
+
+ public string GetSubtitleCachePath(string mediaPath, int subtitleStreamIndex, string outputSubtitleExtension)
+ {
+ var ticksParam = string.Empty;
+
+ var date = _fileSystem.GetLastWriteTimeUtc(mediaPath);
+
+ var filename = (mediaPath + "_" + subtitleStreamIndex.ToString(_usCulture) + "_" + date.Ticks.ToString(_usCulture) + ticksParam).GetMD5() + outputSubtitleExtension;
+
+ var prefix = filename.Substring(0, 1);
+
+ return Path.Combine(SubtitleCachePath, prefix, filename);
+ }
/// <summary>
- /// Gets the subtitle cache path.
+ /// Gets the chapter images data path.
/// </summary>
- /// <value>The subtitle cache path.</value>
- private string SubtitleCachePath
+ /// <value>The chapter images data path.</value>
+ private string GetChapterImagesPath(Guid itemId)
{
- get
- {
- return Path.Combine(_config.ApplicationPaths.CachePath, "subtitles");
- }
+ return Path.Combine(_config.ApplicationPaths.GetInternalMetadataPath(itemId), "chapters");
}
/// <summary>
@@ -95,7 +98,7 @@ namespace MediaBrowser.Controller.MediaInfo
return false;
}
}
- else
+ else
{
if (!_config.Configuration.EnableOtherVideoChapterImageExtraction)
{
@@ -112,18 +115,13 @@ namespace MediaBrowser.Controller.MediaInfo
/// </summary>
private static readonly long FirstChapterTicks = TimeSpan.FromSeconds(15).Ticks;
- /// <summary>
- /// Extracts the chapter images.
- /// </summary>
- /// <param name="video">The video.</param>
- /// <param name="chapters">The chapters.</param>
- /// <param name="extractImages">if set to <c>true</c> [extract images].</param>
- /// <param name="saveChapters">if set to <c>true</c> [save chapters].</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task.</returns>
- /// <exception cref="System.ArgumentNullException"></exception>
- public async Task<bool> PopulateChapterImages(Video video, List<ChapterInfo> chapters, bool extractImages, bool saveChapters, CancellationToken cancellationToken)
+ public async Task<bool> RefreshChapterImages(ChapterImageRefreshOptions options, CancellationToken cancellationToken)
{
+ var extractImages = options.ExtractImages;
+ var video = options.Video;
+ var chapters = options.Chapters;
+ var saveChapters = options.SaveChapters;
+
if (!IsEligibleForChapterImageExtraction(video))
{
extractImages = false;
@@ -173,9 +171,7 @@ namespace MediaBrowser.Controller.MediaInfo
try
{
- var parentPath = Path.GetDirectoryName(path);
-
- Directory.CreateDirectory(parentPath);
+ Directory.CreateDirectory(Path.GetDirectoryName(path));
using (var stream = await _encoder.ExtractImage(inputPath, type, false, video.Video3DFormat, time, cancellationToken).ConfigureAwait(false))
{
@@ -217,6 +213,28 @@ namespace MediaBrowser.Controller.MediaInfo
return success;
}
+ private string GetChapterImagePath(Video video, long chapterPositionTicks)
+ {
+ var filename = video.DateModified.Ticks.ToString(_usCulture) + "_" + chapterPositionTicks.ToString(_usCulture) + ".jpg";
+
+ return Path.Combine(GetChapterImagesPath(video.Id), filename);
+ }
+
+ private List<string> GetSavedChapterImages(Video video)
+ {
+ var path = GetChapterImagesPath(video.Id);
+
+ try
+ {
+ return Directory.EnumerateFiles(path)
+ .ToList();
+ }
+ catch (DirectoryNotFoundException)
+ {
+ return new List<string>();
+ }
+ }
+
private void DeleteDeadImages(IEnumerable<string> images, IEnumerable<ChapterInfo> chapters)
{
var deadImages = images
@@ -238,60 +256,5 @@ namespace MediaBrowser.Controller.MediaInfo
}
}
}
-
- private readonly CultureInfo _usCulture = new CultureInfo("en-US");
-
- /// <summary>
- /// Gets the subtitle cache path.
- /// </summary>
- /// <param name="mediaPath">The media path.</param>
- /// <param name="subtitleStream">The subtitle stream.</param>
- /// <param name="outputExtension">The output extension.</param>
- /// <returns>System.String.</returns>
- public string GetSubtitleCachePath(string mediaPath, MediaStream subtitleStream, string outputExtension)
- {
- var ticksParam = string.Empty;
-
- if (subtitleStream.IsExternal)
- {
- ticksParam += _fileSystem.GetLastWriteTimeUtc(subtitleStream.Path).Ticks;
- }
-
- var date = _fileSystem.GetLastWriteTimeUtc(mediaPath);
-
- var filename = (mediaPath + "_" + subtitleStream.Index.ToString(_usCulture) + "_" + date.Ticks.ToString(_usCulture) + ticksParam).GetMD5() + outputExtension;
-
- var prefix = filename.Substring(0, 1);
-
- return Path.Combine(SubtitleCachePath, prefix, filename);
- }
-
- public string GetChapterImagePath(Video video, long chapterPositionTicks)
- {
- var filename = video.DateModified.Ticks.ToString(_usCulture) + "_" + chapterPositionTicks.ToString(_usCulture) + ".jpg";
-
- var videoId = video.Id.ToString();
- var prefix = videoId.Substring(0, 1);
-
- return Path.Combine(ChapterImagesPath, prefix, videoId, filename);
- }
-
- public List<string> GetSavedChapterImages(Video video)
- {
- var videoId = video.Id.ToString();
- var prefix = videoId.Substring(0, 1);
-
- var path = Path.Combine(ChapterImagesPath, prefix, videoId);
-
- try
- {
- return Directory.EnumerateFiles(path)
- .ToList();
- }
- catch (DirectoryNotFoundException)
- {
- return new List<string>();
- }
- }
}
}
diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
index c1843504c..e71867b05 100644
--- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
+++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
@@ -1,6 +1,6 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
diff --git a/MediaBrowser.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs b/MediaBrowser.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs
index 2608ac172..2a115c8dd 100644
--- a/MediaBrowser.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs
+++ b/MediaBrowser.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs
@@ -1,7 +1,8 @@
-using MediaBrowser.Common.ScheduledTasks;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
@@ -41,17 +42,23 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
private readonly IItemRepository _itemRepo;
+ private readonly IApplicationPaths _appPaths;
+
+ private readonly IEncodingManager _encodingManager;
+
/// <summary>
/// Initializes a new instance of the <see cref="ChapterImagesTask" /> class.
/// </summary>
/// <param name="logManager">The log manager.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="itemRepo">The item repo.</param>
- public ChapterImagesTask(ILogManager logManager, ILibraryManager libraryManager, IItemRepository itemRepo)
+ public ChapterImagesTask(ILogManager logManager, ILibraryManager libraryManager, IItemRepository itemRepo, IApplicationPaths appPaths, IEncodingManager encodingManager)
{
_logger = logManager.GetLogger(GetType().Name);
_libraryManager = libraryManager;
_itemRepo = itemRepo;
+ _appPaths = appPaths;
+ _encodingManager = encodingManager;
libraryManager.ItemAdded += libraryManager_ItemAdded;
libraryManager.ItemUpdated += libraryManager_ItemAdded;
@@ -102,7 +109,14 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
{
var chapters = _itemRepo.GetChapters(item.Id).ToList();
- await FFMpegManager.Instance.PopulateChapterImages(item, chapters, true, true, CancellationToken.None);
+ await _encodingManager.RefreshChapterImages(new ChapterImageRefreshOptions
+ {
+ SaveChapters = true,
+ ExtractImages = true,
+ Video = item,
+ Chapters = chapters
+
+ }, CancellationToken.None);
}
catch (Exception ex)
{
@@ -137,7 +151,7 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
var numComplete = 0;
- var failHistoryPath = Path.Combine(FFMpegManager.Instance.ChapterImagesPath, "failures.txt");
+ var failHistoryPath = Path.Combine(_appPaths.CachePath, "chapter-failures.txt");
List<string> previouslyFailedImages;
@@ -166,7 +180,14 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
var chapters = _itemRepo.GetChapters(video.Id).ToList();
- var success = await FFMpegManager.Instance.PopulateChapterImages(video, chapters, extract, true, cancellationToken);
+ var success = await _encodingManager.RefreshChapterImages(new ChapterImageRefreshOptions
+ {
+ SaveChapters = true,
+ ExtractImages = extract,
+ Video = video,
+ Chapters = chapters
+
+ }, CancellationToken.None);
if (!success)
{
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index 527e00f62..f8a6b7610 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -17,7 +17,7 @@ using MediaBrowser.Controller.FileOrganization;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Localization;
-using MediaBrowser.Controller.MediaInfo;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.News;
using MediaBrowser.Controller.Notifications;
@@ -161,6 +161,8 @@ namespace MediaBrowser.ServerApplication
private ILocalizationManager LocalizationManager { get; set; }
+ private IEncodingManager EncodingManager { get; set; }
+
/// <summary>
/// Gets or sets the user data repository.
/// </summary>
@@ -272,6 +274,15 @@ namespace MediaBrowser.ServerApplication
try
{
+ Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "chapter-images"), true);
+ }
+ catch (IOException)
+ {
+ // Not there, no big deal
+ }
+
+ try
+ {
Directory.Delete(Path.Combine(ApplicationPaths.DataPath, "extracted-video-images"), true);
}
catch (IOException)
@@ -374,6 +385,10 @@ namespace MediaBrowser.ServerApplication
await RegisterMediaEncoder(innerProgress).ConfigureAwait(false);
progress.Report(90);
+ EncodingManager = new EncodingManager(ServerConfigurationManager, FileSystemManager, Logger, ItemRepository,
+ MediaEncoder);
+ RegisterSingleInstance(EncodingManager);
+
LiveTvManager = new LiveTvManager(ServerConfigurationManager, FileSystemManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, MediaEncoder, TaskManager);
RegisterSingleInstance(LiveTvManager);
@@ -419,8 +434,6 @@ namespace MediaBrowser.ServerApplication
/// </summary>
private void SetKernelProperties()
{
- new FFMpegManager(MediaEncoder, Logger, ItemRepository, FileSystemManager, ServerConfigurationManager);
-
LocalizedStrings.StringFiles = GetExports<LocalizedStringData>();
SetStaticProperties();