/// <summary> /// Export a MacGui style plist preset. /// </summary> /// <param name="path"> /// The path. /// </param> /// <param name="preset"> /// The preset. /// </param> public static void Export(string path, Preset preset) { EncodeTask parsed = QueryParserUtility.Parse(preset.Query); 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); // Footer xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); // Closeout xmlWriter.Close(); }
/// <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> /// Set the Preset Crop Warning Label /// </summary> /// <param name="selectedPreset"> /// The Selected preset /// </param> public void SetPresetCropWarningLabel(Preset selectedPreset) { if (this.check_customCrop.Checked) { lbl_presetCropWarning.Visible = true; if (selectedPreset != null && selectedPreset.CropSettings == false) lbl_presetCropWarning.Visible = false; else if (selectedPreset == null) lbl_presetCropWarning.Visible = false; } else { lbl_presetCropWarning.Visible = false; } }
/// <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 }; // 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> /// Select the selected preset and setup the GUI /// </summary> private void selectPreset() { if (treeView_presets.SelectedNode != null) { // Ok, so, we've selected a preset. Now we want to load it. string presetName = treeView_presets.SelectedNode.Text; Preset preset = presetHandler.GetPreset(presetName); if (preset != null) { string query = presetHandler.GetPreset(presetName).Query; if (query != null) { // Ok, Reset all the H264 widgets before changing the preset x264Panel.Reset2Defaults(); // Now load the preset PresetLoader.LoadPreset(this, preset); // The x264 widgets will need updated, so do this now: x264Panel.StandardizeOptString(); x264Panel.SetCurrentSettingsInPanel(); // Finally, let this window have a copy of the preset settings. this.currentlySelectedPreset = preset; PictureSettings.SetPresetCropWarningLabel(preset); } } } }
/// <summary> /// The setup languages. /// </summary> /// <param name="preset"> /// The preset. /// </param> private void SetupLanguages(Preset preset) { // Step 1, Set the behaviour mode this.AudioBehaviours.SelectedBehaviour = AudioBehaviourModes.None; this.AudioBehaviours.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.AudioTrackBehaviours != null) { this.AudioBehaviours.SelectedBehaviour = preset.AudioTrackBehaviours.SelectedBehaviour; foreach (string selectedItem in preset.AudioTrackBehaviours.SelectedLangauges) { this.AvailableLanguages.Remove(selectedItem); this.AudioBehaviours.SelectedLangauges.Add(selectedItem); } } }
/// <summary> /// RMenu - Save Changes to Preset /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void pmnu_saveChanges_Click(object sender, EventArgs e) { if (this.selectedTitle == null) { MessageBox.Show( "Please scan a source before trying to update a preset.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DialogResult result = MessageBox.Show( "Do you wish to include picture settings when updating the preset: " + treeView_presets.SelectedNode.Text, "Update Preset", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); string query = QueryGenerator.GenerateQueryForPreset( this, QueryPictureSettingsMode.SourceMaximum, true, 0, 0); Preset preset = new Preset { Name = this.treeView_presets.SelectedNode.Text, Query = query, CropSettings = (result == DialogResult.Yes), AudioPassthruSettings = this.AudioSettings.PassthruSettings, Task = QueryParserUtility.Parse(query), }; presetHandler.Update(preset); }
/// <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 == 1; 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 "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 == 1; 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 "x264OptionExtra": preset.Task.AdvancedEncoderOptions = kvp.Value; break; case "x264Preset": preset.Task.X264Preset = EnumHelper<x264Preset>.GetValue(kvp.Value, true); break; case "h264Profile": preset.Task.H264Profile = EnumHelper<x264Profile>.GetValue(kvp.Value, true); break; case "x264Tune": string value = kvp.Value; if (value.Contains("fastdecode")) { preset.Task.FastDecode = true; value = value.Replace("fastdecode", string.Empty).Replace(",", string.Empty); } preset.Task.X264Tune = EnumHelper<x264Tune>.GetValue(value, true); break; case "h264Level": preset.Task.H264Level = kvp.Value; break; case "QsvPreset": preset.Task.QsvPreset = EnumHelper<QsvPreset>.GetValue(kvp.Value, true); break; // Chapter Markers Tab case "ChapterMarkers": preset.Task.IncludeChapterMarkers = kvp.Value == 1; break; // Advanced x264 tab case "x264Option": if (preset.Task.VideoEncoder == VideoEncoder.X264) // TODO Temp fix until a better solution is found. { preset.Task.AdvancedEncoderOptions = kvp.Value; } break; case "lavcOption": if (preset.Task.VideoEncoder != VideoEncoder.X264) // TODO Temp fix until a better solution is found. { 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 == 1; break; case "AudioAllowAC3Pass": preset.Task.AllowedPassthruOptions.AudioAllowAC3Pass = kvp.Value == 1; break; case "AudioAllowDTSHDPass": preset.Task.AllowedPassthruOptions.AudioAllowDTSHDPass = kvp.Value == 1; break; case "AudioAllowDTSPass": preset.Task.AllowedPassthruOptions.AudioAllowDTSPass = kvp.Value == 1; break; case "AudioAllowMP3Pass": preset.Task.AllowedPassthruOptions.AudioAllowMP3Pass = kvp.Value == 1; break; case "AudioEncoderFallback": preset.Task.AllowedPassthruOptions.AudioEncoderFallback = EnumHelper<AudioEncoder>.GetValue(kvp.Value); break; } }
/// <summary> /// Setup this window for a new source /// </summary> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(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 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; } double cqStep = userSettingService.GetUserSetting<double>(UserSettingConstants.X264Step); double rfValue = 0; this.SetQualitySliderBounds(); switch (this.SelectedVideoEncoder) { case VideoEncoder.FFMpeg: case VideoEncoder.FFMpeg2: if (preset.Task.Quality.HasValue) { int cq; int.TryParse(preset.Task.Quality.Value.ToString(CultureInfo.InvariantCulture), out cq); this.RF = 32 - cq; } break; case VideoEncoder.X264: double multiplier = 1.0 / cqStep; if (preset.Task.Quality.HasValue) { rfValue = preset.Task.Quality.Value * multiplier; } this.RF = this.QualityMax - (int)Math.Round(rfValue, 0); break; case VideoEncoder.Theora: if (preset.Task.Quality.HasValue) { this.RF = (int)preset.Task.Quality.Value; } break; } this.Task.TwoPass = preset.Task.TwoPass; this.Task.TurboFirstPass = preset.Task.TurboFirstPass; this.Task.VideoBitrate = preset.Task.VideoBitrate; this.NotifyOfPropertyChange(() => this.Task); if (preset.Task != null) { this.SetEncoder(preset.Task.VideoEncoder); this.X264PresetValue = preset.Task.VideoEncoder == VideoEncoder.X264 ? (int)preset.Task.X264Preset : (int)x264Preset.Medium; this.H264Profile = preset.Task.VideoEncoder == VideoEncoder.X264 ? preset.Task.H264Profile : x264Profile.None; this.X264Tune = preset.Task.VideoEncoder == VideoEncoder.X264 ? preset.Task.X264Tune : x264Tune.None; this.H264Level = preset.Task.VideoEncoder == VideoEncoder.X264 ? preset.Task.H264Level : "Auto"; this.FastDecode = preset.Task.VideoEncoder == VideoEncoder.X264 && preset.Task.FastDecode; this.ExtraArguments = preset.Task.ExtraAdvancedArguments; this.UseAdvancedTab = !string.IsNullOrEmpty(preset.Task.AdvancedEncoderOptions) && this.ShowAdvancedTab; } }
/// <summary> /// Set the Source Title /// </summary> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Title title, Preset preset, EncodeTask task) { this.SourceTracks = title.AudioTracks; this.SetPreset(preset, task); this.AutomaticTrackSelection(); }
/// <summary> /// Add the encode settings to the preset /// </summary> /// <param name="xmlWriter"> /// The xml writer. /// </param> /// <param name="parsed"> /// The parsed. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="build"> /// The build. /// </param> private static void AddEncodeSettings(XmlTextWriter xmlWriter, EncodeTask parsed, Preset preset, string build) { AddEncodeElement(xmlWriter, "AudioAllowAACPass", "integer", getNullBoolValue(parsed.AllowedPassthruOptions.AudioAllowAACPass)); AddEncodeElement(xmlWriter, "AudioAllowAC3Pass", "integer", getNullBoolValue(parsed.AllowedPassthruOptions.AudioAllowAC3Pass)); AddEncodeElement(xmlWriter, "AudioAllowDTSHDPass", "integer", getNullBoolValue(parsed.AllowedPassthruOptions.AudioAllowDTSHDPass)); AddEncodeElement(xmlWriter, "AudioAllowDTSPass", "integer", getNullBoolValue(parsed.AllowedPassthruOptions.AudioAllowDTSPass)); AddEncodeElement(xmlWriter, "AudioAllowMP3Pass", "integer", getNullBoolValue(parsed.AllowedPassthruOptions.AudioAllowMP3Pass)); AddEncodeElement(xmlWriter, "AudioEncoderFallback", "string", EnumHelper<AudioEncoder>.GetDisplay(parsed.AllowedPassthruOptions.AudioEncoderFallback)); AddEncodeElement(xmlWriter, "ChapterMarkers", "integer", parsed.IncludeChapterMarkers ? "1" : "0"); AddEncodeElement(xmlWriter, "Default", "integer", "0"); AddEncodeElement(xmlWriter, "FileFormat", "string", (parsed.OutputFormat == OutputFormat.Mp4 || parsed.OutputFormat == OutputFormat.M4V) ? "MP4 file" : "MKV file"); AddBooleanElement(xmlWriter, "Folder", false); AddEncodeElement(xmlWriter, "Mp4HttpOptimize", "integer", parsed.OptimizeMP4 ? "1" : "0"); AddEncodeElement(xmlWriter, "Mp4LargeFile", "integer", parsed.LargeFile ? "1" : "0"); AddEncodeElement(xmlWriter, "Mp4iPodCompatible", "integer", parsed.IPod5GSupport ? "1" : "0"); AddEncodeElement(xmlWriter, "PictureAutoCrop", "integer", "1"); AddEncodeElement(xmlWriter, "PictureBottomCrop", "integer", parsed.Cropping.Bottom.ToString()); // Filters AddEncodeElement(xmlWriter, "PictureDeblock", "integer", parsed.Deblock.ToString()); switch (parsed.Decomb) { case Decomb.Off: AddEncodeElement(xmlWriter, "PictureDecomb", "integer", "0"); AddEncodeElement(xmlWriter, "PictureDecombCustom", "string", string.Empty); break; case Decomb.Default: AddEncodeElement(xmlWriter, "PictureDecomb", "integer", "2"); AddEncodeElement(xmlWriter, "PictureDecombCustom", "string", string.Empty); break; case Decomb.Fast: AddEncodeElement(xmlWriter, "PictureDecomb", "integer", "3"); AddEncodeElement(xmlWriter, "PictureDecombCustom", "string", string.Empty); break; case Decomb.Bob: AddEncodeElement(xmlWriter, "PictureDecomb", "integer", "4"); AddEncodeElement(xmlWriter, "PictureDecombCustom", "string", string.Empty); break; case Decomb.Custom: AddEncodeElement(xmlWriter, "PictureDecomb", "integer", "1"); AddEncodeElement(xmlWriter, "PictureDecombCustom", "string", parsed.CustomDecomb); break; } AddEncodeElement(xmlWriter, "PictureDecombDeinterlace", "integer", parsed.Decomb != Decomb.Off ? "0" : "1"); switch (parsed.Deinterlace) { case Deinterlace.Off: AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "0"); AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", string.Empty); break; case Deinterlace.Fast: AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "2"); AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", string.Empty); break; case Deinterlace.Slow: AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "3"); AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", string.Empty); break; case Deinterlace.Slower: AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "4"); AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", string.Empty); break; case Deinterlace.Bob: AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "5"); AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", string.Empty); break; case Deinterlace.Custom: AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "1"); AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", parsed.CustomDeinterlace); break; } switch (parsed.Denoise) { case Denoise.Off: AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "0"); AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); break; case Denoise.Weak: AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "2"); AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); break; case Denoise.Medium: AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "3"); AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); break; case Denoise.Strong: AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "4"); AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); break; case Denoise.Custom: AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "1"); AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", parsed.CustomDenoise); break; } int detelecine = 0; switch (parsed.Detelecine) { case Detelecine.Off: detelecine = 0; break; case Detelecine.Default: detelecine = 2; break; case Detelecine.Custom: detelecine = 1; break; } AddEncodeElement(xmlWriter, "PictureDetelecine", "integer", detelecine.ToString()); AddEncodeElement(xmlWriter, "PictureDetelecineCustom", "string", detelecine == 1 ? parsed.CustomDecomb : string.Empty); // Picture Settings AddEncodeElement(xmlWriter, "PictureHeight", "integer", parsed.Height.ToString()); AddEncodeElement(xmlWriter, "PictureKeepRatio", "integer", parsed.KeepDisplayAspect ? "1" : "0"); AddEncodeElement(xmlWriter, "PictureLeftCrop", "integer", parsed.Cropping.Left.ToString()); AddEncodeElement(xmlWriter, "PictureModulus", "integer", parsed.Modulus.ToString()); AddEncodeElement(xmlWriter, "PicturePAR", "integer", ((int)parsed.Anamorphic).ToString()); AddEncodeElement(xmlWriter, "PictureRightCrop", "integer", parsed.Cropping.Right.ToString()); AddEncodeElement(xmlWriter, "PictureTopCrop", "integer", parsed.Cropping.Top.ToString()); AddEncodeElement(xmlWriter, "PictureWidth", "integer", parsed.Width.ToString()); // Preset Information AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", build); AddEncodeElement(xmlWriter, "PresetDescription", "string", "No Description"); AddEncodeElement(xmlWriter, "PresetName", "string", preset.Name); AddEncodeElement(xmlWriter, "Type", "integer", "1"); // 1 is user preset, 0 is built in // Preset Settings AddEncodeElement(xmlWriter, "UsesMaxPictureSettings", "integer", (parsed.MaxWidth != 0 || parsed.MaxHeight != 0) ? "1" : "0"); AddEncodeElement(xmlWriter, "UsesPictureFilters", "integer", "1"); AddEncodeElement(xmlWriter, "UsesPictureSettings", "integer", "2"); // Video Settings AddEncodeElement(xmlWriter, "VideoAvgBitrate", "string", parsed.VideoBitrate.ToString()); AddEncodeElement(xmlWriter, "VideoEncoder", "string", EnumHelper<VideoEncoder>.GetDisplay(parsed.VideoEncoder)); AddEncodeElement(xmlWriter, "VideoFramerate", "string", parsed.Framerate == null ? "Same as source" : parsed.Framerate.ToString()); AddEncodeElement(xmlWriter, "VideoFramerateMode", "string", parsed.FramerateMode.ToString().ToLower()); AddEncodeElement(xmlWriter, "VideoGrayScale", "integer", parsed.Grayscale ? "1" : "0"); AddEncodeElement(xmlWriter, "VideoQualitySlider", "real", parsed.Quality.ToString()); AddEncodeElement(xmlWriter, "h264Level", "string", parsed.H264Level); AddEncodeElement(xmlWriter, "x264OptionExtra", "string", parsed.AdvancedEncoderOptions); AddEncodeElement(xmlWriter, "x264Preset", "string", parsed.X264Preset.ToString().ToLower()); AddEncodeElement(xmlWriter, "h264Profile", "string", parsed.H264Profile.ToString().ToLower()); string tune = parsed.X264Tune.ToString().ToLower(); if (parsed.FastDecode) { tune = tune == "none" ? "fastdecode" : tune + ",fastdecode"; } AddEncodeElement(xmlWriter, "x264Tune", "string", tune); AddEncodeElement(xmlWriter, "x264UseAdvancedOptions", "integer", parsed.ShowAdvancedTab ? "1" : "0"); int videoQualityType = 0; if (parsed.VideoBitrate != null) videoQualityType = 1; else if (parsed.Quality != null) videoQualityType = 2; AddEncodeElement(xmlWriter, "VideoQualityType", "integer", videoQualityType.ToString()); AddEncodeElement(xmlWriter, "VideoTargetSize", "string", string.Empty); AddEncodeElement(xmlWriter, "VideoTurboTwoPass", "integer", parsed.TurboFirstPass ? "1" : "0"); AddEncodeElement(xmlWriter, "VideoTwoPass", "integer", parsed.TwoPass ? "1" : "0"); // x264 string AddEncodeElement(xmlWriter, "x264Option", "string", parsed.AdvancedEncoderOptions); }
/// <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; if (preset != null && preset.Task != null) { int mode = this.UserSettingService.GetUserSetting<int>(UserSettingConstants.DubModeAudio); if (mode >= 1) { this.AutomaticTrackSelection(); } else { this.AddTracksFromPreset(preset); } this.AutomaticTrackSelection(); this.Task.AllowedPassthruOptions = new AllowedPassthru(preset.Task.AllowedPassthruOptions); } this.NotifyOfPropertyChange(() => this.Task); }
/// <summary> /// Add the encode settings to the preset /// </summary> /// <param name="xmlWriter"> /// The xml writer. /// </param> /// <param name="parsed"> /// The parsed. /// </param> /// <param name="preset"> /// The preset. /// </param> private static void AddEncodeSettings(XmlTextWriter xmlWriter, EncodeTask parsed, Preset preset) { AddEncodeElement(xmlWriter, "ChapterMarkers", "integer", parsed.IncludeChapterMarkers ? "1" : "0"); AddEncodeElement(xmlWriter, "Default", "integer", "0"); AddEncodeElement(xmlWriter, "FileFormat", "string", Converters.GetFileFormat(parsed.OutputFormat) + " file"); AddBooleanElement(xmlWriter, "Folder", false); AddEncodeElement(xmlWriter, "Mp4HttpOptimize", "integer", parsed.OptimizeMP4 ? "1" : "0"); AddEncodeElement(xmlWriter, "Mp4LargeFile", "integer", parsed.LargeFile ? "1" : "0"); AddEncodeElement(xmlWriter, "Mp4iPodCompatible", "integer", parsed.IPod5GSupport ? "1" : "0"); AddEncodeElement(xmlWriter, "PictureAutoCrop", "integer", "1"); AddEncodeElement(xmlWriter, "PictureBottomCrop", "integer", parsed.Cropping.Bottom.ToString()); // Filters AddEncodeElement(xmlWriter, "PictureDeblock", "integer", parsed.Deblock.ToString()); switch (parsed.Decomb) { case Decomb.Off: AddEncodeElement(xmlWriter, "PictureDecomb", "integer", "0"); AddEncodeElement(xmlWriter, "PictureDecombCustom", "string", string.Empty); break; case Decomb.Default: AddEncodeElement(xmlWriter, "PictureDecomb", "integer", "1"); AddEncodeElement(xmlWriter, "PictureDecombCustom", "string", string.Empty); break; default: AddEncodeElement(xmlWriter, "PictureDecomb", "integer", "2"); AddEncodeElement(xmlWriter, "PictureDecombCustom", "string", parsed.CustomDecomb); break; } AddEncodeElement(xmlWriter, "PictureDecombDeinterlace", "integer", parsed.Decomb != Decomb.Off ? "0" : "1"); switch (parsed.Deinterlace) { case Deinterlace.Off: AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "0"); AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", string.Empty); break; case Deinterlace.Fast: AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "1"); AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", string.Empty); break; case Deinterlace.Slow: AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "2"); AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", string.Empty); break; case Deinterlace.Slower: AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "3"); AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", string.Empty); break; default: AddEncodeElement(xmlWriter, "PictureDeinterlace", "integer", "4"); AddEncodeElement(xmlWriter, "PictureDeinterlaceCustom", "string", parsed.CustomDeinterlace); break; } switch (parsed.Denoise) { case Denoise.Off: AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "0"); AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); break; case Denoise.Weak: AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "1"); AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); break; case Denoise.Medium: AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "2"); AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); break; case Denoise.Strong: AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "3"); AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", string.Empty); break; default: AddEncodeElement(xmlWriter, "PictureDenoise", "integer", "4"); AddEncodeElement(xmlWriter, "PictureDenoiseCustom", "string", parsed.CustomDenoise); break; } int detelecine; switch (parsed.Detelecine) { case Detelecine.Off: detelecine = 0; break; case Detelecine.Default: detelecine = 2; break; default: detelecine = 1; break; } AddEncodeElement(xmlWriter, "PictureDetelecine", "integer", detelecine.ToString()); AddEncodeElement(xmlWriter, "PictureDetelecineCustom", "string", detelecine == 1 ? parsed.CustomDecomb : string.Empty); // Picture Settings AddEncodeElement(xmlWriter, "PictureHeight", "integer", parsed.Height.ToString()); AddEncodeElement(xmlWriter, "PictureKeepRatio", "integer", parsed.KeepDisplayAspect ? "1" : "0"); AddEncodeElement(xmlWriter, "PictureLeftCrop", "integer", parsed.Cropping.Left.ToString()); AddEncodeElement(xmlWriter, "PictureModulus", "integer", parsed.Modulus.ToString()); AddEncodeElement(xmlWriter, "PicturePAR", "integer", ((int)parsed.Anamorphic).ToString()); AddEncodeElement(xmlWriter, "PictureRightCrop", "integer", parsed.Cropping.Right.ToString()); AddEncodeElement(xmlWriter, "PictureTopCrop", "integer", parsed.Cropping.Top.ToString()); AddEncodeElement(xmlWriter, "PictureWidth", "integer", parsed.Width.ToString()); // Preset Information AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeBuild)); AddEncodeElement(xmlWriter, "PresetDescription", "string", "No Description"); AddEncodeElement(xmlWriter, "PresetName", "string", preset.Name); AddEncodeElement(xmlWriter, "Type", "integer", "1"); // 1 is user preset, 0 is built in // Preset Settings AddEncodeElement(xmlWriter, "UsesMaxPictureSettings", "integer", (parsed.MaxWidth != 0 || parsed.MaxHeight != 0) ? "1" : "0"); AddEncodeElement(xmlWriter, "UsesPictureFilters", "integer", "1"); AddEncodeElement(xmlWriter, "UsesPictureSettings", "integer", "2"); // Video Settings AddEncodeElement(xmlWriter, "VideoAvgBitrate", "string", parsed.VideoBitrate.ToString()); AddEncodeElement(xmlWriter, "VideoEncoder", "string", EnumHelper<VideoEncoder>.GetDisplay(parsed.VideoEncoder)); AddEncodeElement(xmlWriter, "VideoFramerate", "string", parsed.Framerate.ToString()); AddEncodeElement(xmlWriter, "VideFrameratePFR", "integer", parsed.FramerateMode == FramerateMode.PFR ? "1" : "0"); AddEncodeElement(xmlWriter, "VideoGrayScale", "integer", parsed.Grayscale ? "1" : "0"); AddEncodeElement(xmlWriter, "VideoQualitySlider", "real", parsed.Quality.ToString()); int videoQualityType = 0; if (parsed.VideoBitrate != null) videoQualityType = 1; else if (parsed.Quality != null) videoQualityType = 2; AddEncodeElement(xmlWriter, "VideoQualityType", "integer", videoQualityType.ToString()); AddEncodeElement(xmlWriter, "VideoTargetSize", "string", string.Empty); AddEncodeElement(xmlWriter, "VideoTurboTwoPass", "integer", parsed.TurboFirstPass ? "1" : "0"); AddEncodeElement(xmlWriter, "VideoTwoPass", "integer", parsed.TwoPass ? "1" : "0"); // x264 string AddEncodeElement(xmlWriter, "x264Option", "string", parsed.AdvancedEncoderOptions); }
/// <summary> /// Import a plist preset /// </summary> private void ImportPreset() { if (openPreset.ShowDialog() == DialogResult.OK) { EncodeTask parsed = PlistPresetHandler.Import(openPreset.FileName); if (presetHandler.CheckIfPresetExists(parsed.PresetName)) { if (!presetHandler.CanUpdatePreset(parsed.PresetName)) { MessageBox.Show( "You can not import a preset with the same name as a built-in preset.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DialogResult result = MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?", "Overwrite preset?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { Preset preset = new Preset { Name = parsed.PresetName, Query = QueryGeneratorUtility.GenerateQuery(parsed), CropSettings = parsed.UsesPictureSettings, Description = string.Empty, AudioPassthruSettings = parsed.AllowedPassthruOptions }; presetHandler.Update(preset); } } else { Preset preset = new Preset { Name = parsed.PresetName, Query = QueryGeneratorUtility.GenerateQuery(parsed), CropSettings = parsed.UsesPictureSettings, Description = string.Empty, AudioPassthruSettings = parsed.AllowedPassthruOptions }; if (presetHandler.Add(preset)) { TreeNode preset_treeview = new TreeNode(parsed.PresetName) { ForeColor = Color.Black, Tag = preset, }; treeView_presets.Nodes.Add(preset_treeview); } } } }
/// <summary> /// Add the required tracks for the current preset /// </summary> /// <param name="preset"> /// The preset. /// </param> private void AddTracksFromPreset(Preset preset) { // Clear out the old tracks this.Task.AudioTracks.Clear(); // Add the preset audio tracks with the preferred language foreach (AudioTrack track in preset.Task.AudioTracks) { this.Task.AudioTracks.Add(new AudioTrack(track) { ScannedTrack = this.GetPreferredAudioTrack() }); } }
/// <summary> /// This function takes in a Query which has been parsed by QueryParser and /// set's all the GUI widgets correctly. /// </summary> /// <param name="mainWindow"> /// FrmMain window /// </param> /// <param name="preset"> /// The preset. /// </param> public static void LoadPreset(frmMain mainWindow, Preset preset) { // Send the query from the file to the Query Parser class EncodeTask presetQuery = preset.Task ?? QueryParserUtility.Parse(preset.Query); if (preset.Task == null) { preset.Task = presetQuery; } #region Source // Reset some vaules to stock first to prevent errors. mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked; // Now load all the new settings onto the main window string destination = mainWindow.text_destination.Text; destination = destination.Replace(".mp4", "." + presetQuery.OutputFormat); destination = destination.Replace(".m4v", "." + presetQuery.OutputFormat); destination = destination.Replace(".mkv", "." + presetQuery.OutputFormat); mainWindow.text_destination.Text = destination; #endregion #region Destination and Output Settings if (presetQuery.OutputFormat == OutputFormat.Mp4 || presetQuery.OutputFormat == OutputFormat.M4V) { if (mainWindow.drop_format.SelectedIndex == 0) { mainWindow.SetExtension(".mp4"); } else { mainWindow.drop_format.SelectedIndex = 0; } } else if (presetQuery.OutputFormat == OutputFormat.Mkv) { if (mainWindow.drop_format.SelectedIndex == 1) { mainWindow.SetExtension(".mkv"); } else { mainWindow.drop_format.SelectedIndex = 1; } } mainWindow.check_iPodAtom.CheckState = presetQuery.IPod5GSupport ? CheckState.Checked : CheckState.Unchecked; mainWindow.check_optimiseMP4.CheckState = presetQuery.OptimizeMP4 ? CheckState.Checked : CheckState.Unchecked; mainWindow.check_largeFile.CheckState = presetQuery.LargeFile ? CheckState.Checked : CheckState.Unchecked; mainWindow.setContainerOpts(); // select the container options according to the selected format #endregion #region Picture mainWindow.PictureSettings.check_autoCrop.Checked = true; if (preset.CropSettings && presetQuery.HasCropping) { mainWindow.PictureSettings.check_customCrop.Checked = true; mainWindow.PictureSettings.crop_top.Value = presetQuery.Cropping.Top; mainWindow.PictureSettings.crop_bottom.Value = presetQuery.Cropping.Bottom; mainWindow.PictureSettings.crop_left.Value = presetQuery.Cropping.Left; mainWindow.PictureSettings.crop_right.Value = presetQuery.Cropping.Right; } // Set the anamorphic mode 0,1,2,3 switch (presetQuery.Anamorphic) { case Anamorphic.None: mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = 0; break; case Anamorphic.Strict: mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = 1; break; case Anamorphic.Loose: mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = 2; break; case Anamorphic.Custom: mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = 3; break; } // Keep Aspect Ration Anamorphic Setting. mainWindow.PictureSettings.check_KeepAR.CheckState = presetQuery.KeepDisplayAspect ? CheckState.Checked : CheckState.Unchecked; bool sizeSet = false; // Set the Width and height as Required. if (presetQuery.Width.HasValue) { mainWindow.PictureSettings.text_width.Value = presetQuery.Width.Value; sizeSet = true; } if (presetQuery.Height.HasValue) { mainWindow.PictureSettings.text_height.Value = presetQuery.Height.Value; sizeSet = true; } // Max Width/Height override Width/Height if (presetQuery.MaxWidth.HasValue) { mainWindow.PictureSettings.text_width.Value = presetQuery.MaxWidth.Value; sizeSet = true; } if (presetQuery.MaxHeight.HasValue) { mainWindow.PictureSettings.text_height.Value = presetQuery.MaxHeight.Value; sizeSet = true; } mainWindow.PictureSettings.SizeSet = sizeSet; mainWindow.PictureSettings.PresetMaximumResolution = new Size( presetQuery.MaxWidth.HasValue ? presetQuery.MaxWidth.Value : 0, presetQuery.MaxHeight.HasValue ? presetQuery.MaxHeight.Value : 0); // Case where both height and max height are 0 - For built-in presets if (presetQuery.MaxHeight == 0 && presetQuery.Height == 0) { mainWindow.PictureSettings.text_height.Value = 0; } if (presetQuery.MaxWidth == 0 && presetQuery.Width == 0) { if (mainWindow.selectedTitle != null && mainWindow.selectedTitle.Resolution.Width != 0) { mainWindow.PictureSettings.text_width.Value = mainWindow.selectedTitle.Resolution.Width; } } // Aspect Ratio for non anamorphic sources if (presetQuery.Anamorphic == Anamorphic.None) { mainWindow.PictureSettings.check_KeepAR.CheckState = presetQuery.Height == 0 ? CheckState.Checked : CheckState.Unchecked; } // Custom Anamorphic Controls mainWindow.PictureSettings.updownDisplayWidth.Text = presetQuery.DisplayWidth.ToString(); mainWindow.PictureSettings.updownParHeight.Text = presetQuery.PixelAspectY.ToString(); mainWindow.PictureSettings.updownParWidth.Text = presetQuery.PixelAspectX.ToString(); mainWindow.PictureSettings.drp_modulus.SelectedItem = presetQuery.Modulus.ToString(); #endregion #region Filters mainWindow.Filters.SetDecomb(presetQuery.Decomb, presetQuery.CustomDecomb); mainWindow.Filters.SetDeInterlace(presetQuery.Deinterlace, presetQuery.CustomDeinterlace); mainWindow.Filters.SetDeNoise(presetQuery.Denoise, presetQuery.CustomDenoise); mainWindow.Filters.SetDeTelecine(presetQuery.Detelecine, presetQuery.CustomDetelecine); mainWindow.Filters.SetDeBlock(presetQuery.Deblock); mainWindow.Filters.SetGrayScale(presetQuery.Grayscale); #endregion #region Video switch (presetQuery.VideoEncoder) { case VideoEncoder.X264: mainWindow.drp_videoEncoder.SelectedIndex = 0; break; case VideoEncoder.FFMpeg: mainWindow.drp_videoEncoder.SelectedIndex = 1; break; case VideoEncoder.FFMpeg2: mainWindow.drp_videoEncoder.SelectedIndex = 2; break; case VideoEncoder.Theora: mainWindow.drp_videoEncoder.SelectedIndex = 3; break; } // Quality if (presetQuery.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality) { mainWindow.radio_cq.Checked = true; mainWindow.slider_videoQuality.Value = QualityToSliderValue(presetQuery.VideoEncoder, presetQuery.Quality); mainWindow.check_2PassEncode.CheckState = CheckState.Unchecked; mainWindow.check_turbo.CheckState = CheckState.Unchecked; } else if (presetQuery.VideoEncodeRateType == VideoEncodeRateType.AverageBitrate) { mainWindow.radio_avgBitrate.Checked = true; mainWindow.text_bitrate.Text = presetQuery.VideoBitrate.ToString(); mainWindow.check_2PassEncode.CheckState = presetQuery.TwoPass ? CheckState.Checked : CheckState.Unchecked; mainWindow.check_turbo.CheckState = presetQuery.TurboFirstPass ? CheckState.Checked : CheckState.Unchecked; } if (presetQuery.Framerate != null) { mainWindow.drp_videoFramerate.Text = presetQuery.Framerate.ToString(); } else { mainWindow.drp_videoFramerate.SelectedIndex = 0; } if (presetQuery.Framerate != null) { // Constant or Peak Framerate for a set framerate. if (presetQuery.FramerateMode == FramerateMode.CFR) mainWindow.radio_constantFramerate.Checked = true; else mainWindow.radio_peakAndVariable.Checked = true; } else { // Constant or Variable Framerate for Same as Source. if (presetQuery.FramerateMode == FramerateMode.CFR) mainWindow.radio_constantFramerate.Checked = true; else mainWindow.radio_peakAndVariable.Checked = true; } #endregion #region Chapter Markers if (presetQuery.IncludeChapterMarkers) { mainWindow.Check_ChapterMarkers.CheckState = CheckState.Checked; mainWindow.Check_ChapterMarkers.Enabled = true; } else { mainWindow.Check_ChapterMarkers.CheckState = CheckState.Unchecked; } #endregion #region Audio mainWindow.AudioSettings.LoadTracks(preset); #endregion #region Other mainWindow.x264Panel.X264Query = presetQuery.AdvancedEncoderOptions; // Set the preset name mainWindow.labelPreset.Text = "Output Settings (Preset: " + preset.Name + ")"; #endregion }
/// <summary> /// Load an Encode task as a Preset /// </summary> /// <param name="mainWindow"> /// The main window. /// </param> /// <param name="encodeTask"> /// The encode task. /// </param> public static void LoadPreset(frmMain mainWindow, EncodeTask encodeTask) { Preset preset = new Preset { Name = "Unknown", Task = encodeTask }; LoadPreset(mainWindow, preset); }
/// <summary> /// Update the UI after the scan has completed /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void SourceScanScanCompleted(object sender, EventArgs e) { if (this.InvokeRequired) { this.BeginInvoke(new ScanCompletedStatus(this.SourceScanScanCompleted), new[] { sender, e }); return; } try { currentSource = SourceScan.SouceData; // Setup some GUI components drp_dvdtitle.Items.Clear(); if (currentSource.Titles.Count != 0) drp_dvdtitle.Items.AddRange(currentSource.Titles.ToArray()); foreach (Title title in currentSource.Titles) { if (title.MainTitle) { drp_dvdtitle.SelectedItem = title; } } if (drp_dvdtitle.SelectedItem == null && drp_dvdtitle.Items.Count > 0) { drp_dvdtitle.SelectedIndex = 0; } // Enable the creation of chapter markers if the file is an image of a dvd if (drop_chapterStart.Items.Count > 0) { int start, end; int.TryParse(drop_chapterStart.Items[0].ToString(), out start); int.TryParse(drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString(), out end); if (end > start) Check_ChapterMarkers.Enabled = true; else { Check_ChapterMarkers.Enabled = false; Check_ChapterMarkers.Checked = false; data_chpt.Rows.Clear(); } } // If no titles were found, Display an error message if (drp_dvdtitle.Items.Count == 0) { MessageBox.Show( "No Title(s) found. \n\nYour Source may be copy protected, badly mastered or in a format which HandBrake does not support. \nPlease refer to the Documentation and FAQ (see Help Menu).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); sourcePath = string.Empty; } UpdateSourceLabel(); // This is a bit of a hack to fix the queue editing. // If afte the scan, we find a job sitting in queueEdit, then the user has rescaned the source from the queue by clicking edit. // When this occures, we want to repopulate their old settings. if (queueEdit != null) { // Setup UI if (queueEdit.Query != null) { Preset preset = new Preset { Name = "Loaded Back From Queue", Query = queueEdit.Query, CropSettings = true, }; // Now load the preset PresetLoader.LoadPreset(this, preset); preset.Task = queueEdit.Task; this.AudioSettings.LoadTracks(preset); // Set the destination path); this.text_destination.Text = queueEdit.Task.Destination; // The x264 widgets will need updated, so do this now: x264Panel.StandardizeOptString(); x264Panel.SetCurrentSettingsInPanel(); // Set the crop label PictureSettings.SetPresetCropWarningLabel(null); } queueEdit = null; } // Enable the GUI components and enable any disabled components EnableGUI(); } catch (Exception exc) { MessageBox.Show("frmMain.cs - updateUIafterScan " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); EnableGUI(); } }
/// <summary> /// Write the Preset to a file /// </summary> /// <param name="xmlWriter"> /// The xml writer. /// </param> /// <param name="parsed"> /// The parsed. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="build"> /// The build. /// </param> private static void WritePreset(XmlTextWriter xmlWriter, EncodeTask parsed, Preset preset, string build) { xmlWriter.WriteStartElement("dict"); AudioListArrayDict(xmlWriter, parsed); AddEncodeSettings(xmlWriter, parsed, preset, build); xmlWriter.WriteEndElement(); }
/// <summary> /// Take a job from the Queue, rescan it, and reload the GUI for that job. /// </summary> /// <param name="job"> /// The job. /// </param> public void RecievingJob(QueueTask job) { // Reset this.currentlySelectedPreset = null; x264Panel.Reset2Defaults(); // Scan queueEdit = job; // Nasty but will do for now. TODO StartScan(job.Task.Source, job.Task.Title); }
/// <summary> /// Setup this window for a new source /// </summary> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(Title title, Preset preset, EncodeTask 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) { this.AddTracksFromPreset(preset); this.Task.AllowedPassthruOptions = new AllowedPassthru(preset.Task.AllowedPassthruOptions); } this.NotifyOfPropertyChange(() => this.Task); this.Task.AllowedPassthruOptions.IsEnabled = this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.ShowAdvancedAudioPassthruOpts); }
/// <summary> /// RMenu - Save Changes to Preset /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void pmnu_saveChanges_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show( "Do you wish to include picture settings when updating the preset: " + treeView_presets.SelectedNode.Text, "Update Preset", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); Preset preset = new Preset { Name = this.treeView_presets.SelectedNode.Text, Query = QueryGenerator.GenerateQueryForPreset(this, QueryPictureSettingsMode.SourceMaximum, true, 0, 0), CropSettings = (result == DialogResult.Yes) }; presetHandler.Update(preset); }
/// <summary> /// Add the required tracks for the current preset /// </summary> /// <param name="preset"> /// The preset. /// </param> private void AddTracksFromPreset(Preset preset) { // Clear out the old tracks this.Task.AudioTracks.Clear(); // Get the preferred Language IEnumerable<Audio> languages = this.SourceTracks.Where( item => item.Language.Contains( this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguage))); Audio preferred = languages.FirstOrDefault() ?? this.SourceTracks.FirstOrDefault(); // Get the currently selected langauges List<Audio> selectedTracks = this.Task.AudioTracks.Select(track => track.ScannedTrack).ToList(); // Add the preset audio tracks with the preferred language foreach (AudioTrack track in preset.Task.AudioTracks) { this.Task.AudioTracks.Add(new AudioTrack(track) { ScannedTrack = preferred }); } // Attempt to restore the previously selected tracks. // or fallback to the first source track. foreach (AudioTrack track in this.Task.AudioTracks) { if (selectedTracks.Count != 0) { track.ScannedTrack = selectedTracks[0]; selectedTracks.RemoveAt(0); } else { break; } } }
/// <summary> /// Set the Source Title /// </summary> /// <param name="title"> /// The title. /// </param> /// <param name="preset"> /// The preset. /// </param> /// <param name="task"> /// The task. /// </param> public void SetSource(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); }
/// <summary> /// The set preset. /// </summary> /// <param name="preset"> /// The preset. /// </param> /// <param name="currentTitle"> /// The current Title. /// </param> public void Setup(Preset preset, Title currentTitle) { this.IncludeChapterMarkers = preset.Task.IncludeChapterMarkers; this.SetSourceChapters(currentTitle.Chapters); }
/// <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); }
/// <summary> /// Set the Track list dropdown from the parsed title captured during the scan /// </summary> /// <param name="selectedTitle">The selected title</param> /// <param name="preset">A preset</param> public void SetTrackListAfterTitleChange(Title selectedTitle, Preset preset) { // Reset this.AudioTracks.Clear(); this.ScannedTracks.Clear(); if (selectedTitle.AudioTracks.Count == 0) { this.ScannedTracks.Add(AudioHelper.NoneFound); this.drp_audioTrack.Refresh(); drp_audioTrack.SelectedIndex = 0; return; } // Setup the Audio track source dropdown with the new audio tracks. // this.ScannedTracks.Clear(); this.drp_audioTrack.SelectedItem = null; this.ScannedTracks = new BindingList<Audio>(selectedTitle.AudioTracks.ToList()); drp_audioTrack.DataSource = this.ScannedTracks; drp_audioTrack.SelectedItem = this.ScannedTracks.FirstOrDefault(); this.drp_audioTrack.Refresh(); // Add any tracks the preset has, if there is a preset and no audio tracks in the list currently if (audioList.Rows.Count == 0 && preset != null) { EncodeTask parsed = QueryParserUtility.Parse(preset.Query); foreach (AudioTrack audioTrack in parsed.AudioTracks) { audioTrack.ScannedTrack = drp_audioTrack.SelectedItem as Audio; this.audioTracks.Add(audioTrack); } } if (selectedTitle.AudioTracks.Count > 0) { this.AutomaticTrackSelection(); } }
/// <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.SetupTracks(); this.Task.AllowedPassthruOptions = new AllowedPassthru(preset.Task.AllowedPassthruOptions); } this.NotifyOfPropertyChange(() => this.Task); }