From deec7e2a6b0ee438b308b6a71e4f382e55a0aaa1 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Thu, 25 Oct 2018 08:31:29 +0200 Subject: [PATCH 1/9] Add custom command argument for ffmpeg. --- .../ConversionJobs/ConversionJob_FFMPEG.cs | 10 ++++++++++ .../FileConverter/ConversionPreset/ConversionPreset.cs | 1 + 2 files changed, 11 insertions(+) diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs index 4d94c55..eff9f42 100644 --- a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs +++ b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs @@ -84,6 +84,16 @@ namespace FileConverter.ConversionJobs protected virtual void FillFFMpegArgumentsList() { + string customCommand = this.ConversionPreset.GetSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand); + if (!string.IsNullOrEmpty(customCommand)) + { + // Custom command override other settings. + string arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, customCommand); + + this.ffmpegArgumentStringByPass.Add(new FFMpegPass(arguments)); + return; + } + // This option are necessary to be able to read metadata on Windows. src: http://jonhall.info/how_to/create_id3_tags_using_ffmpeg const string MP3MetadataArgs = "-id3v2_version 3 -write_id3v1 1"; diff --git a/Application/FileConverter/ConversionPreset/ConversionPreset.cs b/Application/FileConverter/ConversionPreset/ConversionPreset.cs index 669b287..1b25b2f 100644 --- a/Application/FileConverter/ConversionPreset/ConversionPreset.cs +++ b/Application/FileConverter/ConversionPreset/ConversionPreset.cs @@ -597,6 +597,7 @@ namespace FileConverter public const string VideoScale = "VideoScale"; public const string VideoRotation = "VideoRotation"; public const string VideoFramesPerSecond = "VideoFramesPerSecond"; + public const string FFMPEGCustomCommand = "FFMPEGCustomCommand"; public const string EnableAudio = "EnableAudio"; public const string EnableVideo = "EnableVideo"; From f289e5c5b47b019235878b1c424711ea65956deb Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Fri, 12 Jul 2019 18:25:47 +0200 Subject: [PATCH 2/9] Rename ConversionPresetTemplates.xaml --- Application/FileConverter/FileConverter.csproj | 2 +- .../{ConversionPresets.xaml => ConversionPresetTemplates.xaml} | 0 Application/FileConverter/Views/SettingsWindow.xaml | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename Application/FileConverter/Views/Resources/{ConversionPresets.xaml => ConversionPresetTemplates.xaml} (100%) diff --git a/Application/FileConverter/FileConverter.csproj b/Application/FileConverter/FileConverter.csproj index 35da5d2..5242b88 100644 --- a/Application/FileConverter/FileConverter.csproj +++ b/Application/FileConverter/FileConverter.csproj @@ -287,7 +287,7 @@ MainWindow.xaml Code - + MSBuild:Compile Designer diff --git a/Application/FileConverter/Views/Resources/ConversionPresets.xaml b/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml similarity index 100% rename from Application/FileConverter/Views/Resources/ConversionPresets.xaml rename to Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml diff --git a/Application/FileConverter/Views/SettingsWindow.xaml b/Application/FileConverter/Views/SettingsWindow.xaml index 346866a..f0ee062 100644 --- a/Application/FileConverter/Views/SettingsWindow.xaml +++ b/Application/FileConverter/Views/SettingsWindow.xaml @@ -25,7 +25,7 @@ - + From 78e689a1021738c2ff0cff0ee4083b510e391dcd Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Fri, 12 Jul 2019 18:41:37 +0200 Subject: [PATCH 3/9] Initialize preset for custom command. --- .../ConversionPreset/ConversionPreset.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Application/FileConverter/ConversionPreset/ConversionPreset.cs b/Application/FileConverter/ConversionPreset/ConversionPreset.cs index 1b25b2f..36d3b6d 100644 --- a/Application/FileConverter/ConversionPreset/ConversionPreset.cs +++ b/Application/FileConverter/ConversionPreset/ConversionPreset.cs @@ -341,9 +341,9 @@ namespace FileConverter throw new ArgumentNullException("key"); } - if (string.IsNullOrEmpty(value)) + if (value == null) { - throw new ArgumentNullException("value"); + throw new ArgumentNullException(nameof(value)); } if (!this.IsRelevantSetting(settingsKey)) @@ -428,26 +428,31 @@ namespace FileConverter case OutputType.Aac: this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "128"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioChannelCount, "0"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; case OutputType.Flac: this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioChannelCount, "0"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; case OutputType.Ogg: this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "160"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioChannelCount, "0"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; case OutputType.Mp3: this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioEncodingMode, EncodingMode.Mp3VBR.ToString(), true); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "190"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioChannelCount, "0"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; case OutputType.Wav: this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioEncodingMode, EncodingMode.Wav16.ToString(), true); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioChannelCount, "0"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; // Video @@ -457,6 +462,7 @@ namespace FileConverter this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoScale, "1"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoRotation, "0"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "190"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; case OutputType.Mkv: @@ -466,6 +472,7 @@ namespace FileConverter this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoScale, "1"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoRotation, "0"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "128"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; case OutputType.Mp4: @@ -475,6 +482,7 @@ namespace FileConverter this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoScale, "1"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoRotation, "0"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "128"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; case OutputType.Ogv: @@ -483,6 +491,7 @@ namespace FileConverter this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoScale, "1"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoRotation, "0"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "160"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; case OutputType.Webm: @@ -491,6 +500,7 @@ namespace FileConverter this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoQuality, "40"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoScale, "1"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoRotation, "0"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; // Images @@ -544,9 +554,9 @@ namespace FileConverter throw new ArgumentNullException("key"); } - if (string.IsNullOrEmpty(value)) + if (value == null) { - throw new ArgumentNullException("value"); + throw new ArgumentNullException(nameof(value)); } if (!this.settings.ContainsKey(settingsKey)) From 70fcb74da69012174173cb7d4aea6d7bcd7250ef Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Mon, 15 Jul 2019 16:47:48 +0200 Subject: [PATCH 4/9] Add boolean to activate FFMPEG custom command --- .../ConversionJobs/ConversionJob_FFMPEG.cs | 8 +++++--- .../ConversionPreset/ConversionPreset.cs | 11 +++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs index eff9f42..cac27bb 100644 --- a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs +++ b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs @@ -84,13 +84,15 @@ namespace FileConverter.ConversionJobs protected virtual void FillFFMpegArgumentsList() { - string customCommand = this.ConversionPreset.GetSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand); - if (!string.IsNullOrEmpty(customCommand)) + bool customCommandEnabled = this.ConversionPreset.GetSettingsValue(ConversionPreset.ConversionSettingKeys.EnableFFMPEGCustomCommand); + if (customCommandEnabled) { // Custom command override other settings. - string arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, customCommand); + string customCommand = this.ConversionPreset.GetSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand) ?? string.Empty; + string arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, customCommand); this.ffmpegArgumentStringByPass.Add(new FFMpegPass(arguments)); + return; } diff --git a/Application/FileConverter/ConversionPreset/ConversionPreset.cs b/Application/FileConverter/ConversionPreset/ConversionPreset.cs index 36d3b6d..dda2109 100644 --- a/Application/FileConverter/ConversionPreset/ConversionPreset.cs +++ b/Application/FileConverter/ConversionPreset/ConversionPreset.cs @@ -428,17 +428,20 @@ namespace FileConverter case OutputType.Aac: this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "128"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioChannelCount, "0"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.EnableFFMPEGCustomCommand, "False"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; case OutputType.Flac: this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioChannelCount, "0"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.EnableFFMPEGCustomCommand, "False"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; case OutputType.Ogg: this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "160"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioChannelCount, "0"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.EnableFFMPEGCustomCommand, "False"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; @@ -446,12 +449,14 @@ namespace FileConverter this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioEncodingMode, EncodingMode.Mp3VBR.ToString(), true); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "190"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioChannelCount, "0"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.EnableFFMPEGCustomCommand, "False"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; case OutputType.Wav: this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioEncodingMode, EncodingMode.Wav16.ToString(), true); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioChannelCount, "0"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.EnableFFMPEGCustomCommand, "False"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; @@ -462,6 +467,7 @@ namespace FileConverter this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoScale, "1"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoRotation, "0"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "190"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.EnableFFMPEGCustomCommand, "False"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; @@ -472,6 +478,7 @@ namespace FileConverter this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoScale, "1"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoRotation, "0"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "128"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.EnableFFMPEGCustomCommand, "False"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; @@ -482,6 +489,7 @@ namespace FileConverter this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoScale, "1"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoRotation, "0"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "128"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.EnableFFMPEGCustomCommand, "False"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; @@ -491,6 +499,7 @@ namespace FileConverter this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoScale, "1"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoRotation, "0"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "160"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.EnableFFMPEGCustomCommand, "False"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; @@ -500,6 +509,7 @@ namespace FileConverter this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoQuality, "40"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoScale, "1"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoRotation, "0"); + this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.EnableFFMPEGCustomCommand, "False"); this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.FFMPEGCustomCommand, string.Empty); break; @@ -611,6 +621,7 @@ namespace FileConverter public const string EnableAudio = "EnableAudio"; public const string EnableVideo = "EnableVideo"; + public const string EnableFFMPEGCustomCommand = "EnableFFMPEGCustomCommand"; } } } From 1c43f3f40a52b00c6361afd8f1478b3186060258 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Mon, 15 Jul 2019 16:48:55 +0200 Subject: [PATCH 5/9] Add UI to configure FFMPEG custom command for Mkv and Mp4 --- Application/FileConverter/Application.xaml | 5 - .../Properties/Resources.Designer.cs | 27 +++ .../FileConverter/Properties/Resources.resx | 9 + .../Generic/BoolToVisibility.cs | 20 ++- .../Resources/ConversionPresetTemplates.xaml | 166 +++++++++++------- 5 files changed, 154 insertions(+), 73 deletions(-) diff --git a/Application/FileConverter/Application.xaml b/Application/FileConverter/Application.xaml index 89ccb9e..0a4644e 100644 --- a/Application/FileConverter/Application.xaml +++ b/Application/FileConverter/Application.xaml @@ -57,11 +57,6 @@ - - - - - diff --git a/Application/FileConverter/Properties/Resources.Designer.cs b/Application/FileConverter/Properties/Resources.Designer.cs index 489b5af..c2cb5e1 100644 --- a/Application/FileConverter/Properties/Resources.Designer.cs +++ b/Application/FileConverter/Properties/Resources.Designer.cs @@ -96,6 +96,15 @@ namespace FileConverter.Properties { } } + /// + /// Looks up a localized string similar to Advance mode. + /// + public static string AdvanceMode { + get { + return ResourceManager.GetString("AdvanceMode", resourceCulture); + } + } + /// /// Looks up a localized string similar to Application. /// @@ -627,6 +636,24 @@ namespace FileConverter.Properties { } } + /// + /// Looks up a localized string similar to Custom Arguments. + /// + public static string FFMPEGCustomArguments { + get { + return ResourceManager.GetString("FFMPEGCustomArguments", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Custom FFMPEG command line arguments. + /// + public static string FFMPEGCustomArgumentsTooltip { + get { + return ResourceManager.GetString("FFMPEGCustomArgumentsTooltip", resourceCulture); + } + } + /// /// Looks up a localized string similar to File Converter is a shell extension.. /// diff --git a/Application/FileConverter/Properties/Resources.resx b/Application/FileConverter/Properties/Resources.resx index 359b577..d0da4cf 100644 --- a/Application/FileConverter/Properties/Resources.resx +++ b/Application/FileConverter/Properties/Resources.resx @@ -562,4 +562,13 @@ use maj for uppercase version Folder Name + + Advance mode + + + Custom Arguments + + + Custom FFMPEG command line arguments + \ No newline at end of file diff --git a/Application/FileConverter/ValueConverters/Generic/BoolToVisibility.cs b/Application/FileConverter/ValueConverters/Generic/BoolToVisibility.cs index 5ecfbcc..e278ef6 100644 --- a/Application/FileConverter/ValueConverters/Generic/BoolToVisibility.cs +++ b/Application/FileConverter/ValueConverters/Generic/BoolToVisibility.cs @@ -17,11 +17,27 @@ namespace FileConverter.ValueConverters.Generic string stringParameter = parameter as string; - string falseResult = stringParameter ?? "Hidden"; + string trueResult = "Visible"; + string falseResult = "Hidden"; + if (!string.IsNullOrEmpty(stringParameter)) + { + string[] results = stringParameter.Split(';'); + Diagnostics.Debug.Assert(results.Length <= 2, "results.Length <= 2"); + + if (results.Length >= 1) + { + falseResult = results[0]; + } + + if (results.Length >= 2) + { + trueResult = results[1]; + } + } bool booleanValue = (bool)value; - return booleanValue ? "Visible" : falseResult; + return booleanValue ? trueResult : falseResult; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) diff --git a/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml b/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml index 0dfa7d0..502ec63 100644 --- a/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml +++ b/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml @@ -35,6 +35,12 @@ + + + + + + @@ -292,81 +298,109 @@ - - - - - - - - - - - - - - - - - From 20ea28c32860c99be7cbb06c2fe5d9b5ecc5aaa8 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Thu, 18 Jul 2019 19:06:41 +0200 Subject: [PATCH 6/9] Add UI to edit FFMPEGCustomCommand when the option is available. --- .../ConversionPreset/ConversionPreset.cs | 10 +- .../FileConverter/FileConverter.csproj | 2 +- .../ConversionSettingsRelevant.cs | 39 +++ .../ConversionSettingsTemplateSelector.cs | 157 ---------- .../Resources/ConversionPresetTemplates.xaml | 271 +++++++++++------- .../FileConverter/Views/SettingsWindow.xaml | 8 +- 6 files changed, 208 insertions(+), 279 deletions(-) create mode 100644 Application/FileConverter/ValueConverters/ConversionSettingsRelevant.cs delete mode 100644 Application/FileConverter/Views/ConversionSettingsTemplateSelector.cs diff --git a/Application/FileConverter/ConversionPreset/ConversionPreset.cs b/Application/FileConverter/ConversionPreset/ConversionPreset.cs index dda2109..59a4c6e 100644 --- a/Application/FileConverter/ConversionPreset/ConversionPreset.cs +++ b/Application/FileConverter/ConversionPreset/ConversionPreset.cs @@ -127,10 +127,7 @@ namespace FileConverter [XmlAttribute] public OutputType OutputType { - get - { - return this.outputType; - } + get => this.outputType; set { @@ -254,10 +251,7 @@ namespace FileConverter [XmlIgnore] public IConversionSettings Settings { - get - { - return this.settings; - } + get => this.settings; set { diff --git a/Application/FileConverter/FileConverter.csproj b/Application/FileConverter/FileConverter.csproj index 5242b88..0e77bd1 100644 --- a/Application/FileConverter/FileConverter.csproj +++ b/Application/FileConverter/FileConverter.csproj @@ -201,6 +201,7 @@ + @@ -236,7 +237,6 @@ DiagnosticsWindow.xaml - diff --git a/Application/FileConverter/ValueConverters/ConversionSettingsRelevant.cs b/Application/FileConverter/ValueConverters/ConversionSettingsRelevant.cs new file mode 100644 index 0000000..a0b7a27 --- /dev/null +++ b/Application/FileConverter/ValueConverters/ConversionSettingsRelevant.cs @@ -0,0 +1,39 @@ +// License: http://www.gnu.org/licenses/gpl.html GPL version 3. + +namespace FileConverter.ValueConverters +{ + using System; + using System.Globalization; + using System.Windows.Data; + + public class ConversionSettingsRelevant : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return null; + } + + if (!(value is IConversionSettings)) + { + throw new ArgumentException("The value must be a conversion preset array."); + } + + IConversionSettings settings = (IConversionSettings)value; + + string key = parameter as string; + if (key == null) + { + throw new ArgumentException("The parameter must be a string value."); + } + + return settings.ContainsKey(key); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new Exception(); + } + } +} diff --git a/Application/FileConverter/Views/ConversionSettingsTemplateSelector.cs b/Application/FileConverter/Views/ConversionSettingsTemplateSelector.cs deleted file mode 100644 index 946d062..0000000 --- a/Application/FileConverter/Views/ConversionSettingsTemplateSelector.cs +++ /dev/null @@ -1,157 +0,0 @@ -// License: http://www.gnu.org/licenses/gpl.html GPL version 3. - -namespace FileConverter.Views -{ - using System.Windows; - using System.Windows.Controls; - - public class ConversionSettingsTemplateSelector : DataTemplateSelector - { - public DataTemplate DefaultDataTemplate - { - get; - set; - } - - public DataTemplate AviSettingsDataTemplate - { - get; - set; - } - - public DataTemplate FlacSettingsDataTemplate - { - get; - set; - } - - public DataTemplate WavSettingsDataTemplate - { - get; - set; - } - - public DataTemplate Mp3SettingsDataTemplate - { - get; - set; - } - - public DataTemplate Mp4SettingsDataTemplate - { - get; - set; - } - - public DataTemplate OggSettingsDataTemplate - { - get; - set; - } - - public DataTemplate OgvSettingsDataTemplate - { - get; - set; - } - - public DataTemplate AacSettingsDataTemplate - { - get; - set; - } - - public DataTemplate GifSettingsDataTemplate - { - get; - set; - } - - public DataTemplate JpgSettingsDataTemplate - { - get; - set; - } - - public DataTemplate PngSettingsDataTemplate - { - get; - set; - } - - public DataTemplate MkvSettingsDataTemplate - { - get; - set; - } - - public DataTemplate WebmSettingsDataTemplate - { - get; - set; - } - - public DataTemplate WebpSettingsDataTemplate - { - get; - set; - } - - public override DataTemplate SelectTemplate(object item, DependencyObject container) - { - if (item == null) - { - return this.DefaultDataTemplate; - } - - ConversionPreset conversionPreset = (ConversionPreset)item; - - switch (conversionPreset.OutputType) - { - case OutputType.Aac: - return this.AacSettingsDataTemplate; - - case OutputType.Avi: - return this.AviSettingsDataTemplate; - - case OutputType.Flac: - return this.FlacSettingsDataTemplate; - - case OutputType.Gif: - return this.GifSettingsDataTemplate; - - case OutputType.Jpg: - return this.JpgSettingsDataTemplate; - - case OutputType.Mkv: - return this.MkvSettingsDataTemplate; - - case OutputType.Mp3: - return this.Mp3SettingsDataTemplate; - - case OutputType.Mp4: - return this.Mp4SettingsDataTemplate; - - case OutputType.Ogg: - return this.OggSettingsDataTemplate; - - case OutputType.Ogv: - return this.OgvSettingsDataTemplate; - - case OutputType.Png: - return this.PngSettingsDataTemplate; - - case OutputType.Wav: - return this.WavSettingsDataTemplate; - - case OutputType.Webm: - return this.WebmSettingsDataTemplate; - - case OutputType.Webp: - return this.WebpSettingsDataTemplate; - } - - return this.DefaultDataTemplate; - } - } -} diff --git a/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml b/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml index 502ec63..b66111d 100644 --- a/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml +++ b/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml @@ -19,6 +19,7 @@ + @@ -298,109 +299,82 @@ - - - - + @@ -640,22 +614,99 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Application/FileConverter/Views/SettingsWindow.xaml b/Application/FileConverter/Views/SettingsWindow.xaml index f0ee062..63bf555 100644 --- a/Application/FileConverter/Views/SettingsWindow.xaml +++ b/Application/FileConverter/Views/SettingsWindow.xaml @@ -277,14 +277,16 @@ - + - + + + From c8095c48cfcb90822c30bc3ca21eaf04ccd61770 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Fri, 19 Jul 2019 09:14:04 +0200 Subject: [PATCH 7/9] Add new custom preset to convert video in 720p and 1080p --- .../FileConverter/Settings.default.xml | 384 ++++++++++++++++-- 1 file changed, 355 insertions(+), 29 deletions(-) diff --git a/Application/FileConverter/Settings.default.xml b/Application/FileConverter/Settings.default.xml index fc588fa..b770030 100644 --- a/Application/FileConverter/Settings.default.xml +++ b/Application/FileConverter/Settings.default.xml @@ -24,6 +24,8 @@ + + (p)(f) @@ -47,6 +49,8 @@ + + (p)(f) @@ -70,6 +74,8 @@ + + (p)(f) @@ -92,6 +98,8 @@ + + (p)(f) @@ -114,6 +122,8 @@ + + (p)(f) @@ -136,6 +146,8 @@ + + (p)(f) @@ -235,6 +247,8 @@ None + + (p)(f) @@ -244,6 +258,8 @@ aiff None + + (p)(f) @@ -271,6 +287,8 @@ None + + (p)(f) @@ -299,6 +317,8 @@ + + (p)(f) @@ -326,6 +346,8 @@ None + + (p)(f) @@ -337,6 +359,8 @@ + + (p:v)DVD Extraction\(f) @@ -348,12 +372,16 @@ + + (p:v)DVD Extraction\(f) vob None + + (p:m)DVD Extraction\(f) @@ -361,6 +389,8 @@ None + + (p:m)DVD Extraction\(f) @@ -369,12 +399,16 @@ + + (p:m)DVD Extraction\(f) cda None + + (p:m)CDA Extraction\(f) @@ -382,6 +416,8 @@ None + + (p:m)CDA Extraction\(f) @@ -390,6 +426,8 @@ + + (p:m)CDA Extraction\(f) @@ -539,7 +577,7 @@ None (p)(f) - + 3gp avi bik @@ -560,9 +598,11 @@ + + (p)(f) - + gif 3gp avi @@ -583,9 +623,11 @@ + + (p)(f) - + avi bik flv @@ -605,9 +647,11 @@ + + (p)(f) - + 3gp avi bik @@ -627,9 +671,11 @@ + + (p)(f) - + 3gp avi bik @@ -649,9 +695,11 @@ + + (p)(f) - + arw bmp cr2 @@ -677,7 +725,7 @@ (p)(f)-small - + arw bmp cr2 @@ -704,7 +752,7 @@ (p)(f) - + arw bmp cr2 @@ -731,7 +779,7 @@ (p)(f) - + 3gp avi bik @@ -752,9 +800,11 @@ + + (p)(f) - + gif 3gp avi @@ -775,9 +825,11 @@ + + (p)(f) - + avi bik flv @@ -797,9 +849,11 @@ + + (p)(f) - + 3gp avi bik @@ -819,9 +873,11 @@ + + (p)(f) - + 3gp avi bik @@ -841,6 +897,8 @@ + + (p)(f) @@ -869,7 +927,7 @@ (p)(f)-small - + arw bmp cr2 @@ -896,7 +954,7 @@ (p)(f) - + arw bmp cr2 @@ -923,7 +981,251 @@ (p)(f) - + + 3gp + avi + bik + flv + m4v + mkv + mov + mp4 + mpeg + ogv + webm + wmv + gif + None + + + + + + + + + (p)(f) (720p) + + + 3gp + avi + bik + flv + m4v + mkv + mov + mp4 + mpeg + ogv + webm + wmv + gif + None + + + + + + + + + (p)(f) (720p) + + + 3gp + avi + bik + flv + m4v + mkv + mov + mp4 + mpeg + ogv + webm + wmv + gif + None + + + + + + + + (p)(f) (720p) + + + 3gp + avi + bik + flv + m4v + mkv + mov + mp4 + mpeg + ogv + webm + wmv + gif + None + + + + + + + + (p)(f) (720p) + + + 3gp + avi + bik + flv + m4v + mkv + mov + mp4 + mpeg + ogv + webm + wmv + gif + None + + + + + + + + (p)(f) (720p) + + + 3gp + avi + bik + flv + m4v + mkv + mov + mp4 + mpeg + ogv + webm + wmv + gif + None + + + + + + + + + (p)(f) (720p) + + + 3gp + avi + bik + flv + m4v + mkv + mov + mp4 + mpeg + ogv + webm + wmv + gif + None + + + + + + + + + (p)(f) (720p) + + + 3gp + avi + bik + flv + m4v + mkv + mov + mp4 + mpeg + ogv + webm + wmv + gif + None + + + + + + + + (p)(f) (720p) + + + 3gp + avi + bik + flv + m4v + mkv + mov + mp4 + mpeg + ogv + webm + wmv + gif + None + + + + + + + + (p)(f) (720p) + + + 3gp + avi + bik + flv + m4v + mkv + mov + mp4 + mpeg + ogv + webm + wmv + gif + None + + + + + + + + (p)(f) (720p) + + 3gp avi bik @@ -944,6 +1246,8 @@ + + (p)(f) @@ -967,9 +1271,11 @@ + + (p)(f) - + 3gp avi bik @@ -990,9 +1296,11 @@ + + (p)(f) - + avi bik flv @@ -1012,9 +1320,11 @@ + + (p)(f) - + 3gp avi bik @@ -1034,9 +1344,11 @@ + + (p)(f) - + gif 3gp avi @@ -1056,6 +1368,8 @@ + + (p)(f) @@ -1083,7 +1397,7 @@ (p)(f) - + arw bmp cr2 @@ -1110,7 +1424,7 @@ (p)(f) - + arw bmp cr2 @@ -1137,7 +1451,7 @@ (p)(f) - + 3gp avi bik @@ -1158,6 +1472,8 @@ + + (p)(f) @@ -1181,9 +1497,11 @@ + + (p)(f) - + 3gp avi bik @@ -1204,9 +1522,11 @@ + + (p)(f) - + avi bik flv @@ -1226,9 +1546,11 @@ + + (p)(f) - + 3gp avi bik @@ -1248,9 +1570,11 @@ + + (p)(f) - + gif 3gp avi @@ -1270,6 +1594,8 @@ + + (p)(f) @@ -1297,7 +1623,7 @@ (p)(f) - + arw bmp cr2 @@ -1324,7 +1650,7 @@ (p)(f) - + arw bmp cr2 From 33c54dd910b1082b550dce5c168b8df3595f6e54 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Fri, 19 Jul 2019 09:16:09 +0200 Subject: [PATCH 8/9] Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c682e11..42a84db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log ## Next version +- Added: Possibility to create custom command line preset for types converted with FFMPEG (video and audio). - Added: Possibility to create preset folders in File Converter context menu. - Added: Ability to drag and drop to move conversion presets. - Added: Brazilian Portuguese translation (thanks to Marhc). From 7965df847b542850913d2811d96e0cffd95fd876 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Fri, 19 Jul 2019 20:05:19 +0200 Subject: [PATCH 9/9] Review --- Application/FileConverter/Properties/Resources.Designer.cs | 6 +++--- Application/FileConverter/Properties/Resources.resx | 4 ++-- .../ValueConverters/ConversionSettingsRelevant.cs | 2 +- .../Views/Resources/ConversionPresetTemplates.xaml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Application/FileConverter/Properties/Resources.Designer.cs b/Application/FileConverter/Properties/Resources.Designer.cs index c2cb5e1..0c0ca11 100644 --- a/Application/FileConverter/Properties/Resources.Designer.cs +++ b/Application/FileConverter/Properties/Resources.Designer.cs @@ -97,11 +97,11 @@ namespace FileConverter.Properties { } /// - /// Looks up a localized string similar to Advance mode. + /// Looks up a localized string similar to Advanced mode. /// - public static string AdvanceMode { + public static string AdvancedMode { get { - return ResourceManager.GetString("AdvanceMode", resourceCulture); + return ResourceManager.GetString("AdvancedMode", resourceCulture); } } diff --git a/Application/FileConverter/Properties/Resources.resx b/Application/FileConverter/Properties/Resources.resx index d0da4cf..7412c0e 100644 --- a/Application/FileConverter/Properties/Resources.resx +++ b/Application/FileConverter/Properties/Resources.resx @@ -562,8 +562,8 @@ use maj for uppercase version Folder Name - - Advance mode + + Advanced mode Custom Arguments diff --git a/Application/FileConverter/ValueConverters/ConversionSettingsRelevant.cs b/Application/FileConverter/ValueConverters/ConversionSettingsRelevant.cs index a0b7a27..4cf79a3 100644 --- a/Application/FileConverter/ValueConverters/ConversionSettingsRelevant.cs +++ b/Application/FileConverter/ValueConverters/ConversionSettingsRelevant.cs @@ -33,7 +33,7 @@ namespace FileConverter.ValueConverters public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - throw new Exception(); + throw new NotImplementedException(); } } } diff --git a/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml b/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml index b66111d..59ec8ef 100644 --- a/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml +++ b/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml @@ -668,7 +668,7 @@