diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.Converters.cs b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.Converters.cs
new file mode 100644
index 0000000..abf91de
--- /dev/null
+++ b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.Converters.cs
@@ -0,0 +1,242 @@
+// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
+
+namespace FileConverter.ConversionJobs
+{
+ using System;
+
+ public partial class ConversionJob_FFMPEG
+ {
+ ///
+ /// Convert bitrate in mp3 encoder quality index.
+ ///
+ /// Wanted bitrate value.
+ /// The mp3 encoder quality index associated to the given bitrate value.
+ /// https://trac.ffmpeg.org/wiki/Encode/MP3
+ private int MP3VBRBitrateToQualityIndex(int bitrate)
+ {
+ switch (bitrate)
+ {
+ case 245:
+ return 0;
+
+ case 225:
+ return 1;
+
+ case 190:
+ return 2;
+
+ case 175:
+ return 3;
+
+ case 165:
+ return 4;
+
+ case 130:
+ return 5;
+
+ case 115:
+ return 6;
+
+ case 100:
+ return 7;
+
+ case 85:
+ return 8;
+
+ case 65:
+ return 9;
+ }
+
+ throw new Exception("Unknown VBR bitrate.");
+ }
+
+ ///
+ /// Convert bitrate in vorbis encoder quality index.
+ ///
+ /// Wanted bitrate value.
+ /// The vorbis encoder quality index associated to the given bitrate value.
+ /// http://wiki.hydrogenaud.io/index.php?title=Recommended_Ogg_Vorbis
+ private int OGGVBRBitrateToQualityIndex(int bitrate)
+ {
+ switch (bitrate)
+ {
+ case 500:
+ return 10;
+
+ case 320:
+ return 9;
+
+ case 256:
+ return 8;
+
+ case 224:
+ return 7;
+
+ case 192:
+ return 6;
+
+ case 160:
+ return 5;
+
+ case 128:
+ return 4;
+
+ case 112:
+ return 3;
+
+ case 96:
+ return 2;
+
+ case 80:
+ return 1;
+
+ case 64:
+ return 0;
+
+ case 48:
+ return -1;
+
+ case 32:
+ return -2;
+ }
+
+ throw new Exception("Unknown VBR bitrate.");
+ }
+
+ ///
+ /// Convert encoding mode setting to ffmpeg argument option.
+ ///
+ /// The encoding mode setting.
+ /// Returns the ffmpeg argument corresponding to the given encoding mode.
+ /// https://trac.ffmpeg.org/wiki/audio%20types
+ private string WAVEncodingToCodecArgument(EncodingMode encoding)
+ {
+ switch (encoding)
+ {
+ case EncodingMode.Wav8:
+ return "pcm_s8le";
+
+ case EncodingMode.Wav16:
+ return "pcm_s16le";
+
+ case EncodingMode.Wav24:
+ return "pcm_s24le";
+
+ case EncodingMode.Wav32:
+ return "pcm_s32le";
+ }
+
+ throw new Exception("Unknown Wav encoding.");
+ }
+
+ ///
+ /// Convert video quality index to H264 constant rate factor.
+ ///
+ /// The quality index.
+ /// Returns the H264 constant rate factor.
+ /// The range of the quantizer scale is 0-51: where 0 is lossless, 23 is default, and 51 is worst possible.
+ /// A lower value is a higher quality and a subjectively sane range is 18-28.
+ /// https://trac.ffmpeg.org/wiki/Encode/H.264
+ private int H264QualityToCRF(int quality)
+ {
+ return 51 - quality;
+ }
+
+ ///
+ /// Convert video encoding speed to H264 preset.
+ ///
+ /// The encoding speed.
+ /// The H264 preset.
+ private string H264EncodingSpeedToPreset(string encodingSpeed)
+ {
+ switch (encodingSpeed)
+ {
+ case "Ultra Fast":
+ return "ultrafast";
+
+ case "Super Fast":
+ return "superfast";
+
+ case "Very Fast":
+ return "veryfast";
+
+ case "Faster":
+ return "faster";
+
+ case "Fast":
+ return "fast";
+
+ case "Medium":
+ return "medium";
+
+ case "Slow":
+ return "slow";
+
+ case "Slower":
+ return "slower";
+
+ case "Very Slow":
+ return "veryslow";
+ }
+
+ throw new Exception("Unknown H264 encoding speed.");
+ }
+
+ ///
+ /// Convert bitrate in aac encoder quality index.
+ ///
+ /// Wanted bitrate value.
+ /// The aac encoder quality index associated to the given bitrate value.
+ /// See the file Resources/FFMPEG retro engineering.ods for details.
+ private string AACBitrateToQualityIndex(int bitrate)
+ {
+ switch (bitrate)
+ {
+ case 460:
+ return "3.9";
+
+ case 340:
+ return "3";
+
+ case 256:
+ return "2.2";
+
+ case 224:
+ return "1.9";
+
+ case 192:
+ return "1.6";
+
+ case 155:
+ return "1.3";
+
+ case 128:
+ return "1";
+
+ case 112:
+ return "0.9";
+
+ case 96:
+ return "0.75";
+
+ case 80:
+ return "0.6";
+
+ case 64:
+ return "0.45";
+
+ case 48:
+ return "0.3";
+
+ case 32:
+ return "0.2";
+
+ case 16:
+ return "0.1";
+ }
+
+ throw new Exception("Unknown VBR bitrate.");
+ }
+
+ }
+}
diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs
index 1f99e35..b06c30e 100644
--- a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs
+++ b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs
@@ -7,7 +7,7 @@ namespace FileConverter.ConversionJobs
using System.IO;
using System.Text.RegularExpressions;
- public class ConversionJob_FFMPEG : ConversionJob
+ public partial class ConversionJob_FFMPEG : ConversionJob
{
private readonly Regex durationRegex = new Regex(@"Duration:\s*([0-9][0-9]):([0-9][0-9]):([0-9][0-9])\.([0-9][0-9]),.*bitrate:\s*([0-9]+) kb\/s");
private readonly Regex progressRegex = new Regex(@"size=\s*([0-9]+)kB\s+time=([0-9][0-9]):([0-9][0-9]):([0-9][0-9]).([0-9][0-9])\s+bitrate=\s*([0-9]+.[0-9])kbits\/s");
@@ -115,6 +115,15 @@ namespace FileConverter.ConversionJobs
break;
+ case OutputType.Aac:
+ {
+ int audioEncodingBitrate = this.ConversionPreset.GetSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate);
+ string encoderArgs = string.Format("-c:a aac -q:a {0} -strict experimental", this.AACBitrateToQualityIndex(audioEncodingBitrate));
+ arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
+ }
+
+ break;
+
default:
throw new NotImplementedException("Converter not implemented for output file type " + this.ConversionPreset.OutputType);
}
@@ -164,226 +173,6 @@ namespace FileConverter.ConversionJobs
}
}
- private int MP3VBRBitrateToQualityIndex(int bitrate)
- {
- switch (bitrate)
- {
- case 245:
- return 0;
-
- case 225:
- return 1;
-
- case 190:
- return 2;
-
- case 175:
- return 3;
-
- case 165:
- return 4;
-
- case 130:
- return 5;
-
- case 115:
- return 6;
-
- case 100:
- return 7;
-
- case 85:
- return 8;
-
- case 65:
- return 9;
- }
-
- throw new Exception("Unknown VBR bitrate.");
- }
-
- ///
- /// Convert bitrate in vorbis encoder quality index.
- ///
- /// Wanted bitrate value.
- /// The vorbis encoder quality index associated to the given bitrate value.
- /// http://wiki.hydrogenaud.io/index.php?title=Recommended_Ogg_Vorbis
- private int OGGVBRBitrateToQualityIndex(int bitrate)
- {
- switch (bitrate)
- {
- case 500:
- return 10;
-
- case 320:
- return 9;
-
- case 256:
- return 8;
-
- case 224:
- return 7;
-
- case 192:
- return 6;
-
- case 160:
- return 5;
-
- case 128:
- return 4;
-
- case 112:
- return 3;
-
- case 96:
- return 2;
-
- case 80:
- return 1;
-
- case 64:
- return 0;
-
- case 48:
- return -1;
-
- case 32:
- return -2;
- }
-
- throw new Exception("Unknown VBR bitrate.");
- }
-
- ///
- /// Convert encoding mode setting to ffmpeg argument option.
- ///
- /// The encoding mode setting.
- /// Returns the ffmpeg argument corresponding to the given encoding mode.
- /// https://trac.ffmpeg.org/wiki/audio%20types
- private string WAVEncodingToCodecArgument(EncodingMode encoding)
- {
- switch (encoding)
- {
- case EncodingMode.Wav8:
- return "pcm_s8le";
-
- case EncodingMode.Wav16:
- return "pcm_s16le";
-
- case EncodingMode.Wav24:
- return "pcm_s24le";
-
- case EncodingMode.Wav32:
- return "pcm_s32le";
- }
-
- throw new Exception("Unknown Wav encoding.");
- }
-
- ///
- /// Convert video quality index to H264 constant rate factor.
- ///
- /// The quality index.
- /// Returns the H264 constant rate factor.
- /// The range of the quantizer scale is 0-51: where 0 is lossless, 23 is default, and 51 is worst possible.
- /// A lower value is a higher quality and a subjectively sane range is 18-28.
- /// https://trac.ffmpeg.org/wiki/Encode/H.264
- private int H264QualityToCRF(int quality)
- {
- return 51 - quality;
- }
-
- ///
- /// Convert video encoding speed to H264 preset.
- ///
- /// The encoding speed.
- /// The H264 preset.
- private string H264EncodingSpeedToPreset(string encodingSpeed)
- {
- switch (encodingSpeed)
- {
- case "Ultra Fast":
- return "ultrafast";
-
- case "Super Fast":
- return "superfast";
-
- case "Very Fast":
- return "veryfast";
-
- case "Faster":
- return "faster";
-
- case "Fast":
- return "fast";
-
- case "Medium":
- return "medium";
-
- case "Slow":
- return "slow";
-
- case "Slower":
- return "slower";
-
- case "Very Slow":
- return "veryslow";
- }
-
- throw new Exception("Unknown H264 encoding speed.");
- }
-
- private string AACBitrateToQualityIndex(int bitrate)
- {
- switch (bitrate)
- {
- case 460:
- return "3.9";
-
- case 340:
- return "3";
-
- case 256:
- return "2.2";
-
- case 224:
- return "1.9";
-
- case 192:
- return "1.6";
-
- case 155:
- return "1.3";
-
- case 128:
- return "1";
-
- case 112:
- return "0.9";
-
- case 96:
- return "0.75";
-
- case 80:
- return "0.6";
-
- case 64:
- return "0.45";
-
- case 48:
- return "0.3";
-
- case 32:
- return "0.2";
-
- case 16:
- return "0.1";
- }
-
- throw new Exception("Unknown VBR bitrate.");
- }
-
private void ParseFFMPEGOutput(string input)
{
Match match = this.durationRegex.Match(input);
diff --git a/Application/FileConverter/FileConverter.csproj b/Application/FileConverter/FileConverter.csproj
index 9c788ee..138a8fe 100644
--- a/Application/FileConverter/FileConverter.csproj
+++ b/Application/FileConverter/FileConverter.csproj
@@ -77,6 +77,7 @@
EncodingQualitySliderControl.xaml
+
diff --git a/Application/FileConverter/OutputType.cs b/Application/FileConverter/OutputType.cs
index 57a25d0..f56c934 100644
--- a/Application/FileConverter/OutputType.cs
+++ b/Application/FileConverter/OutputType.cs
@@ -5,10 +5,12 @@ namespace FileConverter
public enum OutputType
{
None,
+
+ Aac,
+ Flac,
Mkv,
Mp3,
Ogg,
- Flac,
Wav,
}
}
\ No newline at end of file
diff --git a/Application/FileConverter/PathHelpers.cs b/Application/FileConverter/PathHelpers.cs
index 46f0bf3..4eff34b 100644
--- a/Application/FileConverter/PathHelpers.cs
+++ b/Application/FileConverter/PathHelpers.cs
@@ -63,6 +63,7 @@ namespace FileConverter
{
switch (extension)
{
+ case "aac":
case "aiff":
case "ape":
case "flac":
diff --git a/Application/FileConverter/Windows/ConversionSettingsTemplateSelector.cs b/Application/FileConverter/Windows/ConversionSettingsTemplateSelector.cs
index a11723e..9850c53 100644
--- a/Application/FileConverter/Windows/ConversionSettingsTemplateSelector.cs
+++ b/Application/FileConverter/Windows/ConversionSettingsTemplateSelector.cs
@@ -31,6 +31,12 @@ namespace FileConverter.Windows
set;
}
+ public DataTemplate AacSettingsDataTemplate
+ {
+ get;
+ set;
+ }
+
public DataTemplate MkvSettingsDataTemplate
{
get;
@@ -57,6 +63,9 @@ namespace FileConverter.Windows
case OutputType.Ogg:
return this.OggSettingsDataTemplate;
+ case OutputType.Aac:
+ return this.AacSettingsDataTemplate;
+
case OutputType.Mkv:
return this.MkvSettingsDataTemplate;
}
diff --git a/Application/FileConverter/Windows/SettingsWindow.xaml b/Application/FileConverter/Windows/SettingsWindow.xaml
index 79152fd..c1f3723 100644
--- a/Application/FileConverter/Windows/SettingsWindow.xaml
+++ b/Application/FileConverter/Windows/SettingsWindow.xaml
@@ -99,6 +99,16 @@
+
+
+
+
+
+
+
+
+
@@ -139,7 +149,8 @@
WavSettingsDataTemplate="{StaticResource WavSettingsDataTemplate}"
Mp3SettingsDataTemplate="{StaticResource Mp3SettingsDataTemplate}"
OggSettingsDataTemplate="{StaticResource OggSettingsDataTemplate}"
- MkvSettingsDataTemplate="{StaticResource MkvSettingsDataTemplate}" />
+ MkvSettingsDataTemplate="{StaticResource MkvSettingsDataTemplate}"
+ AacSettingsDataTemplate="{StaticResource AacSettingsDataTemplate}" />
diff --git a/Application/FileConverter/Windows/SettingsWindow.xaml.cs b/Application/FileConverter/Windows/SettingsWindow.xaml.cs
index 4b24ea5..590d02c 100644
--- a/Application/FileConverter/Windows/SettingsWindow.xaml.cs
+++ b/Application/FileConverter/Windows/SettingsWindow.xaml.cs
@@ -34,11 +34,12 @@ namespace FileConverter
OutputType[] outputTypes = new[]
{
- OutputType.Flac,
- OutputType.Mkv,
- OutputType.Mp3,
OutputType.Ogg,
+ OutputType.Mp3,
+ OutputType.Aac,
+ OutputType.Flac,
OutputType.Wav,
+ OutputType.Mkv,
};
this.OutputFormats.ItemsSource = outputTypes;
diff --git a/Installer/Product.wxs b/Installer/Product.wxs
index fe4c3cf..8662a6c 100644
--- a/Installer/Product.wxs
+++ b/Installer/Product.wxs
@@ -71,7 +71,7 @@
-
+