From 888b8d619aec031f57cfd03410ccda52edcca958 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 20 Feb 2014 11:37:41 -0500 Subject: [PATCH] added encoding manager interface --- MediaBrowser.Api/MediaBrowser.Api.csproj | 1 - .../Playback/BaseStreamingService.cs | 12 +- .../Playback/Hls/AudioHlsService.cs | 119 ------------ .../Playback/Hls/BaseHlsService.cs | 5 +- .../Playback/Hls/DynamicHlsService.cs | 5 +- .../Playback/Hls/VideoHlsService.cs | 5 +- .../Playback/Progressive/AudioService.cs | 5 +- .../BaseProgressiveStreamingService.cs | 10 +- .../Playback/Progressive/VideoService.cs | 5 +- .../MediaBrowser.Controller.csproj | 9 +- .../ChapterImageRefreshOptions.cs | 17 ++ .../MediaEncoding/IEncodingManager.cs | 33 ++++ .../IMediaEncoder.cs | 2 +- .../InternalMediaInfoResult.cs | 6 +- .../MediaEncoderHelpers.cs | 8 +- .../BoxSets/MovieDbBoxSetProvider.cs | 2 +- .../MediaInfo/AudioImageProvider.cs | 2 +- .../MediaInfo/FFProbeAudioInfo.cs | 2 +- .../MediaInfo/FFProbeHelpers.cs | 2 +- .../MediaInfo/FFProbeProvider.cs | 7 +- .../MediaInfo/FFProbeVideoInfo.cs | 15 +- .../MediaInfo/VideoImageProvider.cs | 2 +- MediaBrowser.Providers/Omdb/OmdbProvider.cs | 3 - .../TV/MovieDbSeriesProvider.cs | 2 +- .../LiveTv/LiveTvManager.cs | 2 +- ...MediaBrowser.Server.Implementations.csproj | 1 + .../MediaEncoder/EncodingManager.cs | 183 +++++++----------- .../MediaEncoder/MediaEncoder.cs | 2 +- .../ScheduledTasks/ChapterImagesTask.cs | 33 +++- .../ApplicationHost.cs | 19 +- 30 files changed, 226 insertions(+), 293 deletions(-) delete mode 100644 MediaBrowser.Api/Playback/Hls/AudioHlsService.cs create mode 100644 MediaBrowser.Controller/MediaEncoding/ChapterImageRefreshOptions.cs create mode 100644 MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs rename MediaBrowser.Controller/{MediaInfo => MediaEncoding}/IMediaEncoder.cs (98%) rename MediaBrowser.Controller/{MediaInfo => MediaEncoding}/InternalMediaInfoResult.cs (98%) rename MediaBrowser.Controller/{MediaInfo => MediaEncoding}/MediaEncoderHelpers.cs (99%) rename MediaBrowser.Controller/MediaInfo/FFMpegManager.cs => MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs (70%) 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 @@ - 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 /// /// The media encoder. 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 /// The dto service. /// The file system. /// The item repository. - 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 /// System.String. 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 /// System.String. 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 -{ - /// - /// Class GetHlsAudioStream - /// - [Route("/Audio/{Id}/stream.m3u8", "GET")] - [Api(Description = "Gets an audio stream using HTTP live streaming.")] - public class GetHlsAudioStream : StreamRequest - { - - } - - /// - /// Class AudioHlsService - /// - 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) - { - } - - /// - /// Gets the specified request. - /// - /// The request. - /// System.Object. - public object Get(GetHlsAudioStream request) - { - return ProcessRequest(request); - } - - /// - /// Gets the audio arguments. - /// - /// The state. - /// System.String. - 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; - } - - /// - /// Gets the video arguments. - /// - /// The state. - /// if set to true [perform subtitle conversion]. - /// System.String. - protected override string GetVideoArguments(StreamState state, bool performSubtitleConversion) - { - // No video - return string.Empty; - } - - /// - /// Gets the segment file extension. - /// - /// The state. - /// System.String. - /// Must specify either aac or mp3 audio codec. - /// Only aac and mp3 audio codecs are supported. - 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."); - } - - /// - /// Gets the map args. - /// - /// The state. - /// System.String. - 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 /// 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 /// 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 /// 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; } /// 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 /// 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 @@ - - + + + + @@ -198,7 +200,7 @@ - + @@ -209,7 +211,6 @@ - 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 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 + { + /// + /// Gets the subtitle cache path. + /// + /// The original subtitle path. + /// The output subtitle extension. + /// System.String. + string GetSubtitleCachePath(string originalSubtitlePath, string outputSubtitleExtension); + + /// + /// Gets the subtitle cache path. + /// + /// The media path. + /// Index of the subtitle stream. + /// The output subtitle extension. + /// System.String. + string GetSubtitleCachePath(string mediaPath, int subtitleStreamIndex, string outputSubtitleExtension); + + /// + /// Refreshes the chapter images. + /// + /// The options. + /// The cancellation token. + /// Task{System.Boolean}. + Task RefreshChapterImages(ChapterImageRefreshOptions options, CancellationToken cancellationToken); + } +} diff --git a/MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs similarity index 98% rename from MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs rename to 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 { /// /// Interface IMediaEncoder diff --git a/MediaBrowser.Controller/MediaInfo/InternalMediaInfoResult.cs b/MediaBrowser.Controller/MediaEncoding/InternalMediaInfoResult.cs similarity index 98% rename from MediaBrowser.Controller/MediaInfo/InternalMediaInfoResult.cs rename to 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 { /// /// Class MediaInfoResult diff --git a/MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs similarity index 99% rename from MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs rename to 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 { /// /// 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 ProbeVideo(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 @@ + diff --git a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs b/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs similarity index 70% rename from MediaBrowser.Controller/MediaInfo/FFMpegManager.cs rename to 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,57 +16,26 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -namespace MediaBrowser.Controller.MediaInfo +namespace MediaBrowser.Server.Implementations.MediaEncoder { - /// - /// Class FFMpegManager - /// - 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; } - - /// - /// Initializes a new instance of the class. - /// - /// The encoder. - /// The logger. - /// The item repo. - /// zipClient - 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; } - /// - /// Gets the chapter images data path. - /// - /// The chapter images data path. - public string ChapterImagesPath - { - get - { - return Path.Combine(_config.ApplicationPaths.DataPath, "chapter-images"); - } - } - - /// - /// Gets the subtitle cache path. - /// - /// The subtitle cache path. private string SubtitleCachePath { get @@ -73,6 +43,39 @@ namespace MediaBrowser.Controller.MediaInfo 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); + } + + /// + /// Gets the chapter images data path. + /// + /// The chapter images data path. + private string GetChapterImagesPath(Guid itemId) + { + return Path.Combine(_config.ApplicationPaths.GetInternalMetadataPath(itemId), "chapters"); + } /// /// Determines whether [is eligible for chapter image extraction] [the specified video]. @@ -95,7 +98,7 @@ namespace MediaBrowser.Controller.MediaInfo return false; } } - else + else { if (!_config.Configuration.EnableOtherVideoChapterImageExtraction) { @@ -112,18 +115,13 @@ namespace MediaBrowser.Controller.MediaInfo /// private static readonly long FirstChapterTicks = TimeSpan.FromSeconds(15).Ticks; - /// - /// Extracts the chapter images. - /// - /// The video. - /// The chapters. - /// if set to true [extract images]. - /// if set to true [save chapters]. - /// The cancellation token. - /// Task. - /// - public async Task PopulateChapterImages(Video video, List chapters, bool extractImages, bool saveChapters, CancellationToken cancellationToken) + public async Task 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 GetSavedChapterImages(Video video) + { + var path = GetChapterImagesPath(video.Id); + + try + { + return Directory.EnumerateFiles(path) + .ToList(); + } + catch (DirectoryNotFoundException) + { + return new List(); + } + } + private void DeleteDeadImages(IEnumerable images, IEnumerable chapters) { var deadImages = images @@ -238,60 +256,5 @@ namespace MediaBrowser.Controller.MediaInfo } } } - - private readonly CultureInfo _usCulture = new CultureInfo("en-US"); - - /// - /// Gets the subtitle cache path. - /// - /// The media path. - /// The subtitle stream. - /// The output extension. - /// System.String. - 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 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(); - } - } } } 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; + /// /// Initializes a new instance of the class. /// /// The log manager. /// The library manager. /// The item repo. - 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 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; } + /// /// Gets or sets the user data repository. /// @@ -270,6 +272,15 @@ namespace MediaBrowser.ServerApplication // Not there, no big deal } + 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); @@ -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 /// private void SetKernelProperties() { - new FFMpegManager(MediaEncoder, Logger, ItemRepository, FileSystemManager, ServerConfigurationManager); - LocalizedStrings.StringFiles = GetExports(); SetStaticProperties();