|
|
|
@ -8,7 +8,6 @@ using System.Xml;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Model.Dto;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using MediaBrowser.Model.Extensions;
|
|
|
|
|
using MediaBrowser.Model.Globalization;
|
|
|
|
|
using MediaBrowser.Model.IO;
|
|
|
|
|
using MediaBrowser.Model.MediaInfo;
|
|
|
|
@ -41,9 +40,9 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
FFProbeHelpers.NormalizeFFProbeResult(data);
|
|
|
|
|
SetSize(data, info);
|
|
|
|
|
|
|
|
|
|
var internalStreams = data.streams ?? new MediaStreamInfo[] { };
|
|
|
|
|
var internalStreams = data.Streams ?? new MediaStreamInfo[] { };
|
|
|
|
|
|
|
|
|
|
info.MediaStreams = internalStreams.Select(s => GetMediaStream(isAudio, s, data.format))
|
|
|
|
|
info.MediaStreams = internalStreams.Select(s => GetMediaStream(isAudio, s, data.Format))
|
|
|
|
|
.Where(i => i != null)
|
|
|
|
|
// Drop subtitle streams if we don't know the codec because it will just cause failures if we don't know how to handle them
|
|
|
|
|
.Where(i => i.Type != MediaStreamType.Subtitle || !string.IsNullOrWhiteSpace(i.Codec))
|
|
|
|
@ -53,13 +52,13 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
.Where(i => i != null)
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
if (data.format != null)
|
|
|
|
|
if (data.Format != null)
|
|
|
|
|
{
|
|
|
|
|
info.Container = NormalizeFormat(data.format.format_name);
|
|
|
|
|
info.Container = NormalizeFormat(data.Format.FormatName);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(data.format.bit_rate))
|
|
|
|
|
if (!string.IsNullOrEmpty(data.Format.BitRate))
|
|
|
|
|
{
|
|
|
|
|
if (int.TryParse(data.format.bit_rate, NumberStyles.Any, _usCulture, out var value))
|
|
|
|
|
if (int.TryParse(data.Format.BitRate, NumberStyles.Any, _usCulture, out var value))
|
|
|
|
|
{
|
|
|
|
|
info.Bitrate = value;
|
|
|
|
|
}
|
|
|
|
@ -69,22 +68,22 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
var tags = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
var tagStreamType = isAudio ? "audio" : "video";
|
|
|
|
|
|
|
|
|
|
if (data.streams != null)
|
|
|
|
|
if (data.Streams != null)
|
|
|
|
|
{
|
|
|
|
|
var tagStream = data.streams.FirstOrDefault(i => string.Equals(i.codec_type, tagStreamType, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
var tagStream = data.Streams.FirstOrDefault(i => string.Equals(i.CodecType, tagStreamType, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
if (tagStream != null && tagStream.tags != null)
|
|
|
|
|
if (tagStream != null && tagStream.Tags != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var pair in tagStream.tags)
|
|
|
|
|
foreach (var pair in tagStream.Tags)
|
|
|
|
|
{
|
|
|
|
|
tags[pair.Key] = pair.Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data.format != null && data.format.tags != null)
|
|
|
|
|
if (data.Format != null && data.Format.Tags != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var pair in data.format.tags)
|
|
|
|
|
foreach (var pair in data.Format.Tags)
|
|
|
|
|
{
|
|
|
|
|
tags[pair.Key] = pair.Value;
|
|
|
|
|
}
|
|
|
|
@ -157,9 +156,9 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
FetchFromItunesInfo(itunesXml, info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data.format != null && !string.IsNullOrEmpty(data.format.duration))
|
|
|
|
|
if (data.Format != null && !string.IsNullOrEmpty(data.Format.Duration))
|
|
|
|
|
{
|
|
|
|
|
info.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.format.duration, _usCulture)).Ticks;
|
|
|
|
|
info.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.Format.Duration, _usCulture)).Ticks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FetchWtvInfo(info, data);
|
|
|
|
@ -524,27 +523,27 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
/// <returns>MediaAttachments.</returns>
|
|
|
|
|
private MediaAttachment GetMediaAttachment(MediaStreamInfo streamInfo)
|
|
|
|
|
{
|
|
|
|
|
if (!string.Equals(streamInfo.codec_type, "attachment", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
if (!string.Equals(streamInfo.CodecType, "attachment", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var attachment = new MediaAttachment
|
|
|
|
|
{
|
|
|
|
|
Codec = streamInfo.codec_name,
|
|
|
|
|
Index = streamInfo.index
|
|
|
|
|
Codec = streamInfo.CodecName,
|
|
|
|
|
Index = streamInfo.Index
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(streamInfo.codec_tag_string))
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(streamInfo.CodecTagString))
|
|
|
|
|
{
|
|
|
|
|
attachment.CodecTag = streamInfo.codec_tag_string;
|
|
|
|
|
attachment.CodecTag = streamInfo.CodecTagString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (streamInfo.tags != null)
|
|
|
|
|
if (streamInfo.Tags != null)
|
|
|
|
|
{
|
|
|
|
|
attachment.FileName = GetDictionaryValue(streamInfo.tags, "filename");
|
|
|
|
|
attachment.MimeType = GetDictionaryValue(streamInfo.tags, "mimetype");
|
|
|
|
|
attachment.Comment = GetDictionaryValue(streamInfo.tags, "comment");
|
|
|
|
|
attachment.FileName = GetDictionaryValue(streamInfo.Tags, "filename");
|
|
|
|
|
attachment.MimeType = GetDictionaryValue(streamInfo.Tags, "mimetype");
|
|
|
|
|
attachment.Comment = GetDictionaryValue(streamInfo.Tags, "comment");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return attachment;
|
|
|
|
@ -560,7 +559,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
private MediaStream GetMediaStream(bool isAudio, MediaStreamInfo streamInfo, MediaFormatInfo formatInfo)
|
|
|
|
|
{
|
|
|
|
|
// These are mp4 chapters
|
|
|
|
|
if (string.Equals(streamInfo.codec_name, "mov_text", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
if (string.Equals(streamInfo.CodecName, "mov_text", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
// Edit: but these are also sometimes subtitles?
|
|
|
|
|
//return null;
|
|
|
|
@ -568,71 +567,71 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
|
|
|
|
|
var stream = new MediaStream
|
|
|
|
|
{
|
|
|
|
|
Codec = streamInfo.codec_name,
|
|
|
|
|
Profile = streamInfo.profile,
|
|
|
|
|
Level = streamInfo.level,
|
|
|
|
|
Index = streamInfo.index,
|
|
|
|
|
PixelFormat = streamInfo.pix_fmt,
|
|
|
|
|
NalLengthSize = streamInfo.nal_length_size,
|
|
|
|
|
TimeBase = streamInfo.time_base,
|
|
|
|
|
CodecTimeBase = streamInfo.codec_time_base
|
|
|
|
|
Codec = streamInfo.CodecName,
|
|
|
|
|
Profile = streamInfo.Profile,
|
|
|
|
|
Level = streamInfo.Level,
|
|
|
|
|
Index = streamInfo.Index,
|
|
|
|
|
PixelFormat = streamInfo.PixelFormat,
|
|
|
|
|
NalLengthSize = streamInfo.NalLengthSize,
|
|
|
|
|
TimeBase = streamInfo.TimeBase,
|
|
|
|
|
CodecTimeBase = streamInfo.CodecTimeBase
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (string.Equals(streamInfo.is_avc, "true", StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
string.Equals(streamInfo.is_avc, "1", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
if (string.Equals(streamInfo.IsAvc, "true", StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
string.Equals(streamInfo.IsAvc, "1", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
stream.IsAVC = true;
|
|
|
|
|
}
|
|
|
|
|
else if (string.Equals(streamInfo.is_avc, "false", StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
string.Equals(streamInfo.is_avc, "0", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
else if (string.Equals(streamInfo.IsAvc, "false", StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
string.Equals(streamInfo.IsAvc, "0", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
stream.IsAVC = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(streamInfo.field_order) && !string.Equals(streamInfo.field_order, "progressive", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(streamInfo.FieldOrder) && !string.Equals(streamInfo.FieldOrder, "progressive", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
stream.IsInterlaced = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Filter out junk
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(streamInfo.codec_tag_string) && streamInfo.codec_tag_string.IndexOf("[0]", StringComparison.OrdinalIgnoreCase) == -1)
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(streamInfo.CodecTagString) && streamInfo.CodecTagString.IndexOf("[0]", StringComparison.OrdinalIgnoreCase) == -1)
|
|
|
|
|
{
|
|
|
|
|
stream.CodecTag = streamInfo.codec_tag_string;
|
|
|
|
|
stream.CodecTag = streamInfo.CodecTagString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (streamInfo.tags != null)
|
|
|
|
|
if (streamInfo.Tags != null)
|
|
|
|
|
{
|
|
|
|
|
stream.Language = GetDictionaryValue(streamInfo.tags, "language");
|
|
|
|
|
stream.Comment = GetDictionaryValue(streamInfo.tags, "comment");
|
|
|
|
|
stream.Title = GetDictionaryValue(streamInfo.tags, "title");
|
|
|
|
|
stream.Language = GetDictionaryValue(streamInfo.Tags, "language");
|
|
|
|
|
stream.Comment = GetDictionaryValue(streamInfo.Tags, "comment");
|
|
|
|
|
stream.Title = GetDictionaryValue(streamInfo.Tags, "title");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.Equals(streamInfo.codec_type, "audio", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
if (string.Equals(streamInfo.CodecType, "audio", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
stream.Type = MediaStreamType.Audio;
|
|
|
|
|
|
|
|
|
|
stream.Channels = streamInfo.channels;
|
|
|
|
|
stream.Channels = streamInfo.Channels;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(streamInfo.sample_rate))
|
|
|
|
|
if (!string.IsNullOrEmpty(streamInfo.SampleRate))
|
|
|
|
|
{
|
|
|
|
|
if (int.TryParse(streamInfo.sample_rate, NumberStyles.Any, _usCulture, out var value))
|
|
|
|
|
if (int.TryParse(streamInfo.SampleRate, NumberStyles.Any, _usCulture, out var value))
|
|
|
|
|
{
|
|
|
|
|
stream.SampleRate = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stream.ChannelLayout = ParseChannelLayout(streamInfo.channel_layout);
|
|
|
|
|
stream.ChannelLayout = ParseChannelLayout(streamInfo.ChannelLayout);
|
|
|
|
|
|
|
|
|
|
if (streamInfo.bits_per_sample > 0)
|
|
|
|
|
if (streamInfo.BitsPerSample > 0)
|
|
|
|
|
{
|
|
|
|
|
stream.BitDepth = streamInfo.bits_per_sample;
|
|
|
|
|
stream.BitDepth = streamInfo.BitsPerSample;
|
|
|
|
|
}
|
|
|
|
|
else if (streamInfo.bits_per_raw_sample > 0)
|
|
|
|
|
else if (streamInfo.BitsPerRawSample > 0)
|
|
|
|
|
{
|
|
|
|
|
stream.BitDepth = streamInfo.bits_per_raw_sample;
|
|
|
|
|
stream.BitDepth = streamInfo.BitsPerRawSample;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (string.Equals(streamInfo.codec_type, "subtitle", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
else if (string.Equals(streamInfo.CodecType, "subtitle", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
stream.Type = MediaStreamType.Subtitle;
|
|
|
|
|
stream.Codec = NormalizeSubtitleCodec(stream.Codec);
|
|
|
|
@ -640,14 +639,14 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
stream.localizedDefault = _localization.GetLocalizedString("Default");
|
|
|
|
|
stream.localizedForced = _localization.GetLocalizedString("Forced");
|
|
|
|
|
}
|
|
|
|
|
else if (string.Equals(streamInfo.codec_type, "video", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
else if (string.Equals(streamInfo.CodecType, "video", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
stream.Type = isAudio || string.Equals(stream.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase) || string.Equals(stream.Codec, "gif", StringComparison.OrdinalIgnoreCase) || string.Equals(stream.Codec, "png", StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
? MediaStreamType.EmbeddedImage
|
|
|
|
|
: MediaStreamType.Video;
|
|
|
|
|
|
|
|
|
|
stream.AverageFrameRate = GetFrameRate(streamInfo.avg_frame_rate);
|
|
|
|
|
stream.RealFrameRate = GetFrameRate(streamInfo.r_frame_rate);
|
|
|
|
|
stream.AverageFrameRate = GetFrameRate(streamInfo.AverageFrameRate);
|
|
|
|
|
stream.RealFrameRate = GetFrameRate(streamInfo.RFrameRate);
|
|
|
|
|
|
|
|
|
|
if (isAudio || string.Equals(stream.Codec, "gif", StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
string.Equals(stream.Codec, "png", StringComparison.OrdinalIgnoreCase))
|
|
|
|
@ -672,17 +671,17 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
stream.Type = MediaStreamType.Video;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stream.Width = streamInfo.width;
|
|
|
|
|
stream.Height = streamInfo.height;
|
|
|
|
|
stream.Width = streamInfo.Width;
|
|
|
|
|
stream.Height = streamInfo.Height;
|
|
|
|
|
stream.AspectRatio = GetAspectRatio(streamInfo);
|
|
|
|
|
|
|
|
|
|
if (streamInfo.bits_per_sample > 0)
|
|
|
|
|
if (streamInfo.BitsPerSample > 0)
|
|
|
|
|
{
|
|
|
|
|
stream.BitDepth = streamInfo.bits_per_sample;
|
|
|
|
|
stream.BitDepth = streamInfo.BitsPerSample;
|
|
|
|
|
}
|
|
|
|
|
else if (streamInfo.bits_per_raw_sample > 0)
|
|
|
|
|
else if (streamInfo.BitsPerRawSample > 0)
|
|
|
|
|
{
|
|
|
|
|
stream.BitDepth = streamInfo.bits_per_raw_sample;
|
|
|
|
|
stream.BitDepth = streamInfo.BitsPerRawSample;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//stream.IsAnamorphic = string.Equals(streamInfo.sample_aspect_ratio, "0:1", StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
@ -690,11 +689,11 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
// string.Equals(stream.AspectRatio, "2.40:1", StringComparison.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
|
|
// http://stackoverflow.com/questions/17353387/how-to-detect-anamorphic-video-with-ffprobe
|
|
|
|
|
stream.IsAnamorphic = string.Equals(streamInfo.sample_aspect_ratio, "0:1", StringComparison.OrdinalIgnoreCase);
|
|
|
|
|
stream.IsAnamorphic = string.Equals(streamInfo.SampleAspectRatio, "0:1", StringComparison.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
|
|
if (streamInfo.refs > 0)
|
|
|
|
|
if (streamInfo.Refs > 0)
|
|
|
|
|
{
|
|
|
|
|
stream.RefFrames = streamInfo.refs;
|
|
|
|
|
stream.RefFrames = streamInfo.Refs;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -705,18 +704,18 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
// Get stream bitrate
|
|
|
|
|
var bitrate = 0;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(streamInfo.bit_rate))
|
|
|
|
|
if (!string.IsNullOrEmpty(streamInfo.BitRate))
|
|
|
|
|
{
|
|
|
|
|
if (int.TryParse(streamInfo.bit_rate, NumberStyles.Any, _usCulture, out var value))
|
|
|
|
|
if (int.TryParse(streamInfo.BitRate, NumberStyles.Any, _usCulture, out var value))
|
|
|
|
|
{
|
|
|
|
|
bitrate = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bitrate == 0 && formatInfo != null && !string.IsNullOrEmpty(formatInfo.bit_rate) && stream.Type == MediaStreamType.Video)
|
|
|
|
|
if (bitrate == 0 && formatInfo != null && !string.IsNullOrEmpty(formatInfo.BitRate) && stream.Type == MediaStreamType.Video)
|
|
|
|
|
{
|
|
|
|
|
// If the stream info doesn't have a bitrate get the value from the media format info
|
|
|
|
|
if (int.TryParse(formatInfo.bit_rate, NumberStyles.Any, _usCulture, out var value))
|
|
|
|
|
if (int.TryParse(formatInfo.BitRate, NumberStyles.Any, _usCulture, out var value))
|
|
|
|
|
{
|
|
|
|
|
bitrate = value;
|
|
|
|
|
}
|
|
|
|
@ -727,14 +726,18 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
stream.BitRate = bitrate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (streamInfo.disposition != null)
|
|
|
|
|
var disposition = streamInfo.Disposition;
|
|
|
|
|
if (disposition != null)
|
|
|
|
|
{
|
|
|
|
|
var isDefault = GetDictionaryValue(streamInfo.disposition, "default");
|
|
|
|
|
var isForced = GetDictionaryValue(streamInfo.disposition, "forced");
|
|
|
|
|
|
|
|
|
|
stream.IsDefault = string.Equals(isDefault, "1", StringComparison.OrdinalIgnoreCase);
|
|
|
|
|
if (disposition.GetValueOrDefault("default") == 1)
|
|
|
|
|
{
|
|
|
|
|
stream.IsDefault = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stream.IsForced = string.Equals(isForced, "1", StringComparison.OrdinalIgnoreCase);
|
|
|
|
|
if (disposition.GetValueOrDefault("forced") == 1)
|
|
|
|
|
{
|
|
|
|
|
stream.IsForced = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NormalizeStreamTitle(stream);
|
|
|
|
@ -761,7 +764,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
/// <param name="tags">The tags.</param>
|
|
|
|
|
/// <param name="key">The key.</param>
|
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
|
private string GetDictionaryValue(Dictionary<string, string> tags, string key)
|
|
|
|
|
private string GetDictionaryValue(IReadOnlyDictionary<string, string> tags, string key)
|
|
|
|
|
{
|
|
|
|
|
if (tags == null)
|
|
|
|
|
{
|
|
|
|
@ -784,7 +787,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
|
|
|
|
|
private string GetAspectRatio(MediaStreamInfo info)
|
|
|
|
|
{
|
|
|
|
|
var original = info.display_aspect_ratio;
|
|
|
|
|
var original = info.DisplayAspectRatio;
|
|
|
|
|
|
|
|
|
|
var parts = (original ?? string.Empty).Split(':');
|
|
|
|
|
if (!(parts.Length == 2 &&
|
|
|
|
@ -793,8 +796,8 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
width > 0 &&
|
|
|
|
|
height > 0))
|
|
|
|
|
{
|
|
|
|
|
width = info.width;
|
|
|
|
|
height = info.height;
|
|
|
|
|
width = info.Width;
|
|
|
|
|
height = info.Height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (width > 0 && height > 0)
|
|
|
|
@ -887,20 +890,20 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
|
|
|
|
|
private void SetAudioRuntimeTicks(InternalMediaInfoResult result, MediaInfo data)
|
|
|
|
|
{
|
|
|
|
|
if (result.streams != null)
|
|
|
|
|
if (result.Streams != null)
|
|
|
|
|
{
|
|
|
|
|
// Get the first info stream
|
|
|
|
|
var stream = result.streams.FirstOrDefault(s => string.Equals(s.codec_type, "audio", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
var stream = result.Streams.FirstOrDefault(s => string.Equals(s.CodecType, "audio", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
if (stream != null)
|
|
|
|
|
{
|
|
|
|
|
// Get duration from stream properties
|
|
|
|
|
var duration = stream.duration;
|
|
|
|
|
var duration = stream.Duration;
|
|
|
|
|
|
|
|
|
|
// If it's not there go into format properties
|
|
|
|
|
if (string.IsNullOrEmpty(duration))
|
|
|
|
|
{
|
|
|
|
|
duration = result.format.duration;
|
|
|
|
|
duration = result.Format.Duration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If we got something, parse it
|
|
|
|
@ -914,11 +917,11 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
|
|
|
|
|
private void SetSize(InternalMediaInfoResult data, MediaInfo info)
|
|
|
|
|
{
|
|
|
|
|
if (data.format != null)
|
|
|
|
|
if (data.Format != null)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(data.format.size))
|
|
|
|
|
if (!string.IsNullOrEmpty(data.Format.Size))
|
|
|
|
|
{
|
|
|
|
|
info.Size = long.Parse(data.format.size, _usCulture);
|
|
|
|
|
info.Size = long.Parse(data.Format.Size, _usCulture);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -1231,16 +1234,16 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
{
|
|
|
|
|
var info = new ChapterInfo();
|
|
|
|
|
|
|
|
|
|
if (chapter.tags != null)
|
|
|
|
|
if (chapter.Tags != null)
|
|
|
|
|
{
|
|
|
|
|
if (chapter.tags.TryGetValue("title", out string name))
|
|
|
|
|
if (chapter.Tags.TryGetValue("title", out string name))
|
|
|
|
|
{
|
|
|
|
|
info.Name = name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Limit accuracy to milliseconds to match xml saving
|
|
|
|
|
var secondsString = chapter.start_time;
|
|
|
|
|
var secondsString = chapter.StartTime;
|
|
|
|
|
|
|
|
|
|
if (double.TryParse(secondsString, NumberStyles.Any, CultureInfo.InvariantCulture, out var seconds))
|
|
|
|
|
{
|
|
|
|
@ -1255,12 +1258,12 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
|
|
|
|
|
private void FetchWtvInfo(MediaInfo video, InternalMediaInfoResult data)
|
|
|
|
|
{
|
|
|
|
|
if (data.format == null || data.format.tags == null)
|
|
|
|
|
if (data.Format == null || data.Format.Tags == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var genres = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/Genre");
|
|
|
|
|
var genres = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/Genre");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(genres))
|
|
|
|
|
{
|
|
|
|
@ -1276,14 +1279,14 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var officialRating = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/ParentalRating");
|
|
|
|
|
var officialRating = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/ParentalRating");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(officialRating))
|
|
|
|
|
{
|
|
|
|
|
video.OfficialRating = officialRating;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var people = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/MediaCredits");
|
|
|
|
|
var people = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/MediaCredits");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(people))
|
|
|
|
|
{
|
|
|
|
@ -1293,7 +1296,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var year = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/OriginalReleaseTime");
|
|
|
|
|
var year = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/OriginalReleaseTime");
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(year))
|
|
|
|
|
{
|
|
|
|
|
if (int.TryParse(year, NumberStyles.Integer, _usCulture, out var val))
|
|
|
|
@ -1302,7 +1305,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var premiereDateString = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/MediaOriginalBroadcastDateTime");
|
|
|
|
|
var premiereDateString = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/MediaOriginalBroadcastDateTime");
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(premiereDateString))
|
|
|
|
|
{
|
|
|
|
|
// Credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
|
|
|
|
@ -1313,9 +1316,9 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var description = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/SubTitleDescription");
|
|
|
|
|
var description = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/SubTitleDescription");
|
|
|
|
|
|
|
|
|
|
var subTitle = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/SubTitle");
|
|
|
|
|
var subTitle = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/SubTitle");
|
|
|
|
|
|
|
|
|
|
// For below code, credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
|
|
|
|
|
|
|
|
|
|