diff options
4 files changed, 51 insertions, 8 deletions
diff --git a/MediaBrowser.Controller/Configuration/ServerConfiguration.cs b/MediaBrowser.Controller/Configuration/ServerConfiguration.cs index d58a81db9..f6dde3aa1 100644 --- a/MediaBrowser.Controller/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Controller/Configuration/ServerConfiguration.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic;
-using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Configuration;
namespace MediaBrowser.Controller.Configuration
{
public class ServerConfiguration : BaseApplicationConfiguration
{
+ public bool EnableInternetProviders { get; set; }
}
}
diff --git a/MediaBrowser.Controller/FFMpeg/FFProbeResult.cs b/MediaBrowser.Controller/FFMpeg/FFProbeResult.cs index e7e7e5694..3bb7dce13 100644 --- a/MediaBrowser.Controller/FFMpeg/FFProbeResult.cs +++ b/MediaBrowser.Controller/FFMpeg/FFProbeResult.cs @@ -44,7 +44,7 @@ namespace MediaBrowser.Controller.FFMpeg public int height { get; set; }
//public int has_b_frames { get; set; }
//public string sample_aspect_ratio { get; set; }
- //public string display_aspect_ratio { get; set; }
+ public string display_aspect_ratio { get; set; }
//public string pix_fmt { get; set; }
//public int level { get; set; }
public Dictionary<string,string> tags { get; set; }
diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs index 2738e3c82..440457161 100644 --- a/MediaBrowser.Controller/Kernel.cs +++ b/MediaBrowser.Controller/Kernel.cs @@ -238,11 +238,16 @@ namespace MediaBrowser.Controller // Get all supported providers
BaseMetadataProvider[] supportedProviders = Kernel.Instance.MetadataProviders.Where(i => i.Supports(item)).ToArray();
- // Run them
+ // Run them sequentially in order of priority
for (int i = 0; i < supportedProviders.Length; i++)
{
var provider = supportedProviders[i];
+ if (provider.RequiresInternet && !Configuration.EnableInternetProviders)
+ {
+ continue;
+ }
+
await provider.Fetch(item, args);
}
}
diff --git a/MediaBrowser.Controller/Providers/VideoInfoProvider.cs b/MediaBrowser.Controller/Providers/VideoInfoProvider.cs index b3d78e356..5f88aa1cb 100644 --- a/MediaBrowser.Controller/Providers/VideoInfoProvider.cs +++ b/MediaBrowser.Controller/Providers/VideoInfoProvider.cs @@ -1,4 +1,5 @@ -using System.ComponentModel.Composition;
+using System;
+using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@@ -8,7 +9,7 @@ using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Providers
{
- //[Export(typeof(BaseMetadataProvider))]
+ [Export(typeof(BaseMetadataProvider))]
public class VideoInfoProvider : BaseMetadataProvider
{
public override bool Supports(BaseEntity item)
@@ -19,8 +20,7 @@ namespace MediaBrowser.Controller.Providers public override MetadataProviderPriority Priority
{
// Give this second priority
- // Give metadata xml providers a chance to fill in data first
- // Then we can skip this step whenever possible
+ // Give metadata xml providers a chance to fill in data first, so that we can skip this whenever possible
get { return MetadataProviderPriority.Second; }
}
@@ -46,6 +46,34 @@ namespace MediaBrowser.Controller.Providers FFProbeResult data = await FFProbe.Run(video, outputPath).ConfigureAwait(false);
}
+ private void Fetch(Video video, FFProbeResult data)
+ {
+ if (!string.IsNullOrEmpty(data.format.duration))
+ {
+ video.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.format.duration)).Ticks;
+ }
+
+ if (!string.IsNullOrEmpty(data.format.bit_rate))
+ {
+ video.BitRate = int.Parse(data.format.bit_rate);
+ }
+
+ MediaStream videoStream = data.streams.FirstOrDefault(s => s.codec_type.Equals("video", StringComparison.OrdinalIgnoreCase));
+
+ if (videoStream != null)
+ {
+ FetchFromVideoStream(video, videoStream);
+ }
+ }
+
+ private void FetchFromVideoStream(Video video, MediaStream stream)
+ {
+ video.Codec = stream.codec_name;
+ video.Width = stream.width;
+ video.Height = stream.height;
+ video.AspectRatio = stream.display_aspect_ratio;
+ }
+
/// <summary>
/// Determines if there's already enough info in the Video object to allow us to skip running ffprobe
/// </summary>
@@ -56,6 +84,11 @@ namespace MediaBrowser.Controller.Providers return false;
}
+ if (string.IsNullOrEmpty(video.AspectRatio))
+ {
+ return false;
+ }
+
if (string.IsNullOrEmpty(video.Codec))
{
return false;
@@ -66,6 +99,11 @@ namespace MediaBrowser.Controller.Providers return false;
}
+ if (!video.RunTimeTicks.HasValue || video.RunTimeTicks.Value == 0)
+ {
+ return false;
+ }
+
if (video.FrameRate == 0 || video.Height == 0 || video.Width == 0 || video.BitRate == 0)
{
return false;
|
