Ejemplo n.º 1
0
        public MediaInfo199 MigrateMediaInfo(MediaInfo198 old, string sceneName)
        {
            var m = new MediaInfo199
            {
                SchemaRevision               = old.SchemaRevision,
                ContainerFormat              = old.ContainerFormat,
                VideoProfile                 = old.VideoProfile,
                VideoBitrate                 = old.VideoBitrate,
                VideoBitDepth                = old.VideoBitDepth,
                VideoMultiViewCount          = old.VideoMultiViewCount,
                VideoColourPrimaries         = MigratePrimaries(old.VideoColourPrimaries),
                VideoTransferCharacteristics = MigrateTransferCharacteristics(old.VideoTransferCharacteristics),
                Height           = old.Height,
                Width            = old.Width,
                AudioBitrate     = old.AudioBitrate,
                RunTime          = old.RunTime,
                AudioStreamCount = old.AudioStreamCount,
                VideoFps         = old.VideoFps,
                ScanType         = old.ScanType,
                AudioLanguages   = MigrateLanguages(old.AudioLanguages),
                Subtitles        = MigrateLanguages(old.Subtitles)
            };

            m.VideoHdrFormat = MigrateHdrFormat(old);

            MigrateVideoCodec(old, m, sceneName);
            MigrateAudioCodec(old, m);
            MigrateAudioChannelPositions(old, m);

            m.AudioChannels = old.AudioChannelsStream > 0 ? old.AudioChannelsStream : old.AudioChannelsContainer;

            return(m);
        }
Ejemplo n.º 2
0
        private void MigrateVideoCodecLegacy(MediaInfo198 mediaInfo, MediaInfo199 m, string sceneName)
        {
            var videoCodec = mediaInfo.VideoCodec;

            m.VideoFormat  = videoCodec;
            m.VideoCodecID = null;

            if (videoCodec.IsNullOrWhiteSpace())
            {
                m.VideoFormat = null;
                return;
            }

            if (videoCodec == "AVC")
            {
                m.VideoFormat = "h264";
            }

            if (videoCodec == "V_MPEGH/ISO/HEVC" || videoCodec == "HEVC")
            {
                m.VideoFormat = "hevc";
            }

            if (videoCodec == "MPEG-2 Video")
            {
                m.VideoFormat = "mpeg2video";
            }

            if (videoCodec == "MPEG-4 Visual")
            {
                var result = GetSceneNameMatch(sceneName, "DivX", "XviD");
                if (result == "DivX")
                {
                    m.VideoFormat  = "mpeg4";
                    m.VideoCodecID = "DIVX";
                }

                m.VideoFormat  = "mpeg4";
                m.VideoCodecID = "XVID";
            }

            if (videoCodec.StartsWithIgnoreCase("XviD"))
            {
                m.VideoFormat  = "mpeg4";
                m.VideoCodecID = "XVID";
            }

            if (videoCodec.StartsWithIgnoreCase("DivX"))
            {
                m.VideoFormat  = "mpeg4";
                m.VideoCodecID = "DIVX";
            }

            if (videoCodec.EqualsIgnoreCase("VC-1"))
            {
                m.VideoFormat = "vc1";
            }
        }
Ejemplo n.º 3
0
        private void MigrateAudioChannelPositions(MediaInfo198 mediaInfo, MediaInfo199 m)
        {
            var audioChannels = FormatAudioChannelsFromAudioChannelPositions(mediaInfo);

            if (audioChannels == null || audioChannels == 0.0m)
            {
                audioChannels = FormatAudioChannelsFromAudioChannelPositionsText(mediaInfo);
            }

            if (audioChannels == null || audioChannels == 0.0m)
            {
                audioChannels = FormatAudioChannelsFromAudioChannels(mediaInfo);
            }

            audioChannels ??= 0;

            m.AudioChannelPositions = audioChannels.ToString();
        }
Ejemplo n.º 4
0
        private void MigrateAudioCodecLegacy(MediaInfo198 mediaInfo, MediaInfo199 m)
        {
            var audioFormat = mediaInfo.AudioFormat;

            m.AudioFormat = audioFormat;

            if (audioFormat.IsNullOrWhiteSpace())
            {
                m.AudioFormat = null;
                return;
            }

            if (audioFormat.EqualsIgnoreCase("AC-3"))
            {
                m.AudioFormat = "ac3";
                return;
            }

            if (audioFormat.EqualsIgnoreCase("E-AC-3"))
            {
                m.AudioFormat = "eac3";
                return;
            }

            if (audioFormat.EqualsIgnoreCase("AAC"))
            {
                m.AudioFormat = "aac";
                return;
            }

            if (audioFormat.EqualsIgnoreCase("MPEG Audio") && mediaInfo.AudioProfile == "Layer 3")
            {
                m.AudioFormat = "mp3";
                return;
            }

            if (audioFormat.EqualsIgnoreCase("DTS"))
            {
                m.AudioFormat = "DTS";
                return;
            }

            if (audioFormat.EqualsIgnoreCase("TrueHD"))
            {
                m.AudioFormat = "truehd";
                return;
            }

            if (audioFormat.EqualsIgnoreCase("FLAC"))
            {
                m.AudioFormat = "flac";
                return;
            }

            if (audioFormat.EqualsIgnoreCase("Vorbis"))
            {
                m.AudioFormat = "vorbis";
                return;
            }

            if (audioFormat.EqualsIgnoreCase("Opus"))
            {
                m.AudioFormat = "opus";
                return;
            }
        }
Ejemplo n.º 5
0
        private void MigrateAudioCodec(MediaInfo198 mediaInfo, MediaInfo199 m)
        {
            if (mediaInfo.AudioCodecID == null)
            {
                MigrateAudioCodecLegacy(mediaInfo, m);
                return;
            }

            var audioFormat             = mediaInfo.AudioFormat.Trim().Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries);
            var audioCodecID            = mediaInfo.AudioCodecID ?? string.Empty;
            var splitAdditionalFeatures = (mediaInfo.AudioAdditionalFeatures ?? string.Empty).Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            m.AudioFormat = "";

            if (audioFormat.Empty())
            {
                return;
            }

            if (audioFormat.ContainsIgnoreCase("Atmos"))
            {
                m.AudioFormat  = "truehd";
                m.AudioCodecID = "thd+";
                return;
            }

            if (audioFormat.ContainsIgnoreCase("MLP FBA"))
            {
                m.AudioFormat = "truehd";

                if (splitAdditionalFeatures.ContainsIgnoreCase("16-ch"))
                {
                    m.AudioCodecID = "thd+";
                    return;
                }

                return;
            }

            if (audioFormat.ContainsIgnoreCase("TrueHD"))
            {
                m.AudioFormat = "truehd";
                return;
            }

            if (audioFormat.ContainsIgnoreCase("FLAC"))
            {
                m.AudioFormat = "flac";
                return;
            }

            if (audioFormat.ContainsIgnoreCase("DTS"))
            {
                m.AudioFormat = "dts";

                if (splitAdditionalFeatures.ContainsIgnoreCase("XLL"))
                {
                    if (splitAdditionalFeatures.ContainsIgnoreCase("X"))
                    {
                        m.AudioProfile = "DTS:X";
                        return;
                    }

                    m.AudioProfile = "DTS-HD MA";
                    return;
                }

                if (splitAdditionalFeatures.ContainsIgnoreCase("ES"))
                {
                    m.AudioProfile = "DTS-ES";
                    return;
                }

                if (splitAdditionalFeatures.ContainsIgnoreCase("XBR"))
                {
                    m.AudioProfile = "DTS-HD HRA";
                    return;
                }

                return;
            }

            if (audioFormat.ContainsIgnoreCase("E-AC-3"))
            {
                m.AudioFormat = "eac3";

                if (splitAdditionalFeatures.ContainsIgnoreCase("JOC"))
                {
                    m.AudioCodecID = "ec+3";
                }

                return;
            }

            if (audioFormat.ContainsIgnoreCase("AC-3"))
            {
                m.AudioFormat = "ac3";
                return;
            }

            if (audioFormat.ContainsIgnoreCase("AAC"))
            {
                m.AudioFormat = "aac";

                if (audioCodecID == "A_AAC/MPEG4/LC/SBR")
                {
                    m.AudioCodecID = audioCodecID;
                }

                return;
            }

            if (audioFormat.ContainsIgnoreCase("mp3"))
            {
                m.AudioFormat = "mp3";
                return;
            }

            if (audioFormat.ContainsIgnoreCase("MPEG Audio"))
            {
                if (mediaInfo.AudioCodecID == "55" || mediaInfo.AudioCodecID == "A_MPEG/L3" || mediaInfo.AudioProfile == "Layer 3")
                {
                    m.AudioFormat = "mp3";
                    return;
                }

                if (mediaInfo.AudioCodecID == "A_MPEG/L2" || mediaInfo.AudioProfile == "Layer 2")
                {
                    m.AudioFormat = "mp2";
                }
            }

            if (audioFormat.ContainsIgnoreCase("Opus"))
            {
                m.AudioFormat = "opus";
                return;
            }

            if (audioFormat.ContainsIgnoreCase("PCM"))
            {
                m.AudioFormat = "pcm_s16le";
                return;
            }

            if (audioFormat.ContainsIgnoreCase("ADPCM"))
            {
                m.AudioFormat = "pcm_s16le";
                return;
            }

            if (audioFormat.ContainsIgnoreCase("Vorbis"))
            {
                m.AudioFormat = "vorbis";
                return;
            }

            if (audioFormat.ContainsIgnoreCase("WMA"))
            {
                m.AudioFormat = "wmav1";
                return;
            }
        }
Ejemplo n.º 6
0
        private void MigrateVideoCodec(MediaInfo198 mediaInfo, MediaInfo199 m, string sceneName)
        {
            if (mediaInfo.VideoFormat == null)
            {
                MigrateVideoCodecLegacy(mediaInfo, m, sceneName);
                return;
            }

            var videoFormat       = mediaInfo.VideoFormat.Trim().Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries);
            var videoCodecID      = mediaInfo.VideoCodecID ?? string.Empty;
            var videoCodecLibrary = mediaInfo.VideoCodecLibrary ?? string.Empty;

            var result = mediaInfo.VideoFormat.Trim();

            m.VideoFormat  = result;
            m.VideoCodecID = null;

            if (videoFormat.ContainsIgnoreCase("x264"))
            {
                m.VideoFormat  = "h264";
                m.VideoCodecID = "x264";
                return;
            }

            if (videoFormat.ContainsIgnoreCase("AVC") || videoFormat.ContainsIgnoreCase("V.MPEG4/ISO/AVC"))
            {
                m.VideoFormat = "h264";

                if (videoCodecLibrary.StartsWithIgnoreCase("x264"))
                {
                    m.VideoCodecID = "x264";
                }

                return;
            }

            if (videoFormat.ContainsIgnoreCase("HEVC") || videoFormat.ContainsIgnoreCase("V_MPEGH/ISO/HEVC"))
            {
                m.VideoFormat = "hevc";
                if (videoCodecLibrary.StartsWithIgnoreCase("x265"))
                {
                    m.VideoCodecID = "x265";
                }

                return;
            }

            if (videoFormat.ContainsIgnoreCase("MPEG Video"))
            {
                if (videoCodecID == "2" || videoCodecID == "V_MPEG2")
                {
                    m.VideoFormat = "mpeg2video";
                }

                if (videoCodecID.IsNullOrWhiteSpace())
                {
                    m.VideoFormat = "MPEG";
                }
            }

            if (videoFormat.ContainsIgnoreCase("MPEG-2 Video"))
            {
                m.VideoFormat = "mpeg2video";
            }

            if (videoFormat.ContainsIgnoreCase("MPEG-4 Visual"))
            {
                m.VideoFormat = "mpeg4";

                if (videoCodecID.ContainsIgnoreCase("XVID") ||
                    videoCodecLibrary.StartsWithIgnoreCase("XviD"))
                {
                    m.VideoCodecID = "XVID";
                }

                if (videoCodecID.ContainsIgnoreCase("DIV3") ||
                    videoCodecID.ContainsIgnoreCase("DIVX") ||
                    videoCodecID.ContainsIgnoreCase("DX50") ||
                    videoCodecLibrary.StartsWithIgnoreCase("DivX"))
                {
                    m.VideoCodecID = "DIVX";
                }

                return;
            }

            if (videoFormat.ContainsIgnoreCase("MPEG-4 Visual") || videoFormat.ContainsIgnoreCase("mp4v"))
            {
                m.VideoFormat = "mpeg4";

                result = GetSceneNameMatch(sceneName, "XviD", "DivX", "");

                if (result == "XviD")
                {
                    m.VideoCodecID = "XVID";
                }

                if (result == "DivX")
                {
                    m.VideoCodecID = "DIVX";
                }

                return;
            }

            if (videoFormat.ContainsIgnoreCase("VC-1"))
            {
                m.VideoFormat = "vc1";
                return;
            }

            if (videoFormat.ContainsIgnoreCase("AV1"))
            {
                m.VideoFormat = "av1";
                return;
            }

            if (videoFormat.ContainsIgnoreCase("VP6") || videoFormat.ContainsIgnoreCase("VP7") ||
                videoFormat.ContainsIgnoreCase("VP8") || videoFormat.ContainsIgnoreCase("VP9"))
            {
                m.VideoFormat = videoFormat.First().ToLowerInvariant();
                return;
            }

            if (videoFormat.ContainsIgnoreCase("WMV1") || videoFormat.ContainsIgnoreCase("WMV2"))
            {
                m.VideoFormat = "WMV";
                return;
            }

            if (videoFormat.ContainsIgnoreCase("DivX") || videoFormat.ContainsIgnoreCase("div3"))
            {
                m.VideoFormat  = "mpeg4";
                m.VideoCodecID = "DIVX";
                return;
            }

            if (videoFormat.ContainsIgnoreCase("XviD"))
            {
                m.VideoFormat  = "mpeg4";
                m.VideoCodecID = "XVID";
                return;
            }

            if (videoFormat.ContainsIgnoreCase("V_QUICKTIME") ||
                videoFormat.ContainsIgnoreCase("RealVideo 4"))
            {
                m.VideoFormat = "qtrle";
                return;
            }

            if (videoFormat.ContainsIgnoreCase("mp42") ||
                videoFormat.ContainsIgnoreCase("mp43"))
            {
                m.VideoFormat = "mpeg4";
                return;
            }
        }