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/ConversionJobs/ConversionJob_FFMPEG.cs b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs index 4d94c55..cac27bb 100644 --- a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs +++ b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs @@ -84,6 +84,18 @@ namespace FileConverter.ConversionJobs protected virtual void FillFFMpegArgumentsList() { + bool customCommandEnabled = this.ConversionPreset.GetSettingsValue(ConversionPreset.ConversionSettingKeys.EnableFFMPEGCustomCommand); + if (customCommandEnabled) + { + // Custom command override other settings. + 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; + } + // 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..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 { @@ -341,9 +335,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 +422,36 @@ 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; 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.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; // Video @@ -457,6 +461,8 @@ 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; case OutputType.Mkv: @@ -466,6 +472,8 @@ 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; case OutputType.Mp4: @@ -475,6 +483,8 @@ 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; case OutputType.Ogv: @@ -483,6 +493,8 @@ 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; case OutputType.Webm: @@ -491,6 +503,8 @@ 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; // Images @@ -544,9 +558,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)) @@ -597,9 +611,11 @@ 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"; + public const string EnableFFMPEGCustomCommand = "EnableFFMPEGCustomCommand"; } } } diff --git a/Application/FileConverter/FileConverter.csproj b/Application/FileConverter/FileConverter.csproj index 35da5d2..0e77bd1 100644 --- a/Application/FileConverter/FileConverter.csproj +++ b/Application/FileConverter/FileConverter.csproj @@ -201,6 +201,7 @@ + @@ -236,7 +237,6 @@ DiagnosticsWindow.xaml - @@ -287,7 +287,7 @@ MainWindow.xaml Code - + MSBuild:Compile Designer diff --git a/Application/FileConverter/Properties/Resources.Designer.cs b/Application/FileConverter/Properties/Resources.Designer.cs index 489b5af..0c0ca11 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 Advanced mode. + /// + public static string AdvancedMode { + get { + return ResourceManager.GetString("AdvancedMode", 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..7412c0e 100644 --- a/Application/FileConverter/Properties/Resources.resx +++ b/Application/FileConverter/Properties/Resources.resx @@ -562,4 +562,13 @@ use maj for uppercase version Folder Name + + Advanced mode + + + Custom Arguments + + + Custom FFMPEG command line arguments + \ No newline at end of file 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 diff --git a/Application/FileConverter/ValueConverters/ConversionSettingsRelevant.cs b/Application/FileConverter/ValueConverters/ConversionSettingsRelevant.cs new file mode 100644 index 0000000..4cf79a3 --- /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 NotImplementedException(); + } + } +} 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/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/ConversionPresets.xaml b/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml similarity index 87% rename from Application/FileConverter/Views/Resources/ConversionPresets.xaml rename to Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml index 0dfa7d0..59ec8ef 100644 --- a/Application/FileConverter/Views/Resources/ConversionPresets.xaml +++ b/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml @@ -19,6 +19,7 @@ + @@ -35,6 +36,12 @@ + + + + + + @@ -312,11 +319,12 @@