diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-09-09 15:42:40 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-09 15:42:40 -0400 |
| commit | 080a6511dc44edde960e6aefcab7e6cc068a3414 (patch) | |
| tree | 499c61fec48dcc080888d9cfc021baf734886fe7 /MediaBrowser.Server.Implementations/MediaEncoder | |
| parent | 51051c27cd4a30010eee98f4f99ebb895e166a91 (diff) | |
| parent | 5ad606a2232c6911e2cd8cf5d03da635c7c0c75d (diff) | |
Merge pull request #2151 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.Server.Implementations/MediaEncoder')
| -rw-r--r-- | MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs b/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs index 67ddcc5cc..7d0841fa6 100644 --- a/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -14,6 +14,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using CommonIO; +using MediaBrowser.Controller.Library; namespace MediaBrowser.Server.Implementations.MediaEncoder { @@ -24,16 +25,18 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder private readonly ILogger _logger; private readonly IMediaEncoder _encoder; private readonly IChapterManager _chapterManager; + private readonly ILibraryManager _libraryManager; public EncodingManager(IFileSystem fileSystem, ILogger logger, IMediaEncoder encoder, - IChapterManager chapterManager) + IChapterManager chapterManager, ILibraryManager libraryManager) { _fileSystem = fileSystem; _logger = logger; _encoder = encoder; _chapterManager = chapterManager; + _libraryManager = libraryManager; } /// <summary> @@ -57,27 +60,38 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder return false; } - var options = _chapterManager.GetConfiguration(); - - if (video is Movie) + var libraryOptions = _libraryManager.GetLibraryOptions(video); + if (libraryOptions != null && libraryOptions.SchemaVersion >= 2) { - if (!options.EnableMovieChapterImageExtraction) + if (!libraryOptions.EnableChapterImageExtraction) { return false; } } - else if (video is Episode) + else { - if (!options.EnableEpisodeChapterImageExtraction) + var options = _chapterManager.GetConfiguration(); + + if (video is Movie) { - return false; + if (!options.EnableMovieChapterImageExtraction) + { + return false; + } } - } - else - { - if (!options.EnableOtherVideoChapterImageExtraction) + else if (video is Episode) { - return false; + if (!options.EnableEpisodeChapterImageExtraction) + { + return false; + } + } + else + { + if (!options.EnableOtherVideoChapterImageExtraction) + { + return false; + } } } @@ -135,16 +149,16 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder } } - // Add some time for the first chapter to make sure we don't end up with a black image - var time = chapter.StartPositionTicks == 0 ? TimeSpan.FromTicks(Math.Min(FirstChapterTicks, video.RunTimeTicks ?? 0)) : TimeSpan.FromTicks(chapter.StartPositionTicks); + try + { + // Add some time for the first chapter to make sure we don't end up with a black image + var time = chapter.StartPositionTicks == 0 ? TimeSpan.FromTicks(Math.Min(FirstChapterTicks, video.RunTimeTicks ?? 0)) : TimeSpan.FromTicks(chapter.StartPositionTicks); - var protocol = MediaProtocol.File; + var protocol = MediaProtocol.File; - var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, video.PlayableStreamFileNames); + var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, video.PlayableStreamFileNames); - try - { - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); var tempFile = await _encoder.ExtractVideoImage(inputPath, protocol, video.Video3DFormat, time, cancellationToken).ConfigureAwait(false); File.Copy(tempFile, path, true); @@ -164,7 +178,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder } catch (Exception ex) { - _logger.ErrorException("Error extracting chapter images for {0}", ex, string.Join(",", inputPath)); + _logger.ErrorException("Error extracting chapter images for {0}", ex, string.Join(",", video.Path)); success = false; break; } |
