diff options
Diffstat (limited to 'MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs')
| -rw-r--r-- | MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs | 129 |
1 files changed, 74 insertions, 55 deletions
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 158238557..443eb6eda 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 (item.VideoType == VideoType.Iso) + { + item.IsoType = DetermineIsoType(isoMount); + } - if (streamFileNames.Length == 0) + if (item.VideoType == VideoType.Dvd || (item.IsoType.HasValue && item.IsoType == IsoType.Dvd)) { - _logger.Error("No playable vobs found in dvd 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; + else if (item.VideoType == VideoType.BluRay || (item.IsoType.HasValue && item.IsoType == IsoType.BluRay)) + { + var inputPath = isoMount != null ? isoMount.MountedPath : item.Path; - blurayDiscInfo = GetBDInfo(inputPath); + blurayDiscInfo = GetBDInfo(inputPath); - streamFileNames = blurayDiscInfo.Files; + streamFileNames = blurayDiscInfo.Files; - if (streamFileNames.Length == 0) - { - _logger.Error("No playable vobs found in bluray structure, skipping ffprobe."); - return ItemUpdateType.MetadataImport; + if (streamFileNames.Length == 0) + { + _logger.Error("No playable vobs found in bluray structure, skipping ffprobe."); + return ItemUpdateType.MetadataImport; + } } - } - if (streamFileNames == null) - { - streamFileNames = new string[] { }; - } + if (streamFileNames == null) + { + streamFileNames = new string[] { }; + } - var result = await GetMediaInfo(item, isoMount, streamFileNames, cancellationToken).ConfigureAwait(false); + mediaInfoResult = await GetMediaInfo(item, isoMount, streamFileNames, cancellationToken).ConfigureAwait(false); - cancellationToken.ThrowIfCancellationRequested(); + 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<MediaStream> mediaStreams; + List<ChapterInfo> chapters; - video.TotalBitrate = mediaInfo.Bitrate; - //video.FormatName = (mediaInfo.Container ?? string.Empty) - // .Replace("matroska", "mkv", StringComparison.OrdinalIgnoreCase); + if (mediaInfo != null) + { + mediaStreams = mediaInfo.MediaStreams; - // 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; + video.TotalBitrate = mediaInfo.Bitrate; + //video.FormatName = (mediaInfo.Container ?? string.Empty) + // .Replace("matroska", "mkv", StringComparison.OrdinalIgnoreCase); - if (needToSetRuntime) - { - video.RunTimeTicks = mediaInfo.RunTimeTicks; - } + // 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 (video.VideoType == VideoType.VideoFile) - { - var extension = (Path.GetExtension(video.Path) ?? string.Empty).TrimStart('.'); + 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; - video.Container = extension; + chapters = mediaInfo.Chapters == null ? new List<ChapterInfo>() : 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<ChapterInfo>() : mediaInfo.Chapters.ToList(); - if (blurayInfo != null) - { - FetchBdInfo(video, chapters, mediaStreams, blurayInfo); + mediaStreams = new List<MediaStream>(); + chapters = new List<ChapterInfo>(); } 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); |
