< Summary - Jellyfin

Information
Class: MediaBrowser.MediaEncoding.Probing.ProbeResultNormalizer
Assembly: MediaBrowser.MediaEncoding
File(s): /srv/git/jellyfin/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
Line coverage
79%
Covered lines: 606
Uncovered lines: 155
Coverable lines: 761
Total lines: 1760
Line coverage: 79.6%
Branch coverage
75%
Covered branches: 474
Total branches: 630
Branch coverage: 75.2%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 11/28/2025 - 12:11:11 AM Line coverage: 79.3% (593/747) Branch coverage: 75.2% (462/614) Total lines: 172312/29/2025 - 12:13:19 AM Line coverage: 79.4% (597/751) Branch coverage: 75.4% (468/620) Total lines: 17312/15/2026 - 12:13:43 AM Line coverage: 79.5% (598/752) Branch coverage: 75.4% (468/620) Total lines: 17323/4/2026 - 12:14:01 AM Line coverage: 79.6% (606/761) Branch coverage: 75.2% (474/630) Total lines: 1760 11/28/2025 - 12:11:11 AM Line coverage: 79.3% (593/747) Branch coverage: 75.2% (462/614) Total lines: 172312/29/2025 - 12:13:19 AM Line coverage: 79.4% (597/751) Branch coverage: 75.4% (468/620) Total lines: 17312/15/2026 - 12:13:43 AM Line coverage: 79.5% (598/752) Branch coverage: 75.4% (468/620) Total lines: 17323/4/2026 - 12:14:01 AM Line coverage: 79.6% (606/761) Branch coverage: 75.2% (474/630) Total lines: 1760

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor(...)100%11100%
get_SplitWhitelist()100%22100%
GetMediaInfo(...)84.21%787693.02%
NormalizeFormat(...)87.5%171687.5%
GetEstimatedAudioBitrate(...)50%622662.5%
FetchFromItunesInfo(...)83.33%141276.92%
ReadFromDictNode(...)90%212087.09%
ReadValueArray(...)83.33%141277.77%
ProcessPairs(...)64.28%441446.66%
GetNameValuePair(...)92.85%141490.9%
NormalizeSubtitleCodec(...)62.5%10866.66%
GetMediaAttachment(...)90%1010100%
GetMediaStream(...)78.94%29715281.54%
NormalizeStreamTitle(...)100%44100%
GetDictionaryValue(...)100%22100%
ParseChannelLayout(...)100%22100%
GetAspectRatio(...)85.29%393483.87%
IsClose(...)100%11100%
IsNearSquarePixelSar(...)60%101088.88%
GetFrameRate(...)60%141066.66%
SetAudioRuntimeTicks(...)62.5%9877.77%
GetBPSFromTags(...)75%8883.33%
GetRuntimeSecondsFromTags(...)75%8883.33%
GetNumberOfBytesFromTags(...)75%8885.71%
SetSize(...)75%44100%
SetAudioInfoFromTags(...)80%847085.93%
GetMultipleMusicBrainzId(...)100%22100%
Split(...)100%44100%
SplitDistinctArtists(...)83.33%6691.66%
FetchStudios(...)100%1010100%
FetchGenres(...)100%66100%
GetDictionaryTrackOrDiscNumber(...)50%2275%
GetChapterInfo(...)0%4260%
FetchWtvInfo(...)50%5654233.33%
ExtractTimestamp(...)87.5%9878.57%
GetMpegTimestamp(...)0%1211418.18%

File(s)

/srv/git/jellyfin/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs

#LineLine coverage
 1#nullable disable
 2
 3using System;
 4using System.Collections.Generic;
 5using System.Globalization;
 6using System.IO;
 7using System.Linq;
 8using System.Text;
 9using System.Text.RegularExpressions;
 10using System.Xml;
 11using Jellyfin.Data.Enums;
 12using Jellyfin.Extensions;
 13using MediaBrowser.Controller.Extensions;
 14using MediaBrowser.Controller.Library;
 15using MediaBrowser.Model.Dto;
 16using MediaBrowser.Model.Entities;
 17using MediaBrowser.Model.Globalization;
 18using MediaBrowser.Model.MediaInfo;
 19using Microsoft.Extensions.Logging;
 20
 21namespace MediaBrowser.MediaEncoding.Probing
 22{
 23    /// <summary>
 24    /// Class responsible for normalizing FFprobe output.
 25    /// </summary>
 26    public partial class ProbeResultNormalizer
 27    {
 28        // When extracting subtitles, the maximum length to consider (to avoid invalid filenames)
 29        private const int MaxSubtitleDescriptionExtractionLength = 100;
 30
 31        private const string ArtistReplaceValue = " | ";
 32
 133        private static readonly char[] _basicDelimiters = ['/', ';'];
 134        private static readonly char[] _nameDelimiters = [.. _basicDelimiters, '|', '\\'];
 135        private static readonly char[] _genreDelimiters = [.. _basicDelimiters, ','];
 136        private static readonly string[] _webmVideoCodecs = ["av1", "vp8", "vp9"];
 137        private static readonly string[] _webmAudioCodecs = ["opus", "vorbis"];
 38
 39        private readonly ILogger _logger;
 40        private readonly ILocalizationManager _localization;
 41
 42        private string[] _splitWhiteList;
 43
 44        /// <summary>
 45        /// Initializes a new instance of the <see cref="ProbeResultNormalizer"/> class.
 46        /// </summary>
 47        /// <param name="logger">The <see cref="ILogger{ProbeResultNormalizer}"/> for use with the <see cref="ProbeResul
 48        /// <param name="localization">The <see cref="ILocalizationManager"/> for use with the <see cref="ProbeResultNor
 49        public ProbeResultNormalizer(ILogger logger, ILocalizationManager localization)
 50        {
 3551            _logger = logger;
 3552            _localization = localization;
 3553        }
 54
 555        private IReadOnlyList<string> SplitWhitelist => _splitWhiteList ??= new string[]
 556        {
 557            "AC/DC",
 558            "A/T/O/S",
 559            "As/Hi Soundworks",
 560            "Au/Ra",
 561            "Bremer/McCoy",
 562            "b/bqスタヂオ",
 563            "DOV/S",
 564            "DJ'TEKINA//SOMETHING",
 565            "IX/ON",
 566            "J-CORE SLi//CER",
 567            "M(a/u)SH",
 568            "Kaoru/Brilliance",
 569            "signum/ii",
 570            "Richiter(LORB/DUGEM DI BARAT)",
 571            "이달의 소녀 1/3",
 572            "R!N / Gemie",
 573            "LOONA 1/3",
 574            "LOONA / yyxy",
 575            "LOONA / ODD EYE CIRCLE",
 576            "K/DA",
 577            "22/7",
 578            "諭吉佳作/men",
 579            "//dARTH nULL",
 580            "Phantom/Ghost",
 581            "She/Her/Hers",
 582            "5/8erl in Ehr'n",
 583            "Smith/Kotzen",
 584            "We;Na",
 585            "LSR/CITY",
 586            "Kairon; IRSE!",
 587        };
 88
 89        /// <summary>
 90        /// Transforms a FFprobe response into its <see cref="MediaInfo"/> equivalent.
 91        /// </summary>
 92        /// <param name="data">The <see cref="InternalMediaInfoResult"/>.</param>
 93        /// <param name="videoType">The <see cref="VideoType"/>.</param>
 94        /// <param name="isAudio">A boolean indicating whether the media is audio.</param>
 95        /// <param name="path">Path to media file.</param>
 96        /// <param name="protocol">Path media protocol.</param>
 97        /// <returns>The <see cref="MediaInfo"/>.</returns>
 98        public MediaInfo GetMediaInfo(InternalMediaInfoResult data, VideoType? videoType, bool isAudio, string path, Med
 99        {
 12100            var info = new MediaInfo
 12101            {
 12102                Path = path,
 12103                Protocol = protocol,
 12104                VideoType = videoType
 12105            };
 106
 12107            FFProbeHelpers.NormalizeFFProbeResult(data);
 12108            SetSize(data, info);
 109
 12110            var internalStreams = data.Streams ?? Array.Empty<MediaStreamInfo>();
 12111            var internalFrames = data.Frames ?? Array.Empty<MediaFrameInfo>();
 112
 12113            info.MediaStreams = internalStreams.Select(s => GetMediaStream(isAudio, s, data.Format, internalFrames))
 12114                .Where(i => i is not null)
 12115                // Drop subtitle streams if we don't know the codec because it will just cause failures if we don't know
 12116                .Where(i => i.Type != MediaStreamType.Subtitle || !string.IsNullOrWhiteSpace(i.Codec))
 12117                .ToList();
 118
 12119            info.MediaAttachments = internalStreams.Select(GetMediaAttachment)
 12120                .Where(i => i is not null)
 12121                .ToList();
 122
 12123            if (data.Format is not null)
 124            {
 11125                info.Container = NormalizeFormat(data.Format.FormatName, info.MediaStreams);
 126
 11127                if (int.TryParse(data.Format.BitRate, CultureInfo.InvariantCulture, out var value))
 128                {
 11129                    info.Bitrate = value;
 130                }
 131            }
 132
 12133            var tags = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 12134            var tagStreamType = isAudio ? CodecType.Audio : CodecType.Video;
 135
 12136            var tagStream = data.Streams?.FirstOrDefault(i => i.CodecType == tagStreamType);
 137
 12138            if (tagStream?.Tags is not null)
 139            {
 74140                foreach (var (key, value) in tagStream.Tags)
 141                {
 28142                    tags[key] = value;
 143                }
 144            }
 145
 12146            if (data.Format?.Tags is not null)
 147            {
 274148                foreach (var (key, value) in data.Format.Tags)
 149                {
 129150                    tags[key] = value;
 151                }
 152            }
 153
 12154            FetchGenres(info, tags);
 155
 12156            info.Name = tags.GetFirstNotNullNorWhiteSpaceValue("title", "title-eng");
 12157            info.ForcedSortName = tags.GetFirstNotNullNorWhiteSpaceValue("sort_name", "title-sort", "titlesort");
 12158            info.Overview = tags.GetFirstNotNullNorWhiteSpaceValue("synopsis", "description", "desc", "comment");
 159
 12160            info.ParentIndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "season_number");
 12161            info.IndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "episode_sort") ??
 12162                               FFProbeHelpers.GetDictionaryNumericValue(tags, "episode_id");
 12163            info.ShowName = tags.GetValueOrDefault("show_name", "show");
 12164            info.ProductionYear = FFProbeHelpers.GetDictionaryNumericValue(tags, "date");
 165
 166            // Several different forms of retail/premiere date
 12167            info.PremiereDate =
 12168                FFProbeHelpers.GetDictionaryDateTime(tags, "originaldate") ??
 12169                FFProbeHelpers.GetDictionaryDateTime(tags, "retaildate") ??
 12170                FFProbeHelpers.GetDictionaryDateTime(tags, "retail date") ??
 12171                FFProbeHelpers.GetDictionaryDateTime(tags, "retail_date") ??
 12172                FFProbeHelpers.GetDictionaryDateTime(tags, "date_released") ??
 12173                FFProbeHelpers.GetDictionaryDateTime(tags, "date") ??
 12174                FFProbeHelpers.GetDictionaryDateTime(tags, "creation_time");
 175
 176            // Set common metadata for music (audio) and music videos (video)
 12177            info.Album = tags.GetValueOrDefault("album");
 178
 12179            if (tags.TryGetValue("artists", out var artists) && !string.IsNullOrWhiteSpace(artists))
 180            {
 2181                info.Artists = SplitDistinctArtists(artists, _basicDelimiters, false).ToArray();
 182            }
 183            else
 184            {
 10185                var artist = tags.GetFirstNotNullNorWhiteSpaceValue("artist");
 10186                info.Artists = artist is null
 10187                    ? Array.Empty<string>()
 10188                    : SplitDistinctArtists(artist, _nameDelimiters, true).ToArray();
 189            }
 190
 191            // Guess ProductionYear from PremiereDate if missing
 12192            if (!info.ProductionYear.HasValue && info.PremiereDate.HasValue)
 193            {
 5194                info.ProductionYear = info.PremiereDate.Value.Year;
 195            }
 196
 197            // Set mediaType-specific metadata
 12198            if (isAudio)
 199            {
 2200                SetAudioRuntimeTicks(data, info);
 201
 202                // tags are normally located under data.format, but we've seen some cases with ogg where they're part of
 203                // so let's create a combined list of both
 204
 2205                SetAudioInfoFromTags(info, tags);
 206            }
 207            else
 208            {
 10209                FetchStudios(info, tags, "copyright");
 210
 10211                var iTunExtc = tags.GetFirstNotNullNorWhiteSpaceValue("iTunEXTC");
 10212                if (iTunExtc is not null)
 213                {
 0214                    var parts = iTunExtc.Split('|', StringSplitOptions.RemoveEmptyEntries);
 215                    // Example
 216                    // mpaa|G|100|For crude humor
 0217                    if (parts.Length > 1)
 218                    {
 0219                        info.OfficialRating = parts[1];
 220
 0221                        if (parts.Length > 3)
 222                        {
 0223                            info.OfficialRatingDescription = parts[3];
 224                        }
 225                    }
 226                }
 227
 10228                var iTunXml = tags.GetFirstNotNullNorWhiteSpaceValue("iTunMOVI");
 10229                if (iTunXml is not null)
 230                {
 1231                    FetchFromItunesInfo(iTunXml, info);
 232                }
 233
 10234                if (data.Format is not null && !string.IsNullOrEmpty(data.Format.Duration))
 235                {
 9236                    info.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.Format.Duration, CultureInfo.InvariantCul
 237                }
 238
 10239                FetchWtvInfo(info, data);
 240
 10241                if (data.Chapters is not null)
 242                {
 3243                    info.Chapters = data.Chapters.Select(GetChapterInfo).ToArray();
 244                }
 245
 10246                ExtractTimestamp(info);
 247
 10248                if (tags.TryGetValue("stereo_mode", out var stereoMode) && string.Equals(stereoMode, "left_right", Strin
 249                {
 0250                    info.Video3DFormat = Video3DFormat.FullSideBySide;
 251                }
 252
 70253                foreach (var mediaStream in info.MediaStreams)
 254                {
 25255                    if (mediaStream.Type == MediaStreamType.Audio && !mediaStream.BitRate.HasValue)
 256                    {
 3257                        mediaStream.BitRate = GetEstimatedAudioBitrate(mediaStream.Codec, mediaStream.Channels);
 258                    }
 259                }
 260
 10261                var videoStreamsBitrate = info.MediaStreams.Where(i => i.Type == MediaStreamType.Video).Select(i => i.Bi
 262                // If ffprobe reported the container bitrate as being the same as the video stream bitrate, then it's wr
 10263                if (videoStreamsBitrate == (info.Bitrate ?? 0))
 264                {
 6265                    info.InferTotalBitrate(true);
 266                }
 267            }
 268
 12269            return info;
 270        }
 271
 272        private string NormalizeFormat(string format, IReadOnlyList<MediaStream> mediaStreams)
 273        {
 11274            if (string.IsNullOrWhiteSpace(format))
 275            {
 0276                return null;
 277            }
 278
 279            // Input can be a list of multiple, comma-delimited formats - each of them needs to be checked
 11280            var splitFormat = format.Split(',');
 84281            for (var i = 0; i < splitFormat.Length; i++)
 282            {
 283                // Handle MPEG-1 container
 31284                if (string.Equals(splitFormat[i], "mpegvideo", StringComparison.OrdinalIgnoreCase))
 285                {
 0286                    splitFormat[i] = "mpeg";
 287                }
 288
 289                // Handle MPEG-TS container
 31290                else if (string.Equals(splitFormat[i], "mpegts", StringComparison.OrdinalIgnoreCase))
 291                {
 1292                    splitFormat[i] = "ts";
 293                }
 294
 295                // Handle matroska container
 30296                else if (string.Equals(splitFormat[i], "matroska", StringComparison.OrdinalIgnoreCase))
 297                {
 5298                    splitFormat[i] = "mkv";
 299                }
 300
 301                // Handle WebM
 25302                else if (string.Equals(splitFormat[i], "webm", StringComparison.OrdinalIgnoreCase))
 303                {
 304                    // Limit WebM to supported stream types and codecs.
 305                    // FFprobe can report "matroska,webm" for Matroska-like containers, so only keep "webm" if all strea
 306                    // Any stream that is not video nor audio is not supported in WebM and should disqualify the webm co
 5307                    if (mediaStreams.Any(stream => stream.Type is not MediaStreamType.Video and not MediaStreamType.Audi
 5308                        || mediaStreams.Any(stream => (stream.Type == MediaStreamType.Video && !_webmVideoCodecs.Contain
 5309                            || (stream.Type == MediaStreamType.Audio && !_webmAudioCodecs.Contains(stream.Codec, StringC
 310                    {
 4311                        splitFormat[i] = string.Empty;
 312                    }
 313                }
 314            }
 315
 11316            return string.Join(',', splitFormat.Where(s => !string.IsNullOrEmpty(s)));
 317        }
 318
 319        private static int? GetEstimatedAudioBitrate(string codec, int? channels)
 320        {
 3321            if (!channels.HasValue)
 322            {
 0323                return null;
 324            }
 325
 3326            var channelsValue = channels.Value;
 327
 3328            if (string.Equals(codec, "aac", StringComparison.OrdinalIgnoreCase)
 3329                || string.Equals(codec, "mp3", StringComparison.OrdinalIgnoreCase))
 330            {
 331                switch (channelsValue)
 332                {
 333                    case <= 2:
 1334                        return 192000;
 335                    case >= 5:
 0336                        return 320000;
 337                }
 338            }
 339
 2340            if (string.Equals(codec, "ac3", StringComparison.OrdinalIgnoreCase)
 2341                || string.Equals(codec, "eac3", StringComparison.OrdinalIgnoreCase))
 342            {
 343                switch (channelsValue)
 344                {
 345                    case <= 2:
 0346                        return 192000;
 347                    case >= 5:
 0348                        return 640000;
 349                }
 350            }
 351
 2352            if (string.Equals(codec, "flac", StringComparison.OrdinalIgnoreCase)
 2353                || string.Equals(codec, "alac", StringComparison.OrdinalIgnoreCase))
 354            {
 355                switch (channelsValue)
 356                {
 357                    case <= 2:
 0358                        return 960000;
 359                    case >= 5:
 0360                        return 2880000;
 361                }
 362            }
 363
 2364            return null;
 365        }
 366
 367        private void FetchFromItunesInfo(string xml, MediaInfo info)
 368        {
 369            // Make things simpler and strip out the dtd
 1370            var plistIndex = xml.IndexOf("<plist", StringComparison.OrdinalIgnoreCase);
 371
 1372            if (plistIndex != -1)
 373            {
 1374                xml = xml.Substring(plistIndex);
 375            }
 376
 1377            xml = "<?xml version=\"1.0\"?>" + xml;
 378
 379            // <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http
 1380            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)))
 1381            using (var streamReader = new StreamReader(stream))
 382            {
 383                try
 384                {
 1385                    using (var reader = XmlReader.Create(streamReader))
 386                    {
 1387                        reader.MoveToContent();
 1388                        reader.Read();
 389
 390                        // Loop through each element
 4391                        while (!reader.EOF && reader.ReadState == ReadState.Interactive)
 392                        {
 3393                            if (reader.NodeType == XmlNodeType.Element)
 394                            {
 1395                                switch (reader.Name)
 396                                {
 397                                    case "dict":
 1398                                        if (reader.IsEmptyElement)
 399                                        {
 0400                                            reader.Read();
 0401                                            continue;
 402                                        }
 403
 1404                                        using (var subtree = reader.ReadSubtree())
 405                                        {
 1406                                            ReadFromDictNode(subtree, info);
 1407                                        }
 408
 409                                        break;
 410                                    default:
 0411                                        reader.Skip();
 0412                                        break;
 413                                }
 414                            }
 415                            else
 416                            {
 2417                                reader.Read();
 418                            }
 419                        }
 1420                    }
 1421                }
 0422                catch (XmlException)
 423                {
 424                    // I've seen probe examples where the iTunMOVI value is just "<"
 425                    // So we should not allow this to fail the entire probing operation
 0426                }
 427            }
 1428        }
 429
 430        private void ReadFromDictNode(XmlReader reader, MediaInfo info)
 431        {
 1432            string currentKey = null;
 1433            var pairs = new List<NameValuePair>();
 434
 1435            reader.MoveToContent();
 1436            reader.Read();
 437
 438            // Loop through each element
 19439            while (!reader.EOF && reader.ReadState == ReadState.Interactive)
 440            {
 18441                if (reader.NodeType == XmlNodeType.Element)
 442                {
 12443                    switch (reader.Name)
 444                    {
 445                        case "key":
 6446                            if (!string.IsNullOrWhiteSpace(currentKey))
 447                            {
 5448                                ProcessPairs(currentKey, pairs, info);
 449                            }
 450
 6451                            currentKey = reader.ReadElementContentAsString();
 6452                            pairs = new List<NameValuePair>();
 6453                            break;
 454                        case "string":
 1455                            var value = reader.ReadElementContentAsString();
 1456                            if (!string.IsNullOrWhiteSpace(value))
 457                            {
 1458                                pairs.Add(new NameValuePair
 1459                                {
 1460                                    Name = value,
 1461                                    Value = value
 1462                                });
 463                            }
 464
 1465                            break;
 466                        case "array":
 5467                            if (reader.IsEmptyElement)
 468                            {
 0469                                reader.Read();
 0470                                continue;
 471                            }
 472
 5473                            using (var subtree = reader.ReadSubtree())
 474                            {
 5475                                if (!string.IsNullOrWhiteSpace(currentKey))
 476                                {
 5477                                    pairs.AddRange(ReadValueArray(subtree));
 478                                }
 5479                            }
 480
 481                            break;
 482                        default:
 0483                            reader.Skip();
 0484                            break;
 485                    }
 486                }
 487                else
 488                {
 6489                    reader.Read();
 490                }
 491            }
 1492        }
 493
 494        private List<NameValuePair> ReadValueArray(XmlReader reader)
 495        {
 5496            var pairs = new List<NameValuePair>();
 497
 5498            reader.MoveToContent();
 5499            reader.Read();
 500
 501            // Loop through each element
 20502            while (!reader.EOF && reader.ReadState == ReadState.Interactive)
 503            {
 15504                if (reader.NodeType == XmlNodeType.Element)
 505                {
 5506                    switch (reader.Name)
 507                    {
 508                        case "dict":
 509
 5510                            if (reader.IsEmptyElement)
 511                            {
 0512                                reader.Read();
 0513                                continue;
 514                            }
 515
 5516                            using (var subtree = reader.ReadSubtree())
 517                            {
 5518                                var dict = GetNameValuePair(subtree);
 5519                                if (dict is not null)
 520                                {
 1521                                    pairs.Add(dict);
 522                                }
 5523                            }
 524
 525                            break;
 526                        default:
 0527                            reader.Skip();
 0528                            break;
 529                    }
 530                }
 531                else
 532                {
 10533                    reader.Read();
 534                }
 535            }
 536
 5537            return pairs;
 538        }
 539
 540        private static void ProcessPairs(string key, List<NameValuePair> pairs, MediaInfo info)
 541        {
 5542            List<BaseItemPerson> peoples = new List<BaseItemPerson>();
 5543            var distinctPairs = pairs.Select(p => p.Value)
 5544                    .Where(i => !string.IsNullOrWhiteSpace(i))
 5545                    .Trimmed()
 5546                    .Distinct(StringComparer.OrdinalIgnoreCase);
 547
 5548            if (string.Equals(key, "studio", StringComparison.OrdinalIgnoreCase))
 549            {
 1550                info.Studios = distinctPairs.ToArray();
 551            }
 4552            else if (string.Equals(key, "screenwriters", StringComparison.OrdinalIgnoreCase))
 553            {
 0554                foreach (var pair in distinctPairs)
 555                {
 0556                    peoples.Add(new BaseItemPerson
 0557                    {
 0558                        Name = pair,
 0559                        Type = PersonKind.Writer
 0560                    });
 561                }
 562            }
 4563            else if (string.Equals(key, "producers", StringComparison.OrdinalIgnoreCase))
 564            {
 2565                foreach (var pair in distinctPairs)
 566                {
 0567                    peoples.Add(new BaseItemPerson
 0568                    {
 0569                        Name = pair,
 0570                        Type = PersonKind.Producer
 0571                    });
 572                }
 573            }
 3574            else if (string.Equals(key, "directors", StringComparison.OrdinalIgnoreCase))
 575            {
 2576                foreach (var pair in distinctPairs)
 577                {
 0578                    peoples.Add(new BaseItemPerson
 0579                    {
 0580                        Name = pair,
 0581                        Type = PersonKind.Director
 0582                    });
 583                }
 584            }
 585
 5586            info.People = peoples.ToArray();
 5587        }
 588
 589        private static NameValuePair GetNameValuePair(XmlReader reader)
 590        {
 5591            string name = null;
 5592            string value = null;
 593
 5594            reader.MoveToContent();
 5595            reader.Read();
 596
 597            // Loop through each element
 20598            while (!reader.EOF && reader.ReadState == ReadState.Interactive)
 599            {
 15600                if (reader.NodeType == XmlNodeType.Element)
 601                {
 10602                    switch (reader.Name)
 603                    {
 604                        case "key":
 5605                            name = reader.ReadNormalizedString();
 5606                            break;
 607                        case "string":
 5608                            value = reader.ReadNormalizedString();
 5609                            break;
 610                        default:
 0611                            reader.Skip();
 0612                            break;
 613                    }
 614                }
 615                else
 616                {
 5617                    reader.Read();
 618                }
 619            }
 620
 5621            if (string.IsNullOrEmpty(name)
 5622                || string.IsNullOrEmpty(value))
 623            {
 4624                return null;
 625            }
 626
 1627            return new NameValuePair
 1628            {
 1629                Name = name,
 1630                Value = value
 1631            };
 632        }
 633
 634        private static string NormalizeSubtitleCodec(string codec)
 635        {
 4636            if (string.Equals(codec, "dvb_subtitle", StringComparison.OrdinalIgnoreCase))
 637            {
 0638                codec = "DVBSUB";
 639            }
 4640            else if (string.Equals(codec, "dvb_teletext", StringComparison.OrdinalIgnoreCase))
 641            {
 0642                codec = "DVBTXT";
 643            }
 4644            else if (string.Equals(codec, "dvd_subtitle", StringComparison.OrdinalIgnoreCase))
 645            {
 1646                codec = "DVDSUB"; // .sub+.idx
 647            }
 3648            else if (string.Equals(codec, "hdmv_pgs_subtitle", StringComparison.OrdinalIgnoreCase))
 649            {
 0650                codec = "PGSSUB"; // .sup
 651            }
 652
 4653            return codec;
 654        }
 655
 656        /// <summary>
 657        /// Converts ffprobe stream info to our MediaAttachment class.
 658        /// </summary>
 659        /// <param name="streamInfo">The stream info.</param>
 660        /// <returns>MediaAttachments.</returns>
 661        private MediaAttachment GetMediaAttachment(MediaStreamInfo streamInfo)
 662        {
 29663            if (streamInfo.CodecType != CodecType.Attachment
 29664                && streamInfo.Disposition?.GetValueOrDefault("attached_pic") != 1)
 665            {
 27666                return null;
 667            }
 668
 2669            var attachment = new MediaAttachment
 2670            {
 2671                Codec = streamInfo.CodecName,
 2672                Index = streamInfo.Index
 2673            };
 674
 2675            if (!string.IsNullOrWhiteSpace(streamInfo.CodecTagString))
 676            {
 2677                attachment.CodecTag = streamInfo.CodecTagString;
 678            }
 679
 2680            if (streamInfo.Tags is not null)
 681            {
 2682                attachment.FileName = GetDictionaryValue(streamInfo.Tags, "filename");
 2683                attachment.MimeType = GetDictionaryValue(streamInfo.Tags, "mimetype");
 2684                attachment.Comment = GetDictionaryValue(streamInfo.Tags, "comment");
 685            }
 686
 2687            return attachment;
 688        }
 689
 690        /// <summary>
 691        /// Converts ffprobe stream info to our MediaStream class.
 692        /// </summary>
 693        /// <param name="isAudio">if set to <c>true</c> [is info].</param>
 694        /// <param name="streamInfo">The stream info.</param>
 695        /// <param name="formatInfo">The format info.</param>
 696        /// <param name="frameInfoList">The frame info.</param>
 697        /// <returns>MediaStream.</returns>
 698        private MediaStream GetMediaStream(bool isAudio, MediaStreamInfo streamInfo, MediaFormatInfo formatInfo, IReadOn
 699        {
 700            // These are mp4 chapters
 29701            if (string.Equals(streamInfo.CodecName, "mov_text", StringComparison.OrdinalIgnoreCase))
 702            {
 703                // Edit: but these are also sometimes subtitles?
 704                // return null;
 705            }
 706
 29707            var stream = new MediaStream
 29708            {
 29709                Codec = streamInfo.CodecName,
 29710                Profile = streamInfo.Profile,
 29711                Level = streamInfo.Level,
 29712                Index = streamInfo.Index,
 29713                PixelFormat = streamInfo.PixelFormat,
 29714                NalLengthSize = streamInfo.NalLengthSize,
 29715                TimeBase = streamInfo.TimeBase,
 29716                CodecTimeBase = streamInfo.CodecTimeBase,
 29717                IsAVC = streamInfo.IsAvc
 29718            };
 719
 720            // Filter out junk
 29721            if (!string.IsNullOrWhiteSpace(streamInfo.CodecTagString) && !streamInfo.CodecTagString.Contains("[0]", Stri
 722            {
 10723                stream.CodecTag = streamInfo.CodecTagString;
 724            }
 725
 29726            if (streamInfo.Tags is not null)
 727            {
 25728                stream.Language = GetDictionaryValue(streamInfo.Tags, "language");
 25729                stream.Comment = GetDictionaryValue(streamInfo.Tags, "comment");
 25730                stream.Title = GetDictionaryValue(streamInfo.Tags, "title");
 731            }
 732
 29733            if (streamInfo.CodecType == CodecType.Audio)
 734            {
 12735                stream.Type = MediaStreamType.Audio;
 12736                stream.LocalizedDefault = _localization.GetLocalizedString("Default");
 12737                stream.LocalizedExternal = _localization.GetLocalizedString("External");
 738
 12739                stream.Channels = streamInfo.Channels;
 740
 12741                if (int.TryParse(streamInfo.SampleRate, CultureInfo.InvariantCulture, out var sampleRate))
 742                {
 12743                    stream.SampleRate = sampleRate;
 744                }
 745
 12746                stream.ChannelLayout = ParseChannelLayout(streamInfo.ChannelLayout);
 747
 12748                if (streamInfo.BitsPerSample > 0)
 749                {
 0750                    stream.BitDepth = streamInfo.BitsPerSample;
 751                }
 12752                else if (streamInfo.BitsPerRawSample > 0)
 753                {
 3754                    stream.BitDepth = streamInfo.BitsPerRawSample;
 755                }
 756
 12757                if (string.IsNullOrEmpty(stream.Title))
 758                {
 759                    // mp4 missing track title workaround: fall back to handler_name if populated and not the default "S
 12760                    string handlerName = GetDictionaryValue(streamInfo.Tags, "handler_name");
 12761                    if (!string.IsNullOrEmpty(handlerName) && !string.Equals(handlerName, "SoundHandler", StringComparis
 762                    {
 3763                        stream.Title = handlerName;
 764                    }
 765                }
 766            }
 17767            else if (streamInfo.CodecType == CodecType.Subtitle)
 768            {
 4769                stream.Type = MediaStreamType.Subtitle;
 4770                stream.Codec = NormalizeSubtitleCodec(stream.Codec);
 4771                stream.LocalizedUndefined = _localization.GetLocalizedString("Undefined");
 4772                stream.LocalizedDefault = _localization.GetLocalizedString("Default");
 4773                stream.LocalizedForced = _localization.GetLocalizedString("Forced");
 4774                stream.LocalizedExternal = _localization.GetLocalizedString("External");
 4775                stream.LocalizedHearingImpaired = _localization.GetLocalizedString("HearingImpaired");
 776
 777                // Graphical subtitle may have width and height info
 4778                stream.Width = streamInfo.Width;
 4779                stream.Height = streamInfo.Height;
 780
 4781                if (string.IsNullOrEmpty(stream.Title))
 782                {
 783                    // mp4 missing track title workaround: fall back to handler_name if populated and not the default "S
 4784                    string handlerName = GetDictionaryValue(streamInfo.Tags, "handler_name");
 4785                    if (!string.IsNullOrEmpty(handlerName) && !string.Equals(handlerName, "SubtitleHandler", StringCompa
 786                    {
 1787                        stream.Title = handlerName;
 788                    }
 789                }
 790            }
 13791            else if (streamInfo.CodecType == CodecType.Video)
 792            {
 13793                stream.AverageFrameRate = GetFrameRate(streamInfo.AverageFrameRate);
 13794                stream.RealFrameRate = GetFrameRate(streamInfo.RFrameRate);
 795
 13796                stream.IsInterlaced = !string.IsNullOrWhiteSpace(streamInfo.FieldOrder)
 13797                    && !string.Equals(streamInfo.FieldOrder, "progressive", StringComparison.OrdinalIgnoreCase);
 798
 13799                if (isAudio
 13800                    || string.Equals(stream.Codec, "bmp", StringComparison.OrdinalIgnoreCase)
 13801                    || string.Equals(stream.Codec, "gif", StringComparison.OrdinalIgnoreCase)
 13802                    || string.Equals(stream.Codec, "png", StringComparison.OrdinalIgnoreCase)
 13803                    || string.Equals(stream.Codec, "webp", StringComparison.OrdinalIgnoreCase))
 804                {
 2805                    stream.Type = MediaStreamType.EmbeddedImage;
 806                }
 11807                else if (string.Equals(stream.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase))
 808                {
 809                    // How to differentiate between video and embedded image?
 810                    // The only difference I've seen thus far is presence of codec tag, also embedded images have high (
 1811                    if (!string.IsNullOrWhiteSpace(stream.CodecTag))
 812                    {
 0813                        stream.Type = MediaStreamType.Video;
 814                    }
 815                    else
 816                    {
 1817                        stream.Type = MediaStreamType.EmbeddedImage;
 818                    }
 819                }
 820                else
 821                {
 10822                    stream.Type = MediaStreamType.Video;
 823                }
 824
 13825                stream.Width = streamInfo.Width;
 13826                stream.Height = streamInfo.Height;
 13827                stream.AspectRatio = GetAspectRatio(streamInfo);
 828
 13829                if (streamInfo.BitsPerSample > 0)
 830                {
 0831                    stream.BitDepth = streamInfo.BitsPerSample;
 832                }
 13833                else if (streamInfo.BitsPerRawSample > 0)
 834                {
 11835                    stream.BitDepth = streamInfo.BitsPerRawSample;
 836                }
 837
 13838                if (!stream.BitDepth.HasValue)
 839                {
 2840                    if (!string.IsNullOrEmpty(streamInfo.PixelFormat))
 841                    {
 2842                        if (string.Equals(streamInfo.PixelFormat, "yuv420p", StringComparison.OrdinalIgnoreCase)
 2843                            || string.Equals(streamInfo.PixelFormat, "yuv444p", StringComparison.OrdinalIgnoreCase))
 844                        {
 2845                            stream.BitDepth = 8;
 846                        }
 0847                        else if (string.Equals(streamInfo.PixelFormat, "yuv420p10le", StringComparison.OrdinalIgnoreCase
 0848                                 || string.Equals(streamInfo.PixelFormat, "yuv444p10le", StringComparison.OrdinalIgnoreC
 849                        {
 0850                            stream.BitDepth = 10;
 851                        }
 0852                        else if (string.Equals(streamInfo.PixelFormat, "yuv420p12le", StringComparison.OrdinalIgnoreCase
 0853                                 || string.Equals(streamInfo.PixelFormat, "yuv444p12le", StringComparison.OrdinalIgnoreC
 854                        {
 0855                            stream.BitDepth = 12;
 856                        }
 857                    }
 858                }
 859
 860                // http://stackoverflow.com/questions/17353387/how-to-detect-anamorphic-video-with-ffprobe
 13861                if (string.IsNullOrEmpty(streamInfo.SampleAspectRatio)
 13862                    && string.IsNullOrEmpty(streamInfo.DisplayAspectRatio))
 863                {
 2864                    stream.IsAnamorphic = false;
 865                }
 11866                else if (IsNearSquarePixelSar(streamInfo.SampleAspectRatio))
 867                {
 9868                    stream.IsAnamorphic = false;
 869                }
 2870                else if (!string.Equals(streamInfo.SampleAspectRatio, "0:1", StringComparison.Ordinal))
 871                {
 1872                    stream.IsAnamorphic = true;
 873                }
 1874                else if (string.Equals(streamInfo.DisplayAspectRatio, "0:1", StringComparison.Ordinal))
 875                {
 1876                    stream.IsAnamorphic = false;
 877                }
 0878                else if (!string.Equals(
 0879                             streamInfo.DisplayAspectRatio,
 0880                             // Force GetAspectRatio() to derive ratio from Width/Height directly by using null DAR
 0881                             GetAspectRatio(new MediaStreamInfo
 0882                             {
 0883                                 Width = streamInfo.Width,
 0884                                 Height = streamInfo.Height,
 0885                                 DisplayAspectRatio = null
 0886                             }),
 0887                             StringComparison.Ordinal))
 888                {
 0889                    stream.IsAnamorphic = true;
 890                }
 891                else
 892                {
 0893                    stream.IsAnamorphic = false;
 894                }
 895
 13896                if (streamInfo.Refs > 0)
 897                {
 13898                    stream.RefFrames = streamInfo.Refs;
 899                }
 900
 13901                if (!string.IsNullOrEmpty(streamInfo.ColorRange))
 902                {
 5903                    stream.ColorRange = streamInfo.ColorRange;
 904                }
 905
 13906                if (!string.IsNullOrEmpty(streamInfo.ColorSpace))
 907                {
 5908                    stream.ColorSpace = streamInfo.ColorSpace;
 909                }
 910
 13911                if (!string.IsNullOrEmpty(streamInfo.ColorTransfer))
 912                {
 2913                    stream.ColorTransfer = streamInfo.ColorTransfer;
 914                }
 915
 13916                if (!string.IsNullOrEmpty(streamInfo.ColorPrimaries))
 917                {
 2918                    stream.ColorPrimaries = streamInfo.ColorPrimaries;
 919                }
 920
 13921                if (streamInfo.SideDataList is not null)
 922                {
 6923                    foreach (var data in streamInfo.SideDataList)
 924                    {
 925                        // Parse Dolby Vision metadata from side_data
 2926                        if (string.Equals(data.SideDataType, "DOVI configuration record", StringComparison.OrdinalIgnore
 927                        {
 1928                            stream.DvVersionMajor = data.DvVersionMajor;
 1929                            stream.DvVersionMinor = data.DvVersionMinor;
 1930                            stream.DvProfile = data.DvProfile;
 1931                            stream.DvLevel = data.DvLevel;
 1932                            stream.RpuPresentFlag = data.RpuPresentFlag;
 1933                            stream.ElPresentFlag = data.ElPresentFlag;
 1934                            stream.BlPresentFlag = data.BlPresentFlag;
 1935                            stream.DvBlSignalCompatibilityId = data.DvBlSignalCompatibilityId;
 936                        }
 937
 938                        // Parse video rotation metadata from side_data
 1939                        else if (string.Equals(data.SideDataType, "Display Matrix", StringComparison.OrdinalIgnoreCase))
 940                        {
 1941                            stream.Rotation = data.Rotation;
 942                        }
 943
 944                        // Parse video frame cropping metadata from side_data
 945                        // TODO: save them and make HW filters to apply them in HWA pipelines
 0946                        else if (string.Equals(data.SideDataType, "Frame Cropping", StringComparison.OrdinalIgnoreCase))
 947                        {
 948                            // Streams containing artificially added frame cropping
 949                            // metadata should not be marked as anamorphic.
 0950                            stream.IsAnamorphic = false;
 951                        }
 952                    }
 953                }
 954
 13955                var frameInfo = frameInfoList?.FirstOrDefault(i => i.StreamIndex == stream.Index);
 13956                if (frameInfo?.SideDataList is not null
 13957                    && frameInfo.SideDataList.Any(data => string.Equals(data.SideDataType, "HDR Dynamic Metadata SMPTE20
 958                {
 0959                    stream.Hdr10PlusPresentFlag = true;
 960                }
 961            }
 0962            else if (streamInfo.CodecType == CodecType.Data)
 963            {
 0964                stream.Type = MediaStreamType.Data;
 965            }
 966            else
 967            {
 0968                return null;
 969            }
 970
 971            // Get stream bitrate
 29972            var bitrate = 0;
 973
 29974            if (int.TryParse(streamInfo.BitRate, CultureInfo.InvariantCulture, out var value))
 975            {
 13976                bitrate = value;
 977            }
 978
 979            // The bitrate info of FLAC musics and some videos is included in formatInfo.
 29980            if (bitrate == 0
 29981                && formatInfo is not null
 29982                && (stream.Type == MediaStreamType.Video || (isAudio && stream.Type == MediaStreamType.Audio)))
 983            {
 984                // If the stream info doesn't have a bitrate get the value from the media format info
 8985                if (int.TryParse(formatInfo.BitRate, CultureInfo.InvariantCulture, out value))
 986                {
 8987                    bitrate = value;
 988                }
 989            }
 990
 29991            if (bitrate > 0)
 992            {
 21993                stream.BitRate = bitrate;
 994            }
 995
 996            // Extract bitrate info from tag "BPS" if possible.
 29997            if (!stream.BitRate.HasValue
 29998                && (streamInfo.CodecType == CodecType.Audio
 29999                    || streamInfo.CodecType == CodecType.Video))
 1000            {
 71001                var bps = GetBPSFromTags(streamInfo);
 71002                if (bps > 0)
 1003                {
 11004                    stream.BitRate = bps;
 1005                }
 1006                else
 1007                {
 1008                    // Get average bitrate info from tag "NUMBER_OF_BYTES" and "DURATION" if possible.
 61009                    var durationInSeconds = GetRuntimeSecondsFromTags(streamInfo);
 61010                    var bytes = GetNumberOfBytesFromTags(streamInfo);
 61011                    if (durationInSeconds is not null && durationInSeconds.Value >= 1 && bytes is not null)
 1012                    {
 01013                        bps = Convert.ToInt32(bytes * 8 / durationInSeconds, CultureInfo.InvariantCulture);
 01014                        if (bps > 0)
 1015                        {
 01016                            stream.BitRate = bps;
 1017                        }
 1018                    }
 1019                }
 1020            }
 1021
 291022            var disposition = streamInfo.Disposition;
 291023            if (disposition is not null)
 1024            {
 291025                if (disposition.GetValueOrDefault("default") == 1)
 1026                {
 171027                    stream.IsDefault = true;
 1028                }
 1029
 291030                if (disposition.GetValueOrDefault("forced") == 1)
 1031                {
 01032                    stream.IsForced = true;
 1033                }
 1034
 291035                if (disposition.GetValueOrDefault("hearing_impaired") == 1)
 1036                {
 11037                    stream.IsHearingImpaired = true;
 1038                }
 1039            }
 1040
 291041            NormalizeStreamTitle(stream);
 1042
 291043            return stream;
 1044        }
 1045
 1046        private static void NormalizeStreamTitle(MediaStream stream)
 1047        {
 291048            if (string.Equals(stream.Title, "cc", StringComparison.OrdinalIgnoreCase)
 291049                || stream.Type == MediaStreamType.EmbeddedImage)
 1050            {
 31051                stream.Title = null;
 1052            }
 291053        }
 1054
 1055        /// <summary>
 1056        /// Gets a string from an FFProbeResult tags dictionary.
 1057        /// </summary>
 1058        /// <param name="tags">The tags.</param>
 1059        /// <param name="key">The key.</param>
 1060        /// <returns>System.String.</returns>
 1061        private static string GetDictionaryValue(IReadOnlyDictionary<string, string> tags, string key)
 1062        {
 1351063            if (tags is null)
 1064            {
 31065                return null;
 1066            }
 1067
 1321068            tags.TryGetValue(key, out var val);
 1069
 1321070            return val;
 1071        }
 1072
 1073        private static string ParseChannelLayout(string input)
 1074        {
 121075            if (string.IsNullOrEmpty(input))
 1076            {
 11077                return null;
 1078            }
 1079
 111080            return input.AsSpan().LeftPart('(').ToString();
 1081        }
 1082
 1083        private static string GetAspectRatio(MediaStreamInfo info)
 1084        {
 131085            var original = info.DisplayAspectRatio;
 1086
 131087            var parts = (original ?? string.Empty).Split(':');
 131088            if (!(parts.Length == 2
 131089                    && int.TryParse(parts[0], CultureInfo.InvariantCulture, out var width)
 131090                    && int.TryParse(parts[1], CultureInfo.InvariantCulture, out var height)
 131091                    && width > 0
 131092                    && height > 0))
 1093            {
 31094                width = info.Width;
 31095                height = info.Height;
 1096            }
 1097
 131098            if (width > 0 && height > 0)
 1099            {
 131100                double ratio = width;
 131101                ratio /= height;
 1102
 131103                if (IsClose(ratio, 1.777777778, .03))
 1104                {
 71105                    return "16:9";
 1106                }
 1107
 61108                if (IsClose(ratio, 1.3333333333, .05))
 1109                {
 11110                    return "4:3";
 1111                }
 1112
 51113                if (IsClose(ratio, 1.41))
 1114                {
 01115                    return "1.41:1";
 1116                }
 1117
 51118                if (IsClose(ratio, 1.5))
 1119                {
 21120                    return "1.5:1";
 1121                }
 1122
 31123                if (IsClose(ratio, 1.6))
 1124                {
 01125                    return "1.6:1";
 1126                }
 1127
 31128                if (IsClose(ratio, 1.66666666667))
 1129                {
 01130                    return "5:3";
 1131                }
 1132
 31133                if (IsClose(ratio, 1.85, .02))
 1134                {
 01135                    return "1.85:1";
 1136                }
 1137
 31138                if (IsClose(ratio, 2.35, .025))
 1139                {
 01140                    return "2.35:1";
 1141                }
 1142
 31143                if (IsClose(ratio, 2.4, .025))
 1144                {
 11145                    return "2.40:1";
 1146                }
 1147            }
 1148
 21149            return original;
 1150        }
 1151
 1152        private static bool IsClose(double d1, double d2, double variance = .005)
 1153        {
 661154            return Math.Abs(d1 - d2) <= variance;
 1155        }
 1156
 1157        /// <summary>
 1158        /// Determines whether a sample aspect ratio represents square (or near-square) pixels.
 1159        /// Some encoders produce SARs like 3201:3200 for content that is effectively 1:1,
 1160        /// which would be falsely classified as anamorphic by an exact string comparison.
 1161        /// A 1% tolerance safely covers encoder rounding artifacts while preserving detection
 1162        /// of genuine anamorphic content (closest standard is PAL 4:3 at 16:15 = 6.67% off).
 1163        /// </summary>
 1164        /// <param name="sar">The sample aspect ratio string in "N:D" format.</param>
 1165        /// <returns><c>true</c> if the SAR is within 1% of 1:1; otherwise <c>false</c>.</returns>
 1166        internal static bool IsNearSquarePixelSar(string sar)
 1167        {
 241168            if (string.IsNullOrEmpty(sar))
 1169            {
 21170                return false;
 1171            }
 1172
 221173            var parts = sar.Split(':');
 221174            if (parts.Length == 2
 221175                && double.TryParse(parts[0], CultureInfo.InvariantCulture, out var num)
 221176                && double.TryParse(parts[1], CultureInfo.InvariantCulture, out var den)
 221177                && den > 0)
 1178            {
 221179                return IsClose(num / den, 1.0, 0.01);
 1180            }
 1181
 01182            return string.Equals(sar, "1:1", StringComparison.Ordinal);
 1183        }
 1184
 1185        /// <summary>
 1186        /// Gets a frame rate from a string value in ffprobe output
 1187        /// This could be a number or in the format of 2997/125.
 1188        /// </summary>
 1189        /// <param name="value">The value.</param>
 1190        /// <returns>System.Nullable{System.Single}.</returns>
 1191        internal static float? GetFrameRate(ReadOnlySpan<char> value)
 1192        {
 351193            if (value.IsEmpty)
 1194            {
 01195                return null;
 1196            }
 1197
 351198            int index = value.IndexOf('/');
 351199            if (index == -1)
 1200            {
 01201                return null;
 1202            }
 1203
 351204            if (!float.TryParse(value[..index], NumberStyles.Integer, CultureInfo.InvariantCulture, out var dividend)
 351205                || !float.TryParse(value[(index + 1)..], NumberStyles.Integer, CultureInfo.InvariantCulture, out var div
 1206            {
 01207                return null;
 1208            }
 1209
 351210            return divisor == 0f ? null : dividend / divisor;
 1211        }
 1212
 1213        private static void SetAudioRuntimeTicks(InternalMediaInfoResult result, MediaInfo data)
 1214        {
 1215            // Get the first info stream
 21216            var stream = result.Streams?.FirstOrDefault(s => s.CodecType == CodecType.Audio);
 21217            if (stream is null)
 1218            {
 01219                return;
 1220            }
 1221
 1222            // Get duration from stream properties
 21223            var duration = stream.Duration;
 1224
 1225            // If it's not there go into format properties
 21226            if (string.IsNullOrEmpty(duration))
 1227            {
 01228                duration = result.Format.Duration;
 1229            }
 1230
 1231            // If we got something, parse it
 21232            if (!string.IsNullOrEmpty(duration))
 1233            {
 21234                data.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(duration, CultureInfo.InvariantCulture)).Ticks;
 1235            }
 21236        }
 1237
 1238        private static int? GetBPSFromTags(MediaStreamInfo streamInfo)
 1239        {
 71240            if (streamInfo?.Tags is null)
 1241            {
 01242                return null;
 1243            }
 1244
 71245            var bps = GetDictionaryValue(streamInfo.Tags, "BPS-eng") ?? GetDictionaryValue(streamInfo.Tags, "BPS");
 71246            if (int.TryParse(bps, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBps))
 1247            {
 21248                return parsedBps;
 1249            }
 1250
 51251            return null;
 1252        }
 1253
 1254        private static double? GetRuntimeSecondsFromTags(MediaStreamInfo streamInfo)
 1255        {
 61256            if (streamInfo?.Tags is null)
 1257            {
 01258                return null;
 1259            }
 1260
 61261            var duration = GetDictionaryValue(streamInfo.Tags, "DURATION-eng") ?? GetDictionaryValue(streamInfo.Tags, "D
 61262            if (TimeSpan.TryParse(duration, out var parsedDuration))
 1263            {
 11264                return parsedDuration.TotalSeconds;
 1265            }
 1266
 51267            return null;
 1268        }
 1269
 1270        private static long? GetNumberOfBytesFromTags(MediaStreamInfo streamInfo)
 1271        {
 61272            if (streamInfo?.Tags is null)
 1273            {
 01274                return null;
 1275            }
 1276
 61277            var numberOfBytes = GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES-eng")
 61278                                ?? GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES");
 61279            if (long.TryParse(numberOfBytes, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBytes))
 1280            {
 11281                return parsedBytes;
 1282            }
 1283
 51284            return null;
 1285        }
 1286
 1287        private static void SetSize(InternalMediaInfoResult data, MediaInfo info)
 1288        {
 121289            if (data.Format is null)
 1290            {
 11291                return;
 1292            }
 1293
 111294            info.Size = string.IsNullOrEmpty(data.Format.Size) ? null : long.Parse(data.Format.Size, CultureInfo.Invaria
 111295        }
 1296
 1297        private void SetAudioInfoFromTags(MediaInfo audio, Dictionary<string, string> tags)
 1298        {
 21299            var people = new List<BaseItemPerson>();
 21300            if (tags.TryGetValue("composer", out var composer) && !string.IsNullOrWhiteSpace(composer))
 1301            {
 121302                foreach (var person in Split(composer, false))
 1303                {
 41304                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Composer });
 1305                }
 1306            }
 1307
 21308            if (tags.TryGetValue("conductor", out var conductor) && !string.IsNullOrWhiteSpace(conductor))
 1309            {
 01310                foreach (var person in Split(conductor, false))
 1311                {
 01312                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Conductor });
 1313                }
 1314            }
 1315
 21316            if (tags.TryGetValue("lyricist", out var lyricist) && !string.IsNullOrWhiteSpace(lyricist))
 1317            {
 81318                foreach (var person in Split(lyricist, false))
 1319                {
 21320                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Lyricist });
 1321                }
 1322            }
 1323
 21324            if (tags.TryGetValue("performer", out var performer) && !string.IsNullOrWhiteSpace(performer))
 1325            {
 501326                foreach (var person in Split(performer, false))
 1327                {
 231328                    Match match = PerformerRegex().Match(person);
 1329
 1330                    // If the performer doesn't have any instrument/role associated, it won't match. In that case, chanc
 231331                    if (match.Success)
 1332                    {
 221333                        people.Add(new BaseItemPerson
 221334                        {
 221335                            Name = match.Groups["name"].Value,
 221336                            Type = PersonKind.Actor,
 221337                            Role = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(match.Groups["instrument"].Value)
 221338                        });
 1339                    }
 1340                }
 1341            }
 1342
 1343            // In cases where there isn't sufficient information as to which role a writer performed on a recording, tag
 21344            if (tags.TryGetValue("writer", out var writer) && !string.IsNullOrWhiteSpace(writer))
 1345            {
 01346                foreach (var person in Split(writer, false))
 1347                {
 01348                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Writer });
 1349                }
 1350            }
 1351
 21352            if (tags.TryGetValue("arranger", out var arranger) && !string.IsNullOrWhiteSpace(arranger))
 1353            {
 121354                foreach (var person in Split(arranger, false))
 1355                {
 41356                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Arranger });
 1357                }
 1358            }
 1359
 21360            if (tags.TryGetValue("engineer", out var engineer) && !string.IsNullOrWhiteSpace(engineer))
 1361            {
 01362                foreach (var person in Split(engineer, false))
 1363                {
 01364                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Engineer });
 1365                }
 1366            }
 1367
 21368            if (tags.TryGetValue("mixer", out var mixer) && !string.IsNullOrWhiteSpace(mixer))
 1369            {
 81370                foreach (var person in Split(mixer, false))
 1371                {
 21372                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Mixer });
 1373                }
 1374            }
 1375
 21376            if (tags.TryGetValue("remixer", out var remixer) && !string.IsNullOrWhiteSpace(remixer))
 1377            {
 01378                foreach (var person in Split(remixer, false))
 1379                {
 01380                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Remixer });
 1381                }
 1382            }
 1383
 21384            audio.People = people.ToArray();
 1385
 1386            // Set album artist
 21387            var albumArtist = tags.GetFirstNotNullNorWhiteSpaceValue("albumartist", "album artist", "album_artist");
 21388            audio.AlbumArtists = albumArtist is not null
 21389                ? SplitDistinctArtists(albumArtist, _nameDelimiters, true).ToArray()
 21390                : Array.Empty<string>();
 1391
 1392            // Set album artist to artist if empty
 21393            if (audio.AlbumArtists.Length == 0)
 1394            {
 01395                audio.AlbumArtists = audio.Artists;
 1396            }
 1397
 1398            // Track number
 21399            audio.IndexNumber = GetDictionaryTrackOrDiscNumber(tags, "track");
 1400
 1401            // Disc number
 21402            audio.ParentIndexNumber = GetDictionaryTrackOrDiscNumber(tags, "disc");
 1403
 1404            // There's several values in tags may or may not be present
 21405            FetchStudios(audio, tags, "organization");
 21406            FetchStudios(audio, tags, "ensemble");
 21407            FetchStudios(audio, tags, "publisher");
 21408            FetchStudios(audio, tags, "label");
 1409
 1410            // These support multiple values, but for now we only store the first.
 21411            var mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Album Artist Id"))
 21412                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ALBUMARTISTID"));
 21413            audio.TrySetProviderId(MetadataProvider.MusicBrainzAlbumArtist, mb);
 1414
 21415            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Artist Id"))
 21416                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ARTISTID"));
 21417            audio.TrySetProviderId(MetadataProvider.MusicBrainzArtist, mb);
 1418
 21419            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Album Id"))
 21420                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ALBUMID"));
 21421            audio.TrySetProviderId(MetadataProvider.MusicBrainzAlbum, mb);
 1422
 21423            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Release Group Id"))
 21424                 ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_RELEASEGROUPID"));
 21425            audio.TrySetProviderId(MetadataProvider.MusicBrainzReleaseGroup, mb);
 1426
 21427            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Release Track Id"))
 21428                 ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_RELEASETRACKID"));
 21429            audio.TrySetProviderId(MetadataProvider.MusicBrainzTrack, mb);
 21430        }
 1431
 1432        private static string GetMultipleMusicBrainzId(string value)
 1433        {
 201434            if (string.IsNullOrWhiteSpace(value))
 1435            {
 101436                return null;
 1437            }
 1438
 101439            return value.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
 101440                .FirstOrDefault();
 1441        }
 1442
 1443        /// <summary>
 1444        /// Splits the specified val.
 1445        /// </summary>
 1446        /// <param name="val">The val.</param>
 1447        /// <param name="allowCommaDelimiter">if set to <c>true</c> [allow comma delimiter].</param>
 1448        /// <returns>System.String[][].</returns>
 1449        private string[] Split(string val, bool allowCommaDelimiter)
 1450        {
 1451            // Only use the comma as a delimiter if there are no slashes or pipes.
 1452            // We want to be careful not to split names that have commas in them
 141453            return !allowCommaDelimiter || _nameDelimiters.Any(i => val.Contains(i, StringComparison.Ordinal)) ?
 141454                val.Split(_nameDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) :
 141455                val.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
 1456        }
 1457
 1458        private IEnumerable<string> SplitDistinctArtists(string val, char[] delimiters, bool splitFeaturing)
 1459        {
 51460            if (splitFeaturing)
 1461            {
 31462                val = val.Replace(" featuring ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase)
 31463                    .Replace(" feat. ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase);
 1464            }
 1465
 51466            var artistsFound = new List<string>();
 1467
 3101468            foreach (var whitelistArtist in SplitWhitelist)
 1469            {
 1501470                var originalVal = val;
 1501471                val = val.Replace(whitelistArtist, "|", StringComparison.OrdinalIgnoreCase);
 1472
 1501473                if (!string.Equals(originalVal, val, StringComparison.OrdinalIgnoreCase))
 1474                {
 01475                    artistsFound.Add(whitelistArtist);
 1476                }
 1477            }
 1478
 51479            var artists = val.Split(delimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
 1480
 51481            artistsFound.AddRange(artists);
 51482            return artistsFound.DistinctNames();
 1483        }
 1484
 1485        /// <summary>
 1486        /// Gets the studios from the tags collection.
 1487        /// </summary>
 1488        /// <param name="info">The info.</param>
 1489        /// <param name="tags">The tags.</param>
 1490        /// <param name="tagName">Name of the tag.</param>
 1491        private void FetchStudios(MediaInfo info, IReadOnlyDictionary<string, string> tags, string tagName)
 1492        {
 181493            var val = tags.GetValueOrDefault(tagName);
 1494
 181495            if (string.IsNullOrEmpty(val))
 1496            {
 161497                return;
 1498            }
 1499
 21500            var studios = Split(val, true);
 21501            var studioList = new List<string>();
 1502
 81503            foreach (var studio in studios)
 1504            {
 21505                if (string.IsNullOrWhiteSpace(studio))
 1506                {
 1507                    continue;
 1508                }
 1509
 1510                // Don't add artist/album artist name to studios, even if it's listed there
 21511                if (info.Artists.Contains(studio, StringComparison.OrdinalIgnoreCase)
 21512                    || info.AlbumArtists.Contains(studio, StringComparison.OrdinalIgnoreCase))
 1513                {
 1514                    continue;
 1515                }
 1516
 21517                studioList.Add(studio);
 1518            }
 1519
 21520            info.Studios = studioList
 21521                .Distinct(StringComparer.OrdinalIgnoreCase)
 21522                .ToArray();
 21523        }
 1524
 1525        /// <summary>
 1526        /// Gets the genres from the tags collection.
 1527        /// </summary>
 1528        /// <param name="info">The information.</param>
 1529        /// <param name="tags">The tags.</param>
 1530        private void FetchGenres(MediaInfo info, IReadOnlyDictionary<string, string> tags)
 1531        {
 121532            var genreVal = tags.GetValueOrDefault("genre");
 121533            if (string.IsNullOrEmpty(genreVal))
 1534            {
 101535                return;
 1536            }
 1537
 21538            var genres = new List<string>(info.Genres);
 201539            foreach (var genre in Split(genreVal, true))
 1540            {
 81541                if (string.IsNullOrEmpty(genre))
 1542                {
 1543                    continue;
 1544                }
 1545
 81546                genres.Add(genre);
 1547            }
 1548
 21549            info.Genres = genres
 21550                .Distinct(StringComparer.OrdinalIgnoreCase)
 21551                .ToArray();
 21552        }
 1553
 1554        /// <summary>
 1555        /// Gets the track or disc number, which can be in the form of '1', or '1/3'.
 1556        /// </summary>
 1557        /// <param name="tags">The tags.</param>
 1558        /// <param name="tagName">Name of the tag.</param>
 1559        /// <returns>The track or disc number, or null, if missing or not parseable.</returns>
 1560        private static int? GetDictionaryTrackOrDiscNumber(IReadOnlyDictionary<string, string> tags, string tagName)
 1561        {
 41562            var disc = tags.GetValueOrDefault(tagName);
 1563
 41564            if (int.TryParse(disc.AsSpan().LeftPart('/'), out var discNum))
 1565            {
 41566                return discNum;
 1567            }
 1568
 01569            return null;
 1570        }
 1571
 1572        private static ChapterInfo GetChapterInfo(MediaChapter chapter)
 1573        {
 01574            var info = new ChapterInfo();
 1575
 01576            if (chapter.Tags is not null && chapter.Tags.TryGetValue("title", out string name))
 1577            {
 01578                info.Name = name;
 1579            }
 1580
 1581            // Limit accuracy to milliseconds to match xml saving
 01582            var secondsString = chapter.StartTime;
 1583
 01584            if (double.TryParse(secondsString, CultureInfo.InvariantCulture, out var seconds))
 1585            {
 01586                var ms = Math.Round(TimeSpan.FromSeconds(seconds).TotalMilliseconds);
 01587                info.StartPositionTicks = TimeSpan.FromMilliseconds(ms).Ticks;
 1588            }
 1589
 01590            return info;
 1591        }
 1592
 1593        private void FetchWtvInfo(MediaInfo video, InternalMediaInfoResult data)
 1594        {
 101595            var tags = data.Format?.Tags;
 1596
 101597            if (tags is null)
 1598            {
 41599                return;
 1600            }
 1601
 61602            if (tags.TryGetValue("WM/Genre", out var genres) && !string.IsNullOrWhiteSpace(genres))
 1603            {
 01604                var genreList = genres.Split(_genreDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOption
 1605
 1606                // If this is empty then don't overwrite genres that might have been fetched earlier
 01607                if (genreList.Length > 0)
 1608                {
 01609                    video.Genres = genreList;
 1610                }
 1611            }
 1612
 61613            if (tags.TryGetValue("WM/ParentalRating", out var officialRating) && !string.IsNullOrWhiteSpace(officialRati
 1614            {
 01615                video.OfficialRating = officialRating;
 1616            }
 1617
 61618            if (tags.TryGetValue("WM/MediaCredits", out var people) && !string.IsNullOrEmpty(people))
 1619            {
 01620                video.People = Array.ConvertAll(
 01621                    people.Split(_basicDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntrie
 01622                    i => new BaseItemPerson { Name = i, Type = PersonKind.Actor });
 1623            }
 1624
 61625            if (tags.TryGetValue("WM/OriginalReleaseTime", out var year) && int.TryParse(year, NumberStyles.Integer, Cul
 1626            {
 01627                video.ProductionYear = parsedYear;
 1628            }
 1629
 1630            // Credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
 1631            // DateTime is reported along with timezone info (typically Z i.e. UTC hence assume None)
 61632            if (tags.TryGetValue("WM/MediaOriginalBroadcastDateTime", out var premiereDateString) && DateTime.TryParse(y
 1633            {
 01634                video.PremiereDate = parsedDate;
 1635            }
 1636
 61637            var description = tags.GetValueOrDefault("WM/SubTitleDescription");
 1638
 61639            var subTitle = tags.GetValueOrDefault("WM/SubTitle");
 1640
 1641            // For below code, credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
 1642
 1643            // Sometimes for TV Shows the Subtitle field is empty and the subtitle description contains the subtitle, ex
 1644            // The format is -> EPISODE/TOTAL_EPISODES_IN_SEASON. SUBTITLE: DESCRIPTION
 1645            // OR -> COMMENT. SUBTITLE: DESCRIPTION
 1646            // e.g. -> 4/13. The Doctor's Wife: Science fiction drama. When he follows a Time Lord distress signal, the 
 1647            // e.g. -> CBeebies Bedtime Hour. The Mystery: Animated adventures of two friends who live on an island in t
 61648            if (string.IsNullOrWhiteSpace(subTitle)
 61649                && !string.IsNullOrWhiteSpace(description)
 61650                && description.AsSpan()[..Math.Min(description.Length, MaxSubtitleDescriptionExtractionLength)].Contains
 1651            {
 01652                string[] descriptionParts = description.Split(':');
 01653                if (descriptionParts.Length > 0)
 1654                {
 01655                    string subtitle = descriptionParts[0];
 1656                    try
 1657                    {
 1658                        // Check if it contains a episode number and season number
 01659                        if (subtitle.Contains('/', StringComparison.Ordinal))
 1660                        {
 01661                            string[] subtitleParts = subtitle.Split(' ');
 01662                            string[] numbers = subtitleParts[0].Replace(".", string.Empty, StringComparison.Ordinal).Spl
 01663                            video.IndexNumber = int.Parse(numbers[0], CultureInfo.InvariantCulture);
 1664                            // int totalEpisodesInSeason = int.Parse(numbers[1], CultureInfo.InvariantCulture);
 1665
 1666                            // Skip the numbers, concatenate the rest, trim and set as new description
 01667                            description = string.Join(' ', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1668                        }
 01669                        else if (subtitle.Contains('.', StringComparison.Ordinal))
 1670                        {
 01671                            var subtitleParts = subtitle.Split('.');
 01672                            description = string.Join('.', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1673                        }
 1674                        else
 1675                        {
 01676                            description = subtitle.Trim();
 1677                        }
 01678                    }
 01679                    catch (Exception ex)
 1680                    {
 01681                        _logger.LogError(ex, "Error while parsing subtitle field");
 1682
 1683                        // Fallback to default parsing
 01684                        if (subtitle.Contains('.', StringComparison.Ordinal))
 1685                        {
 01686                            var subtitleParts = subtitle.Split('.');
 01687                            description = string.Join('.', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1688                        }
 1689                        else
 1690                        {
 01691                            description = subtitle.Trim();
 1692                        }
 01693                    }
 1694                }
 1695            }
 1696
 61697            if (!string.IsNullOrWhiteSpace(description))
 1698            {
 01699                video.Overview = description;
 1700            }
 61701        }
 1702
 1703        private void ExtractTimestamp(MediaInfo video)
 1704        {
 101705            if (video.VideoType != VideoType.VideoFile)
 1706            {
 01707                return;
 1708            }
 1709
 101710            if (!string.Equals(video.Container, "mpeg2ts", StringComparison.OrdinalIgnoreCase)
 101711                && !string.Equals(video.Container, "m2ts", StringComparison.OrdinalIgnoreCase)
 101712                && !string.Equals(video.Container, "ts", StringComparison.OrdinalIgnoreCase))
 1713            {
 91714                return;
 1715            }
 1716
 1717            try
 1718            {
 11719                video.Timestamp = GetMpegTimestamp(video.Path);
 01720                _logger.LogDebug("Video has {Timestamp} timestamp", video.Timestamp);
 01721            }
 11722            catch (Exception ex)
 1723            {
 11724                video.Timestamp = null;
 11725                _logger.LogError(ex, "Error extracting timestamp info from {Path}", video.Path);
 11726            }
 11727        }
 1728
 1729        // REVIEW: find out why the byte array needs to be 197 bytes long and comment the reason
 1730        private static TransportStreamTimestamp GetMpegTimestamp(string path)
 1731        {
 11732            var packetBuffer = new byte[197];
 1733
 11734            using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 1))
 1735            {
 01736                fs.ReadExactly(packetBuffer);
 01737            }
 1738
 01739            if (packetBuffer[0] == 71)
 1740            {
 01741                return TransportStreamTimestamp.None;
 1742            }
 1743
 01744            if ((packetBuffer[4] != 71) || (packetBuffer[196] != 71))
 1745            {
 01746                return TransportStreamTimestamp.None;
 1747            }
 1748
 01749            if ((packetBuffer[0] == 0) && (packetBuffer[1] == 0) && (packetBuffer[2] == 0) && (packetBuffer[3] == 0))
 1750            {
 01751                return TransportStreamTimestamp.Zero;
 1752            }
 1753
 01754            return TransportStreamTimestamp.Valid;
 1755        }
 1756
 1757        [GeneratedRegex("(?<name>.*) \\((?<instrument>.*)\\)")]
 1758        private static partial Regex PerformerRegex();
 1759    }
 1760}

Methods/Properties

.cctor()
.ctor(Microsoft.Extensions.Logging.ILogger,MediaBrowser.Model.Globalization.ILocalizationManager)
get_SplitWhitelist()
GetMediaInfo(MediaBrowser.MediaEncoding.Probing.InternalMediaInfoResult,System.Nullable`1<MediaBrowser.Model.Entities.VideoType>,System.Boolean,System.String,MediaBrowser.Model.MediaInfo.MediaProtocol)
NormalizeFormat(System.String,System.Collections.Generic.IReadOnlyList`1<MediaBrowser.Model.Entities.MediaStream>)
GetEstimatedAudioBitrate(System.String,System.Nullable`1<System.Int32>)
FetchFromItunesInfo(System.String,MediaBrowser.Model.MediaInfo.MediaInfo)
ReadFromDictNode(System.Xml.XmlReader,MediaBrowser.Model.MediaInfo.MediaInfo)
ReadValueArray(System.Xml.XmlReader)
ProcessPairs(System.String,System.Collections.Generic.List`1<MediaBrowser.Model.Dto.NameValuePair>,MediaBrowser.Model.MediaInfo.MediaInfo)
GetNameValuePair(System.Xml.XmlReader)
NormalizeSubtitleCodec(System.String)
GetMediaAttachment(MediaBrowser.MediaEncoding.Probing.MediaStreamInfo)
GetMediaStream(System.Boolean,MediaBrowser.MediaEncoding.Probing.MediaStreamInfo,MediaBrowser.MediaEncoding.Probing.MediaFormatInfo,System.Collections.Generic.IReadOnlyList`1<MediaBrowser.MediaEncoding.Probing.MediaFrameInfo>)
NormalizeStreamTitle(MediaBrowser.Model.Entities.MediaStream)
GetDictionaryValue(System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>,System.String)
ParseChannelLayout(System.String)
GetAspectRatio(MediaBrowser.MediaEncoding.Probing.MediaStreamInfo)
IsClose(System.Double,System.Double,System.Double)
IsNearSquarePixelSar(System.String)
GetFrameRate(System.ReadOnlySpan`1<System.Char>)
SetAudioRuntimeTicks(MediaBrowser.MediaEncoding.Probing.InternalMediaInfoResult,MediaBrowser.Model.MediaInfo.MediaInfo)
GetBPSFromTags(MediaBrowser.MediaEncoding.Probing.MediaStreamInfo)
GetRuntimeSecondsFromTags(MediaBrowser.MediaEncoding.Probing.MediaStreamInfo)
GetNumberOfBytesFromTags(MediaBrowser.MediaEncoding.Probing.MediaStreamInfo)
SetSize(MediaBrowser.MediaEncoding.Probing.InternalMediaInfoResult,MediaBrowser.Model.MediaInfo.MediaInfo)
SetAudioInfoFromTags(MediaBrowser.Model.MediaInfo.MediaInfo,System.Collections.Generic.Dictionary`2<System.String,System.String>)
GetMultipleMusicBrainzId(System.String)
Split(System.String,System.Boolean)
SplitDistinctArtists(System.String,System.Char[],System.Boolean)
FetchStudios(MediaBrowser.Model.MediaInfo.MediaInfo,System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>,System.String)
FetchGenres(MediaBrowser.Model.MediaInfo.MediaInfo,System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>)
GetDictionaryTrackOrDiscNumber(System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>,System.String)
GetChapterInfo(MediaBrowser.MediaEncoding.Probing.MediaChapter)
FetchWtvInfo(MediaBrowser.Model.MediaInfo.MediaInfo,MediaBrowser.MediaEncoding.Probing.InternalMediaInfoResult)
ExtractTimestamp(MediaBrowser.Model.MediaInfo.MediaInfo)
GetMpegTimestamp(System.String)