< 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: 601
Uncovered lines: 157
Coverable lines: 758
Total lines: 1749
Line coverage: 79.2%
Branch coverage
74%
Covered branches: 473
Total branches: 632
Branch coverage: 74.8%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 12/27/2025 - 12:11:51 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: 17603/31/2026 - 12:14:24 AM Line coverage: 79.2% (601/758) Branch coverage: 74.8% (473/632) Total lines: 1749 12/27/2025 - 12:11:51 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: 17603/31/2026 - 12:14:24 AM Line coverage: 79.2% (601/758) Branch coverage: 74.8% (473/632) Total lines: 1749

Coverage delta

Coverage delta 1 -1

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(...)80%101093.33%
GetMediaStream(...)77.92%32715480.6%
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            {
 0677                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        {
 29700            var stream = new MediaStream
 29701            {
 29702                Codec = streamInfo.CodecName,
 29703                Profile = streamInfo.Profile,
 29704                Width = streamInfo.Width,
 29705                Height = streamInfo.Height,
 29706                Level = streamInfo.Level,
 29707                Index = streamInfo.Index,
 29708                PixelFormat = streamInfo.PixelFormat,
 29709                NalLengthSize = streamInfo.NalLengthSize,
 29710                TimeBase = streamInfo.TimeBase,
 29711                CodecTimeBase = streamInfo.CodecTimeBase
 29712            };
 713
 714            // Filter out junk
 29715            if (!string.IsNullOrWhiteSpace(streamInfo.CodecTagString) && !streamInfo.CodecTagString.Contains("[0]", Stri
 716            {
 0717                stream.CodecTag = streamInfo.CodecTagString;
 718            }
 719
 29720            if (streamInfo.Tags is not null)
 721            {
 25722                stream.Language = GetDictionaryValue(streamInfo.Tags, "language");
 25723                stream.Comment = GetDictionaryValue(streamInfo.Tags, "comment");
 25724                stream.Title = GetDictionaryValue(streamInfo.Tags, "title");
 725            }
 726
 29727            if (streamInfo.CodecType == CodecType.Audio)
 728            {
 12729                stream.Type = MediaStreamType.Audio;
 12730                stream.LocalizedDefault = _localization.GetLocalizedString("Default");
 12731                stream.LocalizedExternal = _localization.GetLocalizedString("External");
 732
 12733                stream.Channels = streamInfo.Channels;
 734
 12735                if (int.TryParse(streamInfo.SampleRate, CultureInfo.InvariantCulture, out var sampleRate))
 736                {
 12737                    stream.SampleRate = sampleRate;
 738                }
 739
 12740                stream.ChannelLayout = ParseChannelLayout(streamInfo.ChannelLayout);
 741
 12742                if (streamInfo.BitsPerSample > 0)
 743                {
 0744                    stream.BitDepth = streamInfo.BitsPerSample;
 745                }
 12746                else if (streamInfo.BitsPerRawSample > 0)
 747                {
 3748                    stream.BitDepth = streamInfo.BitsPerRawSample;
 749                }
 750
 12751                if (string.IsNullOrEmpty(stream.Title))
 752                {
 753                    // mp4 missing track title workaround: fall back to handler_name if populated and not the default "S
 12754                    string handlerName = GetDictionaryValue(streamInfo.Tags, "handler_name");
 12755                    if (!string.IsNullOrEmpty(handlerName) && !string.Equals(handlerName, "SoundHandler", StringComparis
 756                    {
 3757                        stream.Title = handlerName;
 758                    }
 759                }
 760            }
 17761            else if (streamInfo.CodecType == CodecType.Subtitle)
 762            {
 4763                stream.Type = MediaStreamType.Subtitle;
 4764                stream.Codec = NormalizeSubtitleCodec(stream.Codec);
 4765                stream.LocalizedUndefined = _localization.GetLocalizedString("Undefined");
 4766                stream.LocalizedDefault = _localization.GetLocalizedString("Default");
 4767                stream.LocalizedForced = _localization.GetLocalizedString("Forced");
 4768                stream.LocalizedExternal = _localization.GetLocalizedString("External");
 4769                stream.LocalizedHearingImpaired = _localization.GetLocalizedString("HearingImpaired");
 770
 4771                if (string.IsNullOrEmpty(stream.Title))
 772                {
 773                    // mp4 missing track title workaround: fall back to handler_name if populated and not the default "S
 4774                    string handlerName = GetDictionaryValue(streamInfo.Tags, "handler_name");
 4775                    if (!string.IsNullOrEmpty(handlerName) && !string.Equals(handlerName, "SubtitleHandler", StringCompa
 776                    {
 1777                        stream.Title = handlerName;
 778                    }
 779                }
 780            }
 13781            else if (streamInfo.CodecType == CodecType.Video)
 782            {
 13783                stream.IsAVC = streamInfo.IsAvc;
 13784                stream.AverageFrameRate = GetFrameRate(streamInfo.AverageFrameRate);
 13785                stream.RealFrameRate = GetFrameRate(streamInfo.RFrameRate);
 786
 13787                stream.IsInterlaced = !string.IsNullOrWhiteSpace(streamInfo.FieldOrder)
 13788                    && !string.Equals(streamInfo.FieldOrder, "progressive", StringComparison.OrdinalIgnoreCase);
 789
 13790                if (isAudio
 13791                    || string.Equals(stream.Codec, "bmp", StringComparison.OrdinalIgnoreCase)
 13792                    || string.Equals(stream.Codec, "gif", StringComparison.OrdinalIgnoreCase)
 13793                    || string.Equals(stream.Codec, "png", StringComparison.OrdinalIgnoreCase)
 13794                    || string.Equals(stream.Codec, "webp", StringComparison.OrdinalIgnoreCase))
 795                {
 2796                    stream.Type = MediaStreamType.EmbeddedImage;
 797                }
 11798                else if (string.Equals(stream.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase))
 799                {
 800                    // How to differentiate between video and embedded image?
 801                    // The only difference I've seen thus far is presence of codec tag, also embedded images have high (
 1802                    if (!string.IsNullOrWhiteSpace(stream.CodecTag))
 803                    {
 0804                        stream.Type = MediaStreamType.Video;
 805                    }
 806                    else
 807                    {
 1808                        stream.Type = MediaStreamType.EmbeddedImage;
 809                    }
 810                }
 811                else
 812                {
 10813                    stream.Type = MediaStreamType.Video;
 814                }
 815
 13816                stream.AspectRatio = GetAspectRatio(streamInfo);
 817
 13818                if (streamInfo.BitsPerSample > 0)
 819                {
 0820                    stream.BitDepth = streamInfo.BitsPerSample;
 821                }
 13822                else if (streamInfo.BitsPerRawSample > 0)
 823                {
 11824                    stream.BitDepth = streamInfo.BitsPerRawSample;
 825                }
 826
 13827                if (!stream.BitDepth.HasValue)
 828                {
 2829                    if (!string.IsNullOrEmpty(streamInfo.PixelFormat))
 830                    {
 2831                        if (string.Equals(streamInfo.PixelFormat, "yuv420p", StringComparison.OrdinalIgnoreCase)
 2832                            || string.Equals(streamInfo.PixelFormat, "yuv444p", StringComparison.OrdinalIgnoreCase))
 833                        {
 2834                            stream.BitDepth = 8;
 835                        }
 0836                        else if (string.Equals(streamInfo.PixelFormat, "yuv420p10le", StringComparison.OrdinalIgnoreCase
 0837                                 || string.Equals(streamInfo.PixelFormat, "yuv444p10le", StringComparison.OrdinalIgnoreC
 838                        {
 0839                            stream.BitDepth = 10;
 840                        }
 0841                        else if (string.Equals(streamInfo.PixelFormat, "yuv420p12le", StringComparison.OrdinalIgnoreCase
 0842                                 || string.Equals(streamInfo.PixelFormat, "yuv444p12le", StringComparison.OrdinalIgnoreC
 843                        {
 0844                            stream.BitDepth = 12;
 845                        }
 846                    }
 847                }
 848
 849                // http://stackoverflow.com/questions/17353387/how-to-detect-anamorphic-video-with-ffprobe
 13850                if (string.IsNullOrEmpty(streamInfo.SampleAspectRatio)
 13851                    && string.IsNullOrEmpty(streamInfo.DisplayAspectRatio))
 852                {
 2853                    stream.IsAnamorphic = false;
 854                }
 11855                else if (IsNearSquarePixelSar(streamInfo.SampleAspectRatio))
 856                {
 9857                    stream.IsAnamorphic = false;
 858                }
 2859                else if (!string.Equals(streamInfo.SampleAspectRatio, "0:1", StringComparison.Ordinal))
 860                {
 1861                    stream.IsAnamorphic = true;
 862                }
 1863                else if (string.Equals(streamInfo.DisplayAspectRatio, "0:1", StringComparison.Ordinal))
 864                {
 1865                    stream.IsAnamorphic = false;
 866                }
 0867                else if (!string.Equals(
 0868                             streamInfo.DisplayAspectRatio,
 0869                             // Force GetAspectRatio() to derive ratio from Width/Height directly by using null DAR
 0870                             GetAspectRatio(new MediaStreamInfo
 0871                             {
 0872                                 Width = streamInfo.Width,
 0873                                 Height = streamInfo.Height,
 0874                                 DisplayAspectRatio = null
 0875                             }),
 0876                             StringComparison.Ordinal))
 877                {
 0878                    stream.IsAnamorphic = true;
 879                }
 880                else
 881                {
 0882                    stream.IsAnamorphic = false;
 883                }
 884
 13885                if (streamInfo.Refs > 0)
 886                {
 13887                    stream.RefFrames = streamInfo.Refs;
 888                }
 889
 13890                if (!string.IsNullOrEmpty(streamInfo.ColorRange))
 891                {
 5892                    stream.ColorRange = streamInfo.ColorRange;
 893                }
 894
 13895                if (!string.IsNullOrEmpty(streamInfo.ColorSpace))
 896                {
 5897                    stream.ColorSpace = streamInfo.ColorSpace;
 898                }
 899
 13900                if (!string.IsNullOrEmpty(streamInfo.ColorTransfer))
 901                {
 2902                    stream.ColorTransfer = streamInfo.ColorTransfer;
 903                }
 904
 13905                if (!string.IsNullOrEmpty(streamInfo.ColorPrimaries))
 906                {
 2907                    stream.ColorPrimaries = streamInfo.ColorPrimaries;
 908                }
 909
 13910                if (streamInfo.SideDataList is not null)
 911                {
 6912                    foreach (var data in streamInfo.SideDataList)
 913                    {
 914                        // Parse Dolby Vision metadata from side_data
 2915                        if (string.Equals(data.SideDataType, "DOVI configuration record", StringComparison.OrdinalIgnore
 916                        {
 1917                            stream.DvVersionMajor = data.DvVersionMajor;
 1918                            stream.DvVersionMinor = data.DvVersionMinor;
 1919                            stream.DvProfile = data.DvProfile;
 1920                            stream.DvLevel = data.DvLevel;
 1921                            stream.RpuPresentFlag = data.RpuPresentFlag;
 1922                            stream.ElPresentFlag = data.ElPresentFlag;
 1923                            stream.BlPresentFlag = data.BlPresentFlag;
 1924                            stream.DvBlSignalCompatibilityId = data.DvBlSignalCompatibilityId;
 925                        }
 926
 927                        // Parse video rotation metadata from side_data
 1928                        else if (string.Equals(data.SideDataType, "Display Matrix", StringComparison.OrdinalIgnoreCase))
 929                        {
 1930                            stream.Rotation = data.Rotation;
 931                        }
 932
 933                        // Parse video frame cropping metadata from side_data
 934                        // TODO: save them and make HW filters to apply them in HWA pipelines
 0935                        else if (string.Equals(data.SideDataType, "Frame Cropping", StringComparison.OrdinalIgnoreCase))
 936                        {
 937                            // Streams containing artificially added frame cropping
 938                            // metadata should not be marked as anamorphic.
 0939                            stream.IsAnamorphic = false;
 940                        }
 941                    }
 942                }
 943
 13944                var frameInfo = frameInfoList?.FirstOrDefault(i => i.StreamIndex == stream.Index);
 13945                if (frameInfo?.SideDataList is not null
 13946                    && frameInfo.SideDataList.Any(data => string.Equals(data.SideDataType, "HDR Dynamic Metadata SMPTE20
 947                {
 0948                    stream.Hdr10PlusPresentFlag = true;
 949                }
 950            }
 0951            else if (streamInfo.CodecType == CodecType.Data)
 952            {
 0953                stream.Type = MediaStreamType.Data;
 954            }
 955            else
 956            {
 0957                return null;
 958            }
 959
 960            // Get stream bitrate
 29961            var bitrate = 0;
 962
 29963            if (int.TryParse(streamInfo.BitRate, CultureInfo.InvariantCulture, out var value))
 964            {
 13965                bitrate = value;
 966            }
 967
 968            // The bitrate info of FLAC musics and some videos is included in formatInfo.
 29969            if (bitrate == 0
 29970                && formatInfo is not null
 29971                && (stream.Type == MediaStreamType.Video || (isAudio && stream.Type == MediaStreamType.Audio)))
 972            {
 973                // If the stream info doesn't have a bitrate get the value from the media format info
 8974                if (int.TryParse(formatInfo.BitRate, CultureInfo.InvariantCulture, out value))
 975                {
 8976                    bitrate = value;
 977                }
 978            }
 979
 29980            if (bitrate > 0)
 981            {
 21982                stream.BitRate = bitrate;
 983            }
 984
 985            // Extract bitrate info from tag "BPS" if possible.
 29986            if (!stream.BitRate.HasValue
 29987                && (streamInfo.CodecType == CodecType.Audio
 29988                    || streamInfo.CodecType == CodecType.Video))
 989            {
 7990                var bps = GetBPSFromTags(streamInfo);
 7991                if (bps > 0)
 992                {
 1993                    stream.BitRate = bps;
 994                }
 995                else
 996                {
 997                    // Get average bitrate info from tag "NUMBER_OF_BYTES" and "DURATION" if possible.
 6998                    var durationInSeconds = GetRuntimeSecondsFromTags(streamInfo);
 6999                    var bytes = GetNumberOfBytesFromTags(streamInfo);
 61000                    if (durationInSeconds is not null && durationInSeconds.Value >= 1 && bytes is not null)
 1001                    {
 01002                        bps = Convert.ToInt32(bytes * 8 / durationInSeconds, CultureInfo.InvariantCulture);
 01003                        if (bps > 0)
 1004                        {
 01005                            stream.BitRate = bps;
 1006                        }
 1007                    }
 1008                }
 1009            }
 1010
 291011            var disposition = streamInfo.Disposition;
 291012            if (disposition is not null)
 1013            {
 291014                if (disposition.GetValueOrDefault("default") == 1)
 1015                {
 171016                    stream.IsDefault = true;
 1017                }
 1018
 291019                if (disposition.GetValueOrDefault("forced") == 1)
 1020                {
 01021                    stream.IsForced = true;
 1022                }
 1023
 291024                if (disposition.GetValueOrDefault("hearing_impaired") == 1)
 1025                {
 11026                    stream.IsHearingImpaired = true;
 1027                }
 1028            }
 1029
 291030            NormalizeStreamTitle(stream);
 1031
 291032            return stream;
 1033        }
 1034
 1035        private static void NormalizeStreamTitle(MediaStream stream)
 1036        {
 291037            if (string.Equals(stream.Title, "cc", StringComparison.OrdinalIgnoreCase)
 291038                || stream.Type == MediaStreamType.EmbeddedImage)
 1039            {
 31040                stream.Title = null;
 1041            }
 291042        }
 1043
 1044        /// <summary>
 1045        /// Gets a string from an FFProbeResult tags dictionary.
 1046        /// </summary>
 1047        /// <param name="tags">The tags.</param>
 1048        /// <param name="key">The key.</param>
 1049        /// <returns>System.String.</returns>
 1050        private static string GetDictionaryValue(IReadOnlyDictionary<string, string> tags, string key)
 1051        {
 1351052            if (tags is null)
 1053            {
 31054                return null;
 1055            }
 1056
 1321057            tags.TryGetValue(key, out var val);
 1058
 1321059            return val;
 1060        }
 1061
 1062        private static string ParseChannelLayout(string input)
 1063        {
 121064            if (string.IsNullOrEmpty(input))
 1065            {
 11066                return null;
 1067            }
 1068
 111069            return input.AsSpan().LeftPart('(').ToString();
 1070        }
 1071
 1072        private static string GetAspectRatio(MediaStreamInfo info)
 1073        {
 131074            var original = info.DisplayAspectRatio;
 1075
 131076            var parts = (original ?? string.Empty).Split(':');
 131077            if (!(parts.Length == 2
 131078                    && int.TryParse(parts[0], CultureInfo.InvariantCulture, out var width)
 131079                    && int.TryParse(parts[1], CultureInfo.InvariantCulture, out var height)
 131080                    && width > 0
 131081                    && height > 0))
 1082            {
 31083                width = info.Width.Value;
 31084                height = info.Height.Value;
 1085            }
 1086
 131087            if (width > 0 && height > 0)
 1088            {
 131089                double ratio = width;
 131090                ratio /= height;
 1091
 131092                if (IsClose(ratio, 1.777777778, .03))
 1093                {
 71094                    return "16:9";
 1095                }
 1096
 61097                if (IsClose(ratio, 1.3333333333, .05))
 1098                {
 11099                    return "4:3";
 1100                }
 1101
 51102                if (IsClose(ratio, 1.41))
 1103                {
 01104                    return "1.41:1";
 1105                }
 1106
 51107                if (IsClose(ratio, 1.5))
 1108                {
 21109                    return "1.5:1";
 1110                }
 1111
 31112                if (IsClose(ratio, 1.6))
 1113                {
 01114                    return "1.6:1";
 1115                }
 1116
 31117                if (IsClose(ratio, 1.66666666667))
 1118                {
 01119                    return "5:3";
 1120                }
 1121
 31122                if (IsClose(ratio, 1.85, .02))
 1123                {
 01124                    return "1.85:1";
 1125                }
 1126
 31127                if (IsClose(ratio, 2.35, .025))
 1128                {
 01129                    return "2.35:1";
 1130                }
 1131
 31132                if (IsClose(ratio, 2.4, .025))
 1133                {
 11134                    return "2.40:1";
 1135                }
 1136            }
 1137
 21138            return original;
 1139        }
 1140
 1141        private static bool IsClose(double d1, double d2, double variance = .005)
 1142        {
 661143            return Math.Abs(d1 - d2) <= variance;
 1144        }
 1145
 1146        /// <summary>
 1147        /// Determines whether a sample aspect ratio represents square (or near-square) pixels.
 1148        /// Some encoders produce SARs like 3201:3200 for content that is effectively 1:1,
 1149        /// which would be falsely classified as anamorphic by an exact string comparison.
 1150        /// A 1% tolerance safely covers encoder rounding artifacts while preserving detection
 1151        /// of genuine anamorphic content (closest standard is PAL 4:3 at 16:15 = 6.67% off).
 1152        /// </summary>
 1153        /// <param name="sar">The sample aspect ratio string in "N:D" format.</param>
 1154        /// <returns><c>true</c> if the SAR is within 1% of 1:1; otherwise <c>false</c>.</returns>
 1155        internal static bool IsNearSquarePixelSar(string sar)
 1156        {
 241157            if (string.IsNullOrEmpty(sar))
 1158            {
 21159                return false;
 1160            }
 1161
 221162            var parts = sar.Split(':');
 221163            if (parts.Length == 2
 221164                && double.TryParse(parts[0], CultureInfo.InvariantCulture, out var num)
 221165                && double.TryParse(parts[1], CultureInfo.InvariantCulture, out var den)
 221166                && den > 0)
 1167            {
 221168                return IsClose(num / den, 1.0, 0.01);
 1169            }
 1170
 01171            return string.Equals(sar, "1:1", StringComparison.Ordinal);
 1172        }
 1173
 1174        /// <summary>
 1175        /// Gets a frame rate from a string value in ffprobe output
 1176        /// This could be a number or in the format of 2997/125.
 1177        /// </summary>
 1178        /// <param name="value">The value.</param>
 1179        /// <returns>System.Nullable{System.Single}.</returns>
 1180        internal static float? GetFrameRate(ReadOnlySpan<char> value)
 1181        {
 351182            if (value.IsEmpty)
 1183            {
 01184                return null;
 1185            }
 1186
 351187            int index = value.IndexOf('/');
 351188            if (index == -1)
 1189            {
 01190                return null;
 1191            }
 1192
 351193            if (!float.TryParse(value[..index], NumberStyles.Integer, CultureInfo.InvariantCulture, out var dividend)
 351194                || !float.TryParse(value[(index + 1)..], NumberStyles.Integer, CultureInfo.InvariantCulture, out var div
 1195            {
 01196                return null;
 1197            }
 1198
 351199            return divisor == 0f ? null : dividend / divisor;
 1200        }
 1201
 1202        private static void SetAudioRuntimeTicks(InternalMediaInfoResult result, MediaInfo data)
 1203        {
 1204            // Get the first info stream
 21205            var stream = result.Streams?.FirstOrDefault(s => s.CodecType == CodecType.Audio);
 21206            if (stream is null)
 1207            {
 01208                return;
 1209            }
 1210
 1211            // Get duration from stream properties
 21212            var duration = stream.Duration;
 1213
 1214            // If it's not there go into format properties
 21215            if (string.IsNullOrEmpty(duration))
 1216            {
 01217                duration = result.Format.Duration;
 1218            }
 1219
 1220            // If we got something, parse it
 21221            if (!string.IsNullOrEmpty(duration))
 1222            {
 21223                data.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(duration, CultureInfo.InvariantCulture)).Ticks;
 1224            }
 21225        }
 1226
 1227        private static int? GetBPSFromTags(MediaStreamInfo streamInfo)
 1228        {
 71229            if (streamInfo?.Tags is null)
 1230            {
 01231                return null;
 1232            }
 1233
 71234            var bps = GetDictionaryValue(streamInfo.Tags, "BPS-eng") ?? GetDictionaryValue(streamInfo.Tags, "BPS");
 71235            if (int.TryParse(bps, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBps))
 1236            {
 21237                return parsedBps;
 1238            }
 1239
 51240            return null;
 1241        }
 1242
 1243        private static double? GetRuntimeSecondsFromTags(MediaStreamInfo streamInfo)
 1244        {
 61245            if (streamInfo?.Tags is null)
 1246            {
 01247                return null;
 1248            }
 1249
 61250            var duration = GetDictionaryValue(streamInfo.Tags, "DURATION-eng") ?? GetDictionaryValue(streamInfo.Tags, "D
 61251            if (TimeSpan.TryParse(duration, out var parsedDuration))
 1252            {
 11253                return parsedDuration.TotalSeconds;
 1254            }
 1255
 51256            return null;
 1257        }
 1258
 1259        private static long? GetNumberOfBytesFromTags(MediaStreamInfo streamInfo)
 1260        {
 61261            if (streamInfo?.Tags is null)
 1262            {
 01263                return null;
 1264            }
 1265
 61266            var numberOfBytes = GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES-eng")
 61267                                ?? GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES");
 61268            if (long.TryParse(numberOfBytes, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBytes))
 1269            {
 11270                return parsedBytes;
 1271            }
 1272
 51273            return null;
 1274        }
 1275
 1276        private static void SetSize(InternalMediaInfoResult data, MediaInfo info)
 1277        {
 121278            if (data.Format is null)
 1279            {
 11280                return;
 1281            }
 1282
 111283            info.Size = string.IsNullOrEmpty(data.Format.Size) ? null : long.Parse(data.Format.Size, CultureInfo.Invaria
 111284        }
 1285
 1286        private void SetAudioInfoFromTags(MediaInfo audio, Dictionary<string, string> tags)
 1287        {
 21288            var people = new List<BaseItemPerson>();
 21289            if (tags.TryGetValue("composer", out var composer) && !string.IsNullOrWhiteSpace(composer))
 1290            {
 121291                foreach (var person in Split(composer, false))
 1292                {
 41293                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Composer });
 1294                }
 1295            }
 1296
 21297            if (tags.TryGetValue("conductor", out var conductor) && !string.IsNullOrWhiteSpace(conductor))
 1298            {
 01299                foreach (var person in Split(conductor, false))
 1300                {
 01301                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Conductor });
 1302                }
 1303            }
 1304
 21305            if (tags.TryGetValue("lyricist", out var lyricist) && !string.IsNullOrWhiteSpace(lyricist))
 1306            {
 81307                foreach (var person in Split(lyricist, false))
 1308                {
 21309                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Lyricist });
 1310                }
 1311            }
 1312
 21313            if (tags.TryGetValue("performer", out var performer) && !string.IsNullOrWhiteSpace(performer))
 1314            {
 501315                foreach (var person in Split(performer, false))
 1316                {
 231317                    Match match = PerformerRegex().Match(person);
 1318
 1319                    // If the performer doesn't have any instrument/role associated, it won't match. In that case, chanc
 231320                    if (match.Success)
 1321                    {
 221322                        people.Add(new BaseItemPerson
 221323                        {
 221324                            Name = match.Groups["name"].Value,
 221325                            Type = PersonKind.Actor,
 221326                            Role = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(match.Groups["instrument"].Value)
 221327                        });
 1328                    }
 1329                }
 1330            }
 1331
 1332            // In cases where there isn't sufficient information as to which role a writer performed on a recording, tag
 21333            if (tags.TryGetValue("writer", out var writer) && !string.IsNullOrWhiteSpace(writer))
 1334            {
 01335                foreach (var person in Split(writer, false))
 1336                {
 01337                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Writer });
 1338                }
 1339            }
 1340
 21341            if (tags.TryGetValue("arranger", out var arranger) && !string.IsNullOrWhiteSpace(arranger))
 1342            {
 121343                foreach (var person in Split(arranger, false))
 1344                {
 41345                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Arranger });
 1346                }
 1347            }
 1348
 21349            if (tags.TryGetValue("engineer", out var engineer) && !string.IsNullOrWhiteSpace(engineer))
 1350            {
 01351                foreach (var person in Split(engineer, false))
 1352                {
 01353                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Engineer });
 1354                }
 1355            }
 1356
 21357            if (tags.TryGetValue("mixer", out var mixer) && !string.IsNullOrWhiteSpace(mixer))
 1358            {
 81359                foreach (var person in Split(mixer, false))
 1360                {
 21361                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Mixer });
 1362                }
 1363            }
 1364
 21365            if (tags.TryGetValue("remixer", out var remixer) && !string.IsNullOrWhiteSpace(remixer))
 1366            {
 01367                foreach (var person in Split(remixer, false))
 1368                {
 01369                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Remixer });
 1370                }
 1371            }
 1372
 21373            audio.People = people.ToArray();
 1374
 1375            // Set album artist
 21376            var albumArtist = tags.GetFirstNotNullNorWhiteSpaceValue("albumartist", "album artist", "album_artist");
 21377            audio.AlbumArtists = albumArtist is not null
 21378                ? SplitDistinctArtists(albumArtist, _nameDelimiters, true).ToArray()
 21379                : Array.Empty<string>();
 1380
 1381            // Set album artist to artist if empty
 21382            if (audio.AlbumArtists.Length == 0)
 1383            {
 01384                audio.AlbumArtists = audio.Artists;
 1385            }
 1386
 1387            // Track number
 21388            audio.IndexNumber = GetDictionaryTrackOrDiscNumber(tags, "track");
 1389
 1390            // Disc number
 21391            audio.ParentIndexNumber = GetDictionaryTrackOrDiscNumber(tags, "disc");
 1392
 1393            // There's several values in tags may or may not be present
 21394            FetchStudios(audio, tags, "organization");
 21395            FetchStudios(audio, tags, "ensemble");
 21396            FetchStudios(audio, tags, "publisher");
 21397            FetchStudios(audio, tags, "label");
 1398
 1399            // These support multiple values, but for now we only store the first.
 21400            var mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Album Artist Id"))
 21401                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ALBUMARTISTID"));
 21402            audio.TrySetProviderId(MetadataProvider.MusicBrainzAlbumArtist, mb);
 1403
 21404            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Artist Id"))
 21405                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ARTISTID"));
 21406            audio.TrySetProviderId(MetadataProvider.MusicBrainzArtist, mb);
 1407
 21408            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Album Id"))
 21409                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ALBUMID"));
 21410            audio.TrySetProviderId(MetadataProvider.MusicBrainzAlbum, mb);
 1411
 21412            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Release Group Id"))
 21413                 ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_RELEASEGROUPID"));
 21414            audio.TrySetProviderId(MetadataProvider.MusicBrainzReleaseGroup, mb);
 1415
 21416            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Release Track Id"))
 21417                 ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_RELEASETRACKID"));
 21418            audio.TrySetProviderId(MetadataProvider.MusicBrainzTrack, mb);
 21419        }
 1420
 1421        private static string GetMultipleMusicBrainzId(string value)
 1422        {
 201423            if (string.IsNullOrWhiteSpace(value))
 1424            {
 101425                return null;
 1426            }
 1427
 101428            return value.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
 101429                .FirstOrDefault();
 1430        }
 1431
 1432        /// <summary>
 1433        /// Splits the specified val.
 1434        /// </summary>
 1435        /// <param name="val">The val.</param>
 1436        /// <param name="allowCommaDelimiter">if set to <c>true</c> [allow comma delimiter].</param>
 1437        /// <returns>System.String[][].</returns>
 1438        private string[] Split(string val, bool allowCommaDelimiter)
 1439        {
 1440            // Only use the comma as a delimiter if there are no slashes or pipes.
 1441            // We want to be careful not to split names that have commas in them
 141442            return !allowCommaDelimiter || _nameDelimiters.Any(i => val.Contains(i, StringComparison.Ordinal)) ?
 141443                val.Split(_nameDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) :
 141444                val.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
 1445        }
 1446
 1447        private IEnumerable<string> SplitDistinctArtists(string val, char[] delimiters, bool splitFeaturing)
 1448        {
 51449            if (splitFeaturing)
 1450            {
 31451                val = val.Replace(" featuring ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase)
 31452                    .Replace(" feat. ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase);
 1453            }
 1454
 51455            var artistsFound = new List<string>();
 1456
 3101457            foreach (var whitelistArtist in SplitWhitelist)
 1458            {
 1501459                var originalVal = val;
 1501460                val = val.Replace(whitelistArtist, "|", StringComparison.OrdinalIgnoreCase);
 1461
 1501462                if (!string.Equals(originalVal, val, StringComparison.OrdinalIgnoreCase))
 1463                {
 01464                    artistsFound.Add(whitelistArtist);
 1465                }
 1466            }
 1467
 51468            var artists = val.Split(delimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
 1469
 51470            artistsFound.AddRange(artists);
 51471            return artistsFound.DistinctNames();
 1472        }
 1473
 1474        /// <summary>
 1475        /// Gets the studios from the tags collection.
 1476        /// </summary>
 1477        /// <param name="info">The info.</param>
 1478        /// <param name="tags">The tags.</param>
 1479        /// <param name="tagName">Name of the tag.</param>
 1480        private void FetchStudios(MediaInfo info, IReadOnlyDictionary<string, string> tags, string tagName)
 1481        {
 181482            var val = tags.GetValueOrDefault(tagName);
 1483
 181484            if (string.IsNullOrEmpty(val))
 1485            {
 161486                return;
 1487            }
 1488
 21489            var studios = Split(val, true);
 21490            var studioList = new List<string>();
 1491
 81492            foreach (var studio in studios)
 1493            {
 21494                if (string.IsNullOrWhiteSpace(studio))
 1495                {
 1496                    continue;
 1497                }
 1498
 1499                // Don't add artist/album artist name to studios, even if it's listed there
 21500                if (info.Artists.Contains(studio, StringComparison.OrdinalIgnoreCase)
 21501                    || info.AlbumArtists.Contains(studio, StringComparison.OrdinalIgnoreCase))
 1502                {
 1503                    continue;
 1504                }
 1505
 21506                studioList.Add(studio);
 1507            }
 1508
 21509            info.Studios = studioList
 21510                .Distinct(StringComparer.OrdinalIgnoreCase)
 21511                .ToArray();
 21512        }
 1513
 1514        /// <summary>
 1515        /// Gets the genres from the tags collection.
 1516        /// </summary>
 1517        /// <param name="info">The information.</param>
 1518        /// <param name="tags">The tags.</param>
 1519        private void FetchGenres(MediaInfo info, IReadOnlyDictionary<string, string> tags)
 1520        {
 121521            var genreVal = tags.GetValueOrDefault("genre");
 121522            if (string.IsNullOrEmpty(genreVal))
 1523            {
 101524                return;
 1525            }
 1526
 21527            var genres = new List<string>(info.Genres);
 201528            foreach (var genre in Split(genreVal, true))
 1529            {
 81530                if (string.IsNullOrEmpty(genre))
 1531                {
 1532                    continue;
 1533                }
 1534
 81535                genres.Add(genre);
 1536            }
 1537
 21538            info.Genres = genres
 21539                .Distinct(StringComparer.OrdinalIgnoreCase)
 21540                .ToArray();
 21541        }
 1542
 1543        /// <summary>
 1544        /// Gets the track or disc number, which can be in the form of '1', or '1/3'.
 1545        /// </summary>
 1546        /// <param name="tags">The tags.</param>
 1547        /// <param name="tagName">Name of the tag.</param>
 1548        /// <returns>The track or disc number, or null, if missing or not parseable.</returns>
 1549        private static int? GetDictionaryTrackOrDiscNumber(IReadOnlyDictionary<string, string> tags, string tagName)
 1550        {
 41551            var disc = tags.GetValueOrDefault(tagName);
 1552
 41553            if (int.TryParse(disc.AsSpan().LeftPart('/'), out var discNum))
 1554            {
 41555                return discNum;
 1556            }
 1557
 01558            return null;
 1559        }
 1560
 1561        private static ChapterInfo GetChapterInfo(MediaChapter chapter)
 1562        {
 01563            var info = new ChapterInfo();
 1564
 01565            if (chapter.Tags is not null && chapter.Tags.TryGetValue("title", out string name))
 1566            {
 01567                info.Name = name;
 1568            }
 1569
 1570            // Limit accuracy to milliseconds to match xml saving
 01571            var secondsString = chapter.StartTime;
 1572
 01573            if (double.TryParse(secondsString, CultureInfo.InvariantCulture, out var seconds))
 1574            {
 01575                var ms = Math.Round(TimeSpan.FromSeconds(seconds).TotalMilliseconds);
 01576                info.StartPositionTicks = TimeSpan.FromMilliseconds(ms).Ticks;
 1577            }
 1578
 01579            return info;
 1580        }
 1581
 1582        private void FetchWtvInfo(MediaInfo video, InternalMediaInfoResult data)
 1583        {
 101584            var tags = data.Format?.Tags;
 1585
 101586            if (tags is null)
 1587            {
 41588                return;
 1589            }
 1590
 61591            if (tags.TryGetValue("WM/Genre", out var genres) && !string.IsNullOrWhiteSpace(genres))
 1592            {
 01593                var genreList = genres.Split(_genreDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOption
 1594
 1595                // If this is empty then don't overwrite genres that might have been fetched earlier
 01596                if (genreList.Length > 0)
 1597                {
 01598                    video.Genres = genreList;
 1599                }
 1600            }
 1601
 61602            if (tags.TryGetValue("WM/ParentalRating", out var officialRating) && !string.IsNullOrWhiteSpace(officialRati
 1603            {
 01604                video.OfficialRating = officialRating;
 1605            }
 1606
 61607            if (tags.TryGetValue("WM/MediaCredits", out var people) && !string.IsNullOrEmpty(people))
 1608            {
 01609                video.People = Array.ConvertAll(
 01610                    people.Split(_basicDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntrie
 01611                    i => new BaseItemPerson { Name = i, Type = PersonKind.Actor });
 1612            }
 1613
 61614            if (tags.TryGetValue("WM/OriginalReleaseTime", out var year) && int.TryParse(year, NumberStyles.Integer, Cul
 1615            {
 01616                video.ProductionYear = parsedYear;
 1617            }
 1618
 1619            // Credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
 1620            // DateTime is reported along with timezone info (typically Z i.e. UTC hence assume None)
 61621            if (tags.TryGetValue("WM/MediaOriginalBroadcastDateTime", out var premiereDateString) && DateTime.TryParse(y
 1622            {
 01623                video.PremiereDate = parsedDate;
 1624            }
 1625
 61626            var description = tags.GetValueOrDefault("WM/SubTitleDescription");
 1627
 61628            var subTitle = tags.GetValueOrDefault("WM/SubTitle");
 1629
 1630            // For below code, credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
 1631
 1632            // Sometimes for TV Shows the Subtitle field is empty and the subtitle description contains the subtitle, ex
 1633            // The format is -> EPISODE/TOTAL_EPISODES_IN_SEASON. SUBTITLE: DESCRIPTION
 1634            // OR -> COMMENT. SUBTITLE: DESCRIPTION
 1635            // e.g. -> 4/13. The Doctor's Wife: Science fiction drama. When he follows a Time Lord distress signal, the 
 1636            // e.g. -> CBeebies Bedtime Hour. The Mystery: Animated adventures of two friends who live on an island in t
 61637            if (string.IsNullOrWhiteSpace(subTitle)
 61638                && !string.IsNullOrWhiteSpace(description)
 61639                && description.AsSpan()[..Math.Min(description.Length, MaxSubtitleDescriptionExtractionLength)].Contains
 1640            {
 01641                string[] descriptionParts = description.Split(':');
 01642                if (descriptionParts.Length > 0)
 1643                {
 01644                    string subtitle = descriptionParts[0];
 1645                    try
 1646                    {
 1647                        // Check if it contains a episode number and season number
 01648                        if (subtitle.Contains('/', StringComparison.Ordinal))
 1649                        {
 01650                            string[] subtitleParts = subtitle.Split(' ');
 01651                            string[] numbers = subtitleParts[0].Replace(".", string.Empty, StringComparison.Ordinal).Spl
 01652                            video.IndexNumber = int.Parse(numbers[0], CultureInfo.InvariantCulture);
 1653                            // int totalEpisodesInSeason = int.Parse(numbers[1], CultureInfo.InvariantCulture);
 1654
 1655                            // Skip the numbers, concatenate the rest, trim and set as new description
 01656                            description = string.Join(' ', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1657                        }
 01658                        else if (subtitle.Contains('.', StringComparison.Ordinal))
 1659                        {
 01660                            var subtitleParts = subtitle.Split('.');
 01661                            description = string.Join('.', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1662                        }
 1663                        else
 1664                        {
 01665                            description = subtitle.Trim();
 1666                        }
 01667                    }
 01668                    catch (Exception ex)
 1669                    {
 01670                        _logger.LogError(ex, "Error while parsing subtitle field");
 1671
 1672                        // Fallback to default parsing
 01673                        if (subtitle.Contains('.', StringComparison.Ordinal))
 1674                        {
 01675                            var subtitleParts = subtitle.Split('.');
 01676                            description = string.Join('.', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1677                        }
 1678                        else
 1679                        {
 01680                            description = subtitle.Trim();
 1681                        }
 01682                    }
 1683                }
 1684            }
 1685
 61686            if (!string.IsNullOrWhiteSpace(description))
 1687            {
 01688                video.Overview = description;
 1689            }
 61690        }
 1691
 1692        private void ExtractTimestamp(MediaInfo video)
 1693        {
 101694            if (video.VideoType != VideoType.VideoFile)
 1695            {
 01696                return;
 1697            }
 1698
 101699            if (!string.Equals(video.Container, "mpeg2ts", StringComparison.OrdinalIgnoreCase)
 101700                && !string.Equals(video.Container, "m2ts", StringComparison.OrdinalIgnoreCase)
 101701                && !string.Equals(video.Container, "ts", StringComparison.OrdinalIgnoreCase))
 1702            {
 91703                return;
 1704            }
 1705
 1706            try
 1707            {
 11708                video.Timestamp = GetMpegTimestamp(video.Path);
 01709                _logger.LogDebug("Video has {Timestamp} timestamp", video.Timestamp);
 01710            }
 11711            catch (Exception ex)
 1712            {
 11713                video.Timestamp = null;
 11714                _logger.LogError(ex, "Error extracting timestamp info from {Path}", video.Path);
 11715            }
 11716        }
 1717
 1718        // REVIEW: find out why the byte array needs to be 197 bytes long and comment the reason
 1719        private static TransportStreamTimestamp GetMpegTimestamp(string path)
 1720        {
 11721            var packetBuffer = new byte[197];
 1722
 11723            using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 1))
 1724            {
 01725                fs.ReadExactly(packetBuffer);
 01726            }
 1727
 01728            if (packetBuffer[0] == 71)
 1729            {
 01730                return TransportStreamTimestamp.None;
 1731            }
 1732
 01733            if ((packetBuffer[4] != 71) || (packetBuffer[196] != 71))
 1734            {
 01735                return TransportStreamTimestamp.None;
 1736            }
 1737
 01738            if ((packetBuffer[0] == 0) && (packetBuffer[1] == 0) && (packetBuffer[2] == 0) && (packetBuffer[3] == 0))
 1739            {
 01740                return TransportStreamTimestamp.Zero;
 1741            }
 1742
 01743            return TransportStreamTimestamp.Valid;
 1744        }
 1745
 1746        [GeneratedRegex("(?<name>.*) \\((?<instrument>.*)\\)")]
 1747        private static partial Regex PerformerRegex();
 1748    }
 1749}

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)