Enabling video info provider
This commit is contained in:
parent
e6a95defc9
commit
0a0a4256b3
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user