From 56a0493beb33fea858bb3f795799994f37523614 Mon Sep 17 00:00:00 2001 From: sr55 Date: Mon, 9 Dec 2019 17:32:21 +0000 Subject: WinGui: Limit iPod atom to H.264. Fixes #2490 --- .../Interop/Model/Encoding/VideoEncoder.cs | 2 +- win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 1 + win/CS/HandBrakeWPF/Helpers/VideoEncoderHelpers.cs | 28 ++++++++++++++++++++++ .../Services/Encode/Factories/EncodeTaskFactory.cs | 3 ++- win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs | 26 +++++++++++++++++++- win/CS/HandBrakeWPF/Views/SummaryView.xaml | 2 +- 6 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 win/CS/HandBrakeWPF/Helpers/VideoEncoderHelpers.cs (limited to 'win/CS') diff --git a/win/CS/HandBrake.Interop/Interop/Model/Encoding/VideoEncoder.cs b/win/CS/HandBrake.Interop/Interop/Model/Encoding/VideoEncoder.cs index e8a2ed485..07da99a20 100644 --- a/win/CS/HandBrake.Interop/Interop/Model/Encoding/VideoEncoder.cs +++ b/win/CS/HandBrake.Interop/Interop/Model/Encoding/VideoEncoder.cs @@ -1,5 +1,5 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 41fce78b6..79d66ca7f 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -139,6 +139,7 @@ + diff --git a/win/CS/HandBrakeWPF/Helpers/VideoEncoderHelpers.cs b/win/CS/HandBrakeWPF/Helpers/VideoEncoderHelpers.cs new file mode 100644 index 000000000..de53cf35c --- /dev/null +++ b/win/CS/HandBrakeWPF/Helpers/VideoEncoderHelpers.cs @@ -0,0 +1,28 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the VideoEncoderHelpers type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Helpers +{ + using System.Configuration; + + using HandBrake.Interop.Interop.Model.Encoding; + + public class VideoEncoderHelpers + { + public static bool IsH264(VideoEncoder encoder) + { + if (encoder == VideoEncoder.X264 || encoder == VideoEncoder.X264_10 || encoder == VideoEncoder.QuickSync || encoder == VideoEncoder.NvencH264) + { + return true; + } + + return false; + } + } +} diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs index 003f13f17..35bd86c39 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs @@ -23,6 +23,7 @@ namespace HandBrakeWPF.Services.Encode.Factories using HandBrake.Interop.Interop.Model.Encoding; using HandBrake.Interop.Model; + using HandBrakeWPF.Helpers; using HandBrakeWPF.Utilities; using Newtonsoft.Json.Linq; @@ -150,7 +151,7 @@ namespace HandBrakeWPF.Services.Encode.Factories File = job.Destination, Mp4Options = new Mp4Options { - IpodAtom = job.IPod5GSupport, + IpodAtom = VideoEncoderHelpers.IsH264(job.VideoEncoder) ? job.IPod5GSupport : false, Mp4Optimize = job.OptimizeMP4 }, ChapterMarkers = job.IncludeChapterMarkers, diff --git a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs index ce4e6969b..161d403a5 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs @@ -228,6 +228,7 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.SelectedOutputFormat); this.NotifyOfPropertyChange(() => this.Task.OutputFormat); this.NotifyOfPropertyChange(() => this.IsMkvOrWebm); + this.NotifyOfPropertyChange(() => this.IsIpodAtomVisible); this.SetExtension(string.Format(".{0}", this.Task.OutputFormat.ToString().ToLower())); this.UpdateDisplayedInfo(); // output format may coreced to another due to container incompatibility @@ -248,6 +249,19 @@ namespace HandBrakeWPF.ViewModels } } + public bool IsIpodAtomVisible + { + get + { + if (this.task == null) + { + return false; + } + + return this.SelectedOutputFormat == OutputFormat.Mp4 && VideoEncoderHelpers.IsH264(this.task.VideoEncoder); + } + } + /// /// Optimise MP4 Checkbox /// @@ -278,6 +292,7 @@ namespace HandBrakeWPF.ViewModels { return this.Task?.IPod5GSupport ?? false; } + set { if (value == this.Task.IPod5GSupport) @@ -334,7 +349,8 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.SelectedOutputFormat); this.NotifyOfPropertyChange(() => this.IsMkvOrWebm); - + this.NotifyOfPropertyChange(() => this.IsIpodAtomVisible); + this.NotifyOfPropertyChange(() => this.OptimizeMP4); this.NotifyOfPropertyChange(() => this.IPod5GSupport); this.NotifyOfPropertyChange(() => this.AlignAVStart); @@ -478,7 +494,13 @@ namespace HandBrakeWPF.ViewModels this.AlignAVStart = false; } + if (!VideoEncoderHelpers.IsH264(this.task.VideoEncoder)) + { + this.IPod5GSupport = false; + } + this.NotifyOfPropertyChange(() => this.IsMkvOrWebm); + this.NotifyOfPropertyChange(() => this.IsIpodAtomVisible); // Update The browse file extension display if (Path.HasExtension(newExtension)) @@ -526,6 +548,8 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.PreviewInfo); this.ShowPreview = this.userSettingService.GetUserSetting(UserSettingConstants.ShowPreviewOnSummaryTab); + + this.NotifyOfPropertyChange(() => this.IsIpodAtomVisible); } private string GetFilterDescription() diff --git a/win/CS/HandBrakeWPF/Views/SummaryView.xaml b/win/CS/HandBrakeWPF/Views/SummaryView.xaml index a6e5081f1..9ec428b0e 100644 --- a/win/CS/HandBrakeWPF/Views/SummaryView.xaml +++ b/win/CS/HandBrakeWPF/Views/SummaryView.xaml @@ -75,7 +75,7 @@ Content="{x:Static Properties:Resources.MainView_iPod5G}" ToolTip="{x:Static Properties:ResourcesTooltips.MainView_IpodAtom}" IsChecked="{Binding Path=IPod5GSupport}" - Visibility="{Binding IsMkvOrWebm, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" /> + Visibility="{Binding IsIpodAtomVisible, Converter={StaticResource boolToVisConverter}}" /> -- cgit v1.2.3