< 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: 597
Uncovered lines: 154
Coverable lines: 751
Total lines: 1731
Line coverage: 79.4%
Branch coverage
75%
Covered branches: 468
Total branches: 620
Branch coverage: 75.4%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 9/28/2025 - 12:11:28 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: 172312/29/2025 - 12:13:19 AM Line coverage: 79.4% (597/751) Branch coverage: 75.4% (468/620) Total lines: 1731 9/28/2025 - 12:11:28 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: 172312/29/2025 - 12:13:19 AM Line coverage: 79.4% (597/751) Branch coverage: 75.4% (468/620) Total lines: 1731

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor(...)100%11100%
get_SplitWhitelist()100%22100%
GetMediaInfo(...)84.21%787693.02%
NormalizeFormat(...)87.5%171687.5%
GetEstimatedAudioBitrate(...)50%622662.5%
FetchFromItunesInfo(...)83.33%141276.92%
ReadFromDictNode(...)90%212087.09%
ReadValueArray(...)83.33%141277.77%
ProcessPairs(...)64.28%441446.66%
GetNameValuePair(...)92.85%141490.9%
NormalizeSubtitleCodec(...)62.5%10866.66%
GetMediaAttachment(...)90%1010100%
GetMediaStream(...)78.94%29715281.54%
NormalizeStreamTitle(...)100%44100%
GetDictionaryValue(...)100%22100%
ParseChannelLayout(...)100%22100%
GetAspectRatio(...)85.29%393483.87%
IsClose(...)100%11100%
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        {
 2251            _logger = logger;
 2252            _localization = localization;
 2253        }
 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        {
 1299            var info = new MediaInfo
 12100            {
 12101                Path = path,
 12102                Protocol = protocol,
 12103                VideoType = videoType
 12104            };
 105
 12106            FFProbeHelpers.NormalizeFFProbeResult(data);
 12107            SetSize(data, info);
 108
 12109            var internalStreams = data.Streams ?? Array.Empty<MediaStreamInfo>();
 12110            var internalFrames = data.Frames ?? Array.Empty<MediaFrameInfo>();
 111
 12112            info.MediaStreams = internalStreams.Select(s => GetMediaStream(isAudio, s, data.Format, internalFrames))
 12113                .Where(i => i is not null)
 12114                // Drop subtitle streams if we don't know the codec because it will just cause failures if we don't know
 12115                .Where(i => i.Type != MediaStreamType.Subtitle || !string.IsNullOrWhiteSpace(i.Codec))
 12116                .ToList();
 117
 12118            info.MediaAttachments = internalStreams.Select(GetMediaAttachment)
 12119                .Where(i => i is not null)
 12120                .ToList();
 121
 12122            if (data.Format is not null)
 123            {
 11124                info.Container = NormalizeFormat(data.Format.FormatName, info.MediaStreams);
 125
 11126                if (int.TryParse(data.Format.BitRate, CultureInfo.InvariantCulture, out var value))
 127                {
 11128                    info.Bitrate = value;
 129                }
 130            }
 131
 12132            var tags = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 12133            var tagStreamType = isAudio ? CodecType.Audio : CodecType.Video;
 134
 12135            var tagStream = data.Streams?.FirstOrDefault(i => i.CodecType == tagStreamType);
 136
 12137            if (tagStream?.Tags is not null)
 138            {
 74139                foreach (var (key, value) in tagStream.Tags)
 140                {
 28141                    tags[key] = value;
 142                }
 143            }
 144
 12145            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
 12153            FetchGenres(info, tags);
 154
 12155            info.Name = tags.GetFirstNotNullNorWhiteSpaceValue("title", "title-eng");
 12156            info.ForcedSortName = tags.GetFirstNotNullNorWhiteSpaceValue("sort_name", "title-sort", "titlesort");
 12157            info.Overview = tags.GetFirstNotNullNorWhiteSpaceValue("synopsis", "description", "desc", "comment");
 158
 12159            info.ParentIndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "season_number");
 12160            info.IndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "episode_sort") ??
 12161                               FFProbeHelpers.GetDictionaryNumericValue(tags, "episode_id");
 12162            info.ShowName = tags.GetValueOrDefault("show_name", "show");
 12163            info.ProductionYear = FFProbeHelpers.GetDictionaryNumericValue(tags, "date");
 164
 165            // Several different forms of retail/premiere date
 12166            info.PremiereDate =
 12167                FFProbeHelpers.GetDictionaryDateTime(tags, "originaldate") ??
 12168                FFProbeHelpers.GetDictionaryDateTime(tags, "retaildate") ??
 12169                FFProbeHelpers.GetDictionaryDateTime(tags, "retail date") ??
 12170                FFProbeHelpers.GetDictionaryDateTime(tags, "retail_date") ??
 12171                FFProbeHelpers.GetDictionaryDateTime(tags, "date_released") ??
 12172                FFProbeHelpers.GetDictionaryDateTime(tags, "date") ??
 12173                FFProbeHelpers.GetDictionaryDateTime(tags, "creation_time");
 174
 175            // Set common metadata for music (audio) and music videos (video)
 12176            info.Album = tags.GetValueOrDefault("album");
 177
 12178            if (tags.TryGetValue("artists", out var artists) && !string.IsNullOrWhiteSpace(artists))
 179            {
 2180                info.Artists = SplitDistinctArtists(artists, _basicDelimiters, false).ToArray();
 181            }
 182            else
 183            {
 10184                var artist = tags.GetFirstNotNullNorWhiteSpaceValue("artist");
 10185                info.Artists = artist is null
 10186                    ? Array.Empty<string>()
 10187                    : SplitDistinctArtists(artist, _nameDelimiters, true).ToArray();
 188            }
 189
 190            // Guess ProductionYear from PremiereDate if missing
 12191            if (!info.ProductionYear.HasValue && info.PremiereDate.HasValue)
 192            {
 5193                info.ProductionYear = info.PremiereDate.Value.Year;
 194            }
 195
 196            // Set mediaType-specific metadata
 12197            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            {
 10208                FetchStudios(info, tags, "copyright");
 209
 10210                var iTunExtc = tags.GetFirstNotNullNorWhiteSpaceValue("iTunEXTC");
 10211                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
 10227                var iTunXml = tags.GetFirstNotNullNorWhiteSpaceValue("iTunMOVI");
 10228                if (iTunXml is not null)
 229                {
 1230                    FetchFromItunesInfo(iTunXml, info);
 231                }
 232
 10233                if (data.Format is not null && !string.IsNullOrEmpty(data.Format.Duration))
 234                {
 9235                    info.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.Format.Duration, CultureInfo.InvariantCul
 236                }
 237
 10238                FetchWtvInfo(info, data);
 239
 10240                if (data.Chapters is not null)
 241                {
 3242                    info.Chapters = data.Chapters.Select(GetChapterInfo).ToArray();
 243                }
 244
 10245                ExtractTimestamp(info);
 246
 10247                if (tags.TryGetValue("stereo_mode", out var stereoMode) && string.Equals(stereoMode, "left_right", Strin
 248                {
 0249                    info.Video3DFormat = Video3DFormat.FullSideBySide;
 250                }
 251
 70252                foreach (var mediaStream in info.MediaStreams)
 253                {
 25254                    if (mediaStream.Type == MediaStreamType.Audio && !mediaStream.BitRate.HasValue)
 255                    {
 3256                        mediaStream.BitRate = GetEstimatedAudioBitrate(mediaStream.Codec, mediaStream.Channels);
 257                    }
 258                }
 259
 10260                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
 10262                if (videoStreamsBitrate == (info.Bitrate ?? 0))
 263                {
 6264                    info.InferTotalBitrate(true);
 265                }
 266            }
 267
 12268            return info;
 269        }
 270
 271        private string NormalizeFormat(string format, IReadOnlyList<MediaStream> mediaStreams)
 272        {
 11273            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
 11279            var splitFormat = format.Split(',');
 84280            for (var i = 0; i < splitFormat.Length; i++)
 281            {
 282                // Handle MPEG-1 container
 31283                if (string.Equals(splitFormat[i], "mpegvideo", StringComparison.OrdinalIgnoreCase))
 284                {
 0285                    splitFormat[i] = "mpeg";
 286                }
 287
 288                // Handle MPEG-TS container
 31289                else if (string.Equals(splitFormat[i], "mpegts", StringComparison.OrdinalIgnoreCase))
 290                {
 1291                    splitFormat[i] = "ts";
 292                }
 293
 294                // Handle matroska container
 30295                else if (string.Equals(splitFormat[i], "matroska", StringComparison.OrdinalIgnoreCase))
 296                {
 5297                    splitFormat[i] = "mkv";
 298                }
 299
 300                // Handle WebM
 25301                else if (string.Equals(splitFormat[i], "webm", StringComparison.OrdinalIgnoreCase))
 302                {
 303                    // Limit WebM to supported stream types and codecs.
 304                    // FFprobe can report "matroska,webm" for Matroska-like containers, so only keep "webm" if all strea
 305                    // Any stream that is not video nor audio is not supported in WebM and should disqualify the webm co
 5306                    if (mediaStreams.Any(stream => stream.Type is not MediaStreamType.Video and not MediaStreamType.Audi
 5307                        || mediaStreams.Any(stream => (stream.Type == MediaStreamType.Video && !_webmVideoCodecs.Contain
 5308                            || (stream.Type == MediaStreamType.Audio && !_webmAudioCodecs.Contains(stream.Codec, StringC
 309                    {
 4310                        splitFormat[i] = string.Empty;
 311                    }
 312                }
 313            }
 314
 11315            return string.Join(',', splitFormat.Where(s => !string.IsNullOrEmpty(s)));
 316        }
 317
 318        private static int? GetEstimatedAudioBitrate(string codec, int? channels)
 319        {
 3320            if (!channels.HasValue)
 321            {
 0322                return null;
 323            }
 324
 3325            var channelsValue = channels.Value;
 326
 3327            if (string.Equals(codec, "aac", StringComparison.OrdinalIgnoreCase)
 3328                || string.Equals(codec, "mp3", StringComparison.OrdinalIgnoreCase))
 329            {
 330                switch (channelsValue)
 331                {
 332                    case <= 2:
 1333                        return 192000;
 334                    case >= 5:
 0335                        return 320000;
 336                }
 337            }
 338
 2339            if (string.Equals(codec, "ac3", StringComparison.OrdinalIgnoreCase)
 2340                || string.Equals(codec, "eac3", StringComparison.OrdinalIgnoreCase))
 341            {
 342                switch (channelsValue)
 343                {
 344                    case <= 2:
 0345                        return 192000;
 346                    case >= 5:
 0347                        return 640000;
 348                }
 349            }
 350
 2351            if (string.Equals(codec, "flac", StringComparison.OrdinalIgnoreCase)
 2352                || string.Equals(codec, "alac", StringComparison.OrdinalIgnoreCase))
 353            {
 354                switch (channelsValue)
 355                {
 356                    case <= 2:
 0357                        return 960000;
 358                    case >= 5:
 0359                        return 2880000;
 360                }
 361            }
 362
 2363            return null;
 364        }
 365
 366        private void FetchFromItunesInfo(string xml, MediaInfo info)
 367        {
 368            // Make things simpler and strip out the dtd
 1369            var plistIndex = xml.IndexOf("<plist", StringComparison.OrdinalIgnoreCase);
 370
 1371            if (plistIndex != -1)
 372            {
 1373                xml = xml.Substring(plistIndex);
 374            }
 375
 1376            xml = "<?xml version=\"1.0\"?>" + xml;
 377
 378            // <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http
 1379            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)))
 1380            using (var streamReader = new StreamReader(stream))
 381            {
 382                try
 383                {
 1384                    using (var reader = XmlReader.Create(streamReader))
 385                    {
 1386                        reader.MoveToContent();
 1387                        reader.Read();
 388
 389                        // Loop through each element
 4390                        while (!reader.EOF && reader.ReadState == ReadState.Interactive)
 391                        {
 3392                            if (reader.NodeType == XmlNodeType.Element)
 393                            {
 1394                                switch (reader.Name)
 395                                {
 396                                    case "dict":
 1397                                        if (reader.IsEmptyElement)
 398                                        {
 0399                                            reader.Read();
 0400                                            continue;
 401                                        }
 402
 1403                                        using (var subtree = reader.ReadSubtree())
 404                                        {
 1405                                            ReadFromDictNode(subtree, info);
 1406                                        }
 407
 408                                        break;
 409                                    default:
 0410                                        reader.Skip();
 0411                                        break;
 412                                }
 413                            }
 414                            else
 415                            {
 2416                                reader.Read();
 417                            }
 418                        }
 1419                    }
 1420                }
 0421                catch (XmlException)
 422                {
 423                    // I've seen probe examples where the iTunMOVI value is just "<"
 424                    // So we should not allow this to fail the entire probing operation
 0425                }
 426            }
 1427        }
 428
 429        private void ReadFromDictNode(XmlReader reader, MediaInfo info)
 430        {
 1431            string currentKey = null;
 1432            var pairs = new List<NameValuePair>();
 433
 1434            reader.MoveToContent();
 1435            reader.Read();
 436
 437            // Loop through each element
 19438            while (!reader.EOF && reader.ReadState == ReadState.Interactive)
 439            {
 18440                if (reader.NodeType == XmlNodeType.Element)
 441                {
 12442                    switch (reader.Name)
 443                    {
 444                        case "key":
 6445                            if (!string.IsNullOrWhiteSpace(currentKey))
 446                            {
 5447                                ProcessPairs(currentKey, pairs, info);
 448                            }
 449
 6450                            currentKey = reader.ReadElementContentAsString();
 6451                            pairs = new List<NameValuePair>();
 6452                            break;
 453                        case "string":
 1454                            var value = reader.ReadElementContentAsString();
 1455                            if (!string.IsNullOrWhiteSpace(value))
 456                            {
 1457                                pairs.Add(new NameValuePair
 1458                                {
 1459                                    Name = value,
 1460                                    Value = value
 1461                                });
 462                            }
 463
 1464                            break;
 465                        case "array":
 5466                            if (reader.IsEmptyElement)
 467                            {
 0468                                reader.Read();
 0469                                continue;
 470                            }
 471
 5472                            using (var subtree = reader.ReadSubtree())
 473                            {
 5474                                if (!string.IsNullOrWhiteSpace(currentKey))
 475                                {
 5476                                    pairs.AddRange(ReadValueArray(subtree));
 477                                }
 5478                            }
 479
 480                            break;
 481                        default:
 0482                            reader.Skip();
 0483                            break;
 484                    }
 485                }
 486                else
 487                {
 6488                    reader.Read();
 489                }
 490            }
 1491        }
 492
 493        private List<NameValuePair> ReadValueArray(XmlReader reader)
 494        {
 5495            var pairs = new List<NameValuePair>();
 496
 5497            reader.MoveToContent();
 5498            reader.Read();
 499
 500            // Loop through each element
 20501            while (!reader.EOF && reader.ReadState == ReadState.Interactive)
 502            {
 15503                if (reader.NodeType == XmlNodeType.Element)
 504                {
 5505                    switch (reader.Name)
 506                    {
 507                        case "dict":
 508
 5509                            if (reader.IsEmptyElement)
 510                            {
 0511                                reader.Read();
 0512                                continue;
 513                            }
 514
 5515                            using (var subtree = reader.ReadSubtree())
 516                            {
 5517                                var dict = GetNameValuePair(subtree);
 5518                                if (dict is not null)
 519                                {
 1520                                    pairs.Add(dict);
 521                                }
 5522                            }
 523
 524                            break;
 525                        default:
 0526                            reader.Skip();
 0527                            break;
 528                    }
 529                }
 530                else
 531                {
 10532                    reader.Read();
 533                }
 534            }
 535
 5536            return pairs;
 537        }
 538
 539        private static void ProcessPairs(string key, List<NameValuePair> pairs, MediaInfo info)
 540        {
 5541            List<BaseItemPerson> peoples = new List<BaseItemPerson>();
 5542            var distinctPairs = pairs.Select(p => p.Value)
 5543                    .Where(i => !string.IsNullOrWhiteSpace(i))
 5544                    .Trimmed()
 5545                    .Distinct(StringComparer.OrdinalIgnoreCase);
 546
 5547            if (string.Equals(key, "studio", StringComparison.OrdinalIgnoreCase))
 548            {
 1549                info.Studios = distinctPairs.ToArray();
 550            }
 4551            else if (string.Equals(key, "screenwriters", StringComparison.OrdinalIgnoreCase))
 552            {
 0553                foreach (var pair in distinctPairs)
 554                {
 0555                    peoples.Add(new BaseItemPerson
 0556                    {
 0557                        Name = pair,
 0558                        Type = PersonKind.Writer
 0559                    });
 560                }
 561            }
 4562            else if (string.Equals(key, "producers", StringComparison.OrdinalIgnoreCase))
 563            {
 2564                foreach (var pair in distinctPairs)
 565                {
 0566                    peoples.Add(new BaseItemPerson
 0567                    {
 0568                        Name = pair,
 0569                        Type = PersonKind.Producer
 0570                    });
 571                }
 572            }
 3573            else if (string.Equals(key, "directors", StringComparison.OrdinalIgnoreCase))
 574            {
 2575                foreach (var pair in distinctPairs)
 576                {
 0577                    peoples.Add(new BaseItemPerson
 0578                    {
 0579                        Name = pair,
 0580                        Type = PersonKind.Director
 0581                    });
 582                }
 583            }
 584
 5585            info.People = peoples.ToArray();
 5586        }
 587
 588        private static NameValuePair GetNameValuePair(XmlReader reader)
 589        {
 5590            string name = null;
 5591            string value = null;
 592
 5593            reader.MoveToContent();
 5594            reader.Read();
 595
 596            // Loop through each element
 20597            while (!reader.EOF && reader.ReadState == ReadState.Interactive)
 598            {
 15599                if (reader.NodeType == XmlNodeType.Element)
 600                {
 10601                    switch (reader.Name)
 602                    {
 603                        case "key":
 5604                            name = reader.ReadNormalizedString();
 5605                            break;
 606                        case "string":
 5607                            value = reader.ReadNormalizedString();
 5608                            break;
 609                        default:
 0610                            reader.Skip();
 0611                            break;
 612                    }
 613                }
 614                else
 615                {
 5616                    reader.Read();
 617                }
 618            }
 619
 5620            if (string.IsNullOrEmpty(name)
 5621                || string.IsNullOrEmpty(value))
 622            {
 4623                return null;
 624            }
 625
 1626            return new NameValuePair
 1627            {
 1628                Name = name,
 1629                Value = value
 1630            };
 631        }
 632
 633        private static string NormalizeSubtitleCodec(string codec)
 634        {
 4635            if (string.Equals(codec, "dvb_subtitle", StringComparison.OrdinalIgnoreCase))
 636            {
 0637                codec = "DVBSUB";
 638            }
 4639            else if (string.Equals(codec, "dvb_teletext", StringComparison.OrdinalIgnoreCase))
 640            {
 0641                codec = "DVBTXT";
 642            }
 4643            else if (string.Equals(codec, "dvd_subtitle", StringComparison.OrdinalIgnoreCase))
 644            {
 1645                codec = "DVDSUB"; // .sub+.idx
 646            }
 3647            else if (string.Equals(codec, "hdmv_pgs_subtitle", StringComparison.OrdinalIgnoreCase))
 648            {
 0649                codec = "PGSSUB"; // .sup
 650            }
 651
 4652            return codec;
 653        }
 654
 655        /// <summary>
 656        /// Converts ffprobe stream info to our MediaAttachment class.
 657        /// </summary>
 658        /// <param name="streamInfo">The stream info.</param>
 659        /// <returns>MediaAttachments.</returns>
 660        private MediaAttachment GetMediaAttachment(MediaStreamInfo streamInfo)
 661        {
 29662            if (streamInfo.CodecType != CodecType.Attachment
 29663                && streamInfo.Disposition?.GetValueOrDefault("attached_pic") != 1)
 664            {
 27665                return null;
 666            }
 667
 2668            var attachment = new MediaAttachment
 2669            {
 2670                Codec = streamInfo.CodecName,
 2671                Index = streamInfo.Index
 2672            };
 673
 2674            if (!string.IsNullOrWhiteSpace(streamInfo.CodecTagString))
 675            {
 2676                attachment.CodecTag = streamInfo.CodecTagString;
 677            }
 678
 2679            if (streamInfo.Tags is not null)
 680            {
 2681                attachment.FileName = GetDictionaryValue(streamInfo.Tags, "filename");
 2682                attachment.MimeType = GetDictionaryValue(streamInfo.Tags, "mimetype");
 2683                attachment.Comment = GetDictionaryValue(streamInfo.Tags, "comment");
 684            }
 685
 2686            return attachment;
 687        }
 688
 689        /// <summary>
 690        /// Converts ffprobe stream info to our MediaStream class.
 691        /// </summary>
 692        /// <param name="isAudio">if set to <c>true</c> [is info].</param>
 693        /// <param name="streamInfo">The stream info.</param>
 694        /// <param name="formatInfo">The format info.</param>
 695        /// <param name="frameInfoList">The frame info.</param>
 696        /// <returns>MediaStream.</returns>
 697        private MediaStream GetMediaStream(bool isAudio, MediaStreamInfo streamInfo, MediaFormatInfo formatInfo, IReadOn
 698        {
 699            // These are mp4 chapters
 29700            if (string.Equals(streamInfo.CodecName, "mov_text", StringComparison.OrdinalIgnoreCase))
 701            {
 702                // Edit: but these are also sometimes subtitles?
 703                // return null;
 704            }
 705
 29706            var stream = new MediaStream
 29707            {
 29708                Codec = streamInfo.CodecName,
 29709                Profile = streamInfo.Profile,
 29710                Level = streamInfo.Level,
 29711                Index = streamInfo.Index,
 29712                PixelFormat = streamInfo.PixelFormat,
 29713                NalLengthSize = streamInfo.NalLengthSize,
 29714                TimeBase = streamInfo.TimeBase,
 29715                CodecTimeBase = streamInfo.CodecTimeBase,
 29716                IsAVC = streamInfo.IsAvc
 29717            };
 718
 719            // Filter out junk
 29720            if (!string.IsNullOrWhiteSpace(streamInfo.CodecTagString) && !streamInfo.CodecTagString.Contains("[0]", Stri
 721            {
 10722                stream.CodecTag = streamInfo.CodecTagString;
 723            }
 724
 29725            if (streamInfo.Tags is not null)
 726            {
 25727                stream.Language = GetDictionaryValue(streamInfo.Tags, "language");
 25728                stream.Comment = GetDictionaryValue(streamInfo.Tags, "comment");
 25729                stream.Title = GetDictionaryValue(streamInfo.Tags, "title");
 730            }
 731
 29732            if (streamInfo.CodecType == CodecType.Audio)
 733            {
 12734                stream.Type = MediaStreamType.Audio;
 12735                stream.LocalizedDefault = _localization.GetLocalizedString("Default");
 12736                stream.LocalizedExternal = _localization.GetLocalizedString("External");
 737
 12738                stream.Channels = streamInfo.Channels;
 739
 12740                if (int.TryParse(streamInfo.SampleRate, CultureInfo.InvariantCulture, out var sampleRate))
 741                {
 12742                    stream.SampleRate = sampleRate;
 743                }
 744
 12745                stream.ChannelLayout = ParseChannelLayout(streamInfo.ChannelLayout);
 746
 12747                if (streamInfo.BitsPerSample > 0)
 748                {
 0749                    stream.BitDepth = streamInfo.BitsPerSample;
 750                }
 12751                else if (streamInfo.BitsPerRawSample > 0)
 752                {
 3753                    stream.BitDepth = streamInfo.BitsPerRawSample;
 754                }
 755
 12756                if (string.IsNullOrEmpty(stream.Title))
 757                {
 758                    // mp4 missing track title workaround: fall back to handler_name if populated and not the default "S
 12759                    string handlerName = GetDictionaryValue(streamInfo.Tags, "handler_name");
 12760                    if (!string.IsNullOrEmpty(handlerName) && !string.Equals(handlerName, "SoundHandler", StringComparis
 761                    {
 3762                        stream.Title = handlerName;
 763                    }
 764                }
 765            }
 17766            else if (streamInfo.CodecType == CodecType.Subtitle)
 767            {
 4768                stream.Type = MediaStreamType.Subtitle;
 4769                stream.Codec = NormalizeSubtitleCodec(stream.Codec);
 4770                stream.LocalizedUndefined = _localization.GetLocalizedString("Undefined");
 4771                stream.LocalizedDefault = _localization.GetLocalizedString("Default");
 4772                stream.LocalizedForced = _localization.GetLocalizedString("Forced");
 4773                stream.LocalizedExternal = _localization.GetLocalizedString("External");
 4774                stream.LocalizedHearingImpaired = _localization.GetLocalizedString("HearingImpaired");
 775
 776                // Graphical subtitle may have width and height info
 4777                stream.Width = streamInfo.Width;
 4778                stream.Height = streamInfo.Height;
 779
 4780                if (string.IsNullOrEmpty(stream.Title))
 781                {
 782                    // mp4 missing track title workaround: fall back to handler_name if populated and not the default "S
 4783                    string handlerName = GetDictionaryValue(streamInfo.Tags, "handler_name");
 4784                    if (!string.IsNullOrEmpty(handlerName) && !string.Equals(handlerName, "SubtitleHandler", StringCompa
 785                    {
 1786                        stream.Title = handlerName;
 787                    }
 788                }
 789            }
 13790            else if (streamInfo.CodecType == CodecType.Video)
 791            {
 13792                stream.AverageFrameRate = GetFrameRate(streamInfo.AverageFrameRate);
 13793                stream.RealFrameRate = GetFrameRate(streamInfo.RFrameRate);
 794
 13795                stream.IsInterlaced = !string.IsNullOrWhiteSpace(streamInfo.FieldOrder)
 13796                    && !string.Equals(streamInfo.FieldOrder, "progressive", StringComparison.OrdinalIgnoreCase);
 797
 13798                if (isAudio
 13799                    || string.Equals(stream.Codec, "bmp", StringComparison.OrdinalIgnoreCase)
 13800                    || string.Equals(stream.Codec, "gif", StringComparison.OrdinalIgnoreCase)
 13801                    || string.Equals(stream.Codec, "png", StringComparison.OrdinalIgnoreCase)
 13802                    || string.Equals(stream.Codec, "webp", StringComparison.OrdinalIgnoreCase))
 803                {
 2804                    stream.Type = MediaStreamType.EmbeddedImage;
 805                }
 11806                else if (string.Equals(stream.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase))
 807                {
 808                    // How to differentiate between video and embedded image?
 809                    // The only difference I've seen thus far is presence of codec tag, also embedded images have high (
 1810                    if (!string.IsNullOrWhiteSpace(stream.CodecTag))
 811                    {
 0812                        stream.Type = MediaStreamType.Video;
 813                    }
 814                    else
 815                    {
 1816                        stream.Type = MediaStreamType.EmbeddedImage;
 817                    }
 818                }
 819                else
 820                {
 10821                    stream.Type = MediaStreamType.Video;
 822                }
 823
 13824                stream.Width = streamInfo.Width;
 13825                stream.Height = streamInfo.Height;
 13826                stream.AspectRatio = GetAspectRatio(streamInfo);
 827
 13828                if (streamInfo.BitsPerSample > 0)
 829                {
 0830                    stream.BitDepth = streamInfo.BitsPerSample;
 831                }
 13832                else if (streamInfo.BitsPerRawSample > 0)
 833                {
 11834                    stream.BitDepth = streamInfo.BitsPerRawSample;
 835                }
 836
 13837                if (!stream.BitDepth.HasValue)
 838                {
 2839                    if (!string.IsNullOrEmpty(streamInfo.PixelFormat))
 840                    {
 2841                        if (string.Equals(streamInfo.PixelFormat, "yuv420p", StringComparison.OrdinalIgnoreCase)
 2842                            || string.Equals(streamInfo.PixelFormat, "yuv444p", StringComparison.OrdinalIgnoreCase))
 843                        {
 2844                            stream.BitDepth = 8;
 845                        }
 0846                        else if (string.Equals(streamInfo.PixelFormat, "yuv420p10le", StringComparison.OrdinalIgnoreCase
 0847                                 || string.Equals(streamInfo.PixelFormat, "yuv444p10le", StringComparison.OrdinalIgnoreC
 848                        {
 0849                            stream.BitDepth = 10;
 850                        }
 0851                        else if (string.Equals(streamInfo.PixelFormat, "yuv420p12le", StringComparison.OrdinalIgnoreCase
 0852                                 || string.Equals(streamInfo.PixelFormat, "yuv444p12le", StringComparison.OrdinalIgnoreC
 853                        {
 0854                            stream.BitDepth = 12;
 855                        }
 856                    }
 857                }
 858
 859                // http://stackoverflow.com/questions/17353387/how-to-detect-anamorphic-video-with-ffprobe
 13860                if (string.IsNullOrEmpty(streamInfo.SampleAspectRatio)
 13861                    && string.IsNullOrEmpty(streamInfo.DisplayAspectRatio))
 862                {
 2863                    stream.IsAnamorphic = false;
 864                }
 11865                else if (string.Equals(streamInfo.SampleAspectRatio, "1:1", StringComparison.Ordinal))
 866                {
 9867                    stream.IsAnamorphic = false;
 868                }
 2869                else if (!string.Equals(streamInfo.SampleAspectRatio, "0:1", StringComparison.Ordinal))
 870                {
 1871                    stream.IsAnamorphic = true;
 872                }
 1873                else if (string.Equals(streamInfo.DisplayAspectRatio, "0:1", StringComparison.Ordinal))
 874                {
 1875                    stream.IsAnamorphic = false;
 876                }
 0877                else if (!string.Equals(
 0878                             streamInfo.DisplayAspectRatio,
 0879                             // Force GetAspectRatio() to derive ratio from Width/Height directly by using null DAR
 0880                             GetAspectRatio(new MediaStreamInfo
 0881                             {
 0882                                 Width = streamInfo.Width,
 0883                                 Height = streamInfo.Height,
 0884                                 DisplayAspectRatio = null
 0885                             }),
 0886                             StringComparison.Ordinal))
 887                {
 0888                    stream.IsAnamorphic = true;
 889                }
 890                else
 891                {
 0892                    stream.IsAnamorphic = false;
 893                }
 894
 13895                if (streamInfo.Refs > 0)
 896                {
 13897                    stream.RefFrames = streamInfo.Refs;
 898                }
 899
 13900                if (!string.IsNullOrEmpty(streamInfo.ColorRange))
 901                {
 5902                    stream.ColorRange = streamInfo.ColorRange;
 903                }
 904
 13905                if (!string.IsNullOrEmpty(streamInfo.ColorSpace))
 906                {
 5907                    stream.ColorSpace = streamInfo.ColorSpace;
 908                }
 909
 13910                if (!string.IsNullOrEmpty(streamInfo.ColorTransfer))
 911                {
 2912                    stream.ColorTransfer = streamInfo.ColorTransfer;
 913                }
 914
 13915                if (!string.IsNullOrEmpty(streamInfo.ColorPrimaries))
 916                {
 2917                    stream.ColorPrimaries = streamInfo.ColorPrimaries;
 918                }
 919
 13920                if (streamInfo.SideDataList is not null)
 921                {
 6922                    foreach (var data in streamInfo.SideDataList)
 923                    {
 924                        // Parse Dolby Vision metadata from side_data
 2925                        if (string.Equals(data.SideDataType, "DOVI configuration record", StringComparison.OrdinalIgnore
 926                        {
 1927                            stream.DvVersionMajor = data.DvVersionMajor;
 1928                            stream.DvVersionMinor = data.DvVersionMinor;
 1929                            stream.DvProfile = data.DvProfile;
 1930                            stream.DvLevel = data.DvLevel;
 1931                            stream.RpuPresentFlag = data.RpuPresentFlag;
 1932                            stream.ElPresentFlag = data.ElPresentFlag;
 1933                            stream.BlPresentFlag = data.BlPresentFlag;
 1934                            stream.DvBlSignalCompatibilityId = data.DvBlSignalCompatibilityId;
 935                        }
 936
 937                        // Parse video rotation metadata from side_data
 1938                        else if (string.Equals(data.SideDataType, "Display Matrix", StringComparison.OrdinalIgnoreCase))
 939                        {
 1940                            stream.Rotation = data.Rotation;
 941                        }
 942
 943                        // Parse video frame cropping metadata from side_data
 944                        // TODO: save them and make HW filters to apply them in HWA pipelines
 0945                        else if (string.Equals(data.SideDataType, "Frame Cropping", StringComparison.OrdinalIgnoreCase))
 946                        {
 947                            // Streams containing artificially added frame cropping
 948                            // metadata should not be marked as anamorphic.
 0949                            stream.IsAnamorphic = false;
 950                        }
 951                    }
 952                }
 953
 13954                var frameInfo = frameInfoList?.FirstOrDefault(i => i.StreamIndex == stream.Index);
 13955                if (frameInfo?.SideDataList is not null
 13956                    && frameInfo.SideDataList.Any(data => string.Equals(data.SideDataType, "HDR Dynamic Metadata SMPTE20
 957                {
 0958                    stream.Hdr10PlusPresentFlag = true;
 959                }
 960            }
 0961            else if (streamInfo.CodecType == CodecType.Data)
 962            {
 0963                stream.Type = MediaStreamType.Data;
 964            }
 965            else
 966            {
 0967                return null;
 968            }
 969
 970            // Get stream bitrate
 29971            var bitrate = 0;
 972
 29973            if (int.TryParse(streamInfo.BitRate, CultureInfo.InvariantCulture, out var value))
 974            {
 13975                bitrate = value;
 976            }
 977
 978            // The bitrate info of FLAC musics and some videos is included in formatInfo.
 29979            if (bitrate == 0
 29980                && formatInfo is not null
 29981                && (stream.Type == MediaStreamType.Video || (isAudio && stream.Type == MediaStreamType.Audio)))
 982            {
 983                // If the stream info doesn't have a bitrate get the value from the media format info
 8984                if (int.TryParse(formatInfo.BitRate, CultureInfo.InvariantCulture, out value))
 985                {
 8986                    bitrate = value;
 987                }
 988            }
 989
 29990            if (bitrate > 0)
 991            {
 21992                stream.BitRate = bitrate;
 993            }
 994
 995            // Extract bitrate info from tag "BPS" if possible.
 29996            if (!stream.BitRate.HasValue
 29997                && (streamInfo.CodecType == CodecType.Audio
 29998                    || streamInfo.CodecType == CodecType.Video))
 999            {
 71000                var bps = GetBPSFromTags(streamInfo);
 71001                if (bps > 0)
 1002                {
 11003                    stream.BitRate = bps;
 1004                }
 1005                else
 1006                {
 1007                    // Get average bitrate info from tag "NUMBER_OF_BYTES" and "DURATION" if possible.
 61008                    var durationInSeconds = GetRuntimeSecondsFromTags(streamInfo);
 61009                    var bytes = GetNumberOfBytesFromTags(streamInfo);
 61010                    if (durationInSeconds is not null && durationInSeconds.Value >= 1 && bytes is not null)
 1011                    {
 01012                        bps = Convert.ToInt32(bytes * 8 / durationInSeconds, CultureInfo.InvariantCulture);
 01013                        if (bps > 0)
 1014                        {
 01015                            stream.BitRate = bps;
 1016                        }
 1017                    }
 1018                }
 1019            }
 1020
 291021            var disposition = streamInfo.Disposition;
 291022            if (disposition is not null)
 1023            {
 291024                if (disposition.GetValueOrDefault("default") == 1)
 1025                {
 171026                    stream.IsDefault = true;
 1027                }
 1028
 291029                if (disposition.GetValueOrDefault("forced") == 1)
 1030                {
 01031                    stream.IsForced = true;
 1032                }
 1033
 291034                if (disposition.GetValueOrDefault("hearing_impaired") == 1)
 1035                {
 11036                    stream.IsHearingImpaired = true;
 1037                }
 1038            }
 1039
 291040            NormalizeStreamTitle(stream);
 1041
 291042            return stream;
 1043        }
 1044
 1045        private static void NormalizeStreamTitle(MediaStream stream)
 1046        {
 291047            if (string.Equals(stream.Title, "cc", StringComparison.OrdinalIgnoreCase)
 291048                || stream.Type == MediaStreamType.EmbeddedImage)
 1049            {
 31050                stream.Title = null;
 1051            }
 291052        }
 1053
 1054        /// <summary>
 1055        /// Gets a string from an FFProbeResult tags dictionary.
 1056        /// </summary>
 1057        /// <param name="tags">The tags.</param>
 1058        /// <param name="key">The key.</param>
 1059        /// <returns>System.String.</returns>
 1060        private static string GetDictionaryValue(IReadOnlyDictionary<string, string> tags, string key)
 1061        {
 1351062            if (tags is null)
 1063            {
 31064                return null;
 1065            }
 1066
 1321067            tags.TryGetValue(key, out var val);
 1068
 1321069            return val;
 1070        }
 1071
 1072        private static string ParseChannelLayout(string input)
 1073        {
 121074            if (string.IsNullOrEmpty(input))
 1075            {
 11076                return null;
 1077            }
 1078
 111079            return input.AsSpan().LeftPart('(').ToString();
 1080        }
 1081
 1082        private static string GetAspectRatio(MediaStreamInfo info)
 1083        {
 131084            var original = info.DisplayAspectRatio;
 1085
 131086            var parts = (original ?? string.Empty).Split(':');
 131087            if (!(parts.Length == 2
 131088                    && int.TryParse(parts[0], CultureInfo.InvariantCulture, out var width)
 131089                    && int.TryParse(parts[1], CultureInfo.InvariantCulture, out var height)
 131090                    && width > 0
 131091                    && height > 0))
 1092            {
 31093                width = info.Width;
 31094                height = info.Height;
 1095            }
 1096
 131097            if (width > 0 && height > 0)
 1098            {
 131099                double ratio = width;
 131100                ratio /= height;
 1101
 131102                if (IsClose(ratio, 1.777777778, .03))
 1103                {
 71104                    return "16:9";
 1105                }
 1106
 61107                if (IsClose(ratio, 1.3333333333, .05))
 1108                {
 11109                    return "4:3";
 1110                }
 1111
 51112                if (IsClose(ratio, 1.41))
 1113                {
 01114                    return "1.41:1";
 1115                }
 1116
 51117                if (IsClose(ratio, 1.5))
 1118                {
 21119                    return "1.5:1";
 1120                }
 1121
 31122                if (IsClose(ratio, 1.6))
 1123                {
 01124                    return "1.6:1";
 1125                }
 1126
 31127                if (IsClose(ratio, 1.66666666667))
 1128                {
 01129                    return "5:3";
 1130                }
 1131
 31132                if (IsClose(ratio, 1.85, .02))
 1133                {
 01134                    return "1.85:1";
 1135                }
 1136
 31137                if (IsClose(ratio, 2.35, .025))
 1138                {
 01139                    return "2.35:1";
 1140                }
 1141
 31142                if (IsClose(ratio, 2.4, .025))
 1143                {
 11144                    return "2.40:1";
 1145                }
 1146            }
 1147
 21148            return original;
 1149        }
 1150
 1151        private static bool IsClose(double d1, double d2, double variance = .005)
 1152        {
 441153            return Math.Abs(d1 - d2) <= variance;
 1154        }
 1155
 1156        /// <summary>
 1157        /// Gets a frame rate from a string value in ffprobe output
 1158        /// This could be a number or in the format of 2997/125.
 1159        /// </summary>
 1160        /// <param name="value">The value.</param>
 1161        /// <returns>System.Nullable{System.Single}.</returns>
 1162        internal static float? GetFrameRate(ReadOnlySpan<char> value)
 1163        {
 351164            if (value.IsEmpty)
 1165            {
 01166                return null;
 1167            }
 1168
 351169            int index = value.IndexOf('/');
 351170            if (index == -1)
 1171            {
 01172                return null;
 1173            }
 1174
 351175            if (!float.TryParse(value[..index], NumberStyles.Integer, CultureInfo.InvariantCulture, out var dividend)
 351176                || !float.TryParse(value[(index + 1)..], NumberStyles.Integer, CultureInfo.InvariantCulture, out var div
 1177            {
 01178                return null;
 1179            }
 1180
 351181            return divisor == 0f ? null : dividend / divisor;
 1182        }
 1183
 1184        private static void SetAudioRuntimeTicks(InternalMediaInfoResult result, MediaInfo data)
 1185        {
 1186            // Get the first info stream
 21187            var stream = result.Streams?.FirstOrDefault(s => s.CodecType == CodecType.Audio);
 21188            if (stream is null)
 1189            {
 01190                return;
 1191            }
 1192
 1193            // Get duration from stream properties
 21194            var duration = stream.Duration;
 1195
 1196            // If it's not there go into format properties
 21197            if (string.IsNullOrEmpty(duration))
 1198            {
 01199                duration = result.Format.Duration;
 1200            }
 1201
 1202            // If we got something, parse it
 21203            if (!string.IsNullOrEmpty(duration))
 1204            {
 21205                data.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(duration, CultureInfo.InvariantCulture)).Ticks;
 1206            }
 21207        }
 1208
 1209        private static int? GetBPSFromTags(MediaStreamInfo streamInfo)
 1210        {
 71211            if (streamInfo?.Tags is null)
 1212            {
 01213                return null;
 1214            }
 1215
 71216            var bps = GetDictionaryValue(streamInfo.Tags, "BPS-eng") ?? GetDictionaryValue(streamInfo.Tags, "BPS");
 71217            if (int.TryParse(bps, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBps))
 1218            {
 21219                return parsedBps;
 1220            }
 1221
 51222            return null;
 1223        }
 1224
 1225        private static double? GetRuntimeSecondsFromTags(MediaStreamInfo streamInfo)
 1226        {
 61227            if (streamInfo?.Tags is null)
 1228            {
 01229                return null;
 1230            }
 1231
 61232            var duration = GetDictionaryValue(streamInfo.Tags, "DURATION-eng") ?? GetDictionaryValue(streamInfo.Tags, "D
 61233            if (TimeSpan.TryParse(duration, out var parsedDuration))
 1234            {
 11235                return parsedDuration.TotalSeconds;
 1236            }
 1237
 51238            return null;
 1239        }
 1240
 1241        private static long? GetNumberOfBytesFromTags(MediaStreamInfo streamInfo)
 1242        {
 61243            if (streamInfo?.Tags is null)
 1244            {
 01245                return null;
 1246            }
 1247
 61248            var numberOfBytes = GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES-eng")
 61249                                ?? GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES");
 61250            if (long.TryParse(numberOfBytes, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBytes))
 1251            {
 11252                return parsedBytes;
 1253            }
 1254
 51255            return null;
 1256        }
 1257
 1258        private static void SetSize(InternalMediaInfoResult data, MediaInfo info)
 1259        {
 121260            if (data.Format is null)
 1261            {
 11262                return;
 1263            }
 1264
 111265            info.Size = string.IsNullOrEmpty(data.Format.Size) ? null : long.Parse(data.Format.Size, CultureInfo.Invaria
 111266        }
 1267
 1268        private void SetAudioInfoFromTags(MediaInfo audio, Dictionary<string, string> tags)
 1269        {
 21270            var people = new List<BaseItemPerson>();
 21271            if (tags.TryGetValue("composer", out var composer) && !string.IsNullOrWhiteSpace(composer))
 1272            {
 121273                foreach (var person in Split(composer, false))
 1274                {
 41275                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Composer });
 1276                }
 1277            }
 1278
 21279            if (tags.TryGetValue("conductor", out var conductor) && !string.IsNullOrWhiteSpace(conductor))
 1280            {
 01281                foreach (var person in Split(conductor, false))
 1282                {
 01283                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Conductor });
 1284                }
 1285            }
 1286
 21287            if (tags.TryGetValue("lyricist", out var lyricist) && !string.IsNullOrWhiteSpace(lyricist))
 1288            {
 81289                foreach (var person in Split(lyricist, false))
 1290                {
 21291                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Lyricist });
 1292                }
 1293            }
 1294
 21295            if (tags.TryGetValue("performer", out var performer) && !string.IsNullOrWhiteSpace(performer))
 1296            {
 501297                foreach (var person in Split(performer, false))
 1298                {
 231299                    Match match = PerformerRegex().Match(person);
 1300
 1301                    // If the performer doesn't have any instrument/role associated, it won't match. In that case, chanc
 231302                    if (match.Success)
 1303                    {
 221304                        people.Add(new BaseItemPerson
 221305                        {
 221306                            Name = match.Groups["name"].Value,
 221307                            Type = PersonKind.Actor,
 221308                            Role = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(match.Groups["instrument"].Value)
 221309                        });
 1310                    }
 1311                }
 1312            }
 1313
 1314            // In cases where there isn't sufficient information as to which role a writer performed on a recording, tag
 21315            if (tags.TryGetValue("writer", out var writer) && !string.IsNullOrWhiteSpace(writer))
 1316            {
 01317                foreach (var person in Split(writer, false))
 1318                {
 01319                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Writer });
 1320                }
 1321            }
 1322
 21323            if (tags.TryGetValue("arranger", out var arranger) && !string.IsNullOrWhiteSpace(arranger))
 1324            {
 121325                foreach (var person in Split(arranger, false))
 1326                {
 41327                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Arranger });
 1328                }
 1329            }
 1330
 21331            if (tags.TryGetValue("engineer", out var engineer) && !string.IsNullOrWhiteSpace(engineer))
 1332            {
 01333                foreach (var person in Split(engineer, false))
 1334                {
 01335                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Engineer });
 1336                }
 1337            }
 1338
 21339            if (tags.TryGetValue("mixer", out var mixer) && !string.IsNullOrWhiteSpace(mixer))
 1340            {
 81341                foreach (var person in Split(mixer, false))
 1342                {
 21343                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Mixer });
 1344                }
 1345            }
 1346
 21347            if (tags.TryGetValue("remixer", out var remixer) && !string.IsNullOrWhiteSpace(remixer))
 1348            {
 01349                foreach (var person in Split(remixer, false))
 1350                {
 01351                    people.Add(new BaseItemPerson { Name = person, Type = PersonKind.Remixer });
 1352                }
 1353            }
 1354
 21355            audio.People = people.ToArray();
 1356
 1357            // Set album artist
 21358            var albumArtist = tags.GetFirstNotNullNorWhiteSpaceValue("albumartist", "album artist", "album_artist");
 21359            audio.AlbumArtists = albumArtist is not null
 21360                ? SplitDistinctArtists(albumArtist, _nameDelimiters, true).ToArray()
 21361                : Array.Empty<string>();
 1362
 1363            // Set album artist to artist if empty
 21364            if (audio.AlbumArtists.Length == 0)
 1365            {
 01366                audio.AlbumArtists = audio.Artists;
 1367            }
 1368
 1369            // Track number
 21370            audio.IndexNumber = GetDictionaryTrackOrDiscNumber(tags, "track");
 1371
 1372            // Disc number
 21373            audio.ParentIndexNumber = GetDictionaryTrackOrDiscNumber(tags, "disc");
 1374
 1375            // There's several values in tags may or may not be present
 21376            FetchStudios(audio, tags, "organization");
 21377            FetchStudios(audio, tags, "ensemble");
 21378            FetchStudios(audio, tags, "publisher");
 21379            FetchStudios(audio, tags, "label");
 1380
 1381            // These support multiple values, but for now we only store the first.
 21382            var mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Album Artist Id"))
 21383                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ALBUMARTISTID"));
 21384            audio.TrySetProviderId(MetadataProvider.MusicBrainzAlbumArtist, mb);
 1385
 21386            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Artist Id"))
 21387                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ARTISTID"));
 21388            audio.TrySetProviderId(MetadataProvider.MusicBrainzArtist, mb);
 1389
 21390            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Album Id"))
 21391                ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_ALBUMID"));
 21392            audio.TrySetProviderId(MetadataProvider.MusicBrainzAlbum, mb);
 1393
 21394            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Release Group Id"))
 21395                 ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_RELEASEGROUPID"));
 21396            audio.TrySetProviderId(MetadataProvider.MusicBrainzReleaseGroup, mb);
 1397
 21398            mb = GetMultipleMusicBrainzId(tags.GetValueOrDefault("MusicBrainz Release Track Id"))
 21399                 ?? GetMultipleMusicBrainzId(tags.GetValueOrDefault("MUSICBRAINZ_RELEASETRACKID"));
 21400            audio.TrySetProviderId(MetadataProvider.MusicBrainzTrack, mb);
 21401        }
 1402
 1403        private static string GetMultipleMusicBrainzId(string value)
 1404        {
 201405            if (string.IsNullOrWhiteSpace(value))
 1406            {
 101407                return null;
 1408            }
 1409
 101410            return value.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
 101411                .FirstOrDefault();
 1412        }
 1413
 1414        /// <summary>
 1415        /// Splits the specified val.
 1416        /// </summary>
 1417        /// <param name="val">The val.</param>
 1418        /// <param name="allowCommaDelimiter">if set to <c>true</c> [allow comma delimiter].</param>
 1419        /// <returns>System.String[][].</returns>
 1420        private string[] Split(string val, bool allowCommaDelimiter)
 1421        {
 1422            // Only use the comma as a delimiter if there are no slashes or pipes.
 1423            // We want to be careful not to split names that have commas in them
 141424            return !allowCommaDelimiter || _nameDelimiters.Any(i => val.Contains(i, StringComparison.Ordinal)) ?
 141425                val.Split(_nameDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) :
 141426                val.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
 1427        }
 1428
 1429        private IEnumerable<string> SplitDistinctArtists(string val, char[] delimiters, bool splitFeaturing)
 1430        {
 51431            if (splitFeaturing)
 1432            {
 31433                val = val.Replace(" featuring ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase)
 31434                    .Replace(" feat. ", ArtistReplaceValue, StringComparison.OrdinalIgnoreCase);
 1435            }
 1436
 51437            var artistsFound = new List<string>();
 1438
 3001439            foreach (var whitelistArtist in SplitWhitelist)
 1440            {
 1451441                var originalVal = val;
 1451442                val = val.Replace(whitelistArtist, "|", StringComparison.OrdinalIgnoreCase);
 1443
 1451444                if (!string.Equals(originalVal, val, StringComparison.OrdinalIgnoreCase))
 1445                {
 01446                    artistsFound.Add(whitelistArtist);
 1447                }
 1448            }
 1449
 51450            var artists = val.Split(delimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
 1451
 51452            artistsFound.AddRange(artists);
 51453            return artistsFound.DistinctNames();
 1454        }
 1455
 1456        /// <summary>
 1457        /// Gets the studios from the tags collection.
 1458        /// </summary>
 1459        /// <param name="info">The info.</param>
 1460        /// <param name="tags">The tags.</param>
 1461        /// <param name="tagName">Name of the tag.</param>
 1462        private void FetchStudios(MediaInfo info, IReadOnlyDictionary<string, string> tags, string tagName)
 1463        {
 181464            var val = tags.GetValueOrDefault(tagName);
 1465
 181466            if (string.IsNullOrEmpty(val))
 1467            {
 161468                return;
 1469            }
 1470
 21471            var studios = Split(val, true);
 21472            var studioList = new List<string>();
 1473
 81474            foreach (var studio in studios)
 1475            {
 21476                if (string.IsNullOrWhiteSpace(studio))
 1477                {
 1478                    continue;
 1479                }
 1480
 1481                // Don't add artist/album artist name to studios, even if it's listed there
 21482                if (info.Artists.Contains(studio, StringComparison.OrdinalIgnoreCase)
 21483                    || info.AlbumArtists.Contains(studio, StringComparison.OrdinalIgnoreCase))
 1484                {
 1485                    continue;
 1486                }
 1487
 21488                studioList.Add(studio);
 1489            }
 1490
 21491            info.Studios = studioList
 21492                .Distinct(StringComparer.OrdinalIgnoreCase)
 21493                .ToArray();
 21494        }
 1495
 1496        /// <summary>
 1497        /// Gets the genres from the tags collection.
 1498        /// </summary>
 1499        /// <param name="info">The information.</param>
 1500        /// <param name="tags">The tags.</param>
 1501        private void FetchGenres(MediaInfo info, IReadOnlyDictionary<string, string> tags)
 1502        {
 121503            var genreVal = tags.GetValueOrDefault("genre");
 121504            if (string.IsNullOrEmpty(genreVal))
 1505            {
 101506                return;
 1507            }
 1508
 21509            var genres = new List<string>(info.Genres);
 201510            foreach (var genre in Split(genreVal, true))
 1511            {
 81512                if (string.IsNullOrEmpty(genre))
 1513                {
 1514                    continue;
 1515                }
 1516
 81517                genres.Add(genre);
 1518            }
 1519
 21520            info.Genres = genres
 21521                .Distinct(StringComparer.OrdinalIgnoreCase)
 21522                .ToArray();
 21523        }
 1524
 1525        /// <summary>
 1526        /// Gets the track or disc number, which can be in the form of '1', or '1/3'.
 1527        /// </summary>
 1528        /// <param name="tags">The tags.</param>
 1529        /// <param name="tagName">Name of the tag.</param>
 1530        /// <returns>The track or disc number, or null, if missing or not parseable.</returns>
 1531        private static int? GetDictionaryTrackOrDiscNumber(IReadOnlyDictionary<string, string> tags, string tagName)
 1532        {
 41533            var disc = tags.GetValueOrDefault(tagName);
 1534
 41535            if (int.TryParse(disc.AsSpan().LeftPart('/'), out var discNum))
 1536            {
 41537                return discNum;
 1538            }
 1539
 01540            return null;
 1541        }
 1542
 1543        private static ChapterInfo GetChapterInfo(MediaChapter chapter)
 1544        {
 01545            var info = new ChapterInfo();
 1546
 01547            if (chapter.Tags is not null && chapter.Tags.TryGetValue("title", out string name))
 1548            {
 01549                info.Name = name;
 1550            }
 1551
 1552            // Limit accuracy to milliseconds to match xml saving
 01553            var secondsString = chapter.StartTime;
 1554
 01555            if (double.TryParse(secondsString, CultureInfo.InvariantCulture, out var seconds))
 1556            {
 01557                var ms = Math.Round(TimeSpan.FromSeconds(seconds).TotalMilliseconds);
 01558                info.StartPositionTicks = TimeSpan.FromMilliseconds(ms).Ticks;
 1559            }
 1560
 01561            return info;
 1562        }
 1563
 1564        private void FetchWtvInfo(MediaInfo video, InternalMediaInfoResult data)
 1565        {
 101566            var tags = data.Format?.Tags;
 1567
 101568            if (tags is null)
 1569            {
 41570                return;
 1571            }
 1572
 61573            if (tags.TryGetValue("WM/Genre", out var genres) && !string.IsNullOrWhiteSpace(genres))
 1574            {
 01575                var genreList = genres.Split(_genreDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOption
 1576
 1577                // If this is empty then don't overwrite genres that might have been fetched earlier
 01578                if (genreList.Length > 0)
 1579                {
 01580                    video.Genres = genreList;
 1581                }
 1582            }
 1583
 61584            if (tags.TryGetValue("WM/ParentalRating", out var officialRating) && !string.IsNullOrWhiteSpace(officialRati
 1585            {
 01586                video.OfficialRating = officialRating;
 1587            }
 1588
 61589            if (tags.TryGetValue("WM/MediaCredits", out var people) && !string.IsNullOrEmpty(people))
 1590            {
 01591                video.People = Array.ConvertAll(
 01592                    people.Split(_basicDelimiters, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntrie
 01593                    i => new BaseItemPerson { Name = i, Type = PersonKind.Actor });
 1594            }
 1595
 61596            if (tags.TryGetValue("WM/OriginalReleaseTime", out var year) && int.TryParse(year, NumberStyles.Integer, Cul
 1597            {
 01598                video.ProductionYear = parsedYear;
 1599            }
 1600
 1601            // Credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
 1602            // DateTime is reported along with timezone info (typically Z i.e. UTC hence assume None)
 61603            if (tags.TryGetValue("WM/MediaOriginalBroadcastDateTime", out var premiereDateString) && DateTime.TryParse(y
 1604            {
 01605                video.PremiereDate = parsedDate;
 1606            }
 1607
 61608            var description = tags.GetValueOrDefault("WM/SubTitleDescription");
 1609
 61610            var subTitle = tags.GetValueOrDefault("WM/SubTitle");
 1611
 1612            // For below code, credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
 1613
 1614            // Sometimes for TV Shows the Subtitle field is empty and the subtitle description contains the subtitle, ex
 1615            // The format is -> EPISODE/TOTAL_EPISODES_IN_SEASON. SUBTITLE: DESCRIPTION
 1616            // OR -> COMMENT. SUBTITLE: DESCRIPTION
 1617            // e.g. -> 4/13. The Doctor's Wife: Science fiction drama. When he follows a Time Lord distress signal, the 
 1618            // e.g. -> CBeebies Bedtime Hour. The Mystery: Animated adventures of two friends who live on an island in t
 61619            if (string.IsNullOrWhiteSpace(subTitle)
 61620                && !string.IsNullOrWhiteSpace(description)
 61621                && description.AsSpan()[..Math.Min(description.Length, MaxSubtitleDescriptionExtractionLength)].Contains
 1622            {
 01623                string[] descriptionParts = description.Split(':');
 01624                if (descriptionParts.Length > 0)
 1625                {
 01626                    string subtitle = descriptionParts[0];
 1627                    try
 1628                    {
 1629                        // Check if it contains a episode number and season number
 01630                        if (subtitle.Contains('/', StringComparison.Ordinal))
 1631                        {
 01632                            string[] subtitleParts = subtitle.Split(' ');
 01633                            string[] numbers = subtitleParts[0].Replace(".", string.Empty, StringComparison.Ordinal).Spl
 01634                            video.IndexNumber = int.Parse(numbers[0], CultureInfo.InvariantCulture);
 1635                            // int totalEpisodesInSeason = int.Parse(numbers[1], CultureInfo.InvariantCulture);
 1636
 1637                            // Skip the numbers, concatenate the rest, trim and set as new description
 01638                            description = string.Join(' ', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1639                        }
 01640                        else if (subtitle.Contains('.', StringComparison.Ordinal))
 1641                        {
 01642                            var subtitleParts = subtitle.Split('.');
 01643                            description = string.Join('.', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1644                        }
 1645                        else
 1646                        {
 01647                            description = subtitle.Trim();
 1648                        }
 01649                    }
 01650                    catch (Exception ex)
 1651                    {
 01652                        _logger.LogError(ex, "Error while parsing subtitle field");
 1653
 1654                        // Fallback to default parsing
 01655                        if (subtitle.Contains('.', StringComparison.Ordinal))
 1656                        {
 01657                            var subtitleParts = subtitle.Split('.');
 01658                            description = string.Join('.', subtitleParts, 1, subtitleParts.Length - 1).Trim();
 1659                        }
 1660                        else
 1661                        {
 01662                            description = subtitle.Trim();
 1663                        }
 01664                    }
 1665                }
 1666            }
 1667
 61668            if (!string.IsNullOrWhiteSpace(description))
 1669            {
 01670                video.Overview = description;
 1671            }
 61672        }
 1673
 1674        private void ExtractTimestamp(MediaInfo video)
 1675        {
 101676            if (video.VideoType != VideoType.VideoFile)
 1677            {
 01678                return;
 1679            }
 1680
 101681            if (!string.Equals(video.Container, "mpeg2ts", StringComparison.OrdinalIgnoreCase)
 101682                && !string.Equals(video.Container, "m2ts", StringComparison.OrdinalIgnoreCase)
 101683                && !string.Equals(video.Container, "ts", StringComparison.OrdinalIgnoreCase))
 1684            {
 91685                return;
 1686            }
 1687
 1688            try
 1689            {
 11690                video.Timestamp = GetMpegTimestamp(video.Path);
 01691                _logger.LogDebug("Video has {Timestamp} timestamp", video.Timestamp);
 01692            }
 11693            catch (Exception ex)
 1694            {
 11695                video.Timestamp = null;
 11696                _logger.LogError(ex, "Error extracting timestamp info from {Path}", video.Path);
 11697            }
 11698        }
 1699
 1700        // REVIEW: find out why the byte array needs to be 197 bytes long and comment the reason
 1701        private static TransportStreamTimestamp GetMpegTimestamp(string path)
 1702        {
 11703            var packetBuffer = new byte[197];
 1704
 11705            using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 1))
 1706            {
 01707                fs.ReadExactly(packetBuffer);
 01708            }
 1709
 01710            if (packetBuffer[0] == 71)
 1711            {
 01712                return TransportStreamTimestamp.None;
 1713            }
 1714
 01715            if ((packetBuffer[4] != 71) || (packetBuffer[196] != 71))
 1716            {
 01717                return TransportStreamTimestamp.None;
 1718            }
 1719
 01720            if ((packetBuffer[0] == 0) && (packetBuffer[1] == 0) && (packetBuffer[2] == 0) && (packetBuffer[3] == 0))
 1721            {
 01722                return TransportStreamTimestamp.Zero;
 1723            }
 1724
 01725            return TransportStreamTimestamp.Valid;
 1726        }
 1727
 1728        [GeneratedRegex("(?<name>.*) \\((?<instrument>.*)\\)")]
 1729        private static partial Regex PerformerRegex();
 1730    }
 1731}

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)