From 70b0dd968fc381faacbf2207e3a5364d793bd98e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 3 Dec 2017 17:12:46 -0500 Subject: [PATCH] Improve support for embedded metadata; support external subtitles with strm files --- .../LiveTv/TunerHosts/BaseTunerHost.cs | 8 + .../MediaEncoder/EncodingManager.cs | 25 ++-- MediaBrowser.Controller/LiveTv/ITunerHost.cs | 4 + .../MediaInfo/FFProbeProvider.cs | 1 - .../MediaInfo/FFProbeVideoInfo.cs | 141 ++++++++++-------- .../Movies/GenericMovieDbInfo.cs | 2 +- 6 files changed, 108 insertions(+), 73 deletions(-) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs index e0fd32aeef..45e96c36d8 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs @@ -39,6 +39,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts FileSystem = fileSystem; } + public virtual bool IsSupported + { + get + { + return true; + } + } + protected abstract Task> GetChannelsInternal(TunerHostInfo tuner, CancellationToken cancellationToken); public abstract string Type { get; } diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs index 6e0e55bef4..d790f4ab8b 100644 --- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -76,6 +76,21 @@ namespace Emby.Server.Implementations.MediaEncoder return false; } + if (video.VideoType == VideoType.Iso) + { + return false; + } + + if (video.VideoType == VideoType.BluRay || video.VideoType == VideoType.Dvd) + { + return false; + } + + if (video.IsShortcut) + { + return false; + } + if (!video.IsCompleteMedia) { return false; @@ -118,16 +133,6 @@ namespace Emby.Server.Implementations.MediaEncoder { if (extractImages) { - if (video.VideoType == VideoType.Iso) - { - continue; - } - - if (video.VideoType == VideoType.BluRay || video.VideoType == VideoType.Dvd) - { - continue; - } - try { // Add some time for the first chapter to make sure we don't end up with a black image diff --git a/MediaBrowser.Controller/LiveTv/ITunerHost.cs b/MediaBrowser.Controller/LiveTv/ITunerHost.cs index 242011db06..80c40f8bde 100644 --- a/MediaBrowser.Controller/LiveTv/ITunerHost.cs +++ b/MediaBrowser.Controller/LiveTv/ITunerHost.cs @@ -46,6 +46,10 @@ namespace MediaBrowser.Controller.LiveTv Task> GetChannelStreamMediaSources(string channelId, CancellationToken cancellationToken); Task> DiscoverDevices(int discoveryDurationMs, CancellationToken cancellationToken); + bool IsSupported + { + get; + } } public interface IConfigurableTunerHost { diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs index e79aec33c1..6a2677b433 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs @@ -153,7 +153,6 @@ namespace MediaBrowser.Providers.MediaInfo if (item.IsShortcut) { FetchShortcutInfo(item); - return Task.FromResult(ItemUpdateType.MetadataImport); } var prober = new FFProbeVideoInfo(_logger, _isoManager, _mediaEncoder, _itemRepo, _blurayExaminer, _localization, _appPaths, _json, _encodingManager, _fileSystem, _config, _subtitleManager, _chapterManager, _libraryManager); diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 1582385571..443eb6eda4 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -75,49 +75,54 @@ namespace MediaBrowser.Providers.MediaInfo try { - string[] streamFileNames = null; + Model.MediaInfo.MediaInfo mediaInfoResult = null; - if (item.VideoType == VideoType.Iso) + if (!item.IsShortcut) { - item.IsoType = DetermineIsoType(isoMount); - } + string[] streamFileNames = null; - if (item.VideoType == VideoType.Dvd || (item.IsoType.HasValue && item.IsoType == IsoType.Dvd)) - { - streamFileNames = FetchFromDvdLib(item, isoMount); - - if (streamFileNames.Length == 0) + if (item.VideoType == VideoType.Iso) { - _logger.Error("No playable vobs found in dvd structure, skipping ffprobe."); - return ItemUpdateType.MetadataImport; + item.IsoType = DetermineIsoType(isoMount); } - } - else if (item.VideoType == VideoType.BluRay || (item.IsoType.HasValue && item.IsoType == IsoType.BluRay)) - { - var inputPath = isoMount != null ? isoMount.MountedPath : item.Path; - - blurayDiscInfo = GetBDInfo(inputPath); - - streamFileNames = blurayDiscInfo.Files; - - if (streamFileNames.Length == 0) + if (item.VideoType == VideoType.Dvd || (item.IsoType.HasValue && item.IsoType == IsoType.Dvd)) { - _logger.Error("No playable vobs found in bluray structure, skipping ffprobe."); - return ItemUpdateType.MetadataImport; + streamFileNames = FetchFromDvdLib(item, isoMount); + + if (streamFileNames.Length == 0) + { + _logger.Error("No playable vobs found in dvd structure, skipping ffprobe."); + return ItemUpdateType.MetadataImport; + } } + + else if (item.VideoType == VideoType.BluRay || (item.IsoType.HasValue && item.IsoType == IsoType.BluRay)) + { + var inputPath = isoMount != null ? isoMount.MountedPath : item.Path; + + blurayDiscInfo = GetBDInfo(inputPath); + + streamFileNames = blurayDiscInfo.Files; + + if (streamFileNames.Length == 0) + { + _logger.Error("No playable vobs found in bluray structure, skipping ffprobe."); + return ItemUpdateType.MetadataImport; + } + } + + if (streamFileNames == null) + { + streamFileNames = new string[] { }; + } + + mediaInfoResult = await GetMediaInfo(item, isoMount, streamFileNames, cancellationToken).ConfigureAwait(false); + + cancellationToken.ThrowIfCancellationRequested(); } - if (streamFileNames == null) - { - streamFileNames = new string[] { }; - } - - var result = await GetMediaInfo(item, isoMount, streamFileNames, cancellationToken).ConfigureAwait(false); - - cancellationToken.ThrowIfCancellationRequested(); - - await Fetch(item, cancellationToken, result, isoMount, blurayDiscInfo, options).ConfigureAwait(false); + await Fetch(item, cancellationToken, mediaInfoResult, isoMount, blurayDiscInfo, options).ConfigureAwait(false); } finally @@ -162,43 +167,60 @@ namespace MediaBrowser.Providers.MediaInfo BlurayDiscInfo blurayInfo, MetadataRefreshOptions options) { - var mediaStreams = mediaInfo.MediaStreams; + List mediaStreams; + List chapters; - video.TotalBitrate = mediaInfo.Bitrate; - //video.FormatName = (mediaInfo.Container ?? string.Empty) - // .Replace("matroska", "mkv", StringComparison.OrdinalIgnoreCase); - - // For dvd's this may not always be accurate, so don't set the runtime if the item already has one - var needToSetRuntime = video.VideoType != VideoType.Dvd || video.RunTimeTicks == null || video.RunTimeTicks.Value == 0; - - if (needToSetRuntime) + if (mediaInfo != null) { - video.RunTimeTicks = mediaInfo.RunTimeTicks; - } + mediaStreams = mediaInfo.MediaStreams; - if (video.VideoType == VideoType.VideoFile) - { - var extension = (Path.GetExtension(video.Path) ?? string.Empty).TrimStart('.'); + video.TotalBitrate = mediaInfo.Bitrate; + //video.FormatName = (mediaInfo.Container ?? string.Empty) + // .Replace("matroska", "mkv", StringComparison.OrdinalIgnoreCase); - video.Container = extension; + // For dvd's this may not always be accurate, so don't set the runtime if the item already has one + var needToSetRuntime = video.VideoType != VideoType.Dvd || video.RunTimeTicks == null || video.RunTimeTicks.Value == 0; + + if (needToSetRuntime) + { + video.RunTimeTicks = mediaInfo.RunTimeTicks; + } + + if (video.VideoType == VideoType.VideoFile) + { + var extension = (Path.GetExtension(video.Path) ?? string.Empty).TrimStart('.'); + + video.Container = extension; + } + else + { + video.Container = null; + } + video.Container = mediaInfo.Container; + + chapters = mediaInfo.Chapters == null ? new List() : mediaInfo.Chapters.ToList(); + if (blurayInfo != null) + { + FetchBdInfo(video, chapters, mediaStreams, blurayInfo); + } } else { - video.Container = null; - } - video.Container = mediaInfo.Container; - - var chapters = mediaInfo.Chapters == null ? new List() : mediaInfo.Chapters.ToList(); - if (blurayInfo != null) - { - FetchBdInfo(video, chapters, mediaStreams, blurayInfo); + mediaStreams = new List(); + chapters = new List(); } await AddExternalSubtitles(video, mediaStreams, options, cancellationToken).ConfigureAwait(false); + var libraryOptions = _libraryManager.GetLibraryOptions(video); - FetchEmbeddedInfo(video, mediaInfo, options, libraryOptions); - FetchPeople(video, mediaInfo, options); + if (mediaInfo != null) + { + FetchEmbeddedInfo(video, mediaInfo, options, libraryOptions); + FetchPeople(video, mediaInfo, options); + video.Timestamp = mediaInfo.Timestamp; + video.Video3DFormat = video.Video3DFormat ?? mediaInfo.Video3DFormat; + } video.IsHD = mediaStreams.Any(i => i.Type == MediaStreamType.Video && i.Width.HasValue && i.Width.Value >= 1260); @@ -207,9 +229,6 @@ namespace MediaBrowser.Providers.MediaInfo video.DefaultVideoStreamIndex = videoStream == null ? (int?)null : videoStream.Index; video.HasSubtitles = mediaStreams.Any(i => i.Type == MediaStreamType.Subtitle); - video.Timestamp = mediaInfo.Timestamp; - - video.Video3DFormat = video.Video3DFormat ?? mediaInfo.Video3DFormat; _itemRepo.SaveMediaStreams(video.Id, mediaStreams, cancellationToken); diff --git a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs index 65742f6e6e..a000ed36e4 100644 --- a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs +++ b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs @@ -262,7 +262,7 @@ namespace MediaBrowser.Providers.Movies var keepTypes = new[] { PersonType.Director, - PersonType.Writer, + //PersonType.Writer, //PersonType.Producer };