From 5ba769f3b41283efb8e7fb3a2407aafe0d6541d4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 5 Apr 2013 00:13:41 -0400 Subject: [PATCH] #79 - Music Image Extraction --- .../MediaBrowser.Controller.csproj | 1 - .../MediaInfo/FFMpegManager.cs | 22 +++- .../MediaInfo/BaseFFMpegImageProvider.cs | 23 ---- .../Providers/MediaInfo/BaseFFMpegProvider.cs | 2 +- .../MediaInfo/FFMpegAudioImageProvider.cs | 118 ++++++++++++------ .../MediaInfo/FFMpegVideoImageProvider.cs | 13 +- .../MediaInfo/FFProbeAudioInfoProvider.cs | 18 ++- .../Library/LibraryManager.cs | 36 +++++- .../Providers/ProviderManager.cs | 20 ++- 9 files changed, 164 insertions(+), 89 deletions(-) delete mode 100644 MediaBrowser.Controller/Providers/MediaInfo/BaseFFMpegImageProvider.cs diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 1c03e11dd..8c2895701 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -146,7 +146,6 @@ - diff --git a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs index 3a4f3cae7..f0a960ce1 100644 --- a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs +++ b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs @@ -735,16 +735,16 @@ namespace MediaBrowser.Controller.MediaInfo /// /// Extracts an image from an Audio file and returns a Task whose result indicates whether it was successful or not /// - /// The input. + /// The input path. /// The output path. /// The cancellation token. /// Task{System.Boolean}. /// input - public async Task ExtractImage(Audio input, string outputPath, CancellationToken cancellationToken) + public async Task ExtractAudioImage(string inputPath, string outputPath, CancellationToken cancellationToken) { - if (input == null) + if (string.IsNullOrEmpty(inputPath)) { - throw new ArgumentNullException("input"); + throw new ArgumentNullException("inputPath"); } if (string.IsNullOrEmpty(outputPath)) @@ -759,7 +759,7 @@ namespace MediaBrowser.Controller.MediaInfo CreateNoWindow = true, UseShellExecute = false, FileName = FFMpegPath, - Arguments = string.Format("-i {0} -threads 0 -v quiet -f image2 \"{1}\"", GetInputArgument(input), outputPath), + Arguments = string.Format("-i {0} -threads 0 -v quiet -f image2 \"{1}\"", GetFileInputArgument(inputPath), outputPath), WindowStyle = ProcessWindowStyle.Hidden, ErrorDialog = false } @@ -780,7 +780,7 @@ namespace MediaBrowser.Controller.MediaInfo return true; } - _logger.Error("ffmpeg audio image extraction failed for {0}", input.Path); + _logger.Error("ffmpeg audio image extraction failed for {0}", inputPath); return false; } @@ -1039,6 +1039,16 @@ namespace MediaBrowser.Controller.MediaInfo return string.Format("file:\"{0}\"", item.Path); } + /// + /// Gets the file input argument. + /// + /// The path. + /// System.String. + private string GetFileInputArgument(string path) + { + return string.Format("file:\"{0}\"", path); + } + /// /// Gets the input argument. /// diff --git a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFMpegImageProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFMpegImageProvider.cs deleted file mode 100644 index 902fdca27..000000000 --- a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFMpegImageProvider.cs +++ /dev/null @@ -1,23 +0,0 @@ -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Entities; -using MediaBrowser.Model.Logging; - -namespace MediaBrowser.Controller.Providers.MediaInfo -{ - public abstract class BaseFFMpegImageProvider : BaseFFMpegProvider - where T : BaseItem - { - protected BaseFFMpegImageProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager) - { - } - - /// - /// Gets the priority. - /// - /// The priority. - public override MetadataProviderPriority Priority - { - get { return MetadataProviderPriority.Last; } - } - } -} diff --git a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFMpegProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFMpegProvider.cs index 20f59b22d..6edd28b24 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFMpegProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFMpegProvider.cs @@ -2,9 +2,9 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Logging; using System; using System.Threading.Tasks; -using MediaBrowser.Model.Logging; namespace MediaBrowser.Controller.Providers.MediaInfo { diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFMpegAudioImageProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFMpegAudioImageProvider.cs index e752a863d..68e552d3c 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/FFMpegAudioImageProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/FFMpegAudioImageProvider.cs @@ -1,21 +1,23 @@ -using MediaBrowser.Controller.Configuration; +using System.Collections.Concurrent; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Logging; using System; using System.Linq; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Logging; namespace MediaBrowser.Controller.Providers.MediaInfo { /// /// Uses ffmpeg to create video images /// - public class FFMpegAudioImageProvider : BaseFFMpegImageProvider