< 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: 593
Uncovered lines: 154
Coverable lines: 747
Total lines: 1723
Line coverage: 79.3%
Branch coverage
75%
Covered branches: 462
Total branches: 614
Branch coverage: 75.2%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 9/14/2025 - 12:09:49 AM Line coverage: 79.5% (592/744) Branch coverage: 75.4% (460/610) Total lines: 171310/28/2025 - 12:11:27 AM Line coverage: 79.3% (592/746) Branch coverage: 75.1% (460/612) Total lines: 172211/28/2025 - 12:11:11 AM Line coverage: 79.3% (593/747) Branch coverage: 75.2% (462/614) Total lines: 1723 9/14/2025 - 12:09:49 AM Line coverage: 79.5% (592/744) Branch coverage: 75.4% (460/610) Total lines: 171310/28/2025 - 12:11:27 AM Line coverage: 79.3% (592/746) Branch coverage: 75.1% (460/612) Total lines: 172211/28/2025 - 12:11:11 AM Line coverage: 79.3% (593/747) Branch coverage: 75.2% (462/614) Total lines: 1723

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(...)85.71%141486.66%
GetEstimatedAudioBitrate(...)50%622662.5%
FetchFromItunesInfo(...)83.33%141276.92%
ReadFromDictNode(...)90%212087.09%
ReadValueArray(...)83.33%141277.77%
ProcessPairs(...)64.28%441446.66%
GetNameValuePair(...)92.85%141490.9%
NormalizeSubtitleCodec(...)62.5%10866.66%
GetMediaAttachment(...)90%1010100%
GetMediaStream(...)78.37%29314881.21%
NormalizeStreamTitle(...)100%44100%
GetDictionaryValue(...)100%22100%
ParseChannelLayout(...)100%22100%
GetAspectRatio(...)85.29%393483.87%
IsClose(...)100%11100%
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        {
 2151            _logger = logger;
 2152            _localization = localization;
 2153        }
 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        };
 87
 88        /// <summary>
 89        /// Transforms a FFprobe response into its <see cref="MediaInfo"/> equivalent.
 90        /// </summary>
 91        /// <param name="data">The <see cref="InternalMediaInfoResult"/>.</param>
 92        /// <param name="videoType">The <see cref="VideoType"/>.</param>
 93        /// <param name="isAudio">A boolean indicating whether the media is audio.</param>
 94        /// <param name="path">Path to media file.</param>
 95        /// <param name="protocol">Path media protocol.</param>
 96        /// <returns>The <see cref="MediaInfo"/>.</returns>
 97        public MediaInfo GetMediaInfo(InternalMediaInfoResult data, VideoType? videoType, bool isAudio, string path, Med
 98        {
 1199            var info = new MediaInfo
 11100            {
 11101                Path = path,
 11102                Protocol = protocol,
 11103                VideoType = videoType
 11104            };
 105
 11106            FFProbeHelpers.NormalizeFFProbeResult(data);
 11107            SetSize(data, info);
 108
 11109            var internalStreams = data.Streams ?? Array.Empty<MediaStreamInfo>();
 11110            var internalFrames = data.Frames ?? Array.Empty<MediaFrameInfo>();
 111
 11112            info.MediaStreams = internalStreams.Select(s => GetMediaStream(isAudio, s, data.Format, internalFrames))
 11113                .Where(i => i is not null)
 11114                // Drop subtitle streams if we don't know the codec because it will just cause failures if we don't know
 11115                .Where(i => i.Type != MediaStreamType.Subtitle || !string.IsNullOrWhiteSpace(i.Codec))
 11116                .ToList();
 117
 11118            info.MediaAttachments = internalStreams.Select(GetMediaAttachment)
 11119                .Where(i => i is not null)
 11120                .ToList();
 121
 11122            if (data.Format is not null)
 123            {
 10124                info.Container = NormalizeFormat(data.Format.FormatName, info.MediaStreams);
 125
 10126                if (int.TryParse(data.Format.BitRate, CultureInfo.InvariantCulture, out var value))
 127                {
 10128                    info.Bitrate = value;
 129                }
 130            }
 131
 11132            var tags = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 11133            var tagStreamType = isAudio ? CodecType.Audio : CodecType.Video;
 134
 11135            var tagStream = data.Streams?.FirstOrDefault(i => i.CodecType == tagStreamType);
 136
 11137            if (tagStream?.Tags is not null)
 138            {
 70139                foreach (var (key, value) in tagStream.Tags)
 140                {
 27141                    tags[key] = value;
 142                }
 143            }
 144
 11145            if (data.Format?.Tags is not null)
 146            {
 274147                foreach (var (key, value) in data.Format.Tags)
 148                {
 129149                    tags[key] = value;
 150                }
 151            }
 152
 11153            FetchGenres(info, tags);
 154
 11155            info.Name = tags.GetFirstNotNullNorWhiteSpaceValue("title", "title-eng");
 11156            info.ForcedSortName = tags.GetFirstNotNullNorWhiteSpaceValue("sort_name", "title-sort", "titlesort");
 11157            info.Overview = tags.GetFirstNotNullNorWhiteSpaceValue("synopsis", "description", "desc", "comment");
 158
 11159            info.ParentIndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "season_number");
 11160            info.IndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "episode_sort") ??
 11161                               FFProbeHelpers.GetDictionaryNumericValue(tags, "episode_id");
 11162            info.ShowName = tags.GetValueOrDefault("show_name", "show");
 11163            info.ProductionYear = FFProbeHelpers.GetDictionaryNumericValue(tags, "date");
 164
 165            // Several different forms of retail/premiere date
 11166            info.PremiereDate =
 11167                FFProbeHelpers.GetDictionaryDateTime(tags, "originaldate") ??
 11168                FFProbeHelpers.GetDictionaryDateTime(tags, "retaildate") ??
 11169                FFProbeHelpers.GetDictionaryDateTime(tags, "retail date") ??
 11170                FFProbeHelpers.GetDictionaryDateTime(tags, "retail_date") ??
 11171                FFProbeHelpers.GetDictionaryDateTime(tags, "date_released") ??
 11172                FFProbeHelpers.GetDictionaryDateTime(tags, "date") ??
 11173                FFProbeHelpers.GetDictionaryDateTime(tags, "creation_time");
 174
 175            // Set common metadata for music (audio) and music videos (video)
 11176            info.Album = tags.GetValueOrDefault("album");
 177
 11178            if (tags.TryGetValue("artists", out var artists) && !string.IsNullOrWhiteSpace(artists))
 179            {
 2180                info.Artists = SplitDistinctArtists(artists, _basicDelimiters, false).ToArray();
 181            }
 182            else
 183            {
 9184                var artist = tags.GetFirstNotNullNorWhiteSpaceValue("artist");
 9185                info.Artists = artist is null
 9186                    ? Array.Empty<string>()
 9187                    : SplitDistinctArtists(artist, _nameDelimiters, true).ToArray();
 188            }
 189
 190            // Guess ProductionYear from PremiereDate if missing
 11191            if (!info.ProductionYear.HasValue && info.PremiereDate.HasValue)
 192            {
 5193                info.ProductionYear = info.PremiereDate.Value.Year;
 194            }
 195
 196            // Set mediaType-specific metadata
 11197            if (isAudio)
 198            {
 2199                SetAudioRuntimeTicks(data, info);
 200
 201                // tags are normally located under data.format, but we've seen some cases with ogg where they're part of
 202                // so let's create a combined list of both
 203
 2204                SetAudioInfoFromTags(info, tags);
 205            }
 206            else
 207            {
 9208                FetchStudios(info, tags, "copyright");
 209
 9210                var iTunExtc = tags.GetFirstNotNullNorWhiteSpaceValue("iTunEXTC");
 9211                if (iTunExtc is not null)
 212                {
 0213                    var parts = iTunExtc.Split('|', StringSplitOptions.RemoveEmptyEntries);
 214                    // Example
 215                    // mpaa|G|100|For crude humor
 0216                    if (parts.Length > 1)
 217                    {
 0218                        info.OfficialRating = parts[1];
 219
 0220                        if (parts.Length > 3)
 221                        {
 0222                            info.OfficialRatingDescription = parts[3];
 223                        }
 224                    }
 225                }
 226
 9227                var iTunXml = tags.GetFirstNotNullNorWhiteSpaceValue("iTunMOVI");
 9228                if (iTunXml is not null)
 229                {
 1230                    FetchFromItunesInfo(iTunXml, info);
 231                }
 232
 9233                if (data.Format is not null && !string.IsNullOrEmpty(data.Format.Duration))
 234                {
 8235                    info.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.Format.Duration, CultureInfo.InvariantCul
 236                }
 237
 9238                FetchWtvInfo(info, data);
 239
 9240                if (data.Chapters is not null)
 241                {
 3242                    info.Chapters = data.Chapters.Select(GetChapterInfo).ToArray();
 243                }
 244
 9245                ExtractTimestamp(info);
 246
 9247                if (tags.TryGetValue("stereo_mode", out var stereoMode) && string.Equals(stereoMode, "left_right", Strin
 248                {
 0249                    info.Video3DFormat = Video3DFormat.FullSideBySide;
 250                }
 251
 62252                foreach (var mediaStream in info.MediaStreams)
 253                {
 22254                    if (mediaStream.Type == MediaStreamType.Audio && !mediaStream.BitRate.HasValue)
 255                    {
 3256                        mediaStream.BitRate = GetEstimatedAudioBitrate(mediaStream.Codec, mediaStream.Channels);
 257                    }
 258                }
 259
 9260                var videoStreamsBitrate = info.MediaStreams.Where(i => i.Type == MediaStreamType.Video).Select(i => i.Bi
 261                // If ffprobe reported the container bitrate as being the same as the video stream bitrate, then it's wr
 9262                if (videoStreamsBitrate == (info.Bitrate ?? 0))
 263                {
 5264                    info.InferTotalBitrate(true);
 265                }
 266            }
 267
 11268            return info;
 269        }
 270
 271        private string NormalizeFormat(string format, IReadOnlyList<MediaStream> mediaStreams)
 272        {
 10273            if (string.IsNullOrWhiteSpace(format))
 274            {
 0275                return null;
 276            }
 277
 278            // Input can be a list of multiple, comma-delimited formats - each of them needs to be checked
 10279            var splitFormat = format.Split(',');
 78280            for (var i = 0; i < splitFormat.Length; i++)
 281            {
 282                // Handle MPEG-1 container
 29283                if (string.Equals(splitFormat[i], "mpegvideo", StringComparison.OrdinalIgnoreCase))
 284                {
 0285                    splitFormat[i] = "mpeg";
 286                }
 287
 288                // Handle MPEG-TS container
 29289                else if (string.Equals(splitFormat[i], "mpegts", StringComparison.OrdinalIgnoreCase))
 290                {
 1291                    splitFormat[i] = "ts";
 292                }
 293
 294                // Handle matroska container
 28295                else if (string.Equals(splitFormat[i], "matroska", StringComparison.OrdinalIgnoreCase))
 296                {
 4297                    splitFormat[i] = "mkv";
 298                }
 299
 300                // Handle WebM
 24301                else if (string.Equals(splitFormat[i], "webm", StringComparison.OrdinalIgnoreCase))
 302                {
 303                    // Limit WebM to supported codecs
 4304                    if (mediaStreams.Any(stream => (stream.Type == MediaStreamType.Video && !_webmVideoCodecs.Contains(s
 4305                        || (stream.Type == MediaStreamType.Audio && !_webmAudioCodecs.Contains(stream.Codec, StringCompa
 306                    {
 3307                        splitFormat[i] = string.Empty;
 308                    }
 309                }
 310            }
 311
 10312            return string.Join(',', splitFormat.Where(s => !string.IsNullOrEmpty(s)));
 313        }
 314
 315        private static int? GetEstimatedAudioBitrate(string codec, int? channels)
 316        {
 3317            if (!channels.HasValue)
 318            {
 0319                return null;
 320            }
 321
 3322            var channelsValue = channels.Value;
 323
 3324            if (string.Equals(codec, "aac", StringComparison.OrdinalIgnoreCase)
 3325                || string.Equals(codec, "mp3", StringComparison.OrdinalIgnoreCase))
 326            {
 327                switch (channelsValue)
 328                {
 329                    case <= 2:
 1330                        return 192000;
 331                    case >= 5:
 0332                        return 320000;
 333                }
 334            }
 335
 2336            if (string.Equals(codec, "ac3", StringComparison.OrdinalIgnoreCase)
 2337                || string.Equals(codec, "eac3", StringComparison.OrdinalIgnoreCase))
 338            {
 339                switch (channelsValue)
 340                {
 341                    case <= 2:
 0342                        return 192000;
 343                    case >= 5:
 0344                        return 640000;
 345                }
 346            }
 347
 2348            if (string.Equals(codec, "flac", StringComparison.OrdinalIgnoreCase)
 2349                || string.Equals(codec, "alac", StringComparison.OrdinalIgnoreCase))
 350            {
 351                switch (channelsValue)
 352                {
 353                    case <= 2:
 0354                        return 960000;
 355                    case >= 5:
 0356                        return 2880000;
 357                }
 358            }
 359
 2360            return null;
 361        }
 362
 363        private void FetchFromItunesInfo(string xml, MediaInfo info)
 364        {
 365            // Make things simpler and strip out the dtd
 1366            var plistIndex = xml.IndexOf("<plist", StringComparison.OrdinalIgnoreCase);
 367
 1368            if (plistIndex != -1)
 369            {
 1370                xml = xml.Substring(plistIndex);
 371            }
 372
 1373            xml = "<?xml version=\"1.0\"?>" + xml;
 374
 375            // <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http
 1376            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)))
 1377            using (var streamReader = new StreamReader(stream))
 378            {
 379                try
 380                {
 1381                    using (var reader = XmlReader.Create(streamReader))
 382                    {
 1383                        reader.MoveToContent();
 1384                        reader.Read();
 385
 386                        // Loop through each element
 4387                        while (!reader.EOF && reader.ReadState == ReadState.Interactive)
 388                        {
 3389                            if (reader.NodeType == XmlNodeType.Element)
 390                            {
 1391                                switch (reader.Name)
 392                                {
 393                                    case "dict":
 1394                                        if (reader.IsEmptyElement)
 395                                        {
 0396                                            reader.Read();
 0397                                            continue;
 398                                        }
 399
 1400                                        using (var subtree = reader.ReadSubtree())
 401                                        {
 1402                                            ReadFromDictNode(subtree, info);
 1403                                        }
 404
 405                                        break;
 406                                    default:
 0407                                        reader.Skip();
 0408                                        break;
 409                                }
 410                            }
 411                            else
 412                            {
 2413                                reader.Read();
 414                            }
 415                        }
 1416                    }
 1417                }
 0418                catch (XmlException)
 419                {
 420                    // I've seen probe examples where the iTunMOVI value is just "<"
 421                    // So we should not allow this to fail the entire probing operation
 0422                }
 423            }
 1424        }
 425
 426        private void ReadFromDictNode(XmlReader reader, MediaInfo info)
 427        {
 1428            string currentKey = null;
 1429            var pairs = new List<NameValuePair>();
 430
 1431            reader.MoveToContent();
 1432            reader.Read();
 433
 434            // Loop through each element
 19435            while (!reader.EOF && reader.ReadState == ReadState.Interactive)
 436            {
 18437                if (reader.NodeType == XmlNodeType.Element)
 438                {
 12439                    switch (reader.Name)
 440                    {
 441                        case "key":
 6442                            if (!string.IsNullOrWhiteSpace(currentKey))
 443                            {
 5444                                ProcessPairs(currentKey, pairs, info);
 445                            }
 446
 6447                            currentKey = reader.ReadElementContentAsString();
 6448                            pairs = new List<NameValuePair>();
 6449                            break;
 450                        case "string":
 1451                            var value = reader.ReadElementContentAsString();
 1452                            if (!string.IsNullOrWhiteSpace(value))
 453                            {
 1454                                pairs.Add(new NameValuePair
 1455                                {
 1456                                    Name = value,
 1457                                    Value = value
 1458                                });
 459                            }
 460
 1461                            break;
 462                        case "array":
 5463                            if (reader.IsEmptyElement)
 464                            {
 0465                                reader.Read();
 0466                                continue;
 467                            }
 468
 5469                            using (var subtree = reader.ReadSubtree())
 470                            {
 5471                                if (!string.IsNullOrWhiteSpace(currentKey))
 472                                {
 5473                                    pairs.AddRange(ReadValueArray(subtree));
 474                                }
 5475                            }
 476
 477                            break;
 478                        default:
 0479                            reader.Skip();
 0480                            break;
 481                    }
 482                }
 483                else
 484                {
 6485                    reader.Read();
 486                }
 487            }
 1488        }
 489
 490        private List<NameValuePair> ReadValueArray(XmlReader reader)
 491        {
 5492            var pairs = new List<NameValuePair>();
 493
 5494            reader.MoveToContent();
 5495            reader.Read();
 496
 497            // Loop through each element
 20498            while (!reader.EOF && reader.ReadState == ReadState.Interactive)
 499            {
 15500                if (reader.NodeType == XmlNodeType.Element)
 501                {
 5502                    switch (reader.Name)
 503                    {
 504                        case "dict":
 505
 5506                            if (reader.IsEmptyElement)
 507                            {
 0508                                reader.Read();
 0509                                continue;
 510                            }
 511
 5512                            using (var subtree = reader.ReadSubtree())
 513                            {
 5514                                var dict = GetNameValuePair(subtree);
 5515                                if (dict is not null)
 516                                {
 1517                                    pairs.Add(dict);
 518                                }
 5519                            }
 520
 521                            break;
 522                        default:
 0523                            reader.Skip();
 0524                            break;
 525                    }
 526                }
 527                else
 528                {
 10529                    reader.Read();
 530                }
 531            }
 532
 5533            return pairs;
 534        }
 535
 536        private static void ProcessPairs(string key, List<NameValuePair> pairs, MediaInfo info)
 537        {
 5538            List<BaseItemPerson> peoples = new List<BaseItemPerson>();
 5539            var distinctPairs = pairs.Select(p => p.Value)
 5540                    .Where(i => !string.IsNullOrWhiteSpace(i))
 5541                    .Trimmed()
 5542                    .Distinct(StringComparer.OrdinalIgnoreCase);
 543
 5544            if (string.Equals(key, "studio", StringComparison.OrdinalIgnoreCase))
 545            {
 1546                info.Studios = distinctPairs.ToArray();
 547            }
 4548            else if (string.Equals(key, "screenwriters", StringComparison.OrdinalIgnoreCase))
 549            {
 0550                foreach (var pair in distinctPairs)
 551                {
 0552                    peoples.Add(new BaseItemPerson
 0553                    {
 0554                        Name = pair,
 0555                        Type = PersonKind.Writer
 0556                    });
 557                }
 558            }
 4559            else if (string.Equals(key, "producers", StringComparison.OrdinalIgnoreCase))
 560            {
 2561                foreach (var pair in distinctPairs)
 562                {
 0563                    peoples.Add(new BaseItemPerson
 0564                    {
 0565                        Name = pair,
 0566                        Type = PersonKind.Producer
 0567                    });
 568                }
 569            }
 3570            else if (string.Equals(key, "directors", StringComparison.OrdinalIgnoreCase))
 571            {
 2572                foreach (var pair in distinctPairs)
 573                {
 0574                    peoples.Add(new BaseItemPerson
 0575                    {
 0576                        Name = pair,
 0577                        Type = PersonKind.Director
 0578                    });
 579                }
 580            }
 581
 5582            info.People = peoples.ToArray();
 5583        }
 584
 585        private static NameValuePair GetNameValuePair(XmlReader reader)
 586        {
 5587            string name = null;
 5588            string value = null;
 589
 5590            reader.MoveToContent();
 5591            reader.Read();
 592
 593            // Loop through each element
 20594            while (!reader.EOF && reader.ReadState == ReadState.Interactive)
 595            {
 15596                if (reader.NodeType == XmlNodeType.Element)
 597                {
 10598                    switch (reader.Name)
 599                    {
 600                        case "key":
 5601                            name = reader.ReadNormalizedString();
 5602                            break;
 603                        case "string":
 5604                            value = reader.ReadNormalizedString();
 5605                            break;
 606                        default:
 0607                            reader.Skip();
 0608                            break;
 609                    }
 610                }
 611                else
 612                {
 5613                    reader.Read();
 614                }
 615            }
 616
 5617            if (string.IsNullOrEmpty(name)
 5618                || string.IsNullOrEmpty(value))
 619            {
 4620                return null;
 621            }
 622
 1623            return new NameValuePair
 1624            {
 1625                Name = name,
 1626                Value = value
 1627            };
 628        }
 629
 630        private static string NormalizeSubtitleCodec(string codec)
 631        {
 3632            if (string.Equals(codec, "dvb_subtitle", StringComparison.OrdinalIgnoreCase))
 633            {
 0634                codec = "DVBSUB";
 635            }
 3636            else if (string.Equals(codec, "dvb_teletext", StringComparison.OrdinalIgnoreCase))
 637            {
 0638                codec = "DVBTXT";
 639            }
 3640            else if (string.Equals(codec, "dvd_subtitle", StringComparison.OrdinalIgnoreCase))
 641            {
 1642                codec = "DVDSUB"; // .sub+.idx
 643            }
 2644            else if (string.Equals(codec, "hdmv_pgs_subtitle", StringComparison.OrdinalIgnoreCase))
 645            {
 0646                codec = "PGSSUB"; // .sup
 647            }
 648
 3649            return codec;
 650        }
 651
 652        /// <summary>
 653        /// Converts ffprobe stream info to our MediaAttachment class.
 654        /// </summary>
 655        /// <param name="streamInfo">The stream info.</param>
 656        /// <returns>MediaAttachments.</returns>
 657        private MediaAttachment GetMediaAttachment(MediaStreamInfo streamInfo)
 658        {
 26659            if (streamInfo.CodecType != CodecType.Attachment
 26660                && streamInfo.Disposition?.GetValueOrDefault("attached_pic") != 1)
 661            {
 24662                return null;
 663            }
 664
 2665            var attachment = new MediaAttachment
 2666            {
 2667                Codec = streamInfo.CodecName,
 2668                Index = streamInfo.Index
 2669            };
 670
 2671            if (!string.IsNullOrWhiteSpace(streamInfo.CodecTagString))
 672            {
 2673                attachment.CodecTag = streamInfo.CodecTagString;
 674            }
 675
 2676            if (streamInfo.Tags is not null)
 677            {
 2678                attachment.FileName = GetDictionaryValue(streamInfo.Tags, "filename");
 2679                attachment.MimeType = GetDictionaryValue(streamInfo.Tags, "mimetype");
 2680                attachment.Comment = GetDictionaryValue(streamInfo.Tags, "comment");
 681            }
 682
 2683            return attachment;
 684        }
 685
 686        /// <summary>
 687        /// Converts ffprobe stream info to our MediaStream class.
 688        /// </summary>
 689        /// <param name="isAudio">if set to <c>true</c> [is info].</param>
 690        /// <param name="streamInfo">The stream info.</param>
 691        /// <param name="formatInfo">The format info.</param>
 692        /// <param name="frameInfoList">The frame info.</param>
 693        /// <returns>MediaStream.</returns>
 694        private MediaStream GetMediaStream(bool isAudio, MediaStreamInfo streamInfo, MediaFormatInfo formatInfo, IReadOn
 695        {
 696            // These are mp4 chapters
 26697            if (string.Equals(streamInfo.CodecName, "mov_text", StringComparison.OrdinalIgnoreCase))
 698            {
 699                // Edit: but these are also sometimes subtitles?
 700                // return null;
 701            }
 702
 26703            var stream = new MediaStream
 26704            {
 26705                Codec = streamInfo.CodecName,
 26706                Profile = streamInfo.Profile,
 26707                Level = streamInfo.Level,
 26708                Index = streamInfo.Index,
 26709                PixelFormat = streamInfo.PixelFormat,
 26710                NalLengthSize = streamInfo.NalLengthSize,
 26711                TimeBase = streamInfo.TimeBase,
 26712                CodecTimeBase = streamInfo.CodecTimeBase,
 26713                IsAVC = streamInfo.IsAvc
 26714            };
 715
 716            // Filter out junk
 26717            if (!string.IsNullOrWhiteSpace(streamInfo.CodecTagString) && !streamInfo.CodecTagString.Contains("[0]", Stri
 718            {
 10719                stream.CodecTag = streamInfo.CodecTagString;
 720            }
 721
 26722            if (streamInfo.Tags is not null)
 723            {
 22724                stream.Language = GetDictionaryValue(streamInfo.Tags, "language");
 22725                stream.Comment = GetDictionaryValue(streamInfo.Tags, "comment");
 22726                stream.Title = GetDictionaryValue(streamInfo.Tags, "title");
 727            }
 728
 26729            if (streamInfo.CodecType == CodecType.Audio)
 730            {
 11731                stream.Type = MediaStreamType.Audio;
 11732                stream.LocalizedDefault = _localization.GetLocalizedString("Default");
 11733                stream.LocalizedExternal = _localization.GetLocalizedString("External");
 734
 11735                stream.Channels = streamInfo.Channels;
 736
 11737                if (int.TryParse(streamInfo.SampleRate, CultureInfo.InvariantCulture, out var sampleRate))
 738                {
 11739                    stream.SampleRate = sampleRate;
 740                }
 741
 11742                stream.ChannelLayout = ParseChannelLayout(streamInfo.ChannelLayout);
 743
 11744                if (streamInfo.BitsPerSample > 0)
 745                {
 0746                    stream.BitDepth = streamInfo.BitsPerSample;
 747                }
 11748                else if (streamInfo.BitsPerRawSample > 0)
 749                {
 3750                    stream.BitDepth = streamInfo.BitsPerRawSample;
 751                }
 752
 11753                if (string.IsNullOrEmpty(stream.Title))
 754                {
 755                    // mp4 missing track title workaround: fall back to handler_name if populated and not the default "S
 11756                    string handlerName = GetDictionaryValue(streamInfo.Tags, "handler_name");
 11757                    if (!string.IsNullOrEmpty(handlerName) && !string.Equals(handlerName, "SoundHandler", StringComparis
 758                    {
 3759                        stream.Title = handlerName;
 760                    }
 761                }
 762            }
 15763            else if (streamInfo.CodecType == CodecType.Subtitle)
 764            {
 3765                stream.Type = MediaStreamType.Subtitle;
 3766                stream.Codec = NormalizeSubtitleCodec(stream.Codec);
 3767                stream.LocalizedUndefined = _localization.GetLocalizedString("Undefined");
 3768                stream.LocalizedDefault = _localization.GetLocalizedString("Default");
 3769                stream.LocalizedForced = _localization.GetLocalizedString("Forced");
 3770                stream.LocalizedExternal = _localization.GetLocalizedString("External");
 3771                stream.LocalizedHearingImpaired = _localization.GetLocalizedString("HearingImpaired");
 772
 773                // Graphical subtitle may have width and height info
 3774                stream.Width = streamInfo.Width;
 3775                stream.Height = streamInfo.Height;
 776
 3777                if (string.IsNullOrEmpty(stream.Title))
 778                {
 779                    // mp4 missing track title workaround: fall back to handler_name if populated and not the default "S
 3780                    string handlerName = GetDictionaryValue(streamInfo.Tags, "handler_name");
 3781                    if (!string.IsNullOrEmpty(handlerName) && !string.Equals(handlerName, "SubtitleHandler", StringCompa
 782                    {
 1783                        stream.Title = handlerName;
 784                    }
 785                }
 786            }
 12787            else if (streamInfo.CodecType == CodecType.Video)
 788            {
 12789                stream.AverageFrameRate = GetFrameRate(streamInfo.AverageFrameRate);
 12790                stream.RealFrameRate = GetFrameRate(streamInfo.RFrameRate);
 791
 12792                stream.IsInterlaced = !string.IsNullOrWhiteSpace(streamInfo.FieldOrder)
 12793                    && !string.Equals(streamInfo.FieldOrder, "progressive", StringComparison.OrdinalIgnoreCase);
 794
 12795                if (isAudio
 12796                    || string.Equals(stream.Codec, "bmp", StringComparison.OrdinalIgnoreCase)
 12797                    || string.Equals(stream.Codec, "gif", StringComparison.OrdinalIgnoreCase)
 12798                    || string.Equals(stream.Codec, "png", StringComparison.OrdinalIgnoreCase)
 12799                    || string.Equals(stream.Codec, "webp", StringComparison.OrdinalIgnoreCase))
 800                {
 2801                    stream.Type = MediaStreamType.EmbeddedImage;
 802                }
 10803                else if (string.Equals(stream.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase))
 804                {
 805                    // How to differentiate between video and embedded image?
 806                    // The only difference I've seen thus far is presence of codec tag, also embedded images have high (
 1807                    if (!string.IsNullOrWhiteSpace(stream.CodecTag))
 808                    {
 0809                        stream.Type = MediaStreamType.Video;
 810                    }
 811                    else
 812                    {
 1813                        stream.Type = MediaStreamType.EmbeddedImage;
 814                    }
 815                }
 816                else
 817                {
 9818                    stream.Type = MediaStreamType.Video;
 819                }
 820
 12821                stream.Width = streamInfo.Width;
 12822                stream.Height = streamInfo.Height;
 12823                stream.AspectRatio = GetAspectRatio(streamInfo);
 824
 12825                if (streamInfo.BitsPerSample > 0)
 826                {
 0827                    stream.BitDepth = streamInfo.BitsPerSample;
 828                }
 12829                else if (streamInfo.BitsPerRawSample > 0)
 830                {
 11831                    stream.BitDepth = streamInfo.BitsPerRawSample;
 832                }
 833
 12834                if (!stream.BitDepth.HasValue)
 835                {
 1836                    if (!string.IsNullOrEmpty(streamInfo.PixelFormat))
 837                    {
 1838                        if (string.Equals(streamInfo.PixelFormat, "yuv420p", StringComparison.OrdinalIgnoreCase)
 1839                            || string.Equals(streamInfo.PixelFormat, "yuv444p", StringComparison.OrdinalIgnoreCase))
 840                        {
 1841                            stream.BitDepth = 8;
 842                        }
 0843                        else if (string.Equals(streamInfo.PixelFormat, "yuv420p10le", StringComparison.OrdinalIgnoreCase
 0844                                 || string.Equals(streamInfo.PixelFormat, "yuv444p10le", StringComparison.OrdinalIgnoreC
 845                        {
 0846                            stream.BitDepth = 10;
 847                        }
 0848                        else if (string.Equals(streamInfo.PixelFormat, "yuv420p12le", StringComparison.OrdinalIgnoreCase
 0849                                 || string.Equals(streamInfo.PixelFormat, "yuv444p12le", StringComparison.OrdinalIgnoreC
 850                        {
 0851                            stream.BitDepth = 12;
 852                        }
 853                    }
 854                }
 855
 856                // http://stackoverflow.com/questions/17353387/how-to-detect-anamorphic-video-with-ffprobe
 12857                if (string.Equals(streamInfo.SampleAspectRatio, "1:1", StringComparison.Ordinal))
 858                {
 8859                    stream.IsAnamorphic = false;
 860                }
 4861                else if (!string.Equals(streamInfo.SampleAspectRatio, "0:1", StringComparison.Ordinal))
 862                {
 3863                    stream.IsAnamorphic = true;
 864                }
 1865                else if (string.Equals(streamInfo.DisplayAspectRatio, "0:1", StringComparison.Ordinal))
 866                {
 1867                    stream.IsAnamorphic = false;
 868                }
 0869                else if (!string.Equals(
 0870                             streamInfo.DisplayAspectRatio,
 0871                             // Force GetAspectRatio() to derive ratio from Width/Height directly by using null DAR
 0872                             GetAspectRatio(new MediaStreamInfo
 0873                             {
 0874                                 Width = streamInfo.Width,
 0875                                 Height = streamInfo.Height,
 0876                                 DisplayAspectRatio = null
 0877                             }),
 0878                             StringComparison.Ordinal))
 879                {
 0880                    stream.IsAnamorphic = true;
 881                }
 882                else
 883                {
 0884                    stream.IsAnamorphic = false;
 885                }
 886
 12887                if (streamInfo.Refs > 0)
 888                {
 12889                    stream.RefFrames = streamInfo.Refs;
 890                }
 891
 12892                if (!string.IsNullOrEmpty(streamInfo.ColorRange))
 893                {
 5894                    stream.ColorRange = streamInfo.ColorRange;
 895                }
 896
 12897                if (!string.IsNullOrEmpty(streamInfo.ColorSpace))
 898                {
 5899                    stream.ColorSpace = streamInfo.ColorSpace;
 900                }
 901
 12902                if (!string.IsNullOrEmpty(streamInfo.ColorTransfer))
 903                {
 2904                    stream.ColorTransfer = streamInfo.ColorTransfer;
 905                }
 906
 12907                if (!string.IsNullOrEmpty(streamInfo.ColorPrimaries))
 908                {
 2909                    stream.ColorPrimaries = streamInfo.ColorPrimaries;
 910                }
 911
 12912                if (streamInfo.SideDataList is not null)
 913                {
 6914                    foreach (var data in streamInfo.SideDataList)
 915                    {
 916                        // Parse Dolby Vision metadata from side_data
 2917                        if (string.Equals(data.SideDataType, "DOVI configuration record", StringComparison.OrdinalIgnore
 918                        {
 1919                            stream.DvVersionMajor = data.DvVersionMajor;
 1920                            stream.DvVersionMinor = data.DvVersionMinor;
 1921                            stream.DvProfile = data.DvProfile;
 1922                            stream.DvLevel = data.DvLevel;
 1923                            stream.RpuPresentFlag = data.RpuPresentFlag;
 1924                            stream.ElPresentFlag = data.ElPresentFlag;
 1925                            stream.BlPresentFlag = data.BlPresentFlag;
 1926                            stream.DvBlSignalCompatibilityId = data.DvBlSignalCompatibilityId;
 927                        }
 928
 929                        // Parse video rotation metadata from side_data
 1930                        else if (string.Equals(data.SideDataType, "Display Matrix", StringComparison.OrdinalIgnoreCase))
 931                        {
 1932                            stream.Rotation = data.Rotation;
 933                        }
 934
 935                        // Parse video frame cropping metadata from side_data
 936                        // TODO: save them and make HW filters to apply them in HWA pipelines
 0937                        else if (string.Equals(data.SideDataType, "Frame Cropping", StringComparison.OrdinalIgnoreCase))
 938                        {
 939                            // Streams containing artificially added frame cropping
 940                            // metadata should not be marked as anamorphic.
 0941                            stream.IsAnamorphic = false;
 942                        }
 943                    }
 944                }
 945
 12946                var frameInfo = frameInfoList?.FirstOrDefault(i => i.StreamIndex == stream.Index);
 12947                if (frameInfo?.SideDataList is not null
 12948                    && frameInfo.SideDataList.Any(data => string.Equals(data.SideDataType, "HDR Dynamic Metadata SMPTE20
 949                {
 0950                    stream.Hdr10PlusPresentFlag = true;
 951                }
 952            }
 0953            else if (streamInfo.CodecType == CodecType.Data)
 954            {
 0955                stream.Type = MediaStreamType.Data;
 956            }
 957            else
 958            {
 0959                return null;
 960            }
 961
 962            // Get stream bitrate
 26963            var bitrate = 0;
 964
 26965            if (int.TryParse(streamInfo.BitRate, CultureInfo.InvariantCulture, out var value))
 966            {
 12967                bitrate = value;
 968            }
 969
 970            // The bitrate info of FLAC musics and some videos is included in formatInfo.
 26971            if (bitrate == 0
 26972                && formatInfo is not null
 26973                && (stream.Type == MediaStreamType.Video || (isAudio && stream.Type == MediaStreamType.Audio)))
 974            {
 975                // If the stream info doesn't have a bitrate get the value from the media format info
 7976                if (int.TryParse(formatInfo.BitRate, CultureInfo.InvariantCulture, out value))
 977                {
 7978                    bitrate = value;
 979                }
 980            }
 981
 26982            if (bitrate > 0)
 983            {
 19984                stream.BitRate = bitrate;
 985            }
 986
 987            // Extract bitrate info from tag "BPS" if possible.
 26988            if (!stream.BitRate.HasValue
 26989                && (streamInfo.CodecType == CodecType.Audio
 26990                    || streamInfo.CodecType == CodecType.Video))
 991            {
 7992                var bps = GetBPSFromTags(streamInfo);
 7993                if (bps > 0)
 994                {
 1995                    stream.BitRate = bps;
 996                }
 997                else
 998                {
 999                    // Get average bitrate info from tag "NUMBER_OF_BYTES" and "DURATION" if possible.
 61000                    var durationInSeconds = GetRuntimeSecondsFromTags(streamInfo);
 61001                    var bytes = GetNumberOfBytesFromTags(streamInfo);
 61002                    if (durationInSeconds is not null && durationInSeconds.Value >= 1 && bytes is not null)
 1003                    {
 01004                        bps = Convert.ToInt32(bytes * 8 / durationInSeconds, CultureInfo.InvariantCulture);
 01005                        if (bps > 0)
 1006                        {
 01007                            stream.BitRate = bps;
 1008                        }
 1009                    }
 1010                }
 1011            }
 1012
 261013            var disposition = streamInfo.Disposition;
 261014            if (disposition is not null)
 1015            {
 261016                if (disposition.GetValueOrDefault("default") == 1)
 1017                {
 151018                    stream.IsDefault = true;
 1019                }
 1020
 261021                if (disposition.GetValueOrDefault("forced") == 1)
 1022                {
 01023                    stream.IsForced = true;
 1024                }
 1025
 261026                if (disposition.GetValueOrDefault("hearing_impaired") == 1)
 1027                {
 11028                    stream.IsHearingImpaired = true;
 1029                }
 1030            }
 1031
 261032            NormalizeStreamTitle(stream);
 1033
 261034            return stream;
 1035        }
 1036
 1037        private static void NormalizeStreamTitle(MediaStream stream)
 1038        {
 261039            if (string.Equals(stream.Title, "cc", StringComparison.OrdinalIgnoreCase)
 261040                || stream.Type == MediaStreamType.EmbeddedImage)
 1041            {
 31042                stream.Title = null;
 1043            }
 261044        }
 1045
 1046        /// <summary>
 1047        /// Gets a string from an FFProbeResult tags dictionary.
 1048        /// </summary>
 1049        /// <param name="tags">The tags.</param>
 1050        /// <param name="key">The key.</param>
 1051        /// <returns>System.String.</returns>
 1052        private static string GetDictionaryValue(IReadOnlyDictionary<string, string> tags, string key)
 1053        {
 1241054            if (tags is null)
 1055            {
 31056                return null;
 1057            }
 1058
 1211059            tags.TryGetValue(key, out var val);
 1060
 1211061            return val;
 1062        }
 1063
 1064        private static string ParseChannelLayout(string input)
 1065        {
 111066            if (string.IsNullOrEmpty(input))
 1067            {
 11068                return null;
 1069            }
 1070
 101071            return input.AsSpan().LeftPart('(').ToString();
 1072        }
 1073
 1074        private static string GetAspectRatio(MediaStreamInfo info)
 1075        {
 121076            var original = info.DisplayAspectRatio;
 1077
 121078            var parts = (original ?? string.Empty).Split(':');
 121079            if (!(parts.Length == 2
 121080                    && int.TryParse(parts[0], CultureInfo.InvariantCulture, out var width)
 121081                    && int.TryParse(parts[1], CultureInfo.InvariantCulture, out var height)
 121082                    && width > 0
 121083                    && height > 0))
 1084            {
 31085                width = info.Width;
 31086                height = info.Height;
 1087            }
 1088
 121089            if (width > 0 && height > 0)
 1090            {
 121091                double ratio = width;
 121092                ratio /= height;
 1093
 121094                if (IsClose(ratio, 1.777777778, .03))
 1095                {
 71096                    return "16:9";
 1097                }
 1098
 51099                if (IsClose(ratio, 1.3333333333, .05))
 1100                {
 11101                    return "4:3";
 1102                }
 1103
 41104                if (IsClose(ratio, 1.41))
 1105                {
 01106                    return "1.41:1";
 1107                }
 1108
 41109                if (IsClose(ratio, 1.5))
 1110                {
 11111                    return "1.5:1";
 1112                }
 1113
 31114                if (IsClose(ratio, 1.6))
 1115                {
 01116                    return "1.6:1";
 1117                }
 1118
 31119                if (IsClose(ratio, 1.66666666667))
 1120                {
 01121                    return "5:3";
 1122                }
 1123
 31124                if (IsClose(ratio, 1.85, .02))
 1125                {
 01126                    return "1.85:1";
 1127                }
 1128
 31129                if (IsClose(ratio, 2.35, .025))
 1130                {
 01131                    return "2.35:1";
 1132                }
 1133
 31134                if (IsClose(ratio, 2.4, .025))
 1135                {
 11136                    return "2.40:1";
 1137                }
 1138            }
 1139
 21140            return original;
 1141        }
 1142
 1143        private static bool IsClose(double d1, double d2, double variance = .005)
 1144        {
 401145            return Math.Abs(d1 - d2) <= variance;
 1146        }
 1147
 1148        /// <summary>
 1149        /// Gets a frame rate from a string value in ffprobe output
 1150        /// This could be a number or in the format of 2997/125.
 1151        /// </summary>
 1152        /// <param name="value">The value.</param>
 1153        /// <returns>System.Nullable{System.Single}.</returns>
 1154        internal static float? GetFrameRate(ReadOnlySpan<char> value)
 1155        {
 331156            if (value.IsEmpty)
 1157            {
 01158                return null;
 1159            }
 1160
 331161            int index = value.IndexOf('/');
 331162            if (index == -1)
 1163            {
 01164                return null;
 1165            }
 1166
 331167            if (!float.TryParse(value[..index], NumberStyles.Integer, CultureInfo.InvariantCulture, out var dividend)
 331168                || !float.TryParse(value[(index + 1)..], NumberStyles.Integer, CultureInfo.InvariantCulture, out var div
 1169            {
 01170                return null;
 1171            }
 1172
 331173            return divisor == 0f ? null : dividend / divisor;
 1174        }
 1175
 1176        private static void SetAudioRuntimeTicks(InternalMediaInfoResult result, MediaInfo data)
 1177        {
 1178            // Get the first info stream
 21179            var stream = result.Streams?.FirstOrDefault(s => s.CodecType == CodecType.Audio);
 21180            if (stream is null)
 1181            {
 01182                return;
 1183            }
 1184
 1185            // Get duration from stream properties
 21186            var duration = stream.Duration;
 1187
 1188            // If it's not there go into format properties
 21189            if (string.IsNullOrEmpty(duration))
 1190            {
 01191                duration = result.Format.Duration;
 1192            }
 1193
 1194            // If we got something, parse it
 21195            if (!string.IsNullOrEmpty(duration))
 1196            {
 21197                data.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(duration, CultureInfo.InvariantCulture)).Ticks;
 1198            }
 21199        }
 1200
 1201        private static int? GetBPSFromTags(MediaStreamInfo streamInfo)
 1202        {
 71203            if (streamInfo?.Tags is null)
 1204            {
 01205                return null;
 1206            }
 1207
 71208            var bps = GetDictionaryValue(streamInfo.Tags, "BPS-eng") ?? GetDictionaryValue(streamInfo.Tags, "BPS");
 71209            if (int.TryParse(bps, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBps))
 1210            {
 21211                return parsedBps;
 1212            }
 1213
 51214            return null;
 1215        }
 1216
 1217        private static double? GetRuntimeSecondsFromTags(MediaStreamInfo streamInfo)
 1218        {
 61219            if (streamInfo?.Tags is null)
 1220            {
 01221                return null;
 1222            }
 1223
 61224            var duration = GetDictionaryValue(streamInfo.Tags, "DURATION-eng") ?? GetDictionaryValue(streamInfo.Tags, "D
 61225            if (TimeSpan.TryParse(duration, out var parsedDuration))
 1226            {
 11227                return parsedDuration.TotalSeconds;
 1228            }
 1229
 51230            return null;
 1231        }
 1232
 1233        private static long? GetNumberOfBytesFromTags(MediaStreamInfo streamInfo)
 1234        {
 61235            if (streamInfo?.Tags is null)
 1236            {
 01237                return null;
 1238            }
 1239
 61240            var numberOfBytes = GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES-eng")
 61241                                ?? GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES");
 61242            if (long.TryParse(numberOfBytes, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBytes))
 1243            {
 11244                return parsedBytes;
 1245            }
 1246
 51247            return null;
 1248        }
 1249
 1250        private static void SetSize(InternalMediaInfoResult data, MediaInfo info)
 1251        {
 111252            if (data.Format is null)
 1253            {
 11254                return;
 1255            }
 1256
 101257            info.Size = string.IsNullOrEmpty(data.Format.Size) ? null : long.Parse(data.Format.Size, CultureInfo.Invaria
 101258        }
 1259
 1260        private void SetAudioInfoFromTags(MediaInfo audio, Dictionary<string, string> tags)
 1261        {
 21262            var people = new List<BaseItemPerson>();
 21263            if (tags.TryGetValue("composer", out var composer) && !string.IsNullOrWhiteSpace(composer))
 1264            {
 121265                foreach (var person in Split(composer, false))
 1266                {
 41267                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Composer });
 1268                }
 1269            }
 1270
 21271            if (tags.TryGetValue("conductor", out var conductor) && !string.IsNullOrWhiteSpace(conductor))
 1272            {
 01273                foreach (var person in Split(conductor, false))
 1274                {
 01275                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Conductor });
 1276                }
 1277            }
 1278
 21279            if (tags.TryGetValue("lyricist", out var lyricist) && !string.IsNullOrWhiteSpace(lyricist))
 1280            {
 81281                foreach (var person in Split(lyricist, false))
 1282                {
 21283                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Lyricist });
 1284                }
 1285            }
 1286
 21287            if (tags.TryGetValue("performer", out var performer) && !string.IsNullOrWhiteSpace(performer))
 1288            {
 501289                foreach (var person in Split(performer, false))
 1290                {
 231291                    Match match = PerformerRegex().Match(person);
 1292
 1293                    // If the performer doesn't have any instrument/role associated, it won't match. In that case, chanc
 231294                    if (match.Success)
 1295                    {
 221296                        people.Add(new BaseItemPerson
 221297                        {
 221298                            Name = match.Groups["name"].Value,
 221299                            Type = PersonKind.Actor,
 221300                            Role = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(match.Groups["instrument"].Value)
 221301                        });
 1302                    }
 1303                }
 1304            }
 1305
 1306            // In cases where there isn't sufficient information as to which role a writer performed on a recording, tag
 21307            if (tags.TryGetValue("writer", out var writer) && !string.IsNullOrWhiteSpace(writer))
 1308            {
 01309                foreach (var person in Split(writer, false))
 1310                {
 01311                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Writer });
 1312                }
 1313            }
 1314
 21315            if (tags.TryGetValue("arranger", out var arranger) && !string.IsNullOrWhiteSpace(arranger))
 1316            {
 121317                foreach (var person in Split(arranger, false))
 1318                {
 41319                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Arranger });
 1320                }
 1321            }
 1322
 21323            if (tags.TryGetValue("engineer", out var engineer) && !string.IsNullOrWhiteSpace(engineer))
 1324            {
 01325                foreach (var person in Split(engineer, false))
 1326                {
 01327                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Engineer });
 1328                }
 1329            }
 1330
 21331            if (tags.TryGetValue("mixer", out var mixer) && !string.IsNullOrWhiteSpace(mixer))
 1332            {
 81333                foreach (var person in Split(mixer, false))
 1334                {
 21335                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Mixer });
 1336                }
 1337            }
 1338
 21339            if (tags.TryGetValue("remixer", out var remixer) && !string.IsNullOrWhiteSpace(remixer))
 1340            {
 01341                foreach (var person in Split(remixer, false))
 1342                {
 01343                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Remixer });
 1344                }
 1345            }
 1346
 21347            audio.People = people.ToArray();
 1348
 1349            // Set album artist
 21350            var albumArtist = tags.GetFirstNotNullNorWhiteSpaceValue("albumartist", "album artist", "album_artist");
 21351            audio.AlbumArtists = albumArtist is not null
 21352                ? SplitDistinctArtists(albumArtist, _nameDelimiters, true).ToArray()
 21353                : Array.Empty<string>();
 1354
 1355            // Set album artist to artist if empty
 21356            if (audio.AlbumArtists.Length == 0)
 1357            {
 01358                audio.AlbumArtists = audio.Artists;
 1359            }
 1360
 1361            // Track number
 21362            audio.IndexNumber = GetDictionaryTrackOrDiscNumber(tags, "track");
 1363
 1364            // Disc number
 21365            audio.ParentIndexNumber = GetDictionaryTrackOrDiscNumber(tags, "disc");
 1366
 1367            // There's several values in tags may or may not be present
 21368            FetchStudios(audio, tags, "organization");
 21369            FetchStudios(audio, tags, "ensemble");
 21370            FetchStudios(audio, tags, "publisher");
 21371            FetchStudios(audio, tags, "label");
 1372
 1373            // These support multiple values, but for now we only store the first.
 21374            var mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Album Artist Id"))
 21375                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ALBUMARTISTID"));
 21376            audio.TrySetProviderId(MetadataProvider.MusicBrainzAlbumArtist, mb);
 1377
 21378            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Artist Id"))
 21379                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ARTISTID"));
 21380            audio.TrySetProviderId(MetadataProvider.MusicBrainzArtist, mb);
 1381
 21382            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Album Id"))
 21383                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ALBUMID"));
 21384            audio.TrySetProviderId(MetadataProvider.MusicBrainzAlbum, mb);
 1385
 21386            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Release Group Id"))
 21387                 ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_RELEASEGROUPID"));
 21388            audio.TrySetProviderId(MetadataProvider.MusicBrainzReleaseGroup, mb);
 1389
 21390            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Release Track Id"))
 21391                 ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_RELEASETRACKID"));
 21392            audio.TrySetProviderId(MetadataProvider.MusicBrainzTrack, mb);
 21393        }
 1394
 1395        private static string GetMultipleMusicBrainzId(string value)
 1396        {
 201397            if (string.IsNullOrWhiteSpace(value))
 1398            {
 101399                return null;
 1400            }
 1401
 101402            return value.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
 101403                .FirstOrDefault();
 1404        }
 1405
 1406        /// <summary>
 1407        /// Splits the specified val.
 1408        /// </summary>
 1409        /// <param name="val">The val.</param>
 1410        /// <param name="allowCommaDelimiter">if set to <c>true</c> [allow comma delimiter].</param>
 1411        /// <returns>System.String[][].</returns>
 1412        private string[] Split(string val, bool allowCommaDelimiter)
 1413        {
 1414            // Only use the comma as a delimiter if there are no slashes or pipes.
 1415            // We want to be careful not to split names that have commas in them
 141416            return !allowCommaDelimiter || _nameDelimiters.Any(i => val.Contains(i, StringComparison.Ordinal)) ?
 141417                val.Split(_nameDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) :
 141418                val.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
 1419        }
 1420
 1421        private IEnumerable<string> SplitDistinctArtists(string val, char[] delimiters, bool splitFeaturing)
 1422        {
 51423            if (splitFeaturing)
 1424            {
 31425                val = val.Replace(" featuring ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase)
 31426                    .Replace(" feat. ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase);
 1427            }
 1428
 51429            var artistsFound = new List<string>();
 1430
 3001431            foreach (var whitelistArtist in SplitWhitelist)
 1432            {
 1451433                var originalVal = val;
 1451434                val = val.Replace(whitelistArtist, "|", StringComparison.OrdinalIgnoreCase);
 1435
 1451436                if (!string.Equals(originalVal, val, StringComparison.OrdinalIgnoreCase))
 1437                {
 01438                    artistsFound.Add(whitelistArtist);
 1439                }
 1440            }
 1441
 51442            var artists = val.Split(delimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
 1443
 51444            artistsFound.AddRange(artists);
 51445            return artistsFound.DistinctNames();
 1446        }
 1447
 1448        /// <summary>
 1449        /// Gets the studios from the tags collection.
 1450        /// </summary>
 1451        /// <param name="info">The info.</param>
 1452        /// <param name="tags">The tags.</param>
 1453        /// <param name="tagName">Name of the tag.</param>
 1454        private void FetchStudios(MediaInfo info, IReadOnlyDictionary<string, string> tags, string tagName)
 1455        {
 171456            var val = tags.GetValueOrDefault(tagName);
 1457
 171458            if (string.IsNullOrEmpty(val))
 1459            {
 151460                return;
 1461            }
 1462
 21463            var studios = Split(val, true);
 21464            var studioList = new List<string>();
 1465
 81466            foreach (var studio in studios)
 1467            {
 21468                if (string.IsNullOrWhiteSpace(studio))
 1469                {
 1470                    continue;
 1471                }
 1472
 1473                // Don't add artist/album artist name to studios, even if it's listed there
 21474                if (info.Artists.Contains(studio, StringComparison.OrdinalIgnoreCase)
 21475                    || info.AlbumArtists.Contains(studio, StringComparison.OrdinalIgnoreCase))
 1476                {
 1477                    continue;
 1478                }
 1479
 21480                studioList.Add(studio);
 1481            }
 1482
 21483            info.Studios = studioList
 21484                .Distinct(StringComparer.OrdinalIgnoreCase)
 21485                .ToArray();
 21486        }
 1487
 1488        /// <summary>
 1489        /// Gets the genres from the tags collection.
 1490        /// </summary>
 1491        /// <param name="info">The information.</param>
 1492        /// <param name="tags">The tags.</param>
 1493        private void FetchGenres(MediaInfo info, IReadOnlyDictionary<string, string> tags)
 1494        {
 111495            var genreVal = tags.GetValueOrDefault("genre");
 111496            if (string.IsNullOrEmpty(genreVal))
 1497            {
 91498                return;
 1499            }
 1500
 21501            var genres = new List<string>(info.Genres);
 201502            foreach (var genre in Split(genreVal, true))
 1503            {
 81504                if (string.IsNullOrEmpty(genre))
 1505                {
 1506                    continue;
 1507                }
 1508
 81509                genres.Add(genre);
 1510            }
 1511
 21512            info.Genres = genres
 21513                .Distinct(StringComparer.OrdinalIgnoreCase)
 21514                .ToArray();
 21515        }
 1516
 1517        /// <summary>
 1518        /// Gets the track or disc number, which can be in the form of '1', or '1/3'.
 1519        /// </summary>
 1520        /// <param name="tags">The tags.</param>
 1521        /// <param name="tagName">Name of the tag.</param>
 1522        /// <returns>The track or disc number, or null, if missing or not parseable.</returns>
 1523        private static int? GetDictionaryTrackOrDiscNumber(IReadOnlyDictionary<string, string> tags, string tagName)
 1524        {
 41525            var disc = tags.GetValueOrDefault(tagName);
 1526
 41527            if (int.TryParse(disc.AsSpan().LeftPart('/'), out var discNum))
 1528            {
 41529                return discNum;
 1530            }
 1531
 01532            return null;
 1533        }
 1534
 1535        private static ChapterInfo GetChapterInfo(MediaChapter chapter)
 1536        {
 01537            var info = new ChapterInfo();
 1538
 01539            if (chapter.Tags is not null && chapter.Tags.TryGetValue("title", out string name))
 1540            {
 01541                info.Name = name;
 1542            }
 1543
 1544            // Limit accuracy to milliseconds to match xml saving
 01545            var secondsString = chapter.StartTime;
 1546
 01547            if (double.TryParse(secondsString, CultureInfo.InvariantCulture, out var seconds))
 1548            {
 01549                var ms = Math.Round(TimeSpan.FromSeconds(seconds).TotalMilliseconds);
 01550                info.StartPositionTicks = TimeSpan.FromMilliseconds(ms).Ticks;
 1551            }
 1552
 01553            return info;
 1554        }
 1555
 1556        private void FetchWtvInfo(MediaInfo video, InternalMediaInfoResult data)
 1557        {
 91558            var tags = data.Format?.Tags;
 1559
 91560            if (tags is null)
 1561            {
 31562                return;
 1563            }
 1564
 61565            if (tags.TryGetValue("WM/Genre", out var genres) && !string.IsNullOrWhiteSpace(genres))
 1566            {
 01567                var genreList = genres.Split(_genreDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOption
 1568
 1569                // If this is empty then don't overwrite genres that might have been fetched earlier
 01570                if (genreList.Length > 0)
 1571                {
 01572                    video.Genres = genreList;
 1573                }
 1574            }
 1575
 61576            if (tags.TryGetValue("WM/ParentalRating", out var officialRating) && !string.IsNullOrWhiteSpace(officialRati
 1577            {
 01578                video.OfficialRating = officialRating;
 1579            }
 1580
 61581            if (tags.TryGetValue("WM/MediaCredits", out var people) && !string.IsNullOrEmpty(people))
 1582            {
 01583                video.People = Array.ConvertAll(
 01584                    people.Split(_basicDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntrie
 01585                    i => new BaseItemPerson { Name = i, Type = PersonKind.Actor });
 1586            }
 1587
 61588            if (tags.TryGetValue("WM/OriginalReleaseTime", out var year) && int.TryParse(year, NumberStyles.Integer, Cul
 1589            {
 01590                video.ProductionYear = parsedYear;
 1591            }
 1592
 1593            // Credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
 1594            // DateTime is reported along with timezone info (typically Z i.e. UTC hence assume None)
 61595            if (tags.TryGetValue("WM/MediaOriginalBroadcastDateTime", out var premiereDateString) && DateTime.TryParse(y
 1596            {
 01597                video.PremiereDate = parsedDate;
 1598            }
 1599
 61600            var description = tags.GetValueOrDefault("WM/SubTitleDescription");
 1601
 61602            var subTitle = tags.GetValueOrDefault("WM/SubTitle");
 1603
 1604            // For below code, credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
 1605
 1606            // Sometimes for TV Shows the Subtitle field is empty and the subtitle description contains the subtitle, ex
 1607            // The format is -> EPISODE/TOTAL_EPISODES_IN_SEASON. SUBTITLE: DESCRIPTION
 1608            // OR -> COMMENT. SUBTITLE: DESCRIPTION
 1609            // e.g. -> 4/13. The Doctor's Wife: Science fiction drama. When he follows a Time Lord distress signal, the 
 1610            // e.g. -> CBeebies Bedtime Hour. The Mystery: Animated adventures of two friends who live on an island in t
 61611            if (string.IsNullOrWhiteSpace(subTitle)
 61612                && !string.IsNullOrWhiteSpace(description)
 61613                && description.AsSpan()[..Math.Min(description.Length, MaxSubtitleDescriptionExtractionLength)].Contains
 1614            {
 01615                string[] descriptionParts = description.Split(':');
 01616                if (descriptionParts.Length > 0)
 1617                {
 01618                    string subtitle = descriptionParts[0];
 1619                    try
 1620                    {
 1621                        // Check if it contains a episode number and season number
 01622                        if (subtitle.Contains('/', StringComparison.Ordinal))
 1623                        {
 01624                            string[] subtitleParts = subtitle.Split(' ');
 01625                            string[] numbers = subtitleParts[0].Replace(".", string.Empty, StringComparison.Ordinal).Spl
 01626                            video.IndexNumber = int.Parse(numbers[0], CultureInfo.InvariantCulture);
 1627                            // int totalEpisodesInSeason = int.Parse(numbers[1], CultureInfo.InvariantCulture);
 1628
 1629                            // Skip the numbers, concatenate the rest, trim and set as new description
 01630                            description = string.Join(' ', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1631                        }
 01632                        else if (subtitle.Contains('.', StringComparison.Ordinal))
 1633                        {
 01634                            var subtitleParts = subtitle.Split('.');
 01635                            description = string.Join('.', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1636                        }
 1637                        else
 1638                        {
 01639                            description = subtitle.Trim();
 1640                        }
 01641                    }
 01642                    catch (Exception ex)
 1643                    {
 01644                        _logger.LogError(ex, "Error while parsing subtitle field");
 1645
 1646                        // Fallback to default parsing
 01647                        if (subtitle.Contains('.', StringComparison.Ordinal))
 1648                        {
 01649                            var subtitleParts = subtitle.Split('.');
 01650                            description = string.Join('.', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1651                        }
 1652                        else
 1653                        {
 01654                            description = subtitle.Trim();
 1655                        }
 01656                    }
 1657                }
 1658            }
 1659
 61660            if (!string.IsNullOrWhiteSpace(description))
 1661            {
 01662                video.Overview = description;
 1663            }
 61664        }
 1665
 1666        private void ExtractTimestamp(MediaInfo video)
 1667        {
 91668            if (video.VideoType != VideoType.VideoFile)
 1669            {
 01670                return;
 1671            }
 1672
 91673            if (!string.Equals(video.Container, "mpeg2ts", StringComparison.OrdinalIgnoreCase)
 91674                && !string.Equals(video.Container, "m2ts", StringComparison.OrdinalIgnoreCase)
 91675                && !string.Equals(video.Container, "ts", StringComparison.OrdinalIgnoreCase))
 1676            {
 81677                return;
 1678            }
 1679
 1680            try
 1681            {
 11682                video.Timestamp = GetMpegTimestamp(video.Path);
 01683                _logger.LogDebug("Video has {Timestamp} timestamp", video.Timestamp);
 01684            }
 11685            catch (Exception ex)
 1686            {
 11687                video.Timestamp = null;
 11688                _logger.LogError(ex, "Error extracting timestamp info from {Path}", video.Path);
 11689            }
 11690        }
 1691
 1692        // REVIEW: find out why the byte array needs to be 197 bytes long and comment the reason
 1693        private static TransportStreamTimestamp GetMpegTimestamp(string path)
 1694        {
 11695            var packetBuffer = new byte[197];
 1696
 11697            using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 1))
 1698            {
 01699                fs.ReadExactly(packetBuffer);
 01700            }
 1701
 01702            if (packetBuffer[0] == 71)
 1703            {
 01704                return TransportStreamTimestamp.None;
 1705            }
 1706
 01707            if ((packetBuffer[4] != 71) || (packetBuffer[196] != 71))
 1708            {
 01709                return TransportStreamTimestamp.None;
 1710            }
 1711
 01712            if ((packetBuffer[0] == 0) && (packetBuffer[1] == 0) && (packetBuffer[2] == 0) && (packetBuffer[3] == 0))
 1713            {
 01714                return TransportStreamTimestamp.Zero;
 1715            }
 1716
 01717            return TransportStreamTimestamp.Valid;
 1718        }
 1719
 1720        [GeneratedRegex("(?<name>.*) \\((?<instrument>.*)\\)")]
 1721        private static partial Regex PerformerRegex();
 1722    }
 1723}

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)
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)