/// <summary> /// Applies 432hz auto-pitch if file PixelAspectRatio is 1 and FPS can be read. /// </summary> /// <param name="video">The video for which to create the auto-pitch script file.</param> /// <returns>Whether auto-pitch is enabled for this video.</returns> public static bool AppyAutoPitch(Media video) { using (MediaInfoReader InfoReader = new MediaInfoReader()) { InfoReader.LoadInfo(Settings.NaturalGroundingFolder + video.FileName); if (Settings.SavedFile.ChangeAudioPitch && InfoReader.PixelAspectRatio == 1 && !video.DisablePitch && (InfoReader.BitDepth ?? 8) == 8) { CreateScript(Settings.NaturalGroundingFolder + video.FileName, InfoReader); return true; } else return false; } }
public async Task StartScan(List<VideoListItem> selection, CancellationToken cancel) { await selection.ForEachAsync(5, cancel, async item => { MediaInfoReader InfoReader = new MediaInfoReader(); Media VideoData = PlayerAccess.GetVideoById(item.MediaId.Value); if (VideoData != null) { // Test MediaInfo not releasing file. string TestFile = Settings.TempFilesPath + Path.GetFileName(VideoData.FileName); File.Delete(TestFile); File.Copy(Settings.NaturalGroundingFolder + VideoData.FileName, TestFile); MediaInfoReader MediaReader = new MediaInfoReader(); MediaReader.LoadInfo(TestFile); string VFormat = MediaReader.VideoFormat; File.Delete(TestFile); try { // Query the server for media info. SetStatus(item, VideoListItemStatusEnum.DownloadingInfo); var VTask = DownloadBusiness.GetDownloadUrlsAsync(VideoData.DownloadUrl); var VideoList = await VTask; if (VideoList != null) { // Get the highest resolution format. BestFormatInfo VideoFormat = DownloadBusiness.SelectBestFormat(VideoList); if (VideoFormat == null || VideoFormat.BestVideo == null) SetStatus(item, VideoListItemStatusEnum.Failed); else { SetStatus(item, await IsHigherQualityAvailable(Settings.NaturalGroundingFolder + VideoData.FileName, VideoFormat)); } if (VideoFormat != null && !string.IsNullOrEmpty(VideoFormat.StatusText)) SetStatus(item, item.Status, item.StatusText + string.Format(" ({0})", VideoFormat.StatusText)); } else SetStatus(item, VideoListItemStatusEnum.InvalidUrl); } catch { SetStatus(item, VideoListItemStatusEnum.Failed); } } }); }
public async Task PreparePreviewFile(MediaEncoderSettings settings, bool overwrite) { if (string.IsNullOrEmpty(settings.FileName)) return; if (overwrite) { File.Delete(PreviewSourceFile); // Select default open method. if (settings.FileName.ToLower().EndsWith(".avi")) settings.ConvertToAvi = false; else { using (MediaInfoReader InfoReader = new MediaInfoReader()) { InfoReader.LoadInfo(Settings.NaturalGroundingFolder + settings.FileName); if (settings.ConvertToAvi && InfoReader.Height.HasValue && InfoReader.Height >= 720) settings.ConvertToAvi = false; } } } bool AviFileReady = File.Exists(PreviewSourceFile); if (!AviFileReady && settings.ConvertToAvi) AviFileReady = await Task.Run(() => FfmpegBusiness.ConvertToAVI(Settings.NaturalGroundingFolder + settings.FileName, PreviewSourceFile, false)); if (AviFileReady && settings.ConvertToAvi) await GetMediaInfo(PreviewSourceFile, settings); else { settings.ConvertToAvi = false; await GetMediaInfo(Settings.NaturalGroundingFolder + settings.FileName, settings); } // Auto-calculate crop settings. if (settings.CropLeft == 0 && settings.CropTop == 0 && settings.CropRight == 0 && settings.CropBottom == 0) { Rect AutoCrop = await Task.Run(() => FfmpegBusiness.GetAutoCropRect(settings, true)); if (settings.CropLeft == 0) settings.CropLeft = AutoCrop.Left; if (settings.CropTop == 0) settings.CropTop = AutoCrop.Top; if (settings.CropRight == 0) settings.CropRight = AutoCrop.Right; if (settings.CropBottom == 0) settings.CropBottom = AutoCrop.Bottom; } }