From e2aaa9f501ab10d6ca3b01dbd3306b73334c917e Mon Sep 17 00:00:00 2001 From: sr55 Date: Wed, 14 Jun 2017 22:07:14 +0100 Subject: [PATCH] WinGui: Add checkbox for Legacy A/V alignment behaviour for players that don't support MP4 Edit Lists. #778 --- .../Interop/Json/Encode/Destination.cs | 5 +++++ .../Interop/Json/Presets/HBPreset.cs | 2 ++ .../Properties/ResourcesTooltips.Designer.cs | 9 +++++++++ .../Properties/ResourcesTooltips.resx | 3 +++ .../Properties/ResourcesUI.Designer.cs | 9 +++++++++ .../HandBrakeWPF/Properties/ResourcesUI.resx | 3 +++ .../Encode/Factories/EncodeFactory.cs | 1 + .../Services/Encode/Model/EncodeTask.cs | 3 +++ .../Presets/Factories/JsonPresetFactory.cs | 2 ++ .../HandBrakeWPF/ViewModels/MainViewModel.cs | 20 +++++++++++++++++++ win/CS/HandBrakeWPF/Views/MainView.xaml | 13 ++++++++++-- 11 files changed, 68 insertions(+), 2 deletions(-) diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Destination.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Destination.cs index 9d22fb98a..910a541ca 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Destination.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Encode/Destination.cs @@ -26,6 +26,11 @@ namespace HandBrake.ApplicationServices.Interop.Json.Encode /// public bool ChapterMarkers { get; set; } + /// + /// Use Legacy A/V Alignment rather than Edit Lists. + /// + public bool AlignAVStart { get; set; } + /// /// Gets or sets the file. /// diff --git a/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/HBPreset.cs b/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/HBPreset.cs index 6ddb9c0c2..1df789cb2 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/HBPreset.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/Json/Presets/HBPreset.cs @@ -16,6 +16,8 @@ namespace HandBrake.ApplicationServices.Interop.Json.Presets /// public class HBPreset { + public bool AlignAVStart { get; set; } + /// /// Gets or sets the audio copy mask. /// diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs index 9da007c10..d629a2424 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.Designer.cs @@ -311,6 +311,15 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to Aligns the initial timestamps of all audio and video streams by inserting blank frames or dropping frames. May improve audio/video sync for broken players that do not honor MP4 edit lists.. + /// + public static string MainView_AlignAVStart { + get { + return ResourceManager.GetString("MainView_AlignAVStart", resourceCulture); + } + } + /// /// Looks up a localized string similar to Video angle to encode. Only applicable to multi-angle DVD and Blu-ray.. /// diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx b/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx index ed2d40c51..e5b35b1b8 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx +++ b/win/CS/HandBrakeWPF/Properties/ResourcesTooltips.resx @@ -454,4 +454,7 @@ Lapsharp's Animation tune is useful for cel animation such as anime and cartoons Lapsharp's Sprite tune is useful for 1-/4-/8-/16-bit 2-dimensional games. Sprite uses a 4-neighbor Laplacian kernel that enhances vertical and horizontal edges more than diagonal edges. + + Aligns the initial timestamps of all audio and video streams by inserting blank frames or dropping frames. May improve audio/video sync for broken players that do not honor MP4 edit lists. + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs index 594420109..6ca2f276e 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs @@ -654,6 +654,15 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to Align A/V Start. + /// + public static string MainView_AlignAVStart { + get { + return ResourceManager.GetString("MainView_AlignAVStart", resourceCulture); + } + } + /// /// Looks up a localized string similar to Angle. /// diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx index 34edf84b0..6349d4978 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx @@ -911,4 +911,7 @@ This will not affect your current settings in the Subtitle tab. Sharpen + + Align A/V Start + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs index 20e4eff14..18021c9bc 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeFactory.cs @@ -146,6 +146,7 @@ namespace HandBrakeWPF.Services.Encode.Factories Mp4Optimize = job.OptimizeMP4 }, ChapterMarkers = job.IncludeChapterMarkers, + AlignAVStart = job.AlignAVStart, Mux = HBFunctions.hb_container_get_from_name(job.OutputFormat == OutputFormat.Mp4 ? "av_mp4" : "av_mkv"), // TODO tidy up. ChapterList = new List() }; diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs index 84d1eb7eb..f65cf6891 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs @@ -87,6 +87,7 @@ namespace HandBrakeWPF.Services.Encode.Model this.ChapterNames.Add(new ChapterMarker(track)); } + this.AlignAVStart = task.AlignAVStart; this.ChapterMarkersFilePath = task.ChapterMarkersFilePath; this.Cropping = new Cropping(task.Cropping); this.CustomDecomb = task.CustomDecomb; @@ -218,6 +219,8 @@ namespace HandBrakeWPF.Services.Encode.Model /// public bool IPod5GSupport { get; set; } + public bool AlignAVStart { get; set; } + #endregion #region Picture diff --git a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs index 9b252e030..787e5ea46 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs @@ -72,6 +72,7 @@ namespace HandBrakeWPF.Services.Presets.Factories preset.Task.OptimizeMP4 = importedPreset.Mp4HttpOptimize; preset.Task.IPod5GSupport = importedPreset.Mp4iPodCompatible; preset.Task.OutputFormat = GetFileFormat(importedPreset.FileFormat.Replace("file", string.Empty).Trim()); // TOOD null check. + preset.Task.AlignAVStart = importedPreset.AlignAVStart; /* Picture Settings */ preset.PictureSettingsMode = (PresetPictureSettingsMode)importedPreset.UsesPictureSettings; @@ -604,6 +605,7 @@ namespace HandBrakeWPF.Services.Presets.Factories preset.FileFormat = EnumHelper.GetShortName(export.Task.OutputFormat); preset.Mp4HttpOptimize = export.Task.OptimizeMP4; preset.Mp4iPodCompatible = export.Task.IPod5GSupport; + preset.AlignAVStart = export.Task.AlignAVStart; // Picture Settings preset.PictureForceHeight = 0; // TODO diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 0a8d0b297..1502d4baa 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -393,6 +393,7 @@ namespace HandBrakeWPF.ViewModels this.OptimizeMP4 = selectedPreset.Task.OptimizeMP4; this.IPod5GSupport = selectedPreset.Task.IPod5GSupport; this.SelectedOutputFormat = selectedPreset.Task.OutputFormat; + this.AlignAVStart = selectedPreset.Task.AlignAVStart; // Tab Settings this.PictureSettingsViewModel.SetPreset(this.selectedPreset, this.CurrentTask); @@ -458,6 +459,23 @@ namespace HandBrakeWPF.ViewModels } } + public bool AlignAVStart + { + get + { + return this.CurrentTask.AlignAVStart; + } + set + { + if (value == this.CurrentTask.AlignAVStart) + { + return; + } + this.CurrentTask.AlignAVStart = value; + this.NotifyOfPropertyChange(() => this.AlignAVStart); + } + } + /// /// Gets or sets The Current Encode Task that the user is building /// @@ -2218,9 +2236,11 @@ namespace HandBrakeWPF.ViewModels this.IsMkv = true; this.CurrentTask.OptimizeMP4 = false; this.CurrentTask.IPod5GSupport = false; + this.CurrentTask.AlignAVStart = false; this.NotifyOfPropertyChange(() => this.OptimizeMP4); this.NotifyOfPropertyChange(() => this.IPod5GSupport); + this.NotifyOfPropertyChange(() => this.AlignAVStart); } // Update The browse file extension display diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index 507ceb41d..b8da5c564 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -431,8 +431,17 @@ IsChecked="{Binding Path=IPod5GSupport}" Visibility="{Binding IsMkv, Converter={StaticResource boolToVisConverter}, - ConverterParameter=true}" - /> + ConverterParameter=true}" /> + + -- 2.40.0