diff options
Diffstat (limited to 'MediaBrowser.Controller')
4 files changed, 64 insertions, 72 deletions
diff --git a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs index bc8052f0e..7c977d02f 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs @@ -93,7 +93,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo cancellationToken.ThrowIfCancellationRequested(); - await Fetch(myItem, cancellationToken, result, isoMount).ConfigureAwait(false); + Fetch(myItem, cancellationToken, result, isoMount); cancellationToken.ThrowIfCancellationRequested(); @@ -180,7 +180,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo /// <param name="result">The result.</param> /// <param name="isoMount">The iso mount.</param> /// <returns>Task.</returns> - protected abstract Task Fetch(T item, CancellationToken cancellationToken, FFProbeResult result, IIsoMount isoMount); + protected abstract void Fetch(T item, CancellationToken cancellationToken, FFProbeResult result, IIsoMount isoMount); /// <summary> /// Converts ffprobe stream info to our MediaStream class diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFMpegVideoImageProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFMpegVideoImageProvider.cs index 9dec93a8c..bc851a0cb 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/FFMpegVideoImageProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/FFMpegVideoImageProvider.cs @@ -57,12 +57,6 @@ namespace MediaBrowser.Controller.Providers.MediaInfo if (video != null) { - // Can't extract images if there are no video streams - if (video.MediaStreams == null || video.MediaStreams.All(m => m.Type != MediaStreamType.Video)) - { - return false; - } - if (video.VideoType == VideoType.Iso && video.IsoType.HasValue && _isoManager.CanMount(item.Path)) { return true; @@ -93,17 +87,21 @@ namespace MediaBrowser.Controller.Providers.MediaInfo { var video = (Video)item; - var filename = item.Id + "_" + item.DateModified.Ticks + "_primary"; + // We can only extract images from videos if we know there's an embedded video stream + if (video.MediaStreams != null && video.MediaStreams.Any(m => m.Type == MediaStreamType.Video)) + { + var filename = item.Id + "_" + item.DateModified.Ticks + "_primary"; - var path = Kernel.Instance.FFMpegManager.VideoImageCache.GetResourcePath(filename, ".jpg"); + var path = Kernel.Instance.FFMpegManager.VideoImageCache.GetResourcePath(filename, ".jpg"); - if (!Kernel.Instance.FFMpegManager.VideoImageCache.ContainsFilePath(path)) - { - return ExtractImage(video, path, cancellationToken); - } + if (!Kernel.Instance.FFMpegManager.VideoImageCache.ContainsFilePath(path)) + { + return ExtractImage(video, path, cancellationToken); + } - // Image is already in the cache - item.PrimaryImagePath = path; + // Image is already in the cache + item.PrimaryImagePath = path; + } } SetLastRefreshed(item, DateTime.UtcNow); diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs index a7cc4985b..8390a0cee 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs @@ -42,41 +42,38 @@ namespace MediaBrowser.Controller.Providers.MediaInfo /// <param name="data">The data.</param> /// <param name="isoMount">The iso mount.</param> /// <returns>Task.</returns> - protected override Task Fetch(Audio audio, CancellationToken cancellationToken, FFProbeResult data, IIsoMount isoMount) + protected override void Fetch(Audio audio, CancellationToken cancellationToken, FFProbeResult data, IIsoMount isoMount) { - return Task.Run(() => + if (data.streams == null) { - if (data.streams == null) - { - Logger.Error("Audio item has no streams: " + audio.Path); - return; - } + Logger.Error("Audio item has no streams: " + audio.Path); + return; + } - audio.MediaStreams = data.streams.Select(s => GetMediaStream(s, data.format)).ToList(); + audio.MediaStreams = data.streams.Select(s => GetMediaStream(s, data.format)).ToList(); - // Get the first audio stream - var stream = data.streams.First(s => s.codec_type.Equals("audio", StringComparison.OrdinalIgnoreCase)); + // Get the first audio stream + var stream = data.streams.First(s => s.codec_type.Equals("audio", StringComparison.OrdinalIgnoreCase)); - // Get duration from stream properties - var duration = stream.duration; + // Get duration from stream properties + var duration = stream.duration; - // If it's not there go into format properties - if (string.IsNullOrEmpty(duration)) - { - duration = data.format.duration; - } + // If it's not there go into format properties + if (string.IsNullOrEmpty(duration)) + { + duration = data.format.duration; + } - // If we got something, parse it - if (!string.IsNullOrEmpty(duration)) - { - audio.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(duration, UsCulture)).Ticks; - } + // If we got something, parse it + if (!string.IsNullOrEmpty(duration)) + { + audio.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(duration, UsCulture)).Ticks; + } - if (data.format.tags != null) - { - FetchDataFromTags(audio, data.format.tags); - } - }); + if (data.format.tags != null) + { + FetchDataFromTags(audio, data.format.tags); + } } /// <summary> diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs index cae74a910..a2a9fa0d1 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs @@ -187,44 +187,41 @@ namespace MediaBrowser.Controller.Providers.MediaInfo /// <param name="data">The data.</param> /// <param name="isoMount">The iso mount.</param> /// <returns>Task.</returns> - protected override Task Fetch(Video video, CancellationToken cancellationToken, FFProbeResult data, IIsoMount isoMount) + protected override void Fetch(Video video, CancellationToken cancellationToken, FFProbeResult data, IIsoMount isoMount) { - return Task.Run(() => + if (data.format != null) { - if (data.format != null) - { - // 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 && !string.IsNullOrEmpty(data.format.duration)) - { - video.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.format.duration, UsCulture)).Ticks; - } - } + // 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 (data.streams != null) + if (needToSetRuntime && !string.IsNullOrEmpty(data.format.duration)) { - video.MediaStreams = data.streams.Select(s => GetMediaStream(s, data.format)).ToList(); + video.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.format.duration, UsCulture)).Ticks; } + } - if (data.Chapters != null) - { - video.Chapters = data.Chapters; - } + if (data.streams != null) + { + video.MediaStreams = data.streams.Select(s => GetMediaStream(s, data.format)).ToList(); + } - if (video.Chapters == null || video.Chapters.Count == 0) - { - AddDummyChapters(video); - } + if (data.Chapters != null) + { + video.Chapters = data.Chapters; + } - if (video.VideoType == VideoType.BluRay || (video.IsoType.HasValue && video.IsoType.Value == IsoType.BluRay)) - { - var inputPath = isoMount != null ? isoMount.MountedPath : video.Path; - FetchBdInfo(video, inputPath, BdInfoCache, cancellationToken); - } + if (video.Chapters == null || video.Chapters.Count == 0) + { + AddDummyChapters(video); + } + + if (video.VideoType == VideoType.BluRay || (video.IsoType.HasValue && video.IsoType.Value == IsoType.BluRay)) + { + var inputPath = isoMount != null ? isoMount.MountedPath : video.Path; + FetchBdInfo(video, inputPath, BdInfoCache, cancellationToken); + } - AddExternalSubtitles(video); - }); + AddExternalSubtitles(video); } /// <summary> |
