< 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: 607
Uncovered lines: 157
Coverable lines: 764
Total lines: 1755
Line coverage: 79.4%
Branch coverage
74%
Covered branches: 478
Total branches: 640
Branch coverage: 74.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 1/23/2026 - 12:11:06 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: 17494/12/2026 - 12:13:54 AM Line coverage: 79.4% (607/764) Branch coverage: 74.6% (478/640) Total lines: 1755 1/23/2026 - 12:11:06 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: 17494/12/2026 - 12:13:54 AM Line coverage: 79.4% (607/764) Branch coverage: 74.6% (478/640) Total lines: 1755

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.16%33416281.28%
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
 12197            if (data.Chapters is not null)
 198            {
 3199                info.Chapters = data.Chapters.Select(GetChapterInfo).ToArray();
 200            }
 201
 202            // Set mediaType-specific metadata
 12203            if (isAudio)
 204            {
 2205                SetAudioRuntimeTicks(data, info);
 206
 207                // tags are normally located under data.format, but we've seen some cases with ogg where they're part of
 208                // so let's create a combined list of both
 209
 2210                SetAudioInfoFromTags(info, tags);
 211            }
 212            else
 213            {
 10214                FetchStudios(info, tags, "copyright");
 215
 10216                var iTunExtc = tags.GetFirstNotNullNorWhiteSpaceValue("iTunEXTC");
 10217                if (iTunExtc is not null)
 218                {
 0219                    var parts = iTunExtc.Split('|', StringSplitOptions.RemoveEmptyEntries);
 220                    // Example
 221                    // mpaa|G|100|For crude humor
 0222                    if (parts.Length > 1)
 223                    {
 0224                        info.OfficialRating = parts[1];
 225
 0226                        if (parts.Length > 3)
 227                        {
 0228                            info.OfficialRatingDescription = parts[3];
 229                        }
 230                    }
 231                }
 232
 10233                var iTunXml = tags.GetFirstNotNullNorWhiteSpaceValue("iTunMOVI");
 10234                if (iTunXml is not null)
 235                {
 1236                    FetchFromItunesInfo(iTunXml, info);
 237                }
 238
 10239                if (data.Format is not null && !string.IsNullOrEmpty(data.Format.Duration))
 240                {
 9241                    info.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.Format.Duration, CultureInfo.InvariantCul
 242                }
 243
 10244                FetchWtvInfo(info, data);
 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");
 12732                stream.LocalizedLanguage = string.IsNullOrEmpty(stream.Language)
 12733                    ? null
 12734                    : _localization.FindLanguageInfo(stream.Language)?.DisplayName;
 735
 12736                stream.Channels = streamInfo.Channels;
 737
 12738                if (int.TryParse(streamInfo.SampleRate, CultureInfo.InvariantCulture, out var sampleRate))
 739                {
 12740                    stream.SampleRate = sampleRate;
 741                }
 742
 12743                stream.ChannelLayout = ParseChannelLayout(streamInfo.ChannelLayout);
 744
 12745                if (streamInfo.BitsPerSample > 0)
 746                {
 0747                    stream.BitDepth = streamInfo.BitsPerSample;
 748                }
 12749                else if (streamInfo.BitsPerRawSample > 0)
 750                {
 3751                    stream.BitDepth = streamInfo.BitsPerRawSample;
 752                }
 753
 12754                if (string.IsNullOrEmpty(stream.Title))
 755                {
 756                    // mp4 missing track title workaround: fall back to handler_name if populated and not the default "S
 12757                    string handlerName = GetDictionaryValue(streamInfo.Tags, "handler_name");
 12758                    if (!string.IsNullOrEmpty(handlerName) && !string.Equals(handlerName, "SoundHandler", StringComparis
 759                    {
 3760                        stream.Title = handlerName;
 761                    }
 762                }
 763            }
 17764            else if (streamInfo.CodecType == CodecType.Subtitle)
 765            {
 4766                stream.Type = MediaStreamType.Subtitle;
 4767                stream.Codec = NormalizeSubtitleCodec(stream.Codec);
 4768                stream.LocalizedUndefined = _localization.GetLocalizedString("Undefined");
 4769                stream.LocalizedDefault = _localization.GetLocalizedString("Default");
 4770                stream.LocalizedForced = _localization.GetLocalizedString("Forced");
 4771                stream.LocalizedExternal = _localization.GetLocalizedString("External");
 4772                stream.LocalizedHearingImpaired = _localization.GetLocalizedString("HearingImpaired");
 4773                stream.LocalizedLanguage = string.IsNullOrEmpty(stream.Language)
 4774                    ? null
 4775                    : _localization.FindLanguageInfo(stream.Language)?.DisplayName;
 776
 4777                if (string.IsNullOrEmpty(stream.Title))
 778                {
 779                    // mp4 missing track title workaround: fall back to handler_name if populated and not the default "S
 4780                    string handlerName = GetDictionaryValue(streamInfo.Tags, "handler_name");
 4781                    if (!string.IsNullOrEmpty(handlerName) && !string.Equals(handlerName, "SubtitleHandler", StringCompa
 782                    {
 1783                        stream.Title = handlerName;
 784                    }
 785                }
 786            }
 13787            else if (streamInfo.CodecType == CodecType.Video)
 788            {
 13789                stream.IsAVC = streamInfo.IsAvc;
 13790                stream.AverageFrameRate = GetFrameRate(streamInfo.AverageFrameRate);
 13791                stream.RealFrameRate = GetFrameRate(streamInfo.RFrameRate);
 792
 13793                stream.IsInterlaced = !string.IsNullOrWhiteSpace(streamInfo.FieldOrder)
 13794                    && !string.Equals(streamInfo.FieldOrder, "progressive", StringComparison.OrdinalIgnoreCase);
 795
 13796                if (isAudio
 13797                    || string.Equals(stream.Codec, "bmp", StringComparison.OrdinalIgnoreCase)
 13798                    || string.Equals(stream.Codec, "gif", StringComparison.OrdinalIgnoreCase)
 13799                    || string.Equals(stream.Codec, "png", StringComparison.OrdinalIgnoreCase)
 13800                    || string.Equals(stream.Codec, "webp", StringComparison.OrdinalIgnoreCase))
 801                {
 2802                    stream.Type = MediaStreamType.EmbeddedImage;
 803                }
 11804                else if (string.Equals(stream.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase))
 805                {
 806                    // How to differentiate between video and embedded image?
 807                    // The only difference I've seen thus far is presence of codec tag, also embedded images have high (
 1808                    if (!string.IsNullOrWhiteSpace(stream.CodecTag))
 809                    {
 0810                        stream.Type = MediaStreamType.Video;
 811                    }
 812                    else
 813                    {
 1814                        stream.Type = MediaStreamType.EmbeddedImage;
 815                    }
 816                }
 817                else
 818                {
 10819                    stream.Type = MediaStreamType.Video;
 820                }
 821
 13822                stream.AspectRatio = GetAspectRatio(streamInfo);
 823
 13824                if (streamInfo.BitsPerSample > 0)
 825                {
 0826                    stream.BitDepth = streamInfo.BitsPerSample;
 827                }
 13828                else if (streamInfo.BitsPerRawSample > 0)
 829                {
 11830                    stream.BitDepth = streamInfo.BitsPerRawSample;
 831                }
 832
 13833                if (!stream.BitDepth.HasValue)
 834                {
 2835                    if (!string.IsNullOrEmpty(streamInfo.PixelFormat))
 836                    {
 2837                        if (string.Equals(streamInfo.PixelFormat, "yuv420p", StringComparison.OrdinalIgnoreCase)
 2838                            || string.Equals(streamInfo.PixelFormat, "yuv444p", StringComparison.OrdinalIgnoreCase))
 839                        {
 2840                            stream.BitDepth = 8;
 841                        }
 0842                        else if (string.Equals(streamInfo.PixelFormat, "yuv420p10le", StringComparison.OrdinalIgnoreCase
 0843                                 || string.Equals(streamInfo.PixelFormat, "yuv444p10le", StringComparison.OrdinalIgnoreC
 844                        {
 0845                            stream.BitDepth = 10;
 846                        }
 0847                        else if (string.Equals(streamInfo.PixelFormat, "yuv420p12le", StringComparison.OrdinalIgnoreCase
 0848                                 || string.Equals(streamInfo.PixelFormat, "yuv444p12le", StringComparison.OrdinalIgnoreC
 849                        {
 0850                            stream.BitDepth = 12;
 851                        }
 852                    }
 853                }
 854
 855                // http://stackoverflow.com/questions/17353387/how-to-detect-anamorphic-video-with-ffprobe
 13856                if (string.IsNullOrEmpty(streamInfo.SampleAspectRatio)
 13857                    && string.IsNullOrEmpty(streamInfo.DisplayAspectRatio))
 858                {
 2859                    stream.IsAnamorphic = false;
 860                }
 11861                else if (IsNearSquarePixelSar(streamInfo.SampleAspectRatio))
 862                {
 9863                    stream.IsAnamorphic = false;
 864                }
 2865                else if (!string.Equals(streamInfo.SampleAspectRatio, "0:1", StringComparison.Ordinal))
 866                {
 1867                    stream.IsAnamorphic = true;
 868                }
 1869                else if (string.Equals(streamInfo.DisplayAspectRatio, "0:1", StringComparison.Ordinal))
 870                {
 1871                    stream.IsAnamorphic = false;
 872                }
 0873                else if (!string.Equals(
 0874                             streamInfo.DisplayAspectRatio,
 0875                             // Force GetAspectRatio() to derive ratio from Width/Height directly by using null DAR
 0876                             GetAspectRatio(new MediaStreamInfo
 0877                             {
 0878                                 Width = streamInfo.Width,
 0879                                 Height = streamInfo.Height,
 0880                                 DisplayAspectRatio = null
 0881                             }),
 0882                             StringComparison.Ordinal))
 883                {
 0884                    stream.IsAnamorphic = true;
 885                }
 886                else
 887                {
 0888                    stream.IsAnamorphic = false;
 889                }
 890
 13891                if (streamInfo.Refs > 0)
 892                {
 13893                    stream.RefFrames = streamInfo.Refs;
 894                }
 895
 13896                if (!string.IsNullOrEmpty(streamInfo.ColorRange))
 897                {
 5898                    stream.ColorRange = streamInfo.ColorRange;
 899                }
 900
 13901                if (!string.IsNullOrEmpty(streamInfo.ColorSpace))
 902                {
 5903                    stream.ColorSpace = streamInfo.ColorSpace;
 904                }
 905
 13906                if (!string.IsNullOrEmpty(streamInfo.ColorTransfer))
 907                {
 2908                    stream.ColorTransfer = streamInfo.ColorTransfer;
 909                }
 910
 13911                if (!string.IsNullOrEmpty(streamInfo.ColorPrimaries))
 912                {
 2913                    stream.ColorPrimaries = streamInfo.ColorPrimaries;
 914                }
 915
 13916                if (streamInfo.SideDataList is not null)
 917                {
 6918                    foreach (var data in streamInfo.SideDataList)
 919                    {
 920                        // Parse Dolby Vision metadata from side_data
 2921                        if (string.Equals(data.SideDataType, "DOVI configuration record", StringComparison.OrdinalIgnore
 922                        {
 1923                            stream.DvVersionMajor = data.DvVersionMajor;
 1924                            stream.DvVersionMinor = data.DvVersionMinor;
 1925                            stream.DvProfile = data.DvProfile;
 1926                            stream.DvLevel = data.DvLevel;
 1927                            stream.RpuPresentFlag = data.RpuPresentFlag;
 1928                            stream.ElPresentFlag = data.ElPresentFlag;
 1929                            stream.BlPresentFlag = data.BlPresentFlag;
 1930                            stream.DvBlSignalCompatibilityId = data.DvBlSignalCompatibilityId;
 931                        }
 932
 933                        // Parse video rotation metadata from side_data
 1934                        else if (string.Equals(data.SideDataType, "Display Matrix", StringComparison.OrdinalIgnoreCase))
 935                        {
 1936                            stream.Rotation = data.Rotation;
 937                        }
 938
 939                        // Parse video frame cropping metadata from side_data
 940                        // TODO: save them and make HW filters to apply them in HWA pipelines
 0941                        else if (string.Equals(data.SideDataType, "Frame Cropping", StringComparison.OrdinalIgnoreCase))
 942                        {
 943                            // Streams containing artificially added frame cropping
 944                            // metadata should not be marked as anamorphic.
 0945                            stream.IsAnamorphic = false;
 946                        }
 947                    }
 948                }
 949
 13950                var frameInfo = frameInfoList?.FirstOrDefault(i => i.StreamIndex == stream.Index);
 13951                if (frameInfo?.SideDataList is not null
 13952                    && frameInfo.SideDataList.Any(data => string.Equals(data.SideDataType, "HDR Dynamic Metadata SMPTE20
 953                {
 0954                    stream.Hdr10PlusPresentFlag = true;
 955                }
 956            }
 0957            else if (streamInfo.CodecType == CodecType.Data)
 958            {
 0959                stream.Type = MediaStreamType.Data;
 960            }
 961            else
 962            {
 0963                return null;
 964            }
 965
 966            // Get stream bitrate
 29967            var bitrate = 0;
 968
 29969            if (int.TryParse(streamInfo.BitRate, CultureInfo.InvariantCulture, out var value))
 970            {
 13971                bitrate = value;
 972            }
 973
 974            // The bitrate info of FLAC musics and some videos is included in formatInfo.
 29975            if (bitrate == 0
 29976                && formatInfo is not null
 29977                && (stream.Type == MediaStreamType.Video || (isAudio && stream.Type == MediaStreamType.Audio)))
 978            {
 979                // If the stream info doesn't have a bitrate get the value from the media format info
 8980                if (int.TryParse(formatInfo.BitRate, CultureInfo.InvariantCulture, out value))
 981                {
 8982                    bitrate = value;
 983                }
 984            }
 985
 29986            if (bitrate > 0)
 987            {
 21988                stream.BitRate = bitrate;
 989            }
 990
 991            // Extract bitrate info from tag "BPS" if possible.
 29992            if (!stream.BitRate.HasValue
 29993                && (streamInfo.CodecType == CodecType.Audio
 29994                    || streamInfo.CodecType == CodecType.Video))
 995            {
 7996                var bps = GetBPSFromTags(streamInfo);
 7997                if (bps > 0)
 998                {
 1999                    stream.BitRate = bps;
 1000                }
 1001                else
 1002                {
 1003                    // Get average bitrate info from tag "NUMBER_OF_BYTES" and "DURATION" if possible.
 61004                    var durationInSeconds = GetRuntimeSecondsFromTags(streamInfo);
 61005                    var bytes = GetNumberOfBytesFromTags(streamInfo);
 61006                    if (durationInSeconds is not null && durationInSeconds.Value >= 1 && bytes is not null)
 1007                    {
 01008                        bps = Convert.ToInt32(bytes * 8 / durationInSeconds, CultureInfo.InvariantCulture);
 01009                        if (bps > 0)
 1010                        {
 01011                            stream.BitRate = bps;
 1012                        }
 1013                    }
 1014                }
 1015            }
 1016
 291017            var disposition = streamInfo.Disposition;
 291018            if (disposition is not null)
 1019            {
 291020                if (disposition.GetValueOrDefault("default") == 1)
 1021                {
 171022                    stream.IsDefault = true;
 1023                }
 1024
 291025                if (disposition.GetValueOrDefault("forced") == 1)
 1026                {
 01027                    stream.IsForced = true;
 1028                }
 1029
 291030                if (disposition.GetValueOrDefault("hearing_impaired") == 1)
 1031                {
 11032                    stream.IsHearingImpaired = true;
 1033                }
 1034            }
 1035
 291036            NormalizeStreamTitle(stream);
 1037
 291038            return stream;
 1039        }
 1040
 1041        private static void NormalizeStreamTitle(MediaStream stream)
 1042        {
 291043            if (string.Equals(stream.Title, "cc", StringComparison.OrdinalIgnoreCase)
 291044                || stream.Type == MediaStreamType.EmbeddedImage)
 1045            {
 31046                stream.Title = null;
 1047            }
 291048        }
 1049
 1050        /// <summary>
 1051        /// Gets a string from an FFProbeResult tags dictionary.
 1052        /// </summary>
 1053        /// <param name="tags">The tags.</param>
 1054        /// <param name="key">The key.</param>
 1055        /// <returns>System.String.</returns>
 1056        private static string GetDictionaryValue(IReadOnlyDictionary<string, string> tags, string key)
 1057        {
 1351058            if (tags is null)
 1059            {
 31060                return null;
 1061            }
 1062
 1321063            tags.TryGetValue(key, out var val);
 1064
 1321065            return val;
 1066        }
 1067
 1068        private static string ParseChannelLayout(string input)
 1069        {
 121070            if (string.IsNullOrEmpty(input))
 1071            {
 11072                return null;
 1073            }
 1074
 111075            return input.AsSpan().LeftPart('(').ToString();
 1076        }
 1077
 1078        private static string GetAspectRatio(MediaStreamInfo info)
 1079        {
 131080            var original = info.DisplayAspectRatio;
 1081
 131082            var parts = (original ?? string.Empty).Split(':');
 131083            if (!(parts.Length == 2
 131084                    && int.TryParse(parts[0], CultureInfo.InvariantCulture, out var width)
 131085                    && int.TryParse(parts[1], CultureInfo.InvariantCulture, out var height)
 131086                    && width > 0
 131087                    && height > 0))
 1088            {
 31089                width = info.Width.Value;
 31090                height = info.Height.Value;
 1091            }
 1092
 131093            if (width > 0 && height > 0)
 1094            {
 131095                double ratio = width;
 131096                ratio /= height;
 1097
 131098                if (IsClose(ratio, 1.777777778, .03))
 1099                {
 71100                    return "16:9";
 1101                }
 1102
 61103                if (IsClose(ratio, 1.3333333333, .05))
 1104                {
 11105                    return "4:3";
 1106                }
 1107
 51108                if (IsClose(ratio, 1.41))
 1109                {
 01110                    return "1.41:1";
 1111                }
 1112
 51113                if (IsClose(ratio, 1.5))
 1114                {
 21115                    return "1.5:1";
 1116                }
 1117
 31118                if (IsClose(ratio, 1.6))
 1119                {
 01120                    return "1.6:1";
 1121                }
 1122
 31123                if (IsClose(ratio, 1.66666666667))
 1124                {
 01125                    return "5:3";
 1126                }
 1127
 31128                if (IsClose(ratio, 1.85, .02))
 1129                {
 01130                    return "1.85:1";
 1131                }
 1132
 31133                if (IsClose(ratio, 2.35, .025))
 1134                {
 01135                    return "2.35:1";
 1136                }
 1137
 31138                if (IsClose(ratio, 2.4, .025))
 1139                {
 11140                    return "2.40:1";
 1141                }
 1142            }
 1143
 21144            return original;
 1145        }
 1146
 1147        private static bool IsClose(double d1, double d2, double variance = .005)
 1148        {
 661149            return Math.Abs(d1 - d2) <= variance;
 1150        }
 1151
 1152        /// <summary>
 1153        /// Determines whether a sample aspect ratio represents square (or near-square) pixels.
 1154        /// Some encoders produce SARs like 3201:3200 for content that is effectively 1:1,
 1155        /// which would be falsely classified as anamorphic by an exact string comparison.
 1156        /// A 1% tolerance safely covers encoder rounding artifacts while preserving detection
 1157        /// of genuine anamorphic content (closest standard is PAL 4:3 at 16:15 = 6.67% off).
 1158        /// </summary>
 1159        /// <param name="sar">The sample aspect ratio string in "N:D" format.</param>
 1160        /// <returns><c>true</c> if the SAR is within 1% of 1:1; otherwise <c>false</c>.</returns>
 1161        internal static bool IsNearSquarePixelSar(string sar)
 1162        {
 241163            if (string.IsNullOrEmpty(sar))
 1164            {
 21165                return false;
 1166            }
 1167
 221168            var parts = sar.Split(':');
 221169            if (parts.Length == 2
 221170                && double.TryParse(parts[0], CultureInfo.InvariantCulture, out var num)
 221171                && double.TryParse(parts[1], CultureInfo.InvariantCulture, out var den)
 221172                && den > 0)
 1173            {
 221174                return IsClose(num / den, 1.0, 0.01);
 1175            }
 1176
 01177            return string.Equals(sar, "1:1", StringComparison.Ordinal);
 1178        }
 1179
 1180        /// <summary>
 1181        /// Gets a frame rate from a string value in ffprobe output
 1182        /// This could be a number or in the format of 2997/125.
 1183        /// </summary>
 1184        /// <param name="value">The value.</param>
 1185        /// <returns>System.Nullable{System.Single}.</returns>
 1186        internal static float? GetFrameRate(ReadOnlySpan<char> value)
 1187        {
 351188            if (value.IsEmpty)
 1189            {
 01190                return null;
 1191            }
 1192
 351193            int index = value.IndexOf('/');
 351194            if (index == -1)
 1195            {
 01196                return null;
 1197            }
 1198
 351199            if (!float.TryParse(value[..index], NumberStyles.Integer, CultureInfo.InvariantCulture, out var dividend)
 351200                || !float.TryParse(value[(index + 1)..], NumberStyles.Integer, CultureInfo.InvariantCulture, out var div
 1201            {
 01202                return null;
 1203            }
 1204
 351205            return divisor == 0f ? null : dividend / divisor;
 1206        }
 1207
 1208        private static void SetAudioRuntimeTicks(InternalMediaInfoResult result, MediaInfo data)
 1209        {
 1210            // Get the first info stream
 21211            var stream = result.Streams?.FirstOrDefault(s => s.CodecType == CodecType.Audio);
 21212            if (stream is null)
 1213            {
 01214                return;
 1215            }
 1216
 1217            // Get duration from stream properties
 21218            var duration = stream.Duration;
 1219
 1220            // If it's not there go into format properties
 21221            if (string.IsNullOrEmpty(duration))
 1222            {
 01223                duration = result.Format.Duration;
 1224            }
 1225
 1226            // If we got something, parse it
 21227            if (!string.IsNullOrEmpty(duration))
 1228            {
 21229                data.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(duration, CultureInfo.InvariantCulture)).Ticks;
 1230            }
 21231        }
 1232
 1233        private static int? GetBPSFromTags(MediaStreamInfo streamInfo)
 1234        {
 71235            if (streamInfo?.Tags is null)
 1236            {
 01237                return null;
 1238            }
 1239
 71240            var bps = GetDictionaryValue(streamInfo.Tags, "BPS-eng") ?? GetDictionaryValue(streamInfo.Tags, "BPS");
 71241            if (int.TryParse(bps, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBps))
 1242            {
 21243                return parsedBps;
 1244            }
 1245
 51246            return null;
 1247        }
 1248
 1249        private static double? GetRuntimeSecondsFromTags(MediaStreamInfo streamInfo)
 1250        {
 61251            if (streamInfo?.Tags is null)
 1252            {
 01253                return null;
 1254            }
 1255
 61256            var duration = GetDictionaryValue(streamInfo.Tags, "DURATION-eng") ?? GetDictionaryValue(streamInfo.Tags, "D
 61257            if (TimeSpan.TryParse(duration, out var parsedDuration))
 1258            {
 11259                return parsedDuration.TotalSeconds;
 1260            }
 1261
 51262            return null;
 1263        }
 1264
 1265        private static long? GetNumberOfBytesFromTags(MediaStreamInfo streamInfo)
 1266        {
 61267            if (streamInfo?.Tags is null)
 1268            {
 01269                return null;
 1270            }
 1271
 61272            var numberOfBytes = GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES-eng")
 61273                                ?? GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES");
 61274            if (long.TryParse(numberOfBytes, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBytes))
 1275            {
 11276                return parsedBytes;
 1277            }
 1278
 51279            return null;
 1280        }
 1281
 1282        private static void SetSize(InternalMediaInfoResult data, MediaInfo info)
 1283        {
 121284            if (data.Format is null)
 1285            {
 11286                return;
 1287            }
 1288
 111289            info.Size = string.IsNullOrEmpty(data.Format.Size) ? null : long.Parse(data.Format.Size, CultureInfo.Invaria
 111290        }
 1291
 1292        private void SetAudioInfoFromTags(MediaInfo audio, Dictionary<string, string> tags)
 1293        {
 21294            var people = new List<BaseItemPerson>();
 21295            if (tags.TryGetValue("composer", out var composer) && !string.IsNullOrWhiteSpace(composer))
 1296            {
 121297                foreach (var person in Split(composer, false))
 1298                {
 41299                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Composer });
 1300                }
 1301            }
 1302
 21303            if (tags.TryGetValue("conductor", out var conductor) && !string.IsNullOrWhiteSpace(conductor))
 1304            {
 01305                foreach (var person in Split(conductor, false))
 1306                {
 01307                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Conductor });
 1308                }
 1309            }
 1310
 21311            if (tags.TryGetValue("lyricist", out var lyricist) && !string.IsNullOrWhiteSpace(lyricist))
 1312            {
 81313                foreach (var person in Split(lyricist, false))
 1314                {
 21315                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Lyricist });
 1316                }
 1317            }
 1318
 21319            if (tags.TryGetValue("performer", out var performer) && !string.IsNullOrWhiteSpace(performer))
 1320            {
 501321                foreach (var person in Split(performer, false))
 1322                {
 231323                    Match match = PerformerRegex().Match(person);
 1324
 1325                    // If the performer doesn't have any instrument/role associated, it won't match. In that case, chanc
 231326                    if (match.Success)
 1327                    {
 221328                        people.Add(new BaseItemPerson
 221329                        {
 221330                            Name = match.Groups["name"].Value,
 221331                            Type = PersonKind.Actor,
 221332                            Role = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(match.Groups["instrument"].Value)
 221333                        });
 1334                    }
 1335                }
 1336            }
 1337
 1338            // In cases where there isn't sufficient information as to which role a writer performed on a recording, tag
 21339            if (tags.TryGetValue("writer", out var writer) && !string.IsNullOrWhiteSpace(writer))
 1340            {
 01341                foreach (var person in Split(writer, false))
 1342                {
 01343                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Writer });
 1344                }
 1345            }
 1346
 21347            if (tags.TryGetValue("arranger", out var arranger) && !string.IsNullOrWhiteSpace(arranger))
 1348            {
 121349                foreach (var person in Split(arranger, false))
 1350                {
 41351                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Arranger });
 1352                }
 1353            }
 1354
 21355            if (tags.TryGetValue("engineer", out var engineer) && !string.IsNullOrWhiteSpace(engineer))
 1356            {
 01357                foreach (var person in Split(engineer, false))
 1358                {
 01359                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Engineer });
 1360                }
 1361            }
 1362
 21363            if (tags.TryGetValue("mixer", out var mixer) && !string.IsNullOrWhiteSpace(mixer))
 1364            {
 81365                foreach (var person in Split(mixer, false))
 1366                {
 21367                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Mixer });
 1368                }
 1369            }
 1370
 21371            if (tags.TryGetValue("remixer", out var remixer) && !string.IsNullOrWhiteSpace(remixer))
 1372            {
 01373                foreach (var person in Split(remixer, false))
 1374                {
 01375                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Remixer });
 1376                }
 1377            }
 1378
 21379            audio.People = people.ToArray();
 1380
 1381            // Set album artist
 21382            var albumArtist = tags.GetFirstNotNullNorWhiteSpaceValue("albumartist", "album artist", "album_artist");
 21383            audio.AlbumArtists = albumArtist is not null
 21384                ? SplitDistinctArtists(albumArtist, _nameDelimiters, true).ToArray()
 21385                : Array.Empty<string>();
 1386
 1387            // Set album artist to artist if empty
 21388            if (audio.AlbumArtists.Length == 0)
 1389            {
 01390                audio.AlbumArtists = audio.Artists;
 1391            }
 1392
 1393            // Track number
 21394            audio.IndexNumber = GetDictionaryTrackOrDiscNumber(tags, "track");
 1395
 1396            // Disc number
 21397            audio.ParentIndexNumber = GetDictionaryTrackOrDiscNumber(tags, "disc");
 1398
 1399            // There's several values in tags may or may not be present
 21400            FetchStudios(audio, tags, "organization");
 21401            FetchStudios(audio, tags, "ensemble");
 21402            FetchStudios(audio, tags, "publisher");
 21403            FetchStudios(audio, tags, "label");
 1404
 1405            // These support multiple values, but for now we only store the first.
 21406            var mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Album Artist Id"))
 21407                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ALBUMARTISTID"));
 21408            audio.TrySetProviderId(MetadataProvider.MusicBrainzAlbumArtist, mb);
 1409
 21410            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Artist Id"))
 21411                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ARTISTID"));
 21412            audio.TrySetProviderId(MetadataProvider.MusicBrainzArtist, mb);
 1413
 21414            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Album Id"))
 21415                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ALBUMID"));
 21416            audio.TrySetProviderId(MetadataProvider.MusicBrainzAlbum, mb);
 1417
 21418            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Release Group Id"))
 21419                 ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_RELEASEGROUPID"));
 21420            audio.TrySetProviderId(MetadataProvider.MusicBrainzReleaseGroup, mb);
 1421
 21422            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Release Track Id"))
 21423                 ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_RELEASETRACKID"));
 21424            audio.TrySetProviderId(MetadataProvider.MusicBrainzTrack, mb);
 21425        }
 1426
 1427        private static string GetMultipleMusicBrainzId(string value)
 1428        {
 201429            if (string.IsNullOrWhiteSpace(value))
 1430            {
 101431                return null;
 1432            }
 1433
 101434            return value.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
 101435                .FirstOrDefault();
 1436        }
 1437
 1438        /// <summary>
 1439        /// Splits the specified val.
 1440        /// </summary>
 1441        /// <param name="val">The val.</param>
 1442        /// <param name="allowCommaDelimiter">if set to <c>true</c> [allow comma delimiter].</param>
 1443        /// <returns>System.String[][].</returns>
 1444        private string[] Split(string val, bool allowCommaDelimiter)
 1445        {
 1446            // Only use the comma as a delimiter if there are no slashes or pipes.
 1447            // We want to be careful not to split names that have commas in them
 141448            return !allowCommaDelimiter || _nameDelimiters.Any(i => val.Contains(i, StringComparison.Ordinal)) ?
 141449                val.Split(_nameDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) :
 141450                val.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
 1451        }
 1452
 1453        private IEnumerable<string> SplitDistinctArtists(string val, char[] delimiters, bool splitFeaturing)
 1454        {
 51455            if (splitFeaturing)
 1456            {
 31457                val = val.Replace(" featuring ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase)
 31458                    .Replace(" feat. ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase);
 1459            }
 1460
 51461            var artistsFound = new List<string>();
 1462
 3101463            foreach (var whitelistArtist in SplitWhitelist)
 1464            {
 1501465                var originalVal = val;
 1501466                val = val.Replace(whitelistArtist, "|", StringComparison.OrdinalIgnoreCase);
 1467
 1501468                if (!string.Equals(originalVal, val, StringComparison.OrdinalIgnoreCase))
 1469                {
 01470                    artistsFound.Add(whitelistArtist);
 1471                }
 1472            }
 1473
 51474            var artists = val.Split(delimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
 1475
 51476            artistsFound.AddRange(artists);
 51477            return artistsFound.DistinctNames();
 1478        }
 1479
 1480        /// <summary>
 1481        /// Gets the studios from the tags collection.
 1482        /// </summary>
 1483        /// <param name="info">The info.</param>
 1484        /// <param name="tags">The tags.</param>
 1485        /// <param name="tagName">Name of the tag.</param>
 1486        private void FetchStudios(MediaInfo info, IReadOnlyDictionary<string, string> tags, string tagName)
 1487        {
 181488            var val = tags.GetValueOrDefault(tagName);
 1489
 181490            if (string.IsNullOrEmpty(val))
 1491            {
 161492                return;
 1493            }
 1494
 21495            var studios = Split(val, true);
 21496            var studioList = new List<string>();
 1497
 81498            foreach (var studio in studios)
 1499            {
 21500                if (string.IsNullOrWhiteSpace(studio))
 1501                {
 1502                    continue;
 1503                }
 1504
 1505                // Don't add artist/album artist name to studios, even if it's listed there
 21506                if (info.Artists.Contains(studio, StringComparison.OrdinalIgnoreCase)
 21507                    || info.AlbumArtists.Contains(studio, StringComparison.OrdinalIgnoreCase))
 1508                {
 1509                    continue;
 1510                }
 1511
 21512                studioList.Add(studio);
 1513            }
 1514
 21515            info.Studios = studioList
 21516                .Distinct(StringComparer.OrdinalIgnoreCase)
 21517                .ToArray();
 21518        }
 1519
 1520        /// <summary>
 1521        /// Gets the genres from the tags collection.
 1522        /// </summary>
 1523        /// <param name="info">The information.</param>
 1524        /// <param name="tags">The tags.</param>
 1525        private void FetchGenres(MediaInfo info, IReadOnlyDictionary<string, string> tags)
 1526        {
 121527            var genreVal = tags.GetValueOrDefault("genre");
 121528            if (string.IsNullOrEmpty(genreVal))
 1529            {
 101530                return;
 1531            }
 1532
 21533            var genres = new List<string>(info.Genres);
 201534            foreach (var genre in Split(genreVal, true))
 1535            {
 81536                if (string.IsNullOrEmpty(genre))
 1537                {
 1538                    continue;
 1539                }
 1540
 81541                genres.Add(genre);
 1542            }
 1543
 21544            info.Genres = genres
 21545                .Distinct(StringComparer.OrdinalIgnoreCase)
 21546                .ToArray();
 21547        }
 1548
 1549        /// <summary>
 1550        /// Gets the track or disc number, which can be in the form of '1', or '1/3'.
 1551        /// </summary>
 1552        /// <param name="tags">The tags.</param>
 1553        /// <param name="tagName">Name of the tag.</param>
 1554        /// <returns>The track or disc number, or null, if missing or not parseable.</returns>
 1555        private static int? GetDictionaryTrackOrDiscNumber(IReadOnlyDictionary<string, string> tags, string tagName)
 1556        {
 41557            var disc = tags.GetValueOrDefault(tagName);
 1558
 41559            if (int.TryParse(disc.AsSpan().LeftPart('/'), out var discNum))
 1560            {
 41561                return discNum;
 1562            }
 1563
 01564            return null;
 1565        }
 1566
 1567        private static ChapterInfo GetChapterInfo(MediaChapter chapter)
 1568        {
 01569            var info = new ChapterInfo();
 1570
 01571            if (chapter.Tags is not null && chapter.Tags.TryGetValue("title", out string name))
 1572            {
 01573                info.Name = name;
 1574            }
 1575
 1576            // Limit accuracy to milliseconds to match xml saving
 01577            var secondsString = chapter.StartTime;
 1578
 01579            if (double.TryParse(secondsString, CultureInfo.InvariantCulture, out var seconds))
 1580            {
 01581                var ms = Math.Round(TimeSpan.FromSeconds(seconds).TotalMilliseconds);
 01582                info.StartPositionTicks = TimeSpan.FromMilliseconds(ms).Ticks;
 1583            }
 1584
 01585            return info;
 1586        }
 1587
 1588        private void FetchWtvInfo(MediaInfo video, InternalMediaInfoResult data)
 1589        {
 101590            var tags = data.Format?.Tags;
 1591
 101592            if (tags is null)
 1593            {
 41594                return;
 1595            }
 1596
 61597            if (tags.TryGetValue("WM/Genre", out var genres) && !string.IsNullOrWhiteSpace(genres))
 1598            {
 01599                var genreList = genres.Split(_genreDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOption
 1600
 1601                // If this is empty then don't overwrite genres that might have been fetched earlier
 01602                if (genreList.Length > 0)
 1603                {
 01604                    video.Genres = genreList;
 1605                }
 1606            }
 1607
 61608            if (tags.TryGetValue("WM/ParentalRating", out var officialRating) && !string.IsNullOrWhiteSpace(officialRati
 1609            {
 01610                video.OfficialRating = officialRating;
 1611            }
 1612
 61613            if (tags.TryGetValue("WM/MediaCredits", out var people) && !string.IsNullOrEmpty(people))
 1614            {
 01615                video.People = Array.ConvertAll(
 01616                    people.Split(_basicDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntrie
 01617                    i => new BaseItemPerson { Name = i, Type = PersonKind.Actor });
 1618            }
 1619
 61620            if (tags.TryGetValue("WM/OriginalReleaseTime", out var year) && int.TryParse(year, NumberStyles.Integer, Cul
 1621            {
 01622                video.ProductionYear = parsedYear;
 1623            }
 1624
 1625            // Credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
 1626            // DateTime is reported along with timezone info (typically Z i.e. UTC hence assume None)
 61627            if (tags.TryGetValue("WM/MediaOriginalBroadcastDateTime", out var premiereDateString) && DateTime.TryParse(y
 1628            {
 01629                video.PremiereDate = parsedDate;
 1630            }
 1631
 61632            var description = tags.GetValueOrDefault("WM/SubTitleDescription");
 1633
 61634            var subTitle = tags.GetValueOrDefault("WM/SubTitle");
 1635
 1636            // For below code, credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
 1637
 1638            // Sometimes for TV Shows the Subtitle field is empty and the subtitle description contains the subtitle, ex
 1639            // The format is -> EPISODE/TOTAL_EPISODES_IN_SEASON. SUBTITLE: DESCRIPTION
 1640            // OR -> COMMENT. SUBTITLE: DESCRIPTION
 1641            // e.g. -> 4/13. The Doctor's Wife: Science fiction drama. When he follows a Time Lord distress signal, the 
 1642            // e.g. -> CBeebies Bedtime Hour. The Mystery: Animated adventures of two friends who live on an island in t
 61643            if (string.IsNullOrWhiteSpace(subTitle)
 61644                && !string.IsNullOrWhiteSpace(description)
 61645                && description.AsSpan()[..Math.Min(description.Length, MaxSubtitleDescriptionExtractionLength)].Contains
 1646            {
 01647                string[] descriptionParts = description.Split(':');
 01648                if (descriptionParts.Length > 0)
 1649                {
 01650                    string subtitle = descriptionParts[0];
 1651                    try
 1652                    {
 1653                        // Check if it contains a episode number and season number
 01654                        if (subtitle.Contains('/', StringComparison.Ordinal))
 1655                        {
 01656                            string[] subtitleParts = subtitle.Split(' ');
 01657                            string[] numbers = subtitleParts[0].Replace(".", string.Empty, StringComparison.Ordinal).Spl
 01658                            video.IndexNumber = int.Parse(numbers[0], CultureInfo.InvariantCulture);
 1659                            // int totalEpisodesInSeason = int.Parse(numbers[1], CultureInfo.InvariantCulture);
 1660
 1661                            // Skip the numbers, concatenate the rest, trim and set as new description
 01662                            description = string.Join(' ', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1663                        }
 01664                        else if (subtitle.Contains('.', StringComparison.Ordinal))
 1665                        {
 01666                            var subtitleParts = subtitle.Split('.');
 01667                            description = string.Join('.', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1668                        }
 1669                        else
 1670                        {
 01671                            description = subtitle.Trim();
 1672                        }
 01673                    }
 01674                    catch (Exception ex)
 1675                    {
 01676                        _logger.LogError(ex, "Error while parsing subtitle field");
 1677
 1678                        // Fallback to default parsing
 01679                        if (subtitle.Contains('.', StringComparison.Ordinal))
 1680                        {
 01681                            var subtitleParts = subtitle.Split('.');
 01682                            description = string.Join('.', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1683                        }
 1684                        else
 1685                        {
 01686                            description = subtitle.Trim();
 1687                        }
 01688                    }
 1689                }
 1690            }
 1691
 61692            if (!string.IsNullOrWhiteSpace(description))
 1693            {
 01694                video.Overview = description;
 1695            }
 61696        }
 1697
 1698        private void ExtractTimestamp(MediaInfo video)
 1699        {
 101700            if (video.VideoType != VideoType.VideoFile)
 1701            {
 01702                return;
 1703            }
 1704
 101705            if (!string.Equals(video.Container, "mpeg2ts", StringComparison.OrdinalIgnoreCase)
 101706                && !string.Equals(video.Container, "m2ts", StringComparison.OrdinalIgnoreCase)
 101707                && !string.Equals(video.Container, "ts", StringComparison.OrdinalIgnoreCase))
 1708            {
 91709                return;
 1710            }
 1711
 1712            try
 1713            {
 11714                video.Timestamp = GetMpegTimestamp(video.Path);
 01715                _logger.LogDebug("Video has {Timestamp} timestamp", video.Timestamp);
 01716            }
 11717            catch (Exception ex)
 1718            {
 11719                video.Timestamp = null;
 11720                _logger.LogError(ex, "Error extracting timestamp info from {Path}", video.Path);
 11721            }
 11722        }
 1723
 1724        // REVIEW: find out why the byte array needs to be 197 bytes long and comment the reason
 1725        private static TransportStreamTimestamp GetMpegTimestamp(string path)
 1726        {
 11727            var packetBuffer = new byte[197];
 1728
 11729            using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 1))
 1730            {
 01731                fs.ReadExactly(packetBuffer);
 01732            }
 1733
 01734            if (packetBuffer[0] == 71)
 1735            {
 01736                return TransportStreamTimestamp.None;
 1737            }
 1738
 01739            if ((packetBuffer[4] != 71) || (packetBuffer[196] != 71))
 1740            {
 01741                return TransportStreamTimestamp.None;
 1742            }
 1743
 01744            if ((packetBuffer[0] == 0) && (packetBuffer[1] == 0) && (packetBuffer[2] == 0) && (packetBuffer[3] == 0))
 1745            {
 01746                return TransportStreamTimestamp.Zero;
 1747            }
 1748
 01749            return TransportStreamTimestamp.Valid;
 1750        }
 1751
 1752        [GeneratedRegex("(?<name>.*) \\((?<instrument>.*)\\)")]
 1753        private static partial Regex PerformerRegex();
 1754    }
 1755}

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)