/// <summary> /// Export a MacGui style plist preset. /// </summary> /// <param name="path"> /// The path. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="build"> /// The build.PictureModulusPictureModulus /// </param> public static void Export(string path, Preset preset, string build) { if (string.IsNullOrEmpty(path)) { return; } EncodeTask parsed = new EncodeTask(preset.Task); using (XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.UTF8) { Formatting = Formatting.Indented }) { // Header xmlWriter.WriteStartDocument(); xmlWriter.WriteDocType( "plist", "-//Apple//DTD PLIST 1.0//EN", @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null); xmlWriter.WriteStartElement("plist"); xmlWriter.WriteStartElement("array"); // Add New Preset Here. Can write multiple presets here if required in future. WritePreset(xmlWriter, parsed, preset, build); // Footer xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); // Closeout xmlWriter.Close(); } }
/// <summary> /// Initializes a new instance of the <see cref="PropertyChangedBase"/> class. /// Creates an instance of <see cref="T:HandBrakeWPF.Utilities.PropertyChangedBase"/>. /// </summary> public Preset(Preset preset) { this.Category = preset.Category; this.Description = preset.Description; this.IsBuildIn = preset.IsBuildIn; this.Name = preset.Name; this.PictureSettingsMode = preset.PictureSettingsMode; this.Task = new EncodeTask(preset.Task); this.AudioTrackBehaviours = new AudioBehaviours(preset.AudioTrackBehaviours); this.SubtitleTrackBehaviours = new SubtitleBehaviours(preset.SubtitleTrackBehaviours); }
/// <summary> /// The create preset. /// </summary> /// <param name="plist"> /// The plist. /// </param> /// <returns> /// The <see cref="Preset"/>. /// </returns> public static Preset CreatePreset(PList plist) { Preset preset = new Preset { Task = new EncodeTask(), Category = PresetService.UserPresetCatgoryName, AudioTrackBehaviours = new AudioBehaviours(), SubtitleTrackBehaviours = new SubtitleBehaviours() }; // Parse the settings out. foreach (var item in plist) { if (item.Key == "AudioList") { List<AudioTrack> tracks = ParseAudioTracks(item.Value); preset.Task.AudioTracks = new ObservableCollection<AudioTrack>(tracks); } else { ParseSetting(item, preset); } } // Handle the PictureDecombDeinterlace key if (preset.UseDeinterlace) { preset.Task.Decomb = Decomb.Off; preset.Task.CustomDecomb = string.Empty; } // Depending on the selected preset options, we may need to change some settings around. // If the user chose not to use fitlers, remove them. if (!preset.UsePictureFilters) { preset.Task.Detelecine = Detelecine.Off; preset.Task.Denoise = Denoise.Off; preset.Task.Deinterlace = Deinterlace.Off; preset.Task.Decomb = Decomb.Off; preset.Task.Deblock = 0; preset.Task.Grayscale = false; } // IF we are using Source Max, Set the Max Width / Height values. if (preset.PictureSettingsMode == PresetPictureSettingsMode.SourceMaximum) { preset.Task.MaxWidth = preset.Task.Height; preset.Task.MaxHeight = preset.Task.Width; } return preset; }
/// <summary> /// The setup. /// </summary> /// <param name="scannedSource"> /// The scanned source. /// </param> /// <param name="srcName"> /// The src Name. /// </param> /// <param name="addAction"> /// The add Action. /// </param> /// <param name="preset"> /// The preset. /// </param> public void Setup(Source scannedSource, string srcName, Action<IEnumerable<SelectionTitle>> addAction, Preset preset) { this.TitleList.Clear(); this.addToQueue = addAction; if (scannedSource != null) { IEnumerable<Title> titles = orderedByTitle ? scannedSource.Titles : scannedSource.Titles.OrderByDescending(o => o.Duration).ToList(); foreach (Title item in titles) { SelectionTitle title = new SelectionTitle(item, srcName) { IsSelected = true }; TitleList.Add(title); } } if (preset != null) { this.CurrentPreset = string.Format(ResourcesUI.QueueSelection_UsingPreset, preset.Name); } this.NotifyOfPropertyChange(() => this.IsAutoNamingEnabled); }
/// <summary> /// Setup this tab for the specified preset. /// </summary> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetPreset(Preset preset, EncodeTask task) { this.Task = task; this.Task.IncludeChapterMarkers = preset.Task.IncludeChapterMarkers; this.NotifyOfPropertyChange(() => this.Task); }
/// <summary> /// Setup this window for a new source /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.SourceTracks.Clear(); this.SourceTracks.Add(ForeignAudioSearchTrack); foreach (Subtitle subtitle in title.Subtitles) { this.SourceTracks.Add(subtitle); } this.Task = task; this.NotifyOfPropertyChange(() => this.Task); this.AutomaticSubtitleSelection(); }
/// <summary> /// Setup this window for a new source /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.Task = task; this.NotifyOfPropertyChange(() => this.AdvancedOptionsString); }
/// <summary> /// Add a new preset to the system. /// Performs an Update if it already exists /// </summary> /// <param name="preset"> /// A Preset to add /// </param> /// <returns> /// True if added, /// False if name already exists /// </returns> public bool Add(Preset preset) { if (this.CheckIfPresetExists(preset.Name) == false) { this.presets.Add(preset); this.LastPresetAdded = preset; // Update the presets file this.UpdatePresetFiles(); return true; } this.Update(preset); return true; }
/// <summary> /// Setup the window after a scan. /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="selectedTitle"> /// The selected title. /// </param> /// <param name="currentPreset"> /// The Current preset /// </param> /// <param name="encodeTask"> /// The task. /// </param> public void SetSource(Source source, Title selectedTitle, Preset currentPreset, EncodeTask encodeTask) { this.Task = encodeTask; }
/// <summary> /// Setup this window for a new source /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.currentTitle = title; this.Task = task; this.scannedSource = source; if (title != null) { // Set cached info this.sourceParValues = title.ParVal; this.sourceResolution = title.Resolution; // Update the cropping values, preffering those in the presets. if (!preset.Task.HasCropping) { this.Task.Cropping.Top = title.AutoCropDimensions.Top; this.Task.Cropping.Bottom = title.AutoCropDimensions.Bottom; this.Task.Cropping.Left = title.AutoCropDimensions.Left; this.Task.Cropping.Right = title.AutoCropDimensions.Right; this.IsCustomCrop = false; } else { this.Task.Cropping.Left = preset.Task.Cropping.Left; this.Task.Cropping.Right = preset.Task.Cropping.Right; this.Task.Cropping.Top = preset.Task.Cropping.Top; this.Task.Cropping.Bottom = preset.Task.Cropping.Bottom; this.IsCustomCrop = true; } if (preset.PictureSettingsMode == PresetPictureSettingsMode.None) { // We have no instructions, so simply set it to the source. this.Task.Width = this.GetModulusValue(this.sourceResolution.Width - this.CropLeft - this.CropRight); this.MaintainAspectRatio = true; } else { // Set the Max Width / Height available to the user controls if (this.sourceResolution.Width < this.MaxWidth) { this.MaxWidth = this.sourceResolution.Width; } else if (this.sourceResolution.Width > this.MaxWidth) { this.MaxWidth = preset.Task.MaxWidth ?? this.sourceResolution.Width; } if (this.sourceResolution.Height < this.MaxHeight) { this.MaxHeight = this.sourceResolution.Height; } else if (this.sourceResolution.Height > this.MaxHeight) { this.MaxHeight = preset.Task.MaxHeight ?? this.sourceResolution.Height; } // Set the Width, and Maintain Aspect ratio. That should calc the Height for us. if (this.SelectedAnamorphicMode == Anamorphic.None) { this.Task.Width = preset.Task.Width ?? (this.MaxWidth - this.CropLeft - this.CropRight); // Note: This will be auto-corrected in the property if it's too large. } else { this.Task.Width = preset.Task.Width ?? this.MaxWidth; int cropHeight = this.Task.Cropping.Top + this.Task.Cropping.Bottom; this.Task.Height = (preset.Task.Height ?? this.MaxHeight) - cropHeight; } // If our height is too large, let it downscale the width for us by setting the height to the lower value. if (!this.MaintainAspectRatio && this.Height > this.MaxHeight) { this.Task.Height = this.MaxHeight; } } // Set Screen Controls this.SourceInfo = string.Format( "{0}x{1}, PAR: {2}/{3}", title.Resolution.Width, title.Resolution.Height, title.ParVal.Width, title.ParVal.Height); this.RecaulcatePictureSettingsProperties(ChangedPictureField.Width); } this.NotifyOfPropertyChange(() => this.Task); }
/// <summary> /// Setup this tab for the specified preset. /// </summary> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetPreset(Preset preset, EncodeTask task) { this.Task = task; if (preset == null || preset.Task == null) { return; } this.SelectedVideoEncoder = preset.Task.VideoEncoder; this.SelectedFramerate = preset.Task.Framerate.HasValue ? preset.Task.Framerate.Value.ToString(CultureInfo.InvariantCulture) : SameAsSource; this.IsConstantQuantity = preset.Task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality; switch (preset.Task.FramerateMode) { case FramerateMode.CFR: this.IsConstantFramerate = true; break; case FramerateMode.VFR: this.IsVariableFramerate = true; this.ShowPeakFramerate = false; break; case FramerateMode.PFR: this.IsPeakFramerate = true; this.ShowPeakFramerate = true; break; } this.SetRF(preset.Task.Quality); this.TwoPass = preset.Task.TwoPass; this.TurboFirstPass = preset.Task.TurboFirstPass; this.Task.VideoBitrate = preset.Task.VideoBitrate; this.NotifyOfPropertyChange(() => this.Task); if (preset.Task != null) { this.HandleEncoderChange(preset.Task.VideoEncoder); HBVideoEncoder encoder = HandBrakeEncoderHelpers.VideoEncoders.FirstOrDefault(s => s.ShortName == EnumHelper<VideoEncoder>.GetShortName(preset.Task.VideoEncoder)); if (encoder != null) { if (preset.Task.VideoEncoder == VideoEncoder.X264 || preset.Task.VideoEncoder == VideoEncoder.X265 || preset.Task.VideoEncoder == VideoEncoder.QuickSync) { this.VideoLevel = preset.Task.VideoLevel != null ? preset.Task.VideoLevel.Clone() : this.VideoLevels.FirstOrDefault(); this.VideoProfile = preset.Task.VideoProfile != null ? preset.Task.VideoProfile.Clone() : this.VideoProfiles.FirstOrDefault(); this.VideoPresetValue = preset.Task.VideoPreset != null ? this.VideoPresets.IndexOf(preset.Task.VideoPreset) : 0; this.FastDecode = preset.Task.VideoTunes != null && preset.Task.VideoTunes.Contains(VideoTune.FastDecode); this.VideoTune = (preset.Task.VideoTunes != null && preset.Task.VideoTunes.Any() ? preset.Task.VideoTunes.FirstOrDefault(t => !Equals(t, VideoTune.FastDecode)) : this.VideoTunes.FirstOrDefault()) ?? VideoTune.None; } } this.ExtraArguments = preset.Task.ExtraAdvancedArguments; this.UseAdvancedTab = !string.IsNullOrEmpty(preset.Task.AdvancedEncoderOptions) && this.ShowAdvancedTab; } }
/// <summary> /// Function which generates the filename and path automatically based on /// the Source Name, DVD title and DVD Chapters /// </summary> /// <param name="task"> /// The task. /// </param> /// <param name="sourceOrLabelName"> /// The Source or Label Name /// </param> /// <returns> /// The Generated FileName /// </returns> public static string AutoName(EncodeTask task, string sourceOrLabelName, Preset presetName) { IUserSettingService userSettingService = IoC.Get<IUserSettingService>(); if (task.Destination == null) { task.Destination = string.Empty; } string autoNamePath = string.Empty; if (task.Title != 0) { // Get the Source Name and remove any invalid characters string sourceName = Path.GetInvalidFileNameChars().Aggregate(sourceOrLabelName, (current, character) => current.Replace(character.ToString(), string.Empty)); string sanitisedPresetName = presetName != null ? Path.GetInvalidFileNameChars().Aggregate(presetName.Name, (current, character) => current.Replace(character.ToString(), string.Empty)) : string.Empty; // Remove Underscores if (userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameRemoveUnderscore)) sourceName = sourceName.Replace("_", " "); if (userSettingService.GetUserSetting<bool>(UserSettingConstants.RemovePunctuation)) { sourceName = sourceName.Replace("-", string.Empty); sourceName = sourceName.Replace(",", string.Empty); sourceName = sourceName.Replace(".", string.Empty); } // Switch to "Title Case" if (userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameTitleCase)) sourceName = sourceName.ToTitleCase(); // Get the Selected Title Number string dvdTitle = task.Title.ToString(); // Get the Chapter Start and Chapter End Numbers string chapterStart = task.StartPoint.ToString(); string chapterFinish = task.EndPoint.ToString(); string combinedChapterTag = chapterStart; if (chapterFinish != chapterStart && chapterFinish != string.Empty) combinedChapterTag = chapterStart + "-" + chapterFinish; /* * File Name */ string destinationFilename; if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat) != string.Empty) { destinationFilename = userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat); destinationFilename = destinationFilename .Replace("{source}", sourceName) .Replace(Constants.Title, dvdTitle) .Replace(Constants.Chapters, combinedChapterTag) .Replace(Constants.Date, DateTime.Now.Date.ToShortDateString().Replace('/', '-')) .Replace(Constants.Time,DateTime.Now.ToString("HH:mm")) .Replace(Constants.Preset, sanitisedPresetName); if (task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality) { destinationFilename = destinationFilename.Replace(Constants.Quality, task.Quality.ToString()); destinationFilename = destinationFilename.Replace(Constants.Bitrate, string.Empty); } else { destinationFilename = destinationFilename.Replace(Constants.Bitrate, task.VideoBitrate.ToString()); destinationFilename = destinationFilename.Replace(Constants.Quality, string.Empty); } } else destinationFilename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag; /* * File Extension */ if (task.OutputFormat == OutputFormat.Mp4) { switch (userSettingService.GetUserSetting<int>(UserSettingConstants.UseM4v)) { case 0: // Automatic destinationFilename += task.IncludeChapterMarkers || MP4Helper.RequiresM4v(task) ? ".m4v" : ".mp4"; break; case 1: // Always MP4 destinationFilename += ".mp4"; break; case 2: // Always M4V destinationFilename += ".m4v"; break; } } else if (task.OutputFormat == OutputFormat.Mkv) destinationFilename += ".mkv"; /* * File Destination Path */ // If there is an auto name path, use it... if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}") && !string.IsNullOrEmpty(task.Source)) { string savedPath = userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim().Replace("{source_path}\\", string.Empty).Replace("{source_path}", string.Empty); string directory = Directory.Exists(task.Source) ? task.Source : Path.GetDirectoryName(task.Source); string requestedPath = Path.Combine(directory, savedPath); autoNamePath = Path.Combine(requestedPath, destinationFilename); if (autoNamePath == task.Source) { // Append out_ to files that already exist or is the source file autoNamePath = Path.Combine(Path.GetDirectoryName(task.Source), "output_" + destinationFilename); } } else if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}") && !string.IsNullOrEmpty(task.Source)) { // Second Case: We have a Path, with "{source_folder}" in it, therefore we need to replace it with the folder name from the source. string path = Path.GetDirectoryName(task.Source); if (!string.IsNullOrEmpty(path)) { string[] filesArray = path.Split(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); string sourceFolder = filesArray[filesArray.Length - 1]; autoNamePath = Path.Combine(userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Replace("{source_folder_name}", sourceFolder), destinationFilename); } } else if (!task.Destination.Contains(Path.DirectorySeparatorChar.ToString())) { // Third case: If the destination box doesn't already contain a path, make one. if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim() != string.Empty && userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim() != "Click 'Browse' to set the default location") { autoNamePath = Path.Combine(userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath), destinationFilename); } else // ...otherwise, output to the source directory autoNamePath = null; } else // Otherwise, use the path that is already there. { // Use the path and change the file extension to match the previous destination autoNamePath = Path.Combine(Path.GetDirectoryName(task.Destination), destinationFilename); } } return autoNamePath; }
/// <summary> /// Setup this tab for the specified preset. /// </summary> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetPreset(Preset preset, EncodeTask task) { this.Task = task; // Handle built-in presets. if (preset.IsBuildIn) { preset.PictureSettingsMode = PresetPictureSettingsMode.Custom; } // Setup the Picture Sizes switch (preset.PictureSettingsMode) { default: case PresetPictureSettingsMode.Custom: case PresetPictureSettingsMode.SourceMaximum: // Anamorphic Mode this.SelectedAnamorphicMode = preset.Task.Anamorphic; // Modulus if (preset.Task.Modulus.HasValue) { this.SelectedModulus = preset.Task.Modulus; } // Set the Maintain Aspect ratio. this.MaintainAspectRatio = preset.Task.KeepDisplayAspect; // Set the Maximum so libhb can correctly manage the size. if (preset.PictureSettingsMode == PresetPictureSettingsMode.SourceMaximum) { this.MaxWidth = this.sourceResolution.Width; this.MaxHeight = this.sourceResolution.Height; } else { this.MaxWidth = preset.Task.MaxWidth ?? this.sourceResolution.Width; this.MaxHeight = preset.Task.MaxHeight ?? this.sourceResolution.Height; } // Set the width, then check the height doesn't breach the max height and correct if necessary. int width = this.GetModulusValue(this.GetRes((this.sourceResolution.Width - this.CropLeft - this.CropRight), preset.Task.MaxWidth)); this.Width = width; // If we have a max height, make sure we havn't breached it. int height = this.GetModulusValue(this.GetRes((this.sourceResolution.Height - this.CropTop - this.CropBottom), preset.Task.MaxHeight)); if (preset.Task.MaxHeight.HasValue && this.Height > preset.Task.MaxHeight.Value) { this.Height = height; } break; case PresetPictureSettingsMode.None: // Do Nothing except reset the Max Width/Height this.MaxWidth = this.sourceResolution.Width; this.MaxHeight = this.sourceResolution.Height; this.SelectedAnamorphicMode = preset.Task.Anamorphic; break; } // Custom Anamorphic if (preset.Task.Anamorphic == Anamorphic.Custom) { this.DisplayWidth = preset.Task.DisplayWidth != null ? int.Parse(preset.Task.DisplayWidth.ToString()) : 0; this.ParWidth = preset.Task.PixelAspectX; this.ParHeight = preset.Task.PixelAspectY; } // Cropping if (preset.Task.HasCropping) { this.IsCustomCrop = true; this.CropLeft = preset.Task.Cropping.Left; this.CropRight = preset.Task.Cropping.Right; this.CropTop = preset.Task.Cropping.Top; this.CropBottom = preset.Task.Cropping.Bottom; } else { this.IsCustomCrop = false; } this.NotifyOfPropertyChange(() => this.Task); this.UpdateVisibileControls(); }
/// <summary> /// The setup languages. /// </summary> /// <param name="preset"> /// The preset. /// </param> public void SetupLanguages(Preset preset) { if (preset != null) { this.SetupLanguages(preset.SubtitleTrackBehaviours); } }
/// <summary> /// The equals. /// </summary> /// <param name="other"> /// The other. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> protected bool Equals(Preset other) { return string.Equals(this.Name, other.Name); }
/// <summary> /// Set the selected preset /// </summary> /// <param name="preset"> /// The preset. /// </param> /// <param name="encodeTask"> /// The task. /// </param> public void SetPreset(Preset preset, EncodeTask encodeTask) { this.Task = encodeTask; }
/// <summary> /// Setup this window for a new source /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.Task = task; this.NotifyOfPropertyChange(() => this.Task); if (preset != null) { this.IncludeChapterMarkers = preset.Task.IncludeChapterMarkers; } this.sourceChaptersList = title.Chapters; this.SetSourceChapters(title.Chapters); }
/// <summary> /// Parse a setting and set it in the given preset. /// </summary> /// <param name="kvp"> /// The kvp setting pair. /// </param> /// <param name="preset"> /// The preset object. /// </param> private static void ParseSetting(KeyValuePair<string, dynamic> kvp, Preset preset) { switch (kvp.Key) { // Output Settings case "FileFormat": preset.Task.OutputFormat = Converters.GetFileFormat(kvp.Value.Replace("file", string.Empty).Trim()); break; case "Mp4HttpOptimize": preset.Task.OptimizeMP4 = kvp.Value == 1; break; case "Mp4iPodCompatible": preset.Task.IPod5GSupport = kvp.Value == 1; break; // Picture Settings case "PictureAutoCrop": preset.Task.HasCropping = kvp.Value != 1; break; case "PictureTopCrop": preset.Task.Cropping.Top = kvp.Value; break; case "PictureBottomCrop": preset.Task.Cropping.Bottom = kvp.Value; break; case "PictureLeftCrop": preset.Task.Cropping.Left = kvp.Value; break; case "PictureRightCrop": preset.Task.Cropping.Right = kvp.Value; break; case "PictureHeight": preset.Task.Height = kvp.Value == null || kvp.Value == 0 ? null : kvp.Value; break; case "PictureWidth": preset.Task.Width = kvp.Value == null || kvp.Value == 0 ? null : kvp.Value; break; case "PictureKeepRatio": preset.Task.KeepDisplayAspect = kvp.Value == 1; break; case "PicturePAR": preset.Task.Anamorphic = (Anamorphic)kvp.Value; break; case "PictureModulus": preset.Task.Modulus = kvp.Value; break; // Filters case "PictureDeblock": preset.Task.Deblock = kvp.Value; break; case "PictureDecomb": preset.Task.Decomb = (Decomb)kvp.Value; break; case "PictureDecombCustom": preset.Task.CustomDecomb = kvp.Value; break; case "PictureDecombDeinterlace": preset.UseDeinterlace = kvp.Value == true; break; case "PictureDeinterlace": preset.Task.Deinterlace = (Deinterlace)kvp.Value; break; case "PictureDeinterlaceCustom": preset.Task.CustomDeinterlace = kvp.Value; break; case "PictureDenoise": preset.Task.Denoise = (Denoise)kvp.Value; break; case "DenoisePreset": preset.Task.DenoisePreset = (DenoisePreset)kvp.Value; // TODO to be confirmed. break; case "DenoiseTune": preset.Task.DenoiseTune = (DenoiseTune)kvp.Value; // TODO to be confirmed. break; case "PictureDenoiseCustom": preset.Task.CustomDenoise = kvp.Value; break; case "PictureDetelecine": preset.Task.Detelecine = (Detelecine)kvp.Value; break; case "PictureDetelecineCustom": preset.Task.CustomDetelecine = kvp.Value; break; // Video Tab case "VideoAvgBitrate": if (!string.IsNullOrEmpty(kvp.Value)) { preset.Task.VideoBitrate = int.Parse(kvp.Value); } break; case "VideoEncoder": preset.Task.VideoEncoder = EnumHelper<VideoEncoder>.GetValue(kvp.Value); break; case "VideoFramerate": preset.Task.Framerate = kvp.Value == "Same as source" || string.IsNullOrEmpty(kvp.Value) ? null : double.Parse(kvp.Value, CultureInfo.InvariantCulture); break; case "VideoFramerateMode": string parsedValue = kvp.Value; switch (parsedValue) { case "vfr": preset.Task.FramerateMode = FramerateMode.VFR; break; case "cfr": preset.Task.FramerateMode = FramerateMode.CFR; break; default: preset.Task.FramerateMode = FramerateMode.PFR; break; } break; case "VideoGrayScale": preset.Task.Grayscale = kvp.Value == true; break; case "VideoQualitySlider": preset.Task.Quality = double.Parse(kvp.Value.ToString(), CultureInfo.InvariantCulture); break; case "VideoQualityType": // The Type of Quality Mode used preset.Task.VideoEncodeRateType = (VideoEncodeRateType)kvp.Value; break; case "VideoTurboTwoPass": preset.Task.TurboFirstPass = kvp.Value == 1; break; case "VideoTwoPass": preset.Task.TwoPass = kvp.Value == 1; break; case "VideoOptionExtra": preset.Task.ExtraAdvancedArguments = kvp.Value; break; case "VideoLevel": preset.Task.VideoLevel = new VideoLevel(kvp.Value, kvp.Value); break; case "VideoProfile": preset.Task.VideoProfile = new VideoProfile(kvp.Value, kvp.Value); break; case "VideoPreset": preset.Task.VideoPreset = new VideoPreset(kvp.Value, kvp.Value); break; case "VideoTune": string[] split = kvp.Value.ToString().Split(','); foreach (var item in split) { preset.Task.VideoTunes.Add(new VideoTune(item, item)); } break; // Chapter Markers Tab case "ChapterMarkers": preset.Task.IncludeChapterMarkers = kvp.Value == true; break; // Advanced tab case "x264Option": case "lavcOption": preset.Task.AdvancedEncoderOptions = kvp.Value; break; // Preset Information case "PresetBuildNumber": preset.Version = kvp.Value; break; case "PresetDescription": preset.Description = kvp.Value; break; case "PresetName": preset.Name = kvp.Value; break; case "Type": // preset.Task.Type = kvp.Value; // TODO find out what this is break; case "UsesMaxPictureSettings": // TODO Not sure if this is used now!? break; case "UsesPictureFilters": preset.UsePictureFilters = kvp.Value == 1; break; case "UsesPictureSettings": preset.PictureSettingsMode = (PresetPictureSettingsMode)kvp.Value; break; // Allowed Passthru case "AudioAllowAACPass": preset.Task.AllowedPassthruOptions.AudioAllowAACPass = kvp.Value == true; break; case "AudioAllowAC3Pass": preset.Task.AllowedPassthruOptions.AudioAllowAC3Pass = kvp.Value == true; break; case "AudioAllowDTSHDPass": preset.Task.AllowedPassthruOptions.AudioAllowDTSHDPass = kvp.Value == true; break; case "AudioAllowDTSPass": preset.Task.AllowedPassthruOptions.AudioAllowDTSPass = kvp.Value == true; break; case "AudioAllowMP3Pass": preset.Task.AllowedPassthruOptions.AudioAllowMP3Pass = kvp.Value == true; break; case "AudioEncoderFallback": preset.Task.AllowedPassthruOptions.AudioEncoderFallback = EnumHelper<AudioEncoder>.GetValue(kvp.Value); break; // Audio Defaults case "AudioLanguageList": preset.AudioTrackBehaviours.SelectedLangauges = new BindingList<string>(ParseLangaugeCodeList(kvp.Value)); break; case "AudioSecondaryEncoderMode": break; case "AudioTrackSelectionBehavior": preset.AudioTrackBehaviours.SelectedBehaviour = kvp.Value == "all" ? AudioBehaviourModes.AllMatching : kvp.Value == "first" ? AudioBehaviourModes.FirstMatch : AudioBehaviourModes.None; break; // Subtitle Defaults case "SubtitleAddForeignAudioSearch": preset.SubtitleTrackBehaviours.AddForeignAudioScanTrack = kvp.Value == true; break; case "SubtitleAddCC": preset.SubtitleTrackBehaviours.AddClosedCaptions = kvp.Value == true; break; case "SubtitleLanguageList": preset.SubtitleTrackBehaviours.SelectedLangauges = new BindingList<string>(ParseLangaugeCodeList(kvp.Value)); break; case "SubtitleTrackSelectionBehavior": preset.SubtitleTrackBehaviours.SelectedBehaviour = kvp.Value == "all" ? SubtitleBehaviourModes.AllMatching : kvp.Value == "first" ? SubtitleBehaviourModes.FirstMatch : SubtitleBehaviourModes.None; break; } }
/// <summary> /// Setup this tab for the specified preset. /// </summary> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetPreset(Preset preset, EncodeTask task) { this.CurrentTask = task; if (preset != null) { // Properties this.SelectedDenoise = preset.Task.Denoise; this.SelectedDecomb = preset.Task.Decomb; this.SelectedDeInterlace = preset.Task.Deinterlace; this.SelectedDetelecine = preset.Task.Detelecine; this.Grayscale = preset.Task.Grayscale; this.DeblockValue = preset.Task.Deblock == 0 ? 4 : preset.Task.Deblock; this.SelectedDenoisePreset = preset.Task.DenoisePreset; this.SelectedDenoiseTune = preset.Task.DenoiseTune; // Custom Values this.CustomDecomb = preset.Task.CustomDecomb; this.CustomDeinterlace = preset.Task.CustomDeinterlace; this.CustomDetelecine = preset.Task.CustomDetelecine; this.CustomDenoise = preset.Task.CustomDenoise; } else { // Default everything to off this.SelectedDenoise = Denoise.Off; this.SelectedDecomb = Decomb.Off; this.SelectedDeInterlace = Deinterlace.Off; this.SelectedDetelecine = Detelecine.Off; this.Grayscale = false; this.DeblockValue = 0; } }
/// <summary> /// Set Default Preset /// </summary> /// <param name="name"> /// The name. /// </param> public void SetDefault(Preset name) { foreach (Preset preset in this.presets) { preset.IsDefault = false; } name.IsDefault = true; this.UpdatePresetFiles(); }
/// <summary> /// Setup this window for a new source /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.Task = task; }
/// <summary> /// The setup languages. /// </summary> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void Setup(Preset preset, EncodeTask task) { // Reset this.AudioBehaviours = new AudioBehaviours(); // Setup for this Encode Task. this.Task = task; IDictionary<string, string> langList = LanguageUtilities.MapLanguages(); langList = (from entry in langList orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value); this.AvailableLanguages.Clear(); foreach (string item in langList.Keys) { this.AvailableLanguages.Add(item); } // Handle the Preset, if it's not null. if (preset == null) { return; } AudioBehaviours behaviours = preset.AudioTrackBehaviours.Clone(); if (behaviours != null) { this.AudioBehaviours.SelectedBehaviour = behaviours.SelectedBehaviour; this.AudioBehaviours.SelectedTrackDefaultBehaviour = behaviours.SelectedTrackDefaultBehaviour; foreach (AudioBehaviourTrack item in preset.AudioTrackBehaviours.BehaviourTracks) { this.BehaviourTracks.Add(new AudioBehaviourTrack(item)); } this.NotifyOfPropertyChange(() => this.BehaviourTracks); foreach (string selectedItem in behaviours.SelectedLangauges) { this.AvailableLanguages.Remove(selectedItem); this.AudioBehaviours.SelectedLangauges.Add(selectedItem); } } this.task.AllowedPassthruOptions = new AllowedPassthru(preset.Task.AllowedPassthruOptions); this.NotifyOfPropertyChange(() => this.AudioAllowMP3Pass); this.NotifyOfPropertyChange(() => this.AudioAllowAACPass); this.NotifyOfPropertyChange(() => this.AudioAllowAC3Pass); this.NotifyOfPropertyChange(() => this.AudioAllowEAC3Pass); this.NotifyOfPropertyChange(() => this.AudioAllowDTSPass); this.NotifyOfPropertyChange(() => this.AudioAllowDTSHDPass); this.NotifyOfPropertyChange(() => this.AudioAllowTrueHDPass); this.NotifyOfPropertyChange(() => this.AudioAllowFlacPass); this.NotifyOfPropertyChange(() => this.AudioEncoderFallback); }
/// <summary> /// Remove a preset with a given name from either the built in or user preset list. /// </summary> /// <param name="preset"> /// The Preset to remove /// </param> public void Remove(Preset preset) { if (preset == null || preset.IsDefault) { return; } this.presets.Remove(preset); this.UpdatePresetFiles(); }
/// <summary>Initializes a new instance of the <see cref="T:System.Object" /> class.</summary> public PresetMenuSelectCommand(Preset preset) { this.preset = preset; }
/// <summary> /// Update a preset /// </summary> /// <param name="update"> /// The updated preset /// </param> public void Update(Preset update) { // TODO - Change this to be a lookup foreach (Preset preset in this.presets) { if (preset.Name == update.Name) { preset.Task = update.Task; preset.UsePictureFilters = update.UsePictureFilters; preset.PictureSettingsMode = update.PictureSettingsMode; preset.Category = update.Category; preset.Description = update.Description; // Update the presets file this.UpdatePresetFiles(); break; } } }
/// <summary> /// Setup this tab for the specified preset. /// </summary> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetPreset(Preset preset, EncodeTask task) { this.Task = task; this.currentPreset = preset; // Audio Behaviours this.SetupLanguages(preset); if (preset != null && preset.Task != null) { this.Task.AllowedPassthruOptions = new AllowedPassthru(preset.Task.AllowedPassthruOptions); this.SetupTracks(); } this.NotifyOfPropertyChange(() => this.Task); }
/// <summary> /// Setup this tab for the specified preset. /// </summary> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetPreset(Preset preset, EncodeTask task) { // Note, We don't support Subtitles in presets yet. this.Task = task; this.NotifyOfPropertyChange(() => this.Task); this.SetupLanguages(preset); this.AutomaticSubtitleSelection(); }
/// <summary> /// Setup this tab for the specified preset. /// </summary> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetPreset(Preset preset, EncodeTask task) { this.Task = task; this.currentPreset = preset; // Audio Behaviours this.AudioDefaultsViewModel.Setup(preset, task); if (preset != null && preset.Task != null) { this.SetupTracks(); } this.NotifyOfPropertyChange(() => this.Task); }
/// <summary> /// The setup languages. /// </summary> /// <param name="preset"> /// The preset. /// </param> private void SetupLanguages(Preset preset) { // Step 1, Set the behaviour mode this.SubtitleBehaviours.SelectedBehaviour = SubtitleBehaviourModes.None; this.SubtitleBehaviours.SelectedBurnInBehaviour = SubtitleBurnInBehaviourModes.None; this.SubtitleBehaviours.AddClosedCaptions = false; this.SubtitleBehaviours.AddForeignAudioScanTrack = false; this.SubtitleBehaviours.SelectedLangauges.Clear(); // Step 2, Get all the languages IDictionary<string, string> langList = LanguageUtilities.MapLanguages(); langList = (from entry in langList orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value); // Step 3, Setup Available Languages this.AvailableLanguages.Clear(); foreach (string item in langList.Keys) { this.AvailableLanguages.Add(item); } // Step 4, Set the Selected Languages if (preset != null && preset.SubtitleTrackBehaviours != null) { this.SubtitleBehaviours.SelectedBehaviour = preset.SubtitleTrackBehaviours.SelectedBehaviour; this.SubtitleBehaviours.SelectedBurnInBehaviour = preset.SubtitleTrackBehaviours.SelectedBurnInBehaviour; this.SubtitleBehaviours.AddClosedCaptions = preset.SubtitleTrackBehaviours.AddClosedCaptions; this.SubtitleBehaviours.AddForeignAudioScanTrack = preset.SubtitleTrackBehaviours.AddForeignAudioScanTrack; foreach (string selectedItem in preset.SubtitleTrackBehaviours.SelectedLangauges) { this.AvailableLanguages.Remove(selectedItem); this.SubtitleBehaviours.SelectedLangauges.Add(selectedItem); } } }
/// <summary> /// Set the Source Title /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.SourceTracks = title.AudioTracks; // Only reset the audio tracks if we have none, or if the task is null. if (this.Task == null) { this.SetPreset(preset, task); } // If there are no source tracks, clear the list, otherwise try to Auto-Select the correct tracks if (this.SourceTracks == null || !this.SourceTracks.Any()) { this.Task.AudioTracks.Clear(); } else { this.SetupTracks(); } // Force UI Updates this.NotifyOfPropertyChange(() => this.Task); }