public static MediaInfoResource ToResource(this MediaInfoModel model, string sceneName)
        {
            if (model == null)
            {
                return(null);
            }

            return(new MediaInfoResource
            {
                AudioBitrate = model.AudioBitrate,
                AudioChannels = MediaInfoFormatter.FormatAudioChannels(model),
                AudioLanguages = model.AudioLanguages.ConcatToString("/"),
                AudioStreamCount = model.AudioStreamCount,
                AudioCodec = MediaInfoFormatter.FormatAudioCodec(model, sceneName),
                VideoBitDepth = model.VideoBitDepth,
                VideoBitrate = model.VideoBitrate,
                VideoCodec = MediaInfoFormatter.FormatVideoCodec(model, sceneName),
                VideoDynamicRangeType = MediaInfoFormatter.FormatVideoDynamicRangeType(model),
                VideoFps = Math.Round(model.VideoFps, 3),
                Resolution = $"{model.Width}x{model.Height}",
                RunTime = FormatRuntime(model.RunTime),
                ScanType = model.ScanType,
                Subtitles = model.Subtitles.ConcatToString("/")
            });
        }
        public void should_return_VideoFormat_by_default()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                VideoFormat = "VideoCodec"
            };

            MediaInfoFormatter.FormatVideoCodec(mediaInfoModel, null).Should().Be(mediaInfoModel.VideoFormat);
        }
Exemple #3
0
        public FileNameSampleService(IBuildFileNames buildFileNames)
        {
            _buildFileNames = buildFileNames;

            var mediaInfo = new MediaInfoModel()
            {
                VideoFormat                  = "AVC",
                VideoBitDepth                = 10,
                VideoMultiViewCount          = 2,
                VideoColourPrimaries         = "BT.2020",
                VideoTransferCharacteristics = "HLG",
                AudioFormat                  = "DTS",
                AudioChannelsContainer       = 6,
                AudioChannelPositions        = "3/2/0.1",
                AudioLanguages               = "German",
                Subtitles = "English/German"
            };

            _movieFile = new MovieFile
            {
                Quality      = new QualityModel(Quality.Bluray1080p, new Revision(2)),
                RelativePath = "The.Movie.Title.2010.1080p.BluRay.DTS.x264-EVOLVE.mkv",
                SceneName    = "The.Movie.Title.2010.1080p.BluRay.DTS.x264-EVOLVE",
                ReleaseGroup = "EVOLVE",
                MediaInfo    = mediaInfo,
                Edition      = "Ultimate extended edition",
            };

            _movie = new Movie
            {
                Title         = "The Movie: Title",
                OriginalTitle = "The Original Movie Title",
                Collection    = new MovieCollection {
                    Name = "The Movie Collection", TmdbId = 123654
                },
                Certification = "R",
                Year          = 2010,
                ImdbId        = "tt0066921",
                TmdbId        = 345691,
                MovieFile     = _movieFile,
                MovieFileId   = 1,
            };

            _customFormats = new List <CustomFormat>
            {
                new CustomFormat
                {
                    Name = "Surround Sound",
                    IncludeCustomFormatWhenRenaming = true
                },
                new CustomFormat
                {
                    Name = "x264",
                    IncludeCustomFormatWhenRenaming = true
                }
            };
        }
        public void should_format_audio_format_legacy(string audioFormat, string expectedFormat)
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioFormat = audioFormat
            };

            MediaInfoFormatter.FormatAudioCodec(mediaInfoModel, sceneName).Should().Be(expectedFormat);
        }
Exemple #5
0
        public void should_format_video_codec_with_source_title_legacy(string videoCodec, string sceneName, string expectedFormat)
        {
            var mediaInfoModel = new MediaInfoModel
            {
                VideoCodec = videoCodec
            };

            MediaInfoFormatter.FormatVideoCodec(mediaInfoModel, sceneName).Should().Be(expectedFormat);
        }
Exemple #6
0
        public static string FormatAudioBitsPerSample(MediaInfoModel mediaInfo)
        {
            if (mediaInfo.AudioBits == 0)
            {
                return(string.Empty);
            }

            return(mediaInfo.AudioBits + "bit");
        }
Exemple #7
0
        public void should_return_VideoFormat_by_default()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                VideoFormat = "VideoCodec"
            };

            MediaInfoFormatter.FormatVideoCodec(mediaInfoModel, null).Should().Be(mediaInfoModel.VideoFormat);
            ExceptionVerification.ExpectedWarns(1);
        }
        public void should_format_video_dynamic_range(HdrFormat format, string expectedVideoDynamicRange)
        {
            var mediaInfo = new MediaInfoModel
            {
                VideoHdrFormat = format,
                SchemaRevision = 8
            };

            MediaInfoFormatter.FormatVideoDynamicRange(mediaInfo).Should().Be(expectedVideoDynamicRange);
        }
        public void should_return_AudioFormat_by_default()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioFormat  = "Other Audio Format",
                AudioCodecID = "Other Audio Codec"
            };

            MediaInfoFormatter.FormatAudioCodec(mediaInfoModel, sceneName).Should().Be(mediaInfoModel.AudioFormat);
        }
Exemple #10
0
        public void should_return_AudioFormat_by_default()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioFormat = "Other Audio Format"
            };

            MediaInfoFormatter.FormatAudioCodec(mediaInfoModel).Should().Be(mediaInfoModel.AudioFormat);
            ExceptionVerification.ExpectedErrors(1);
        }
        public void should_return_MP3_for_MPEG_Audio_with_Layer_3_for_the_profile()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioFormat  = "MPEG Audio",
                AudioProfile = "Layer 3"
            };

            MediaInfoFormatter.FormatAudioCodec(mediaInfoModel, sceneName).Should().Be("MP3");
        }
        [TestCase("hevc, ", "Some.Video.S01E01", "h265")]          // Default value
        public void should_format_video_format_fallbacks(string videoFormatPack, string sceneName, string expectedFormat)
        {
            var split          = videoFormatPack.Split(new string[] { ", " }, System.StringSplitOptions.None);
            var mediaInfoModel = new MediaInfoModel
            {
                VideoFormat  = split[0],
                VideoCodecID = split[1]
            };

            MediaInfoFormatter.FormatVideoCodec(mediaInfoModel, sceneName).Should().Be(expectedFormat);
        }
        public void should_use_AudioChannels_as_total_channels_if_LFE_not_in_AudioChannelPositionsText()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannels             = 2,
                AudioChannelPositions     = null,
                AudioChannelPositionsText = "Front: L R"
            };

            mediaInfoModel.FormattedAudioChannels.Should().Be(2);
        }
        public void should_subtract_one_from_AudioChannels_as_total_channels_if_LFE_in_AudioChannelPositionsText()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannelsContainer             = 6,
                AudioChannelPositions              = null,
                AudioChannelPositionsTextContainer = "Front: L C R, Side: L R, LFE"
            };

            MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(5.1m);
        }
        public void should_use_AudioChannels_as_total_channels_if_LFE_not_in_AudioChannelPositionsText()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannelsContainer             = 2,
                AudioChannelPositions              = null,
                AudioChannelPositionsTextContainer = "Front: L R"
            };

            MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(2);
        }
        public void should_sum_first_series_of_numbers_from_AudioChannelPositions_with_three_digits()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannelsContainer             = 2,
                AudioChannelPositions              = "3/2/0.2.1 / 3/2/0.1",
                AudioChannelPositionsTextContainer = null,
                SchemaRevision = 3
            };

            MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(7.1m);
        }
        public void should_sum_AudioChannelPositions_including_decimal()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannelsContainer             = 2,
                AudioChannelPositions              = "3/2/0.1",
                AudioChannelPositionsTextContainer = null,
                SchemaRevision = 3
            };

            MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(5.1m);
        }
        public void should_sum_AudioChannelPositions()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannelsContainer             = 2,
                AudioChannelPositions              = "2/0/0",
                AudioChannelPositionsTextContainer = null,
                SchemaRevision = 3
            };

            MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(2);
        }
        public void should_use_AudioChannels_if_schema_revision_is_3_and_other_properties_are_null()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannelsContainer             = 2,
                AudioChannelPositions              = null,
                AudioChannelPositionsTextContainer = null,
                SchemaRevision = 3
            };

            MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(2);
        }
        public void should_remove_atmos_objects_from_AudioChannelPostions()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannelsContainer             = 2,
                AudioChannelPositions              = "15 objects / 3/2.1",
                AudioChannelPositionsTextContainer = null,
                SchemaRevision = 3
            };

            MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(5.1m);
        }
        public void should_sum_dual_mono_representation_AudioChannelPositions()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannelsContainer             = 2,
                AudioChannelPositions              = "1+1",
                AudioChannelPositionsTextContainer = null,
                SchemaRevision = 3
            };

            MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(2.0m);
        }
Exemple #22
0
        public void should_return_0_if_schema_revision_is_less_than_3_and_other_properties_are_null()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannels             = 2,
                AudioChannelPositions     = null,
                AudioChannelPositionsText = null,
                SchemaRevision            = 2
            };

            MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(0);
        }
        public void should_format_video_dynamic_range(int bitDepth, string colourPrimaries, string transferCharacteristics, string expectedVideoDynamicRange)
        {
            var mediaInfo = new MediaInfoModel
            {
                VideoBitDepth                = bitDepth,
                VideoColourPrimaries         = colourPrimaries,
                VideoTransferCharacteristics = transferCharacteristics,
                SchemaRevision               = 5
            };

            MediaInfoFormatter.FormatVideoDynamicRange(mediaInfo).Should().Be(expectedVideoDynamicRange);
        }
        public void should_cleanup_extraneous_text_from_AudioChannelPositions()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannelsContainer             = 2,
                AudioChannelPositions              = "Object Based / 3/2/2.1",
                AudioChannelPositionsTextContainer = null,
                SchemaRevision = 3
            };

            MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(7.1m);
        }
        public void should_handle_AudioChannelPositions_three_digits()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannelsContainer             = 2,
                AudioChannelPositions              = "3/2/0.2.1",
                AudioChannelPositionsTextContainer = null,
                SchemaRevision = 3
            };

            MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(7.1m);
        }
        public void should_sum_AudioChannelPositions()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannels             = 2,
                AudioChannelPositions     = "2/0/0",
                AudioChannelPositionsText = null,
                SchemaRevision            = 3
            };

            mediaInfoModel.FormattedAudioChannels.Should().Be(2);
        }
        public void should_sum_AudioChannelPositions_including_decimal()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannels             = 2,
                AudioChannelPositions     = "3/2/0.1",
                AudioChannelPositionsText = null,
                SchemaRevision            = 3
            };

            mediaInfoModel.FormattedAudioChannels.Should().Be(5.1m);
        }
        public void should_use_AudioChannelPositionText_when_AudioChannelChannelPosition_is_invalid()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannelsContainer             = 6,
                AudioChannelPositions              = "15 objects",
                AudioChannelPositionsTextContainer = "15 objects / Front: L C R, Side: L R, LFE",
                SchemaRevision = 3
            };

            MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(5.1m);
        }
        public void should_format_audio_format(string audioFormatPack, string sceneName, string expectedFormat)
        {
            var split          = audioFormatPack.Split(new string[] { ", " }, System.StringSplitOptions.None);
            var mediaInfoModel = new MediaInfoModel
            {
                AudioFormat  = split[0],
                AudioCodecID = split[1],
                AudioProfile = split[2]
            };

            MediaInfoFormatter.FormatAudioCodec(mediaInfoModel, sceneName).Should().Be(expectedFormat);
        }
Exemple #30
0
        public void should_sum_first_series_of_numbers_from_AudioChannelPositions()
        {
            var mediaInfoModel = new MediaInfoModel
            {
                AudioChannels             = 2,
                AudioChannelPositions     = "3/2/2.1 / 3/2/2.1",
                AudioChannelPositionsText = null,
                SchemaRevision            = 3
            };

            MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(7.1m);
        }
 public VideoModel(string FilePath)
 {
     _FileInfo = new FileInfo(FilePath);
     _MediaInfo = new MediaInfoModel();
 }