Compare commits

49 Commits
Author SHA1 Message Date
Tichau 36792c31ab Update change log 2015-12-21 23:05:28 +01:00
Tichau 07f2f9a2dd Merge user settings with default settings to prevent errors after installing a new version. 2015-12-21 22:59:53 +01:00
Tichau b6980780a8 Correction of spell mistakes in readme 2015-12-21 22:34:08 +01:00
Tichau 4f38accc9e Split readme file
Add changelog.md and licence.md
2015-12-21 22:25:41 +01:00
Tichau 1d64c778e7 Change website url in readme. 2015-12-18 19:23:45 +01:00
Tichau 9ea7abd160 Fixed: Default settings not defined for types Aac and Ico 2015-12-18 19:23:31 +01:00
Tichau 7f27737481 Update to version 0.4 2015-12-18 08:48:19 +01:00
Tichau 54d8c4094e Screenshots for version 0.4 2015-12-18 08:29:09 +01:00
Adrien Allard 4fa0863fe7 Fix spell issues in readme file. 2015-12-15 10:17:25 +01:00
Tichau 15bef45d4f Updade readme 2015-12-15 08:46:31 +01:00
Tichau ee1e04f3ff Update readme file. 2015-12-15 08:43:25 +01:00
Tichau 6166bd60d5 Handle incorrect user settings case.
Ask to the user if he want to delete its invalid user settings.
2015-12-14 22:31:57 +01:00
Tichau db86b6c372 Fixed: reordering preset does not modify registry. 2015-12-14 18:46:46 +01:00
Tichau d2b05c9933 Change the application version number to 0.4 2015-12-14 09:14:12 +01:00
Tichau 386e61fec4 Fix mkv 23 video setting 2015-12-14 08:55:38 +01:00
Tichau c0a1ac18e8 Fix loading of default settings. 2015-12-14 08:43:04 +01:00
Tichau c327eae1f6 Define explicitly the flac compression level. 2015-12-13 22:01:16 +01:00
Tichau ee791bcc11 Change default settings (adding new features) 2015-12-13 12:13:41 +01:00
Tichau 8990efddda Add application settings UI. 2015-12-13 11:26:13 +01:00
Tichau 3a2950190f Refactor application settings
Settings can now contains application specific settings (and not only
conversion preset).
Add options: QuitApplicationWhenConversionsFinished and
DurationBetweenEndOfConversionsAndApplicationQuit
2015-12-13 08:43:07 +01:00
Tichau 45162328a9 Add tooltips and infos on mkv converter UI 2015-12-08 19:20:00 +01:00
Tichau 1e05944566 Add user folders on file name generator. 2015-12-08 18:58:14 +01:00
Tichau f58cc625a1 Support new input/output formats
New input formats: ico/bik
New output format: ico
2015-12-08 08:40:31 +01:00
Tichau 09e60f7fa5 Move encoding mode to controls folder. 2015-12-07 20:56:07 +01:00
Tichau 5732007afb Add ripper dlls to installer. 2015-12-07 18:51:36 +01:00
Tichau 69d06f5cde Fixed: Debug are now updated when a new DiagnosticsData is created. 2015-12-07 18:50:39 +01:00
Tichau dd1d5da176 Add prerequisite on conversion job to not be executed at the same time. 2015-12-07 08:40:22 +01:00
Tichau aad9deb7e6 Add multithread conversion job execution. 2015-12-04 19:21:39 +01:00
Tichau 40272e58e4 Fixed: Diagnostics problems (displaying logs) 2015-12-04 08:40:25 +01:00
Tichau 8434b00fe6 Improve diagnostics system
Save logs in files.
Save logs from different threads in different files.
2015-12-04 08:31:48 +01:00
Tichau a6d2786749 Merge branch 'master' into development 2015-11-25 23:08:47 +01:00
Tichau 9d659a0178 Add thanks chapter in readme file. 2015-11-25 23:07:32 +01:00
Tichau 73cecd2722 Add CD Audio extraction job. 2015-11-25 20:30:26 +01:00
Tichau 8ca9734298 Added: Copy th currently selected preset when clicking on Add Preset. 2015-11-24 08:24:46 +01:00
Tichau 866844e369 Add JPG and PNG output types
And add bmp, jpg, png, tiff intput types
2015-11-23 20:05:05 +01:00
Adrien Allard 8007b723a5 Add website link in the readme. 2015-11-19 16:05:14 +01:00
Tichau 673f715ed0 Add 'mov' input extension. 2015-11-17 19:10:26 +01:00
Tichau 43cfa7cd11 Set categories invisible if they are not compatible with the current output type. 2015-11-17 19:06:23 +01:00
Tichau 1f94578556 Move solution file 2015-11-17 18:33:55 +01:00
Tichau 73d3255e76 Disable input extensions that are not compatible with output type. 2015-11-17 08:40:34 +01:00
Tichau 9b0777d54d Add check if category is compatible with output type. 2015-11-13 21:45:32 +01:00
Tichau fedd6fa02d Add aac extension as input and output type. 2015-11-13 08:34:27 +01:00
Tichau 8343bc3e6c Add AAC bitrate selector 2015-11-13 08:16:06 +01:00
Tichau e656462c11 Rename audio settings (add audio prefix) 2015-11-10 18:54:56 +01:00
Tichau 181578ef62 Update fmod version
Version: ffmpeg-20151109-git-480bad7-win64-static
2015-11-10 18:35:45 +01:00
Tichau 3ee0587d24 Add setting keys const to avoid problem with named settings 2015-11-10 08:53:19 +01:00
Tichau d4d8e175e8 Added: New output type: MKV
Video encoder: H264
Audio encoder: AAC
2015-11-10 08:46:51 +01:00
Tichau fb15d8e833 Add input types mkv and flv 2015-11-10 08:13:46 +01:00
Tichau c6e88b320d Merge remote-tracking branch 'refs/remotes/origin/master' into development 2015-11-08 10:58:04 +01:00
44 changed files with 2149 additions and 525 deletions

No files matched your search

+158 -50
View File
@@ -22,13 +22,16 @@ namespace FileConverter
using System.Windows;
using FileConverter.ConversionJobs;
using FileConverter.Diagnostics;
public partial class Application : System.Windows.Application
{
private int numberOfConversionThread = 1;
private static readonly Version Version = new Version()
{
Major = 0,
Minor = 3,
Minor = 4,
};
private readonly List<ConversionJob> conversionJobs = new List<ConversionJob>();
@@ -40,6 +43,11 @@ namespace FileConverter
public Application()
{
this.ConvertionJobs = this.conversionJobs.AsReadOnly();
}
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
this.Initialize();
@@ -67,7 +75,7 @@ namespace FileConverter
public Settings Settings
{
get;
private set;
set;
}
public bool ShowSettings
@@ -89,37 +97,58 @@ namespace FileConverter
private void Initialize()
{
Diagnostics.Debug.Log("The number of processors on this computer is {0}. Set the default number of conversion threads to {0}", Environment.ProcessorCount);
this.numberOfConversionThread = Environment.ProcessorCount;
// Load settigns.
Diagnostics.Log("Retrieve arguments...");
this.Settings = new Settings();
this.Settings.Load();
Debug.Log("Load settings...");
this.Settings = Settings.Load();
if (this.Settings == null)
{
Diagnostics.Debug.LogError("The application will now shutdown. If you want to fix the problem yourself please edit or delete the file: C:\\Users\\UserName\\AppData\\Local\\FileConverter\\Settings.user.xml.");
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
return;
}
// Retrieve arguments.
Diagnostics.Log("Retrieve arguments...");
Debug.Log("Retrieve arguments...");
string[] args = Environment.GetCommandLineArgs();
#if (DEBUG)
if (args.Length <= 1)
{
this.debugMode = true;
System.Array.Resize(ref args, 8);
args[1] = "--conversion-preset";
args[2] = "To Ogg";
args[3] = "--verbose";
args[4] = @"D:\Test\TrailerV2 compressed.mkv";
args[4] = @"D:\Test\image.png";
args[4] = @"E:\Track01.cda";
args[4] = @"D:\Test\Track01.mp3";
args[5] = @"D:\Test\Track02.mp3";
args[6] = @"D:\Test\Track03.mp3";
args[7] = @"D:\Test\Track04.mp3";
//System.Array.Resize(ref args, 2);
//args[1] = "--settings";
System.Array.Resize(ref args, 5);
args[1] = "--conversion-preset";
args[2] = "To Mp3";
args[2] = "To Aac";
args[3] = "--verbose";
args[4] = @"D:\Test\10 - Get around town (lp version).ogg";
System.Array.Resize(ref args, 2);
args[1] = "--settings";
args[4] = @"D:\Test\02 - Corn on the Cob.flac";
}
#endif
for (int index = 0; index < args.Length; index++)
{
string argument = args[index];
Diagnostics.Log("Arg{0}: {1}", index, argument);
Debug.Log("Arg{0}: {1}", index, argument);
}
Diagnostics.Log(string.Empty);
Debug.Log(string.Empty);
ConversionPreset conversionPreset = null;
List<string> filePaths = new List<string>();
@@ -147,15 +176,15 @@ namespace FileConverter
case "conversion-preset":
if (index >= args.Length - 1)
{
MessageBox.Show(string.Format("Invalid format. (code 0x01)"), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Debug.LogError("Invalid format. (code 0x01)");
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
return;
}
conversionPreset = Settings.GetPresetFromName(args[index + 1]);
conversionPreset = this.Settings.GetPresetFromName(args[index + 1]);
if (conversionPreset == null)
{
MessageBox.Show(string.Format("Invalid conversion preset '{0}'. (code 0x02)", args[index + 1]), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Debug.LogError("Invalid conversion preset '{0}'. (code 0x02)", args[index + 1]);
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
return;
}
@@ -171,7 +200,7 @@ namespace FileConverter
break;
default:
Diagnostics.Log("ERROR ! Unknown option {0}.", parameterTitle);
Debug.LogError("Unknown option {0}.", parameterTitle);
return;
}
}
@@ -183,66 +212,145 @@ namespace FileConverter
if (conversionPreset == null)
{
Diagnostics.Log("ERROR ! Can't retrieve the conversion preset from arguments.");
Debug.LogError("Can't retrieve the conversion preset from arguments.");
return;
}
// Create convertion jobs.
for (int index = 0; index < filePaths.Count; index++)
Debug.Log("Create jobs for conversion preset: '{0}'", conversionPreset.Name);
try
{
string inputFilePath = filePaths[index];
ConversionJob conversionJob = ConversionJobFactory.Create(conversionPreset);
conversionJob.PrepareConversion(inputFilePath);
for (int index = 0; index < filePaths.Count; index++)
{
string inputFilePath = filePaths[index];
ConversionJob conversionJob = ConversionJobFactory.Create(conversionPreset, inputFilePath);
conversionJob.PrepareConversion(inputFilePath);
this.conversionJobs.Add(conversionJob);
this.conversionJobs.Add(conversionJob);
}
}
catch (Exception exception)
{
Debug.LogError(exception.Message);
throw;
}
this.initialized = true;
}
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
Debug.Log("Exit application.");
Debug.Release();
}
private void ConvertFiles()
{
for (int index = 0; index < this.conversionJobs.Count; index++)
Thread[] jobThreads = new Thread[this.numberOfConversionThread];
while (true)
{
ConversionJob conversionJob = this.conversionJobs[index];
if (conversionJob.State != ConversionJob.ConversionState.Ready)
// Compute conversion flags.
ConversionFlags conversionFlags = ConversionFlags.None;
bool allJobAreFinished = true;
for (int jobIndex = 0; jobIndex < this.conversionJobs.Count; jobIndex++)
{
continue;
ConversionJob conversionJob = this.conversionJobs[jobIndex];
allJobAreFinished &= !(conversionJob.State == ConversionJob.ConversionState.Ready ||
conversionJob.State == ConversionJob.ConversionState.InProgress);
if (conversionJob.State == ConversionJob.ConversionState.InProgress)
{
conversionFlags |= conversionJob.StateFlags;
}
}
conversionJob.StartConvertion();
if (allJobAreFinished)
{
break;
}
if (System.IO.File.Exists(conversionJob.OutputFilePath))
// Start job if possible.
for (int jobIndex = 0; jobIndex < this.conversionJobs.Count; jobIndex++)
{
Diagnostics.Log("Success!");
}
else
{
Diagnostics.Log("Fail!");
ConversionJob conversionJob = this.conversionJobs[jobIndex];
if (conversionJob.State == ConversionJob.ConversionState.Ready &&
conversionJob.CanStartConversion(conversionFlags))
{
// Find a thread to execute the job.
Thread jobThread = null;
for (int threadIndex = 0; threadIndex < jobThreads.Length; threadIndex++)
{
Thread thread = jobThreads[threadIndex];
if (thread == null || !thread.IsAlive)
{
jobThread = new Thread(this.ExecuteConversionJob);
jobThreads[threadIndex] = jobThread;
break;
}
}
if (jobThread != null)
{
jobThread.Start(conversionJob);
}
break;
}
}
Thread.Sleep(50);
}
Diagnostics.Log("End of job queue.");
#if !DEBUG
bool allConversionsSucceed = true;
for (int index = 0; index < this.conversionJobs.Count; index++)
if (this.Settings.ExitApplicationWhenConversionsFinished)
{
allConversionsSucceed &= this.conversionJobs[index].State == ConversionJob.ConversionState.Done;
}
if (allConversionsSucceed)
{
System.Threading.Thread.Sleep(3000);
if (this.cancelAutoExit)
bool allConversionsSucceed = true;
for (int index = 0; index < this.conversionJobs.Count; index++)
{
return;
allConversionsSucceed &= this.conversionJobs[index].State == ConversionJob.ConversionState.Done;
}
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
if (allConversionsSucceed)
{
System.Threading.Thread.Sleep((int)this.Settings.DurationBetweenEndOfConversionsAndApplicationExit * 1000);
if (this.cancelAutoExit)
{
return;
}
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
}
}
}
private void ExecuteConversionJob(object parameter)
{
ConversionJob conversionJob = parameter as ConversionJob;
if (conversionJob == null)
{
throw new System.ArgumentException("The parameter must be a conversion job.", "parameter");
}
if (conversionJob.State != ConversionJob.ConversionState.Ready)
{
Debug.LogError("Fail to execute conversion job.");
return;
}
conversionJob.StartConvertion();
if (conversionJob.State == ConversionJob.ConversionState.Done && !System.IO.File.Exists(conversionJob.OutputFilePath))
{
Debug.LogError("Can't find the output file.");
}
else if (conversionJob.State == ConversionJob.ConversionState.Failed && System.IO.File.Exists(conversionJob.OutputFilePath))
{
Debug.Log("The conversion job failed but there is an output file that does exists.");
}
#endif
}
}
}
@@ -1,6 +1,6 @@
// <copyright file="EncodingMode.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
namespace FileConverter
namespace FileConverter.Controls
{
public enum EncodingMode
{
@@ -13,5 +13,7 @@ namespace FileConverter
Mp3CBR,
OggVBR,
AacVBR,
}
}
@@ -145,6 +145,30 @@ namespace FileConverter.Controls
sliderControl.Ticks.Add(500);
break;
}
case EncodingMode.AacVBR:
{
sliderControl.Minimum = 16;
sliderControl.Maximum = 460;
sliderControl.SelectionStart = 96;
sliderControl.SelectionEnd = 256;
sliderControl.Ticks.Clear();
sliderControl.Ticks.Add(16);
sliderControl.Ticks.Add(32);
sliderControl.Ticks.Add(48);
sliderControl.Ticks.Add(64);
sliderControl.Ticks.Add(80);
sliderControl.Ticks.Add(96);
sliderControl.Ticks.Add(112);
sliderControl.Ticks.Add(128);
sliderControl.Ticks.Add(155);
sliderControl.Ticks.Add(192);
sliderControl.Ticks.Add(224);
sliderControl.Ticks.Add(256);
sliderControl.Ticks.Add(340);
sliderControl.Ticks.Add(460);
break;
}
}
encodingQualitySliderControl.CoerceValue(EncodingQualitySliderControl.BitrateProperty);
@@ -0,0 +1,14 @@
// // <copyright file="ConversionFlags.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
namespace FileConverter.ConversionJobs
{
/// <summary>
/// This enum describe the special conversion state that need to be multi-threads prerequisites.
/// </summary>
[System.Flags]
public enum ConversionFlags
{
None = 0x00,
CdaExtraction = 0x01,
}
}
@@ -7,12 +7,15 @@ namespace FileConverter.ConversionJobs
using System.Runtime.CompilerServices;
using System.Text;
using FileConverter.Diagnostics;
public class ConversionJob : INotifyPropertyChanged
{
private float progress = 0f;
private ConversionState state = ConversionState.Unknown;
private string errorMessage = string.Empty;
private string initialInputPath = string.Empty;
private string userState = string.Empty;
public ConversionJob()
{
@@ -75,6 +78,20 @@ namespace FileConverter.ConversionJobs
}
}
public string UserState
{
get
{
return this.userState;
}
protected set
{
this.userState = value;
this.NotifyPropertyChanged();
}
}
public float Progress
{
get
@@ -103,7 +120,31 @@ namespace FileConverter.ConversionJobs
}
}
public void PrepareConversion(string inputFilePath)
public ConversionFlags StateFlags
{
get;
protected set;
}
protected virtual InputPostConversionAction InputPostConversionAction
{
get
{
if (this.ConversionPreset == null)
{
return InputPostConversionAction.None;
}
return this.ConversionPreset.InputPostConversionAction;
}
}
public virtual bool CanStartConversion(ConversionFlags conversionFlags)
{
return true;
}
public void PrepareConversion(string inputFilePath, string outputFilePath = null)
{
if (string.IsNullOrEmpty(inputFilePath))
{
@@ -115,14 +156,23 @@ namespace FileConverter.ConversionJobs
throw new Exception("The conversion preset must be valid.");
}
string extension = System.IO.Path.GetExtension(inputFilePath);
extension = extension.Substring(1, extension.Length - 1);
string extensionCategory = PathHelpers.GetExtensionCategory(extension);
if (!PathHelpers.IsOutputTypeCompatibleWithCategory(this.ConversionPreset.OutputType, extensionCategory))
{
this.ConversionFailed("The input file type is not compatible with the output file type.");
return;
}
this.initialInputPath = inputFilePath;
this.InputFilePath = inputFilePath;
this.OutputFilePath = this.ConversionPreset.GenerateOutputFilePath(inputFilePath);
this.OutputFilePath = outputFilePath ?? this.ConversionPreset.GenerateOutputFilePath(inputFilePath);
if (!PathHelpers.IsPathValid(this.OutputFilePath))
{
this.ConvertionFailed("Invalid output path generated by output file path template.");
Diagnostics.Log(string.Format("Invalid output path generated: {0} from input: {1}.", this.OutputFilePath, this.InputFilePath));
this.ConversionFailed("Invalid output path generated by output file path template.");
Debug.Log(string.Format("Invalid output path generated: {0} from input: {1}.", this.OutputFilePath, this.InputFilePath));
return;
}
@@ -155,8 +205,8 @@ namespace FileConverter.ConversionJobs
}
catch (Exception)
{
this.ConvertionFailed("Invalid output path generated by output file path template.");
Diagnostics.Log(string.Format("Can't create directories for path {0}", this.OutputFilePath));
this.ConversionFailed("Invalid output path generated by output file path template.");
Debug.Log(string.Format("Can't create directories for path {0}", this.OutputFilePath));
return;
}
}
@@ -170,17 +220,21 @@ namespace FileConverter.ConversionJobs
}
catch (Exception exception)
{
this.ConvertionFailed("Can't generate a valid output filename.");
Diagnostics.Log(exception.Message);
this.ConversionFailed("Can't generate a valid output filename.");
Debug.Log(exception.Message);
return;
}
this.Initialize();
if (this.State == ConversionState.Unknown)
{
this.State = ConversionState.Ready;
}
Debug.Log("Job initialized: Preset: '{0}' Input: {1} Output: {2}", this.ConversionPreset.Name, this.InputFilePath, this.OutputFilePath);
this.UserState = "In Queue";
}
public void StartConvertion()
@@ -195,13 +249,17 @@ namespace FileConverter.ConversionJobs
throw new Exception("Invalid conversion state.");
}
Diagnostics.Log("Convert file {0} to {1}.", this.InputFilePath, this.OutputFilePath);
Debug.Log("Convert file {0} to {1}.", this.InputFilePath, this.OutputFilePath);
this.State = ConversionState.InProgress;
this.Convert();
if (this.State != ConversionState.Failed)
if (this.State == ConversionState.Failed)
{
this.OnConversionFailed();
}
else
{
this.OnConversionSucceed();
}
@@ -215,12 +273,22 @@ namespace FileConverter.ConversionJobs
{
}
protected virtual void OnConversionFailed()
{
Debug.Log("Conversion Failed.");
if (System.IO.File.Exists(this.OutputFilePath))
{
System.IO.File.Delete(this.OutputFilePath);
}
}
protected virtual void OnConversionSucceed()
{
Diagnostics.Log("Conversion Succeed!");
Debug.Log("Conversion Succeed!");
// Apply the input post conversion action.
switch (this.ConversionPreset.InputPostConversionAction)
switch (this.InputPostConversionAction)
{
case InputPostConversionAction.None:
break;
@@ -236,25 +304,33 @@ namespace FileConverter.ConversionJobs
string newPath = PathHelpers.GenerateUniquePath(archivePath + "\\" + inputFilename);
System.IO.File.Move(this.InputFilePath, newPath);
Diagnostics.Log("Input file moved in archive folder: '{0}'", newPath);
Debug.Log("Input file moved in archive folder: '{0}'", newPath);
break;
case InputPostConversionAction.Delete:
System.IO.File.Delete(this.InputFilePath);
Diagnostics.Log("Input file deleted: '{0}'", this.initialInputPath);
Debug.Log("Input file deleted: '{0}'", this.initialInputPath);
break;
}
Diagnostics.Log(string.Empty);
Debug.Log(string.Empty);
this.Progress = 1f;
this.State = ConversionState.Done;
Diagnostics.Log("Conversion Done!");
this.UserState = "Done";
Debug.Log("Conversion Done!");
}
protected void ConvertionFailed(string exitingMessage)
protected void ConversionFailed(string exitingMessage)
{
if (this.State == ConversionState.Failed)
{
// Already failed, don't override informations.
return;
}
this.State = ConversionState.Failed;
this.UserState = "Failed";
this.ErrorMessage = exitingMessage;
}
@@ -4,9 +4,20 @@ namespace FileConverter.ConversionJobs
{
public static class ConversionJobFactory
{
public static ConversionJob Create(ConversionPreset conversionPreset)
public static ConversionJob Create(ConversionPreset conversionPreset, string inputFilePath)
{
ConversionJob conversionJob = new ConversionJob_FFMPEG(conversionPreset);
ConversionJob conversionJob = null;
string extension = System.IO.Path.GetExtension(inputFilePath);
extension = extension.ToLowerInvariant().Substring(1, extension.Length - 1);
if (extension == "cda")
{
conversionJob = new ConversionJob_ExtractCDA(conversionPreset);
}
else
{
conversionJob = new ConversionJob_FFMPEG(conversionPreset);
}
return conversionJob;
}
@@ -0,0 +1,216 @@
// <copyright file="ConversionJob_ExtractCDA.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
namespace FileConverter.ConversionJobs
{
using System;
using System.IO;
using System.Threading;
using Ripper;
using WaveLib;
using Yeti.MMedia;
using FileConverter.Diagnostics;
public class ConversionJob_ExtractCDA : ConversionJob
{
private Ripper.CDDrive cdDrive;
private int cdaTrackNumber = -1;
private WaveWriter waveWriter;
private string intermediateFilePath;
private ConversionJob compressionConversionJob;
private System.Threading.Thread compressionThread;
public ConversionJob_ExtractCDA() : base()
{
}
public ConversionJob_ExtractCDA(ConversionPreset conversionPreset) : base(conversionPreset)
{
}
protected override InputPostConversionAction InputPostConversionAction
{
get
{
return InputPostConversionAction.None;
}
}
public override bool CanStartConversion(ConversionFlags conversionFlags)
{
return (conversionFlags & ConversionFlags.CdaExtraction) == 0;
}
protected override void Initialize()
{
base.Initialize();
if (this.ConversionPreset == null)
{
throw new Exception("The conversion preset must be valid.");
}
// Retrieve and check drive letter.
string pathDriveLetter = PathHelpers.GetPathDriveLetter(this.InputFilePath);
if (pathDriveLetter.Length == 0)
{
this.ConversionFailed("Can't retrieve input path drive letter.");
return;
}
char driveLetter = pathDriveLetter[0];
this.cdDrive = new Ripper.CDDrive();
this.cdDrive.CDRemoved += new EventHandler(this.CdDriveCdRemoved);
bool driveLetterFound = false;
char[] driveLetters = Ripper.CDDrive.GetCDDriveLetters();
for (int index = 0; index < driveLetters.Length; index++)
{
driveLetterFound |= driveLetters[index] == driveLetter;
}
if (!driveLetterFound)
{
this.ConversionFailed(string.Format("Invalid drive letter {0}.", driveLetter));
return;
}
// Retrieve and track number.
try
{
this.cdaTrackNumber = PathHelpers.GetCDATrackNumber(this.InputFilePath);
}
catch (Exception)
{
this.ConversionFailed(string.Format("Can't retrieve the track number from input path '{0}'.", this.InputFilePath));
return;
}
if (this.cdDrive.IsOpened)
{
this.ConversionFailed(string.Format("CD drive already used."));
return;
}
if (!this.cdDrive.Open(driveLetter))
{
this.ConversionFailed(string.Format("Fail to open cd drive {0}.", driveLetter));
return;
}
// Generate intermediate file path.
string fileName = Path.GetFileName(this.OutputFilePath);
string tempPath = Path.GetTempPath();
this.intermediateFilePath = PathHelpers.GenerateUniquePath(tempPath + fileName + ".wav");
// Sub conversion job (for compression).
this.compressionConversionJob = ConversionJobFactory.Create(this.ConversionPreset, this.intermediateFilePath);
this.compressionConversionJob.PrepareConversion(this.intermediateFilePath, this.OutputFilePath);
this.compressionThread = new Thread(this.CompressAsync);
this.StateFlags = ConversionFlags.CdaExtraction;
}
protected override void Convert()
{
if (this.ConversionPreset == null)
{
throw new Exception("The conversion preset must be valid.");
}
Debug.Log("Starting CDA extraction.");
this.UserState = "Extraction";
if (!this.cdDrive.IsCDReady())
{
this.ConversionFailed(string.Format("CD drive is not ready."));
return;
}
if (!this.cdDrive.Refresh())
{
this.ConversionFailed(string.Format("Can't refresh CD drive data."));
return;
}
if (!this.cdDrive.LockCD())
{
this.ConversionFailed(string.Format("Can't lock cd."));
return;
}
WaveFormat waveFormat = new WaveFormat(44100, 16, 2);
using (Stream waveStream = new FileStream(this.intermediateFilePath, FileMode.Create, FileAccess.Write))
using (this.waveWriter = new WaveWriter(waveStream, waveFormat, this.cdDrive.TrackSize(this.cdaTrackNumber)))
{
this.cdDrive.ReadTrack(this.cdaTrackNumber, this.WriteWaveData, this.CdReadProgress);
}
this.waveWriter = null;
this.cdDrive.UnLockCD();
this.cdDrive.Close();
this.StateFlags = ConversionFlags.None;
if (!File.Exists(this.intermediateFilePath))
{
this.ConversionFailed("Extraction failed.");
return;
}
Debug.Log("CDA extracted to {0}.", this.intermediateFilePath);
Debug.Log(string.Empty);
Debug.Log("Start compression.");
this.UserState = "Conversion";
this.compressionThread.Start();
while (this.compressionConversionJob.State != ConversionState.Done &&
this.compressionConversionJob.State != ConversionState.Failed)
{
this.Progress = this.compressionConversionJob.Progress;
}
if (this.compressionConversionJob.State == ConversionState.Failed)
{
this.ConversionFailed(this.compressionConversionJob.ErrorMessage);
return;
}
Debug.Log(string.Empty);
Debug.Log("Delete intermediate file {0}.", this.intermediateFilePath);
File.Delete(this.intermediateFilePath);
}
private void WriteWaveData(object sender, DataReadEventArgs eventArgs)
{
this.waveWriter?.Write(eventArgs.Data, 0, (int)eventArgs.DataSize);
}
private void CdReadProgress(object sender, ReadProgressEventArgs eventArgs)
{
this.Progress = (float)eventArgs.BytesRead / (float)eventArgs.Bytes2Read;
eventArgs.CancelRead |= this.State != ConversionState.InProgress;
}
private void CdDriveCdRemoved(object sender, System.EventArgs eventArgs)
{
this.ConversionFailed("The CD has been ejected.");
}
private void CompressAsync()
{
this.compressionConversionJob.StartConvertion();
}
}
}
@@ -0,0 +1,255 @@
// <copyright file="ConversionJob_FFMPEG.Converters.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
namespace FileConverter.ConversionJobs
{
using System;
using FileConverter.Controls;
public partial class ConversionJob_FFMPEG
{
/// <summary>
/// Convert bitrate in <c>mp3</c> encoder quality index.
/// </summary>
/// <param name="bitrate">Wanted bitrate value.</param>
/// <returns>The <c>mp3</c> encoder quality index associated to the given bitrate value.</returns>
/// 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.");
}
/// <summary>
/// Convert bitrate in <c>vorbis</c> encoder quality index.
/// </summary>
/// <param name="bitrate">Wanted bitrate value.</param>
/// <returns>The <c>vorbis</c> encoder quality index associated to the given bitrate value.</returns>
/// 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 Ogg VBR bitrate.");
}
/// <summary>
/// Convert encoding mode setting to <c>ffmpeg</c> argument option.
/// </summary>
/// <param name="encoding">The encoding mode setting.</param>
/// <returns>Returns the <c>ffmpeg</c> argument corresponding to the given encoding mode.</returns>
/// 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.");
}
/// <summary>
/// Convert video quality index to H264 constant rate factor.
/// </summary>
/// <param name="quality">The quality index.</param>
/// <returns>Returns the H264 constant rate factor.</returns>
/// 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;
}
/// <summary>
/// Convert image quality index to JPG quality index.
/// </summary>
/// <param name="quality">The quality index.</param>
/// <returns>Returns the JPG quality index.</returns>
/// The range of the quantizer scale is 1-31: where 1 is better quality, and 31 is worst possible.
/// http://superuser.com/questions/318845/improve-quality-of-ffmpeg-created-jpgs
private int JPGQualityToQualityIndex(int quality)
{
return 31 - quality;
}
/// <summary>
/// Convert video encoding speed to H264 preset.
/// </summary>
/// <param name="encodingSpeed">The encoding speed.</param>
/// <returns>The H264 preset.</returns>
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.");
}
/// <summary>
/// Convert bitrate in <c>aac</c> encoder quality index.
/// </summary>
/// <param name="bitrate">Wanted bitrate value.</param>
/// <returns>The <c>aac</c> encoder quality index associated to the given bitrate value.</returns>
/// 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.");
}
}
}
@@ -7,7 +7,9 @@ namespace FileConverter.ConversionJobs
using System.IO;
using System.Text.RegularExpressions;
public class ConversionJob_FFMPEG : ConversionJob
using FileConverter.Controls;
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");
@@ -40,8 +42,8 @@ namespace FileConverter.ConversionJobs
string ffmpegPath = string.Format("{0}\\ffmpeg.exe", applicationDirectory);
if (!System.IO.File.Exists(ffmpegPath))
{
this.ConvertionFailed("Can't find ffmpeg executable. You should try to reinstall the application.");
Diagnostics.Log("Can't find ffmpeg executable ({0}). Try to reinstall the application.", ffmpegPath);
this.ConversionFailed("Can't find ffmpeg executable. You should try to reinstall the application.");
Diagnostics.Debug.Log("Can't find ffmpeg executable ({0}). Try to reinstall the application.", ffmpegPath);
return;
}
@@ -55,10 +57,28 @@ namespace FileConverter.ConversionJobs
string arguments = string.Empty;
switch (this.ConversionPreset.OutputType)
{
case OutputType.Wav:
case OutputType.Aac:
{
EncodingMode encodingMode = this.ConversionPreset.GetSettingsValue<EncodingMode>("Encoding");
string encoderArgs = string.Format("-acodec {0}", this.WAVEncodingToCodecArgument(encodingMode));
// https://trac.ffmpeg.org/wiki/Encode/AAC
int audioEncodingBitrate = this.ConversionPreset.GetSettingsValue<int>(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;
case OutputType.Flac:
{
// http://taer-naguur.blogspot.fr/2013/11/flac-audio-encoding-with-ffmpeg.html
string encoderArgs = string.Format("-compression_level 12");
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
}
break;
case OutputType.Ico:
{
string encoderArgs = string.Empty;
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
}
@@ -67,8 +87,8 @@ namespace FileConverter.ConversionJobs
case OutputType.Mp3:
{
string encoderArgs = string.Empty;
EncodingMode encodingMode = this.ConversionPreset.GetSettingsValue<EncodingMode>("Encoding");
int encodingQuality = this.ConversionPreset.GetSettingsValue<int>("Bitrate");
EncodingMode encodingMode = this.ConversionPreset.GetSettingsValue<EncodingMode>(ConversionPreset.ConversionSettingKeys.AudioEncodingMode);
int encodingQuality = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.AudioBitrate);
switch (encodingMode)
{
case EncodingMode.Mp3VBR:
@@ -88,17 +108,53 @@ namespace FileConverter.ConversionJobs
break;
case OutputType.Mkv:
{
// https://trac.ffmpeg.org/wiki/Encode/H.264
// https://trac.ffmpeg.org/wiki/Encode/AAC
int videoEncodingQuality = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.VideoQuality);
string videoEncodingSpeed = this.ConversionPreset.GetSettingsValue<string>(ConversionPreset.ConversionSettingKeys.VideoEncodingSpeed);
int audioEncodingBitrate = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.AudioBitrate);
string encoderArgs = string.Format("-c:v libx264 -preset {0} -crf {1} -c:a aac -q:a {2} -strict experimental", this.H264EncodingSpeedToPreset(videoEncodingSpeed), this.H264QualityToCRF(videoEncodingQuality), this.AACBitrateToQualityIndex(audioEncodingBitrate));
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
}
break;
case OutputType.Ogg:
{
int encodingQuality = this.ConversionPreset.GetSettingsValue<int>("Bitrate");
int encodingQuality = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.AudioBitrate);
string encoderArgs = string.Format("-codec:a libvorbis -qscale:a {0}", this.OGGVBRBitrateToQualityIndex(encodingQuality));
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
}
break;
break;
case OutputType.Png:
{
// http://www.howtogeek.com/203979/is-the-png-format-lossless-since-it-has-a-compression-parameter/
string encoderArgs = string.Format("-compression_level 100");
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
}
break;
case OutputType.Jpg:
{
int encodingQuality = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.ImageQuality);
string encoderArgs = string.Format("-q:v {0}", this.JPGQualityToQualityIndex(encodingQuality));
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
}
break;
case OutputType.Wav:
{
EncodingMode encodingMode = this.ConversionPreset.GetSettingsValue<EncodingMode>(ConversionPreset.ConversionSettingKeys.AudioEncodingMode);
string encoderArgs = string.Format("-acodec {0}", this.WAVEncodingToCodecArgument(encodingMode));
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
}
case OutputType.Flac:
arguments = string.Format("-n -stats -i \"{0}\" \"{1}\"", this.InputFilePath, this.OutputFilePath);
break;
default:
@@ -120,9 +176,10 @@ namespace FileConverter.ConversionJobs
throw new Exception("The conversion preset must be valid.");
}
Diagnostics.Log("Convert file {0} to {1}.", this.InputFilePath, this.OutputFilePath);
Diagnostics.Log(string.Empty);
Diagnostics.Log("Execute command: {0} {1}.", this.ffmpegProcessStartInfo.FileName, this.ffmpegProcessStartInfo.Arguments);
this.UserState = "Conversion";
Diagnostics.Debug.Log("Execute command: {0} {1}.", this.ffmpegProcessStartInfo.FileName, this.ffmpegProcessStartInfo.Arguments);
Diagnostics.Debug.Log(string.Empty);
try
{
@@ -136,7 +193,7 @@ namespace FileConverter.ConversionJobs
this.ParseFFMPEGOutput(result);
Diagnostics.Log("ffmpeg output: {0}", result);
Diagnostics.Debug.Log("ffmpeg output: {0}", result);
}
}
@@ -145,126 +202,11 @@ namespace FileConverter.ConversionJobs
}
catch
{
this.ConvertionFailed("Failed to launch FFMPEG process.");
this.ConversionFailed("Failed to launch FFMPEG process.");
throw;
}
}
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.");
}
/// <summary>
/// Convert bitrate in <c>vorbis</c> encoder quality index.
/// </summary>
/// <param name="bitrate">Wanted bitrate value.</param>
/// <returns>The <c>vorbis</c> encoder quality index associated to the given bitrate value.</returns>
/// 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.");
}
/// <summary>
/// Convert encoding mode setting to <c>ffmpeg</c> argument option.
/// </summary>
/// <param name="encoding">The encoding mode setting.</param>
/// <returns>Returns the <c>ffmpeg</c> argument corresponding to the given encoding mode.</returns>
/// 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.");
Diagnostics.Debug.Log("");
}
private void ParseFFMPEGOutput(string input)
@@ -298,9 +240,9 @@ namespace FileConverter.ConversionJobs
return;
}
if (input.Contains("Exiting."))
if (input.Contains("Exiting.") || input.Contains("Error") || input.Contains("Unsupported dimensions") || input.Contains("No such file or directory"))
{
this.ConvertionFailed(input);
this.ConversionFailed(input);
}
}
}
@@ -10,6 +10,7 @@ namespace FileConverter
using System.Xml.Serialization;
using FileConverter.Annotations;
using FileConverter.Controls;
using FileConverter.ValueConverters;
[XmlRoot]
@@ -36,10 +37,30 @@ namespace FileConverter
List<string> inputTypeList = new List<string>();
inputTypeList.AddRange(inputTypes);
this.InputTypes = inputTypeList;
this.outputFileNameTemplate = "(p)(f)";
}
public ConversionPreset(string name, ConversionPreset source)
{
this.Name = name;
this.OutputType = source.outputType;
List<string> inputTypeList = new List<string>();
if (source.inputTypes != null)
{
inputTypeList.AddRange(source.inputTypes);
}
this.InputTypes = inputTypeList;
this.outputFileNameTemplate = source.OutputFileNameTemplate;
foreach (KeyValuePair<string, string> conversionSetting in source.settings)
{
this.SetSettingsValue(conversionSetting.Key, conversionSetting.Value);
}
}
public event PropertyChangedEventHandler PropertyChanged;
[XmlAttribute]
@@ -70,6 +91,7 @@ namespace FileConverter
this.outputType = value;
this.InitializeDefaultSettings(this.outputType);
this.OnPropertyChanged();
this.CoerceInputTypes();
}
}
@@ -88,7 +110,7 @@ namespace FileConverter
{
this.inputTypes[index] = this.inputTypes[index].ToLowerInvariant();
}
this.OnPropertyChanged();
}
}
@@ -130,6 +152,20 @@ namespace FileConverter
{
for (int index = 0; index < value.Length; index++)
{
// Compatibility issues.
if (value[index].Key == "Bitrate")
{
this.SetSettingsValue(ConversionSettingKeys.AudioBitrate, value[index].Value);
continue;
}
if (value[index].Key == "Encoding")
{
this.SetSettingsValue(ConversionSettingKeys.AudioEncodingMode, value[index].Value);
continue;
}
// Load settings.
this.SetSettingsValue(value[index].Key, value[index].Value);
}
}
@@ -221,12 +257,32 @@ namespace FileConverter
}
}
public void Clean()
{
// Remove unrelevant settings.
List<string> settingsToRemove = new List<string>();
foreach (string settingsKey in this.settings.Keys)
{
if (!this.IsRelevantSetting(settingsKey))
{
settingsToRemove.Add(settingsKey);
}
}
for (int index = 0; index < settingsToRemove.Count; index++)
{
this.settings.Remove(settingsToRemove[index]);
}
}
public void OnDeserializationComplete()
{
for (int index = 0; index < this.InputTypes.Count; index++)
{
this.InputTypes[index] = this.InputTypes[index].ToLowerInvariant();
}
this.CoerceInputTypes();
}
public void AddInputType(string inputType)
@@ -314,6 +370,25 @@ namespace FileConverter
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private void CoerceInputTypes()
{
if (this.inputTypes == null)
{
return;
}
for (int index = 0; index < this.inputTypes.Count; index++)
{
string inputType = this.inputTypes[index];
string inputCategory = PathHelpers.GetExtensionCategory(inputType);
if (!PathHelpers.IsOutputTypeCompatibleWithCategory(this.OutputType, inputCategory))
{
this.RemoveInputType(inputType);
index--;
}
}
}
private bool IsRelevantSetting(string settingsKey)
{
switch (this.OutputType)
@@ -321,7 +396,7 @@ namespace FileConverter
case OutputType.Wav:
switch (settingsKey)
{
case "Encoding":
case ConversionPreset.ConversionSettingKeys.AudioEncodingMode:
return true;
}
@@ -330,8 +405,8 @@ namespace FileConverter
case OutputType.Mp3:
switch (settingsKey)
{
case "Encoding":
case "Bitrate":
case ConversionPreset.ConversionSettingKeys.AudioEncodingMode:
case ConversionPreset.ConversionSettingKeys.AudioBitrate:
return true;
}
@@ -340,7 +415,27 @@ namespace FileConverter
case OutputType.Ogg:
switch (settingsKey)
{
case "Bitrate":
case ConversionPreset.ConversionSettingKeys.AudioBitrate:
return true;
}
break;
case OutputType.Mkv:
switch (settingsKey)
{
case ConversionPreset.ConversionSettingKeys.AudioBitrate:
case ConversionPreset.ConversionSettingKeys.VideoQuality:
case ConversionPreset.ConversionSettingKeys.VideoEncodingSpeed:
return true;
}
break;
case OutputType.Jpg:
switch (settingsKey)
{
case ConversionPreset.ConversionSettingKeys.ImageQuality:
return true;
}
@@ -352,26 +447,48 @@ namespace FileConverter
private void InitializeDefaultSettings(OutputType outputType)
{
if (outputType == OutputType.Wav)
switch (outputType)
{
this.InitializeSettingsValue("Encoding", "Wav16");
}
case OutputType.Aac:
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "128");
break;
if (outputType == OutputType.Mp3)
{
this.InitializeSettingsValue("Encoding", EncodingMode.Mp3VBR.ToString());
this.InitializeSettingsValue("Bitrate", "190");
}
case OutputType.Flac:
case OutputType.Ico:
case OutputType.Png:
break;
if (outputType == OutputType.Ogg)
{
this.InitializeSettingsValue("Bitrate", "160");
case OutputType.Jpg:
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.ImageQuality, "25");
break;
case OutputType.Mkv:
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoQuality, "28");
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoEncodingSpeed, "Very Slow");
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "128");
break;
case OutputType.Mp3:
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioEncodingMode, EncodingMode.Mp3VBR.ToString(), true);
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "190");
break;
case OutputType.Ogg:
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "160");
break;
case OutputType.Wav:
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioEncodingMode, EncodingMode.Wav16.ToString(), true);
break;
default:
throw new System.Exception("Missing default settings for type " + outputType);
}
this.OnPropertyChanged("Settings");
}
private void InitializeSettingsValue(string settingsKey, string value)
private void InitializeSettingsValue(string settingsKey, string value, bool force = false)
{
if (string.IsNullOrEmpty(settingsKey))
{
@@ -387,6 +504,10 @@ namespace FileConverter
{
this.settings.Add(settingsKey, value);
}
else if (force)
{
this.settings[settingsKey] = value;
}
}
private string Validate(string propertyName)
@@ -484,7 +605,7 @@ namespace FileConverter
return string.Empty;
}
public struct ConversionSetting
{
public ConversionSetting(KeyValuePair<string, string> keyValuePair)
@@ -507,5 +628,14 @@ namespace FileConverter
set;
}
}
public struct ConversionSettingKeys
{
public const string AudioEncodingMode = "AudioEncodingMode";
public const string AudioBitrate = "AudioBitrate";
public const string ImageQuality = "ImageQuality";
public const string VideoQuality = "VideoQuality";
public const string VideoEncodingSpeed = "VideoEncodingSpeed";
}
}
}
-41
View File
@@ -1,41 +0,0 @@
// <copyright file="Diagnostics.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
namespace FileConverter
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
public static class Diagnostics
{
private static List<string> logMessages = new List<string>();
private static StringBuilder workingStringBuilder = new StringBuilder();
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
public static string Content
{
get
{
workingStringBuilder.Clear();
for (int index = 0; index < logMessages.Count; index++)
{
workingStringBuilder.AppendLine(logMessages[index]);
}
return workingStringBuilder.ToString();
}
}
public static void Log(string message, params object[] arguments)
{
Diagnostics.logMessages.Add(string.Format(message, arguments));
if (StaticPropertyChanged != null)
{
StaticPropertyChanged(null, new PropertyChangedEventArgs("Content"));
}
}
}
}
@@ -0,0 +1,96 @@
// <copyright file="Diagnostics.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
using System.Linq;
namespace FileConverter.Diagnostics
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Windows;
public static class Debug
{
private static string diagnosticsFolderPath;
private static Dictionary<int, DiagnosticsData> diagnosticsDataById = new Dictionary<int, DiagnosticsData>();
private static int threadCount = 0;
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
static Debug()
{
string path = PathHelpers.GetUserDataFolderPath();
// Delete old diagnostics folder (1 day).
DateTime expirationDate = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0));
string[] diagnosticsDirectories = Directory.GetDirectories(path, "Diagnostics.*");
for (int index = 0; index < diagnosticsDirectories.Length; index++)
{
string directory = diagnosticsDirectories[index];
DateTime creationTime = Directory.GetCreationTime(directory);
if (creationTime < expirationDate)
{
Directory.Delete(directory, true);
}
}
Debug.diagnosticsFolderPath = Path.Combine(path, "Diagnostics." + Process.GetCurrentProcess().Id);
Debug.diagnosticsFolderPath = PathHelpers.GenerateUniquePath(Debug.diagnosticsFolderPath);
Directory.CreateDirectory(Debug.diagnosticsFolderPath);
}
public static DiagnosticsData[] Data
{
get
{
return Debug.diagnosticsDataById.Values.ToArray();
}
}
public static void Log(string message, params object[] arguments)
{
DiagnosticsData diagnosticsData;
int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
lock (Debug.diagnosticsDataById)
{
if (!Debug.diagnosticsDataById.TryGetValue(threadId, out diagnosticsData))
{
diagnosticsData = new DiagnosticsData(Debug.threadCount > 0 ? string.Format("Thread {0}", Debug.threadCount) : "Application");
diagnosticsData.Initialize(Debug.diagnosticsFolderPath, threadId);
Debug.diagnosticsDataById.Add(threadId, diagnosticsData);
Debug.threadCount++;
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs("Data"));
}
}
diagnosticsData.Log(message, arguments);
}
public static void LogError(string message, params object[] arguments)
{
string log = string.Format(message, arguments);
MessageBox.Show(log, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Debug.Log("Error: " + message, arguments);
}
public static void Release()
{
Debug.Log("Diagnostics manager released correctly.");
foreach (KeyValuePair<int, DiagnosticsData> kvp in Debug.diagnosticsDataById)
{
kvp.Value.Release();
}
Debug.diagnosticsDataById.Clear();
}
}
}
@@ -0,0 +1,100 @@
// <copyright file="DiagnosticsData.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
using System.Collections.ObjectModel;
namespace FileConverter.Diagnostics
{
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Text;
using System.Runtime.CompilerServices;
using FileConverter.Annotations;
public class DiagnosticsData : INotifyPropertyChanged
{
private List<string> logMessages = new List<string>();
private StringBuilder stringBuilder = new StringBuilder();
private System.IO.TextWriter logFileWriter;
private string name;
public event PropertyChangedEventHandler PropertyChanged;
public DiagnosticsData(string name)
{
this.Name = name;
this.LogMessages = new ReadOnlyCollection<string>(this.logMessages);
}
public string Name
{
get
{
return this.name;
}
private set
{
this.name = value;
this.OnPropertyChanged();
}
}
public string Content
{
get
{
this.stringBuilder.Clear();
for (int index = 0; index < this.LogMessages.Count; index++)
{
this.stringBuilder.AppendLine(this.LogMessages[index]);
}
return this.stringBuilder.ToString();
}
}
public ReadOnlyCollection<string> LogMessages
{
get;
private set;
}
public void Initialize(string diagnosticsFolderPath, int id)
{
string path = Path.Combine(diagnosticsFolderPath, string.Format("Diagnostics{0}.log", id));
path = PathHelpers.GenerateUniquePath(path);
this.logFileWriter = new StreamWriter(File.Open(path, FileMode.Create));
this.Log("{0} {1}\n", System.DateTime.Now.ToLongDateString(), System.DateTime.Now.ToLongTimeString());
}
public void Release()
{
this.logFileWriter.Close();
this.logFileWriter = null;
}
public void Log(string message, params object[] arguments)
{
string log = string.Format(message, arguments);
this.logMessages.Add(log);
this.logFileWriter.WriteLine(log);
this.logFileWriter.Flush();
this.OnPropertyChanged("Content");
}
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
+15 -2
View File
@@ -48,6 +48,10 @@
<Reference Include="Accessibility" />
<Reference Include="PresentationUI, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="ReachFramework" />
<Reference Include="Ripper, Version=1.0.5806.33932, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Middleware\Ripper.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
@@ -67,6 +71,9 @@
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="yeti.mmedia">
<HintPath>..\..\Middleware\yeti.mmedia.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="Application.xaml">
@@ -76,11 +83,15 @@
<Compile Include="Controls\EncodingQualitySliderControl.xaml.cs">
<DependentUpon>EncodingQualitySliderControl.xaml</DependentUpon>
</Compile>
<Compile Include="ConversionJobs\ConversionFlags.cs" />
<Compile Include="ConversionJobs\ConversionJob_ExtractCDA.cs" />
<Compile Include="ConversionJobs\ConversionJobFactory.cs" />
<Compile Include="ConversionJobs\ConversionJob_FFMPEG.Converters.cs" />
<Compile Include="ConversionJobs\ConversionJob_FFMPEG.cs" />
<Compile Include="ConversionPreset\ConversionSettingsOverride.cs" />
<Compile Include="ConversionPreset\ConversionSettings.cs" />
<Compile Include="EncodingMode.cs" />
<Compile Include="Diagnostics\DiagnosticsData.cs" />
<Compile Include="Controls\EncodingMode.cs" />
<Compile Include="ConversionPreset\IConversionSettings.cs" />
<Compile Include="InputPostConversionAction.cs" />
<Compile Include="IXmlSerializable.cs" />
@@ -90,6 +101,7 @@
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="Settings.Settings.cs" />
<Compile Include="ValueConverters\ApplicationVersionToApplicationName.cs" />
<Compile Include="ConversionPreset\ConversionPreset.cs" />
<Compile Include="ValueConverters\BitrateToString.cs" />
@@ -97,6 +109,7 @@
<Compile Include="ValueConverters\Generic\BoolToVisibility.cs" />
<Compile Include="ValueConverters\ConversionSettingsToString.cs" />
<Compile Include="ValueConverters\Generic\BoolInverterConverter.cs" />
<Compile Include="ValueConverters\Generic\DoubleToTimeString.cs" />
<Compile Include="ValueConverters\Generic\EqualsConverter.cs" />
<Compile Include="ValueConverters\Generic\CollectionContainsElementToBool.cs" />
<Compile Include="ValueConverters\Generic\StringToValueType.cs" />
@@ -134,7 +147,7 @@
</Compile>
<Compile Include="ValueConverters\ConversionStateToBrush.cs" />
<Compile Include="ConversionJobs\ConversionJob.cs" />
<Compile Include="Diagnostics.cs" />
<Compile Include="Diagnostics\Debug.cs" />
<Compile Include="Windows\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
+7 -1
View File
@@ -5,9 +5,15 @@ namespace FileConverter
public enum OutputType
{
None,
Aac,
Flac,
Ico,
Jpg,
Mkv,
Mp3,
Ogg,
Flac,
Png,
Wav,
}
}
+81 -3
View File
@@ -8,6 +8,7 @@ namespace FileConverter
public static class PathHelpers
{
private static Regex driveLetterRegex = new Regex(@"[a-zA-Z]:\\");
private static Regex cdaTrackNumberRegex = new Regex(@"[a-zA-Z]:\\Track([0-9]+)\.cda");
private static Regex pathRegex = new Regex(@"^[a-zA-Z]:\\(?:[^\\/:*?""<>|\r\n]+\\)*[^\.\\/:*?""<>|\r\n][^\\/:*?""<>|\r\n]*$");
private static Regex filenameRegex = new Regex(@"[^\\]*", RegexOptions.RightToLeft);
private static Regex directoryRegex = new Regex(@"(?:([^\\]*)\\)*");
@@ -17,6 +18,18 @@ namespace FileConverter
return PathHelpers.driveLetterRegex.IsMatch(path);
}
public static string GetPathDriveLetter(string path)
{
return PathHelpers.driveLetterRegex.Match(path).Groups[0].Value;
}
public static int GetCDATrackNumber(string path)
{
Match match = PathHelpers.cdaTrackNumberRegex.Match(path);
string stringNumber = match.Groups[1].Value;
return int.Parse(stringNumber);
}
public static bool IsPathValid(string path)
{
return PathHelpers.pathRegex.IsMatch(path);
@@ -63,22 +76,87 @@ namespace FileConverter
{
switch (extension)
{
case "aac":
case "aiff":
case "ape":
case "cda":
case "flac":
case "mp3":
case "m4a":
case "ogg":
case "wav":
case "wma":
return "Audio";
return InputCategoryNames.Audio;
case "avi":
case "bik":
case "flv":
case "mp4":
return "Video";
case "mov":
case "mkv":
return InputCategoryNames.Video;
case "bmp":
case "ico":
case "jpg":
case "jpeg":
case "png":
case "tiff":
return InputCategoryNames.Image;
}
return "Misc";
return InputCategoryNames.Misc;
}
public static bool IsOutputTypeCompatibleWithCategory(OutputType outputType, string category)
{
if (category == InputCategoryNames.Misc)
{
// Misc category contains unsorted input extensions, so we consider that they are compatible to be tolerant.
return true;
}
switch (outputType)
{
case OutputType.Aac:
case OutputType.Flac:
case OutputType.Mp3:
case OutputType.Ogg:
case OutputType.Wav:
return category == InputCategoryNames.Audio || category == InputCategoryNames.Video;
case OutputType.Mkv:
return category == InputCategoryNames.Video;
case OutputType.Ico:
case OutputType.Png:
case OutputType.Jpg:
return category == InputCategoryNames.Image;
default:
return false;
}
}
public static string GetUserDataFolderPath()
{
string path = System.Environment.GetFolderPath((System.Environment.SpecialFolder.LocalApplicationData));
path = System.IO.Path.Combine(path, "FileConverter");
if (!System.IO.Directory.Exists(path))
{
System.IO.Directory.CreateDirectory(path);
}
return path;
}
public static class InputCategoryNames
{
public const string Audio = "Audio";
public const string Video = "Video";
public const string Image = "Image";
public const string Misc = "Misc";
}
}
}
+26 -2
View File
@@ -61,7 +61,7 @@ namespace FileConverter.Properties {
}
/// <summary>
/// Looks up a localized string similar to C:\Data\MyFolder\Default.wav.
/// Looks up a localized string similar to C:\Music\Artist\Album\Song.wav.
/// </summary>
public static string OuputFileNameTemplateSample {
get {
@@ -77,12 +77,36 @@ namespace FileConverter.Properties {
///(d0): input parent folder
///(d1): input sub parent folder
///...
///use maj for uppercase version.
///use maj for uppercase version
///
///Special paths:
///(p:d): my documents path
///(p:m): my music path
///(p:v): my videos path
///(p:p): my pictures path.
/// </summary>
public static string OutputFilePathTemplateHelp {
get {
return ResourceManager.GetString("OutputFilePathTemplateHelp", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Define the ratio &apos;file size&apos; versus &apos;video quality&apos;. A lower value will give you a smaller file, a greater value give you a better video quality..
/// </summary>
public static string VideoEncodingQualityTooltip {
get {
return ResourceManager.GetString("VideoEncodingQualityTooltip", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Define the ratio &apos;file size&apos; versus &apos;compression duration&apos;. A slow compression will give you a smaller file (for the same video quality) than a faster compression..
/// </summary>
public static string VideoEncodingSpeedTooltip {
get {
return ResourceManager.GetString("VideoEncodingSpeedTooltip", resourceCulture);
}
}
}
}
@@ -128,6 +128,18 @@
(d0): input parent folder
(d1): input sub parent folder
...
use maj for uppercase version</value>
use maj for uppercase version
Special paths:
(p:d): my documents path
(p:m): my music path
(p:v): my videos path
(p:p): my pictures path</value>
</data>
<data name="VideoEncodingQualityTooltip" xml:space="preserve">
<value>Define the ratio 'file size' versus 'video quality'. A lower value will give you a smaller file, a greater value give you a better video quality.</value>
</data>
<data name="VideoEncodingSpeedTooltip" xml:space="preserve">
<value>Define the ratio 'file size' versus 'compression duration'. A slow compression will give you a smaller file (for the same video quality) than a faster compression.</value>
</data>
</root>
@@ -128,6 +128,18 @@
(d0): input parent folder
(d1): input sub parent folder
...
use maj for uppercase version</value>
use maj for uppercase version
Special paths:
(p:d): my documents path
(p:m): my music path
(p:v): my videos path
(p:p): my pictures path</value>
</data>
<data name="VideoEncodingQualityTooltip" xml:space="preserve">
<value>Define the ratio 'file size' versus 'video quality'. A lower value will give you a smaller file, a greater value give you a better video quality.</value>
</data>
<data name="VideoEncodingSpeedTooltip" xml:space="preserve">
<value>Define the ratio 'file size' versus 'compression duration'. A slow compression will give you a smaller file (for the same video quality) than a faster compression.</value>
</data>
</root>
@@ -0,0 +1,98 @@
// <copyright file="Settings.Settings.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
namespace FileConverter
{
using System.Linq;
using System.Collections.ObjectModel;
using System.Xml.Serialization;
public partial class Settings : IXmlSerializable
{
public const int Version = 1;
private double settingsWindowHeight = 640;
private double settingsWindowWidth = 800;
private bool exitApplicationWhenConversionsFinished = true;
private float durationBetweenEndOfConversionsAndApplicationExit = 3f;
private ObservableCollection<ConversionPreset> conversionPresets = new ObservableCollection<ConversionPreset>();
[XmlAttribute]
public int SerializationVersion
{
get;
set;
} = Version;
[XmlIgnore]
public ObservableCollection<ConversionPreset> ConversionPresets
{
get
{
return this.conversionPresets;
}
set
{
this.conversionPresets = value;
this.OnPropertyChanged();
}
}
[XmlElement]
public bool ExitApplicationWhenConversionsFinished
{
get
{
return this.exitApplicationWhenConversionsFinished;
}
set
{
this.exitApplicationWhenConversionsFinished = value;
this.OnPropertyChanged();
}
}
[XmlElement]
public float DurationBetweenEndOfConversionsAndApplicationExit
{
get
{
return this.durationBetweenEndOfConversionsAndApplicationExit;
}
set
{
this.durationBetweenEndOfConversionsAndApplicationExit = value;
this.OnPropertyChanged();
}
}
[XmlElement("ConversionPreset")]
public ConversionPreset[] SerializableConversionPresets
{
get
{
return this.ConversionPresets.ToArray();
}
set
{
for (int index = 0; index < value.Length; index++)
{
this.ConversionPresets.Add(value[index]);
}
}
}
public void OnDeserializationComplete()
{
this.DurationBetweenEndOfConversionsAndApplicationExit = System.Math.Max(0, System.Math.Min(10, this.DurationBetweenEndOfConversionsAndApplicationExit));
for (int index = 0; index < this.ConversionPresets.Count; index++)
{
this.ConversionPresets[index].OnDeserializationComplete();
}
}
}
}
+102 -60
View File
@@ -4,7 +4,6 @@ namespace FileConverter
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
@@ -12,25 +11,22 @@ namespace FileConverter
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Principal;
using System.Xml.Serialization;
using System.Windows;
using FileConverter.Annotations;
using Microsoft.Win32;
public class Settings : INotifyPropertyChanged, IDataErrorInfo
using FileConverter.Annotations;
[XmlRoot]
[XmlType]
public partial class Settings : INotifyPropertyChanged, IDataErrorInfo
{
private const char PresetSeparator = ';';
private ObservableCollection<ConversionPreset> conversionPresets = new ObservableCollection<ConversionPreset>();
public event PropertyChangedEventHandler PropertyChanged;
public ObservableCollection<ConversionPreset> ConversionPresets
{
get { return this.conversionPresets; }
set { this.conversionPresets = value; }
}
[XmlIgnore]
public string Error
{
get
@@ -56,6 +52,7 @@ namespace FileConverter
}
}
[XmlIgnore]
public string this[string columnName]
{
get
@@ -73,18 +70,18 @@ namespace FileConverter
return;
}
ICollection<ConversionPreset> conversionPresets = new ObservableCollection<ConversionPreset>();
XmlHelpers.LoadFromFile("Settings", temporaryFilePath, ref conversionPresets);
Settings settings = null;
XmlHelpers.LoadFromFile("Settings", temporaryFilePath, out settings);
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\FileConverter");
if (registryKey == null)
{
MessageBox.Show("Can't apply settings in registry. (code 0x03)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Diagnostics.Debug.LogError("Can't apply settings in registry. (code 0x03)");
return;
}
// Compute the registry entries data from settings.
Dictionary<string, List<string>> registryEntries = ComputeRegistryEntriesFromConvertionPresets(conversionPresets);
Dictionary<string, List<string>> registryEntries = ComputeRegistryEntriesFromConvertionPresets(settings.ConversionPresets);
bool succeed = Settings.ApplyRegistryModifications(registryEntries);
@@ -97,41 +94,71 @@ namespace FileConverter
}
}
public static Settings Load()
{
Settings defaultSettings = null;
// Load the default settings.
string defaultFilePath = Settings.GetDefaultSettingsFilePath();
if (File.Exists(defaultFilePath))
{
try
{
XmlHelpers.LoadFromFile<Settings>("Settings", defaultFilePath, out defaultSettings);
}
catch (Exception exception)
{
Diagnostics.Debug.LogError("Fail to load file converter default settings. {0}", exception.Message);
}
}
else
{
Diagnostics.Debug.LogError("Default settings not found at path {0}. You should try to reinstall the application.", defaultFilePath);
}
Settings userSettings = null;
string userFilePath = Settings.GetUserSettingsFilePath();
if (File.Exists(userFilePath))
{
try
{
XmlHelpers.LoadFromFile<Settings>("Settings", userFilePath, out userSettings);
}
catch (Exception exception)
{
MessageBoxResult messageBoxResult = MessageBox.Show("Can't load file converter user settings. Do you want to fall back to default settings ?", "Error", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
if (messageBoxResult == MessageBoxResult.Yes)
{
System.IO.File.Delete(userFilePath);
return Settings.Load();
}
else if (messageBoxResult == MessageBoxResult.No)
{
return null;
}
}
if (userSettings != null && userSettings.SerializationVersion != Version)
{
Diagnostics.Debug.Log("File converter settings has been imported from version {0} to version {1}.", userSettings.SerializationVersion, Version);
}
}
return userSettings != null ? userSettings.Merge(defaultSettings) : defaultSettings;
}
public ConversionPreset GetPresetFromName(string presetName)
{
return this.conversionPresets.FirstOrDefault(match => match.Name == presetName);
}
public void Load()
{
ICollection<ConversionPreset> presets = this.ConversionPresets;
presets.Clear();
string userFilePath = Settings.GetUserSettingsFilePath();
if (File.Exists(userFilePath))
{
XmlHelpers.LoadFromFile<ConversionPreset>("Settings", userFilePath, ref presets);
}
else
{
// If user settings doesn't exist, load the default settings.
string defaultFilePath = Settings.GetDefaultSettingsFilePath();
if (File.Exists(defaultFilePath))
{
XmlHelpers.LoadFromFile<ConversionPreset>("Settings", defaultFilePath, ref presets);
}
else
{
Diagnostics.Log("Default settings not found. You should try to reinstall the application.");
}
}
}
public void Save()
{
this.Clean();
// Save the settings in a temporary files (we'll write the settings file when we'll succeed to write the registry keys).
string temporaryFilePath = Settings.GetUserSettingsTemporaryFilePath();
XmlHelpers.SaveToFile("Settings", temporaryFilePath, this.ConversionPresets);
XmlHelpers.SaveToFile("Settings", temporaryFilePath, this);
// Compute the registry entries data from settings.
Dictionary<string, List<string>> registryEntries = Settings.ComputeRegistryEntriesFromConvertionPresets(this.ConversionPresets);
@@ -169,6 +196,14 @@ namespace FileConverter
}
}
public void Clean()
{
for (int index = 0; index < this.ConversionPresets.Count; index++)
{
this.ConversionPresets[index].Clean();
}
}
private static bool ApplyRegistryModifications(Dictionary<string, List<string>> registryEntries)
{
if (!Settings.IsInAdmininstratorPrivileges)
@@ -220,7 +255,7 @@ namespace FileConverter
}
catch (Exception exception)
{
Diagnostics.Log(exception.Message);
Diagnostics.Debug.Log(exception.Message);
}
if (subKey == null)
@@ -273,28 +308,14 @@ namespace FileConverter
private static string GetUserSettingsFilePath()
{
string path = Environment.GetEnvironmentVariable("LocalAppData");
path = Path.Combine(path, "FileConverter");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string path = PathHelpers.GetUserDataFolderPath();
path = Path.Combine(path, "Settings.user.xml");
return path;
}
private static string GetUserSettingsTemporaryFilePath()
{
string path = Environment.GetEnvironmentVariable("LocalAppData");
path = Path.Combine(path, "FileConverter");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string path = PathHelpers.GetUserDataFolderPath();
path = Path.Combine(path, "Settings.temp.xml");
return path;
}
@@ -336,7 +357,7 @@ namespace FileConverter
for (int presetIndex = 0; presetIndex < presets.Length; presetIndex++)
{
if (!presetsList.Contains(presets[presetIndex]))
if (presetsList[presetIndex] != presets[presetIndex])
{
return true;
}
@@ -382,5 +403,26 @@ namespace FileConverter
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private Settings Merge(Settings settings)
{
if (settings == null)
{
return this;
}
for (int index = 0; index < settings.conversionPresets.Count; index++)
{
ConversionPreset conversionPreset = settings.conversionPresets[index];
if (this.conversionPresets.Any(match => match.Name == conversionPreset.Name))
{
continue;
}
this.conversionPresets.Add(conversionPreset);
}
return this;
}
}
}
+136 -27
View File
@@ -1,55 +1,164 @@
<?xml version="1.0" encoding="utf-8"?>
<Settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ConversionPreset Name="To Ogg" OutputType="Ogg">
<InputTypes>flac</InputTypes>
<InputTypes>ape</InputTypes>
<InputTypes>wav</InputTypes>
<InputTypes>wma</InputTypes>
<InputTypes>m4a</InputTypes>
<Settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SerializationVersion="0">
<ExitApplicationWhenConversionsFinished>true</ExitApplicationWhenConversionsFinished>
<DurationBetweenEndOfConversionsAndApplicationExit>3</DurationBetweenEndOfConversionsAndApplicationExit>
<ConversionPreset Name="To Mkv" OutputType="Mkv">
<InputTypes>avi</InputTypes>
<InputTypes>bik</InputTypes>
<InputTypes>flv</InputTypes>
<InputTypes>mkv</InputTypes>
<InputTypes>mov</InputTypes>
<InputTypes>mp4</InputTypes>
<InputTypes>mp3</InputTypes>
<InputTypes>aiff</InputTypes>
<InputPostConversionAction>None</InputPostConversionAction>
<Settings Key="Bitrate" Value="128" />
<Settings Key="VideoQuality" Value="30" />
<Settings Key="VideoEncodingSpeed" Value="Very Slow" />
<Settings Key="AudioBitrate" Value="155" />
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
</ConversionPreset>
<ConversionPreset Name="To Mp3" OutputType="Mp3">
<InputTypes>ogg</InputTypes>
<InputTypes>flac</InputTypes>
<InputTypes>ape</InputTypes>
<InputTypes>wav</InputTypes>
<InputTypes>wma</InputTypes>
<InputTypes>m4a</InputTypes>
<InputTypes>mp4</InputTypes>
<ConversionPreset Name="To Mkv (low quality)" OutputType="Mkv">
<InputTypes>avi</InputTypes>
<InputTypes>aiff</InputTypes>
<InputTypes>bik</InputTypes>
<InputTypes>flv</InputTypes>
<InputTypes>mkv</InputTypes>
<InputTypes>mov</InputTypes>
<InputTypes>mp4</InputTypes>
<InputPostConversionAction>None</InputPostConversionAction>
<Settings Key="Encoding" Value="Mp3VBR" />
<Settings Key="Bitrate" Value="175" />
<Settings Key="VideoQuality" Value="20" />
<Settings Key="VideoEncodingSpeed" Value="Very Slow" />
<Settings Key="AudioBitrate" Value="96" />
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
</ConversionPreset>
<ConversionPreset Name="To Ogg" OutputType="Ogg">
<InputTypes>aac</InputTypes>
<InputTypes>aiff</InputTypes>
<InputTypes>ape</InputTypes>
<InputTypes>flac</InputTypes>
<InputTypes>m4a</InputTypes>
<InputTypes>mp3</InputTypes>
<InputTypes>wma</InputTypes>
<InputTypes>avi</InputTypes>
<InputTypes>bik</InputTypes>
<InputTypes>flv</InputTypes>
<InputTypes>mkv</InputTypes>
<InputTypes>mov</InputTypes>
<InputTypes>mp4</InputTypes>
<InputTypes>wav</InputTypes>
<InputPostConversionAction>None</InputPostConversionAction>
<Settings Key="AudioBitrate" Value="160" />
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
</ConversionPreset>
<ConversionPreset Name="To Flac" OutputType="Flac">
<InputTypes>ape</InputTypes>
<InputTypes>wav</InputTypes>
<InputTypes>avi</InputTypes>
<InputTypes>bik</InputTypes>
<InputTypes>flv</InputTypes>
<InputTypes>mkv</InputTypes>
<InputTypes>mov</InputTypes>
<InputTypes>mp4</InputTypes>
<InputTypes>aiff</InputTypes>
<InputTypes>wav</InputTypes>
<InputTypes>ape</InputTypes>
<InputPostConversionAction>None</InputPostConversionAction>
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
</ConversionPreset>
<ConversionPreset Name="To Wav" OutputType="Wav">
<InputTypes>aac</InputTypes>
<InputTypes>aiff</InputTypes>
<InputTypes>ape</InputTypes>
<InputTypes>flac</InputTypes>
<InputTypes>m4a</InputTypes>
<InputTypes>mp3</InputTypes>
<InputTypes>ogg</InputTypes>
<InputTypes>wma</InputTypes>
<InputTypes>avi</InputTypes>
<InputTypes>bik</InputTypes>
<InputTypes>flv</InputTypes>
<InputTypes>mkv</InputTypes>
<InputTypes>mov</InputTypes>
<InputTypes>mp4</InputTypes>
<InputTypes>m4a</InputTypes>
<InputTypes>aiff</InputTypes>
<InputPostConversionAction>None</InputPostConversionAction>
<Settings Key="Encoding" Value="Wav16" />
<Settings Key="AudioEncodingMode" Value="Wav16" />
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
</ConversionPreset>
<ConversionPreset Name="To Mp3" OutputType="Mp3">
<InputTypes>aac</InputTypes>
<InputTypes>aiff</InputTypes>
<InputTypes>ape</InputTypes>
<InputTypes>flac</InputTypes>
<InputTypes>m4a</InputTypes>
<InputTypes>ogg</InputTypes>
<InputTypes>wma</InputTypes>
<InputTypes>avi</InputTypes>
<InputTypes>bik</InputTypes>
<InputTypes>flv</InputTypes>
<InputTypes>mkv</InputTypes>
<InputTypes>mov</InputTypes>
<InputTypes>mp4</InputTypes>
<InputTypes>wav</InputTypes>
<InputPostConversionAction>None</InputPostConversionAction>
<Settings Key="AudioEncodingMode" Value="Mp3VBR" />
<Settings Key="AudioBitrate" Value="190" />
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
</ConversionPreset>
<ConversionPreset Name="To Aac" OutputType="Aac">
<InputTypes>aiff</InputTypes>
<InputTypes>ape</InputTypes>
<InputTypes>m4a</InputTypes>
<InputTypes>mp3</InputTypes>
<InputTypes>ogg</InputTypes>
<InputTypes>wma</InputTypes>
<InputTypes>avi</InputTypes>
<InputTypes>bik</InputTypes>
<InputTypes>flv</InputTypes>
<InputTypes>mkv</InputTypes>
<InputTypes>mov</InputTypes>
<InputTypes>mp4</InputTypes>
<InputTypes>wav</InputTypes>
<InputTypes>flac</InputTypes>
<InputPostConversionAction>None</InputPostConversionAction>
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
</ConversionPreset>
<ConversionPreset Name="Extract CDA to Flac" OutputType="Flac">
<InputTypes>cda</InputTypes>
<InputPostConversionAction>None</InputPostConversionAction>
<OutputFileNameTemplate>(p:m)CDA Extraction\(f)</OutputFileNameTemplate>
</ConversionPreset>
<ConversionPreset Name="Extract CDA to Ogg" OutputType="Ogg">
<InputTypes>cda</InputTypes>
<InputPostConversionAction>None</InputPostConversionAction>
<Settings Key="AudioBitrate" Value="192" />
<OutputFileNameTemplate>(p:m)CDA Extraction\(f)</OutputFileNameTemplate>
</ConversionPreset>
<ConversionPreset Name="Extract CDA to Mp3" OutputType="Mp3">
<InputTypes>cda</InputTypes>
<InputPostConversionAction>None</InputPostConversionAction>
<Settings Key="AudioEncodingMode" Value="Mp3VBR" />
<Settings Key="AudioBitrate" Value="225" />
<OutputFileNameTemplate>(p:m)CDA Extraction\(f)</OutputFileNameTemplate>
</ConversionPreset>
<ConversionPreset Name="To Png" OutputType="Png">
<InputTypes>bmp</InputTypes>
<InputTypes>tiff</InputTypes>
<InputTypes>ico</InputTypes>
<InputTypes>jpg</InputTypes>
<InputTypes>jpeg</InputTypes>
<InputPostConversionAction>None</InputPostConversionAction>
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
</ConversionPreset>
<ConversionPreset Name="To Jpg" OutputType="Jpg">
<InputTypes>bmp</InputTypes>
<InputTypes>png</InputTypes>
<InputTypes>tiff</InputTypes>
<InputTypes>ico</InputTypes>
<InputPostConversionAction>None</InputPostConversionAction>
<Settings Key="ImageQuality" Value="25" />
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
</ConversionPreset>
<ConversionPreset Name="To Ico (max 256x256)" OutputType="Ico">
<InputTypes>bmp</InputTypes>
<InputTypes>jpg</InputTypes>
<InputTypes>jpeg</InputTypes>
<InputTypes>png</InputTypes>
<InputTypes>tiff</InputTypes>
<InputPostConversionAction>None</InputPostConversionAction>
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
</ConversionPreset>
</Settings>
@@ -62,6 +62,22 @@ namespace FileConverter.ValueConverters
outputPath = outputPath.Replace("(i)", inputExtension);
outputPath = outputPath.Replace("(I)", inputExtension.ToUpperInvariant());
string myDocumentsFolder = System.Environment.GetFolderPath((System.Environment.SpecialFolder.MyDocuments)) + "\\";
outputPath = outputPath.Replace("(p:d)", myDocumentsFolder);
outputPath = outputPath.Replace("(p:documents)", myDocumentsFolder);
string myMusicFolder = System.Environment.GetFolderPath((System.Environment.SpecialFolder.MyMusic)) + "\\";
outputPath = outputPath.Replace("(p:m)", myMusicFolder);
outputPath = outputPath.Replace("(p:music)", myMusicFolder);
string myVideoFolder = System.Environment.GetFolderPath((System.Environment.SpecialFolder.MyVideos)) + "\\";
outputPath = outputPath.Replace("(p:v)", myVideoFolder);
outputPath = outputPath.Replace("(p:videos)", myVideoFolder);
string myPictureFolder = System.Environment.GetFolderPath((System.Environment.SpecialFolder.MyPictures)) + "\\";
outputPath = outputPath.Replace("(p:p)", myPictureFolder);
outputPath = outputPath.Replace("(p:pictures)", myPictureFolder);
for (int index = 0; index < directories.Length; index++)
{
outputPath = outputPath.Replace(string.Format("(d{0})", directories.Length - index - 1), directories[index]);
@@ -15,9 +15,13 @@ namespace FileConverter.ValueConverters.Generic
throw new ArgumentException("The value must be a boolean.");
}
string stringParameter = parameter as string;
string falseResult = stringParameter ?? "Hidden";
bool booleanValue = (bool)value;
return booleanValue ? "Visible" : "Hidden";
return booleanValue ? "Visible" : falseResult;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
@@ -0,0 +1,28 @@
// <copyright file="DoubleToTimeString.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
namespace FileConverter.ValueConverters.Generic
{
using System;
using System.Globalization;
using System.Windows.Data;
public class DoubleToTimeString : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is double))
{
throw new ArgumentException("The value must be a boolean.");
}
double doubleValue = (double)value;
return string.Format("{0} second{1}", doubleValue.ToString("0.#"), doubleValue >= 2 ? "s" : string.Empty);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
@@ -31,6 +31,24 @@ namespace FileConverter.Windows
set;
}
public DataTemplate AacSettingsDataTemplate
{
get;
set;
}
public DataTemplate JpgSettingsDataTemplate
{
get;
set;
}
public DataTemplate MkvSettingsDataTemplate
{
get;
set;
}
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
if (item == null)
@@ -50,6 +68,15 @@ namespace FileConverter.Windows
case OutputType.Ogg:
return this.OggSettingsDataTemplate;
case OutputType.Aac:
return this.AacSettingsDataTemplate;
case OutputType.Mkv:
return this.MkvSettingsDataTemplate;
case OutputType.Jpg:
return this.JpgSettingsDataTemplate;
}
return this.DefaultDataTemplate;
@@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FileConverter.Windows"
xmlns:fileConverter="clr-namespace:FileConverter"
xmlns:diagnostics="clr-namespace:FileConverter.Diagnostics"
mc:Ignorable="d"
Title="Diagnostics" Height="600" Width="800" Icon="/FileConverter;component/Resources/ApplicationIcon.ico">
<Grid>
@@ -13,8 +14,20 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="Logs" VerticalAlignment="Top" Height="30" FontSize="16" FontWeight="Bold" />
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" CanContentScroll="True">
<TextBlock Name="Diagnostics" TextWrapping="NoWrap" Text="{Binding Path=(fileConverter:Diagnostics.Content), Mode=OneWay}" FontFamily="Consolas" Foreground="#FF272727"/>
</ScrollViewer>
<TabControl Grid.Row="1" Margin="5" ItemsSource="{Binding Path=(diagnostics:Debug.Data), Mode=OneWay}">
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" CanContentScroll="True">
<TextBlock Name="Diagnostics" TextWrapping="NoWrap" Text="{Binding Content}" FontFamily="Consolas" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="False"/>
</ScrollViewer>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
</Grid>
</Window>
@@ -57,7 +57,7 @@
<TextBlock Text="{Binding ErrorMessage}" Foreground="{Binding State, ConverterParameter=Foreground, Converter={StaticResource ConversionStateToColor}}" />
</StackPanel>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding State}" FontWeight="Bold" Foreground="{Binding State, ConverterParameter=Foreground, Converter={StaticResource ConversionStateToColor}}" />
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding UserState}" FontWeight="Bold" Foreground="{Binding State, ConverterParameter=Foreground, Converter={StaticResource ConversionStateToColor}}" />
<ProgressBar Grid.Row="1" Grid.Column="1" Height="18" Width="Auto" Minimum="0" Maximum="1" SmallChange="0.001" Value="{Binding Progress, Mode=OneWay}" Foreground="{Binding State, ConverterParameter=Foreground, Converter={StaticResource ConversionStateToColor}}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" MinWidth="100" LargeChange="0.1" />
</Grid>
@@ -7,14 +7,14 @@
xmlns:windows="clr-namespace:FileConverter.Windows"
xmlns:project="clr-namespace:FileConverter.Properties"
xmlns:System="clr-namespace:System;assembly=mscorlib" x:Name="window" x:Class="FileConverter.SettingsWindow"
Height="600" Width="800" MinHeight="480" MinWidth="640"
MinWidth="640" MinHeight="480"
Width="800" Height="600"
WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon.ico"
Closing="SettingsWindow_OnClosing">
<Window.Resources>
<generic:DoubleToTimeString x:Key="DoubleToTimeString"/>
<valueConverters:FileNameConverter x:Key="FileNameConverter"/>
<generic:BoolToVisibility x:Key="BoolToVisibility"/>
<valueConverters:InputTypesToBool x:Key="InputTypesToBool"/>
<valueConverters:OutputTypeToVisibility x:Key="OutputTypeToVisibility"/>
<valueConverters:ApplicationVersionToApplicationName x:Key="ApplicationVersionToApplicationName"/>
<generic:CollectionContainsElementToBool x:Key="CollectionContainsElementToBool"/>
@@ -65,10 +65,10 @@
<StackPanel>
<DockPanel>
<Label Content="Encoding :" />
<RadioButton x:Name="WAV8radioButton" Content="8-bits" ToolTip="PCM signed 8-bit little-endian" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|Wav8, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" />
<RadioButton x:Name="WAV16radioButton" Content="16-bits" ToolTip="PCM signed 16-bit little-endian" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|Wav16, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}"/>
<RadioButton x:Name="WAV24radioButton" Content="24-bits" ToolTip="PCM signed 24-bit little-endian" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|Wav24, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}"/>
<RadioButton x:Name="WAV32radioButton" Content="32-bits" ToolTip="PCM signed 32-bit little-endian" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|Wav32, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}"/>
<RadioButton x:Name="WAV8radioButton" Content="8-bits" ToolTip="PCM signed 8-bit little-endian" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=AudioEncodingMode|Wav8, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" />
<RadioButton x:Name="WAV16radioButton" Content="16-bits" ToolTip="PCM signed 16-bit little-endian" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=AudioEncodingMode|Wav16, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}"/>
<RadioButton x:Name="WAV24radioButton" Content="24-bits" ToolTip="PCM signed 24-bit little-endian" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=AudioEncodingMode|Wav24, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}"/>
<RadioButton x:Name="WAV32radioButton" Content="32-bits" ToolTip="PCM signed 32-bit little-endian" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=AudioEncodingMode|Wav32, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}"/>
</DockPanel>
</StackPanel>
</DataTemplate>
@@ -77,14 +77,14 @@
<StackPanel>
<DockPanel>
<Label Content="Encoding :" />
<RadioButton x:Name="VBRradioButton" Content="VBR" ToolTip="Variable bitrate encoding" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|Mp3VBR, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" />
<RadioButton x:Name="CBRradioButton" Content="CBR" ToolTip="Constant bitrate encoding" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|Mp3CBR, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}"/>
<RadioButton x:Name="VBRradioButton" Content="VBR" ToolTip="Variable bitrate encoding" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=AudioEncodingMode|Mp3VBR, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" />
<RadioButton x:Name="CBRradioButton" Content="CBR" ToolTip="Constant bitrate encoding" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=AudioEncodingMode|Mp3CBR, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}"/>
</DockPanel>
<DockPanel>
<Label Content="Quality :" />
<controls:EncodingQualitySliderControl x:Name="EncodingQualitySlider"
EncodingMode="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|FileConverter.EncodingMode, Converter={StaticResource ConversionSettingsToEnum}, ElementName=window, Mode=OneWay, TargetNullValue=VBR}"
Bitrate="{Binding SelectedPreset.Settings, ConverterParameter=Bitrate|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=190}" />
EncodingMode="{Binding SelectedPreset.Settings, ConverterParameter=AudioEncodingMode|FileConverter.Controls.EncodingMode, Converter={StaticResource ConversionSettingsToEnum}, ElementName=window, Mode=OneWay, TargetNullValue=VBR}"
Bitrate="{Binding SelectedPreset.Settings, ConverterParameter=AudioBitrate|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=190}" />
</DockPanel>
</StackPanel>
</DataTemplate>
@@ -94,7 +94,68 @@
<DockPanel>
<Label Content="Quality :" />
<controls:EncodingQualitySliderControl x:Name="EncodingQualitySlider" EncodingMode="OggVBR"
Bitrate="{Binding SelectedPreset.Settings, ConverterParameter=Bitrate|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=160}" />
Bitrate="{Binding SelectedPreset.Settings, ConverterParameter=AudioBitrate|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=160}" />
</DockPanel>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="AacSettingsDataTemplate">
<StackPanel>
<DockPanel>
<Label Content="Quality :" />
<controls:EncodingQualitySliderControl x:Name="EncodingQualitySlider" EncodingMode="AacVBR"
Bitrate="{Binding SelectedPreset.Settings, ConverterParameter=AudioBitrate|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=128}" />
</DockPanel>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="MkvSettingsDataTemplate">
<StackPanel>
<DockPanel>
<Label Content="Video" FontWeight="Bold" />
<Label Content="(H.264)" FontWeight="Light" Foreground="#004B82" />
</DockPanel>
<DockPanel>
<Label Content="Quality :" ToolTip="{x:Static project:Resources.VideoEncodingQualityTooltip}"/>
<Slider x:Name="QualitySlider" Value="{Binding SelectedPreset.Settings, ConverterParameter=VideoQuality|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay}"
Margin="0,2,0,0" VerticalAlignment="Top" AutoToolTipPlacement="TopLeft" IsSnapToTickEnabled="True" IsSelectionRangeEnabled="True" SelectionStart="20" SelectionEnd="33" Minimum="0" Maximum="51" TickPlacement="BottomRight" SmallChange="1" LargeChange="6" TickFrequency="1" Foreground="#004B82" />
</DockPanel>
<DockPanel>
<Label Content="Encoding speed :" ToolTip="{x:Static project:Resources.VideoEncodingSpeedTooltip}" />
<ComboBox SelectedValue="{Binding SelectedPreset.Settings, ConverterParameter=VideoEncodingSpeed|System.String, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=veryslow}">
<System:String>Ultra Fast</System:String>
<System:String>Super Fast</System:String>
<System:String>Very Fast</System:String>
<System:String>Faster</System:String>
<System:String>Fast</System:String>
<System:String>Medium</System:String>
<System:String>Slow</System:String>
<System:String>Slower</System:String>
<System:String>Very Slow</System:String>
</ComboBox>
</DockPanel>
<DockPanel>
<Label Content="Audio" FontWeight="Bold" />
<Label Content="(AAC)" FontWeight="Light" Foreground="#004B82" />
</DockPanel>
<DockPanel>
<Label Content="Quality :" />
<controls:EncodingQualitySliderControl x:Name="EncodingQualitySlider" EncodingMode="AacVBR"
Bitrate="{Binding SelectedPreset.Settings, ConverterParameter=AudioBitrate|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=128}" />
</DockPanel>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="JpgSettingsDataTemplate">
<StackPanel>
<DockPanel>
<Label Content="Quality :" />
<Slider x:Name="QualitySlider" Value="{Binding SelectedPreset.Settings, ConverterParameter=ImageQuality|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=25}"
Margin="0,2,0,0" VerticalAlignment="Top" AutoToolTipPlacement="TopLeft" IsSnapToTickEnabled="True" IsSelectionRangeEnabled="True" SelectionStart="20" SelectionEnd="30" Minimum="0" Maximum="30" TickPlacement="BottomRight" SmallChange="3" LargeChange="6" TickFrequency="1" Foreground="#004B82" />
</DockPanel>
</StackPanel>
</DataTemplate>
@@ -103,13 +164,16 @@
DefaultDataTemplate="{StaticResource EmptyDataTemplate}"
WavSettingsDataTemplate="{StaticResource WavSettingsDataTemplate}"
Mp3SettingsDataTemplate="{StaticResource Mp3SettingsDataTemplate}"
OggSettingsDataTemplate="{StaticResource OggSettingsDataTemplate}" />
OggSettingsDataTemplate="{StaticResource OggSettingsDataTemplate}"
MkvSettingsDataTemplate="{StaticResource MkvSettingsDataTemplate}"
AacSettingsDataTemplate="{StaticResource AacSettingsDataTemplate}"
JpgSettingsDataTemplate="{StaticResource JpgSettingsDataTemplate}" />
</Window.Resources>
<Window.Title>
<Binding Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" Path="(local:Application.ApplicationVersion)"/>
</Window.Title>
<Grid x:Name="grid" Margin="10">
<Grid x:Name="MainGrid" Margin="10">
<Grid.CommandBindings>
<CommandBinding Command="New" CanExecute="CanSaveSettings" />
</Grid.CommandBindings>
@@ -117,9 +181,11 @@
<Grid.RowDefinitions>
<RowDefinition Height="48"/>
<RowDefinition Height="*"/>
<RowDefinition Height="{Binding Height, ElementName=ApplicationSettingsPanel, Mode=OneWay}"/>
<RowDefinition Height="28"/>
</Grid.RowDefinitions>
<!-- Header -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48"/>
@@ -130,16 +196,17 @@
<Image HorizontalAlignment="Left" Height="48" Width="48" VerticalAlignment="Top" Source="..\Resources\ApplicationIcon.png" />
<Label Grid.Column="1" Content="Settings" FontSize="20" Margin="4" VerticalAlignment="Center" />
<Label Grid.Column="2" HorizontalAlignment="Right" FontStyle="Italic" FontSize="14" VerticalAlignment="Center">
<Label.Content>
<Binding Path="(local:Application.ApplicationVersion)" Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" />
</Label.Content>
<Label.Content>
<Binding Path="(local:Application.ApplicationVersion)" Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" />
</Label.Content>
</Label>
</Grid>
<!-- Conversion presets settings -->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="122"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
<Grid x:Name="PresetListGrid" Margin="5">
@@ -163,7 +230,7 @@
</ListBox.ItemTemplate>
</ListBox>
<DockPanel Grid.Row="2" Margin="0,5,0,0">
<DockPanel Grid.Row="2" Margin="0,5,0,0" HorizontalAlignment="Center">
<Button x:Name="MoveUpPresetButton" Content="^" HorizontalAlignment="Left" Width="25" Margin="0,0,2,0" Click="MovePresetUpButton_Click"/>
<Button x:Name="AddPresetButton" Content="+" HorizontalAlignment="Left" Width="25" Margin="2,0" Click="AddPresetButton_Click"/>
<Button x:Name="RemovePresetButton" Content="-" HorizontalAlignment="Left" Width="25" Margin="2,0" Click="RemovePresetButton_Click"/>
@@ -221,7 +288,7 @@
</TreeView.Resources>
<TreeView.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="True" />
<Setter Property="IsExpanded" Value="True"/>
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
@@ -274,8 +341,18 @@
</GroupBox>
</Grid>
<Button x:Name="CloseButton" Grid.Row="2" Content="Close" HorizontalAlignment="Right" Width="100" Margin="0,4,105,0" Click="CloseButton_Click" />
<Button x:Name="SaveButton" Grid.Row="2" Content="Save" HorizontalAlignment="Right" Width="100" Margin="0,4,0,0" Click="SaveButton_Click" Command="New"/>
<!-- Application settings -->
<StackPanel x:Name="ApplicationSettingsPanel" Grid.Row="2" Margin="5,10,5,5">
<CheckBox x:Name="QuitAtEndCheckBox" Content="Automaticaly exit when all conversions finished" IsChecked="{Binding ApplicationSettings.ExitApplicationWhenConversionsFinished, ElementName=window, Mode=TwoWay}" />
<DockPanel Margin="40,0,0,5" Visibility="{Binding IsChecked, Converter={StaticResource BoolToVisibility}, ConverterParameter=Collapsed, ElementName=QuitAtEndCheckBox}">
<Label Content="Waiting duration :"/>
<Slider x:Name="DurationBeforeQuitSlider" Value="{Binding ApplicationSettings.DurationBetweenEndOfConversionsAndApplicationExit, ElementName=window, Mode=TwoWay}" Minimum="0" Maximum="10" SmallChange="0.1" IsSnapToTickEnabled="True" Width="250" TickFrequency="0.1"/>
<Label Content="{Binding Value, Converter={StaticResource DoubleToTimeString}, ElementName=DurationBeforeQuitSlider}"/>
</DockPanel>
</StackPanel>
<Button x:Name="CloseButton" Grid.Row="3" Content="Close" HorizontalAlignment="Right" Width="100" Margin="0,4,105,0" Click="CloseButton_Click" />
<Button x:Name="SaveButton" Grid.Row="3" Content="Save" HorizontalAlignment="Right" Width="100" Margin="0,4,0,0" Click="SaveButton_Click" Command="New"/>
</Grid>
</Window>
@@ -1,5 +1,7 @@
// <copyright file="SettingsWindow.xaml.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
using System.Linq;
namespace FileConverter
{
using System;
@@ -29,15 +31,20 @@ namespace FileConverter
this.InitializeComponent();
Application application = Application.Current as Application;
this.settings = application.Settings;
this.ApplicationSettings = application.Settings;
this.PresetList.ItemsSource = this.settings.ConversionPresets;
OutputType[] outputTypes = new[]
{
OutputType.Flac,
OutputType.Mp3,
OutputType.Ogg,
OutputType.Wav,
OutputType.Mp3,
OutputType.Aac,
OutputType.Flac,
OutputType.Wav,
OutputType.Mkv,
OutputType.Ico,
OutputType.Jpg,
OutputType.Png,
};
this.OutputFormats.ItemsSource = outputTypes;
@@ -67,25 +74,65 @@ namespace FileConverter
set
{
if (this.selectedPreset != null)
{
this.selectedPreset.PropertyChanged -= this.SelectedPresetPropertyChanged;
}
this.selectedPreset = value;
if (this.selectedPreset != null)
{
this.selectedPreset.PropertyChanged += this.SelectedPresetPropertyChanged;
}
this.OnPropertyChanged();
this.OnPropertyChanged("InputCategories");
}
}
public InputExtensionCategory[] InputCategories
private void SelectedPresetPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "OutputType")
{
this.OnPropertyChanged("InputCategories");
}
}
public Settings ApplicationSettings
{
get
{
return this.inputCategories;
return this.settings;
}
set
{
this.inputCategories = value;
this.settings = value;
this.OnPropertyChanged();
}
}
public IEnumerable<InputExtensionCategory> InputCategories
{
get
{
if (this.inputCategories == null)
{
yield break;
}
for (int index = 0; index < this.inputCategories.Length; index++)
{
InputExtensionCategory category = this.inputCategories[index];
if (this.SelectedPreset == null || PathHelpers.IsOutputTypeCompatibleWithCategory(this.SelectedPreset.OutputType, category.Name))
{
yield return category;
}
}
}
}
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
@@ -100,6 +147,11 @@ namespace FileConverter
}
CheckBox checkBox = sender as System.Windows.Controls.CheckBox;
if (!checkBox.IsVisible)
{
return;
}
string inputFormat = (checkBox.Content as string).ToLowerInvariant();
this.selectedPreset.AddInputType(inputFormat);
@@ -113,6 +165,11 @@ namespace FileConverter
}
CheckBox checkBox = sender as System.Windows.Controls.CheckBox;
if (!checkBox.IsVisible)
{
return;
}
string inputFormat = (checkBox.Content as string).ToLowerInvariant();
this.selectedPreset.RemoveInputType(inputFormat);
@@ -179,7 +236,24 @@ namespace FileConverter
private void AddPresetButton_Click(object sender, RoutedEventArgs e)
{
Application application = Application.Current as Application;
ConversionPreset newPreset = new ConversionPreset("New preset", OutputType.None, new string[0]);
string presetName = "New preset";
int index = 1;
while (application.Settings.ConversionPresets.Any(match => match.Name == presetName))
{
index++;
presetName = string.Format("New preset ({0})", index);
}
ConversionPreset newPreset = null;
if (this.SelectedPreset != null)
{
newPreset = new ConversionPreset(presetName, this.SelectedPreset);
}
else
{
newPreset = new ConversionPreset(presetName, OutputType.Mkv, new string[0]);
}
application.Settings.ConversionPresets.Add(newPreset);
this.SelectedPreset = newPreset;
this.PresetNameTextBox.Focus();
@@ -208,7 +282,7 @@ namespace FileConverter
{
// Load previous preset in order to cancel changes.
Application application = Application.Current as Application;
application.Settings.Load();
application.Settings = Settings.Load();
this.Hide();
@@ -276,7 +350,8 @@ namespace FileConverter
category.AddExtension(compatibleInputExtension);
}
this.InputCategories = categories.ToArray();
this.inputCategories = categories.ToArray();
this.OnPropertyChanged("InputCategories");
}
}
}
+25 -26
View File
@@ -10,7 +10,7 @@ namespace FileConverter
public class XmlHelpers
{
public static void LoadFromFile<T>(string root, string path, ref ICollection<T> collection)
public static void LoadFromFile<T>(string root, string path, out T deserializedObject)
{
if (string.IsNullOrEmpty(path))
{
@@ -22,7 +22,7 @@ namespace FileConverter
ElementName = root
};
XmlSerializer serializer = new XmlSerializer(typeof(List<T>), xmlRoot);
XmlSerializer serializer = new XmlSerializer(typeof(T), xmlRoot);
try
{
@@ -30,48 +30,46 @@ namespace FileConverter
{
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
{
IgnoreWhitespace = true, IgnoreComments = true
IgnoreWhitespace = true,
IgnoreComments = true
};
using (XmlReader xmlReader = XmlReader.Create(reader, xmlReaderSettings))
{
List<T> elements = (List<T>)serializer.Deserialize(xmlReader);
for (int index = 0; index < elements.Count; index++)
{
T item = elements[index];
if (item is IXmlSerializable)
{
(item as IXmlSerializable).OnDeserializationComplete();
}
collection.Add(item);
}
deserializedObject = (T)serializer.Deserialize(xmlReader);
}
}
}
catch (System.Exception exception)
{
Diagnostics.Log("The database of type '" + typeof(T) + "' failed to load the asset. The following exception was raised:\n " + exception.Message);
throw;
}
IXmlSerializable xmlSerializableObject = deserializedObject as IXmlSerializable;
if (xmlSerializableObject != null)
{
xmlSerializableObject.OnDeserializationComplete();
}
}
public static void SaveToFile<T>(string root, string path, ICollection<T> objectsToSerialize)
public static void SaveToFile<T>(string root, string path, T objectToSerialize)
{
if (string.IsNullOrEmpty(path))
{
return;
throw new ArgumentNullException("path");
}
List<T> list = new List<T>();
list.AddRange(objectsToSerialize);
if (objectToSerialize == null)
{
throw new ArgumentNullException("objectToSerialize");
}
XmlRootAttribute xmlRoot = new XmlRootAttribute
{
ElementName = root
};
XmlSerializer serializer = new XmlSerializer(typeof(List<T>), xmlRoot);
XmlSerializer serializer = new XmlSerializer(typeof(T), xmlRoot);
try
{
@@ -79,18 +77,19 @@ namespace FileConverter
{
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings
{
Indent = true, IndentChars = " "
Indent = true,
IndentChars = " "
};
using (XmlWriter xmlWriter = XmlWriter.Create(writer, xmlWriterSettings))
{
serializer.Serialize(xmlWriter, list);
serializer.Serialize(xmlWriter, objectToSerialize);
}
}
}
catch (System.Exception exception)
{
Diagnostics.Log("The database of type '" + typeof(T) + "' failed to load the asset. The following exception was raised:\n " + exception.Message);
Diagnostics.Debug.LogError("Fail to save asset of type '" + typeof(T) + "'. The following exception was raised:\n " + exception.Message);
}
}
}
+46
View File
@@ -0,0 +1,46 @@
# Change Log
## Version 0.4
- New: Possibility to encode videos (mkv output file format) using H.264 video codec and AAC audio codec.
- New: Possibility to extract Audio CD content.
- New: Possibility to encode audio in aac format.
- New: Possibility to encode images (png, jpg and ico formats).
- New: Support new audio input file format: aac
- New: Support new video input file formats: bik, flv, mov, mkv
- New: Support new image input file formats: bmp, tiff, png, jpg and ico.
- New: Multi-thread conversion (file converter will now start multiple conversions at the time depending on your number of cores).
- New: Copy the currently selected preset when clicking on the add preset button.
- New: Add "My Documents", "My Music", "My Videos" and "My Pictures" folder to output file name generator.
- New: Possibility to choose if the application quit after succeeded conversions.
- Fixed: Reordering presets does not update the registry.
- Fixed: Merge default settings with user settings to prevent errors when upgrading the application.
- Tech: Handle incorrect user settings case.
- Tech: Improve diagnostics system (compatibility with logs from multiple threads, dump files in AppData folder and error messages).
- Tech: Update ffmpeg version.
## Version 0.3
- New: Possibility to extract audio from videos.
- New: Support new input file formats: aiff, m4a, avi, mp4.
- New: Quality settings for Mp3 (Encoding mode vbr/cbr and bitrate).
- New: Quality settings for Ogg (Bitrate).
- New: Quality settings for Wav (bits per sample: 8, 16, 24 or 32).
- New: Add output file path template system.
- New: Add button to move up or down a preset.
- New: Add input files post conversion action (No action, move in archive folder or delete).
- New: Add categories on input file extensions.
- Fixed: Lose focus of main window don't terminate the application.
- Fixed: The application icon now have a correct resolution at any size.
- Tech: Add error codes on error messages.
## Version 0.2
- New: Support new input file format: ape.
- New: Add notion of conversion preset (in order to customize the conversion possibilities).
- New: Add settings window to edit conversion presets.
- New: Add application icon.
- New: Customize application installer.
- New: Add diagnostic window to read the application logs.
## Version 0.1
- New: Add decode support for file formats Mp3, Ogg, Wav, Flac, Wma
- New: Add encode support for file formats Mp3, Ogg, Wav, Flac
- New: UI to visualize the conversion progress
@@ -1,40 +1,54 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileConverter", "FileConverter.csproj", "{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}"
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileConverter", "Application\FileConverter\FileConverter.csproj", "{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Installer", "..\..\Installer\Installer.wixproj", "{F14673DF-DF38-44B4-AB1D-99A59182C24C}"
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Installer", "Installer\Installer.wixproj", "{F14673DF-DF38-44B4-AB1D-99A59182C24C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileConverterExtension", "..\FileConverterExtension\FileConverterExtension.csproj", "{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileConverterExtension", "Application\FileConverterExtension\FileConverterExtension.csproj", "{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Debug|x64.ActiveCfg = Debug|Any CPU
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Debug|x64.Build.0 = Debug|Any CPU
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Debug|x86.ActiveCfg = Debug|Any CPU
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Debug|x86.Build.0 = Debug|Any CPU
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Release|Any CPU.Build.0 = Release|Any CPU
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Release|x64.ActiveCfg = Release|Any CPU
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Release|x64.Build.0 = Release|Any CPU
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Release|x86.ActiveCfg = Release|Any CPU
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Release|x86.Build.0 = Release|Any CPU
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Debug|Any CPU.ActiveCfg = Debug|x86
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Debug|x64.ActiveCfg = Debug|x64
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Debug|x64.Build.0 = Debug|x64
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Debug|x86.ActiveCfg = Debug|x86
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Debug|x86.Build.0 = Debug|x86
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Release|Any CPU.ActiveCfg = Release|x86
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Release|x64.ActiveCfg = Release|x64
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Release|x64.Build.0 = Release|x64
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Release|x86.ActiveCfg = Release|x86
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Release|x86.Build.0 = Release|x86
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Debug|x64.ActiveCfg = Debug|Any CPU
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Debug|x64.Build.0 = Debug|Any CPU
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Debug|x86.ActiveCfg = Debug|Any CPU
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Debug|x86.Build.0 = Debug|Any CPU
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Release|Any CPU.Build.0 = Release|Any CPU
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Release|x64.ActiveCfg = Release|Any CPU
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Release|x64.Build.0 = Release|Any CPU
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Release|x86.ActiveCfg = Release|Any CPU
+64 -14
View File
@@ -10,14 +10,16 @@
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?endif ?>
<!-- Upgrade documentation: http://wixtoolset.org/documentation/manual/v3/howtos/updates/major_upgrade.html -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="0.3.0" Manufacturer="AAllard" UpgradeCode="e3ca717b-a897-418a-bbef-5c7e35c76e4b">
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="0.4.0" Manufacturer="AAllard" UpgradeCode="e3ca717b-a897-418a-bbef-5c7e35c76e4b">
<Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="x64" />
<Icon Id="icon.ico" SourceFile="..\Resources\ApplicationIcon-256x256.ico"/>
<Icon Id="icon.ico" SourceFile="..\Resources\ApplicationIcon.ico"/>
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
<Media Id="1" Cabinet="CabFile.cab" EmbedCab="yes" />
<Feature Id="ProductFeature" Title="Installer" Level="1">
@@ -66,43 +68,91 @@
<Component Guid="{A5158756-A107-4010-9E2F-3C0333F5A5F6}" Win64="$(var.Win64)">
<File Source="..\README.md" KeyPath="yes" />
</Component>
<Component Guid="{B57DCB2B-3520-4430-98CB-41B58F530D75}" Win64="$(var.Win64)">
<File Source="..\CHANGELOG.md" KeyPath="yes" />
</Component>
<Component Guid="{6378238B-E44F-414B-A7AE-7E72CFA8616D}" Win64="$(var.Win64)">
<File Source="..\LICENSE.md" KeyPath="yes" />
</Component>
<Component Guid="{55CD0B47-D5B0-4F0C-A54E-3E11DF345B48}" Win64="$(var.Win64)">
<File Id="Ripper.dll" KeyPath="yes" Source="..\Middleware\Ripper.dll" />
</Component>
<Component Guid="{3CE6CF1B-431C-41FD-8381-3F73EDAF7B8A}" Win64="$(var.Win64)">
<File Id="yeti.mmedia.dll" KeyPath="yes" Source="..\Middleware\yeti.mmedia.dll" />
</Component>
<!-- Registry entries -->
<Component Id="RegistryEntries" Guid="{C3EF3D67-0206-4DBD-B2EA-78FF2E290093}">
<RegistryKey Root="HKCU" Key="Software\FileConverter">
<RegistryValue Name="Path" Type="string" Value="[INSTALLFOLDER]FileConverter.exe"/>
<RegistryValue Name="CompatibleInputExtensions" Type="string" Value="aiff;ape;avi;flac;m4a;mp3;mp4;ogg;wav;wma"/>
<RegistryValue Name="CompatibleInputExtensions" Type="string" Value="aac;aiff;ape;avi;bik;bmp;cda;flac;flv;ico;jpg;jpeg;m4a;mkv;mov;mp3;mp4;ogg;png;tiff;wav;wma"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\aac">
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Wav;To Mp3"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\aiff">
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Flac;To Wav"/>
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Wav;To Mp3;To Aac"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\ape">
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Flac;To Wav"/>
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Flac;To Wav;To Mp3;To Aac"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\avi">
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Flac;To Wav"/>
<RegistryValue Name="Presets" Type="string" Value="To Mkv;To Ogg;To Flac;To Wav;To Mp3;To Aac;To Mkv (low quality)"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\bik">
<RegistryValue Name="Presets" Type="string" Value="To Mkv;To Ogg;To Flac;To Wav;To Mp3;To Aac;To Mkv (low quality)"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\bmp">
<RegistryValue Name="Presets" Type="string" Value="To Png;To Jpg;To Ico (max 256x256)"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\cda">
<RegistryValue Name="Presets" Type="string" Value="Extract CDA to Flac;Extract CDA to Ogg;Extract CDA to Mp3"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\flac">
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Wav"/>
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Wav;To Mp3;To Aac"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\flv">
<RegistryValue Name="Presets" Type="string" Value="To Mkv;To Mkv (low quality);To Ogg;To Flac;To Wav;To Mp3;To Aac"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\ico">
<RegistryValue Name="Presets" Type="string" Value="To Png;To Jpg"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\jpeg">
<RegistryValue Name="Presets" Type="string" Value="To Png;To Ico (max 256x256)"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\jpg">
<RegistryValue Name="Presets" Type="string" Value="To Png;To Ico (max 256x256)"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\m4a">
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Wav"/>
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Wav;To Mp3;To Aac"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\mkv">
<RegistryValue Name="Presets" Type="string" Value="To Mkv;To Mkv (low quality);To Ogg;To Flac;To Wav;To Mp3;To Aac"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\mov">
<RegistryValue Name="Presets" Type="string" Value="To Mkv;To Mkv (low quality);To Ogg;To Flac;To Wav;To Mp3;To Aac"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\mp3">
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Wav"/>
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Wav;To Aac"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\mp4">
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Flac;To Wav"/>
<RegistryValue Name="Presets" Type="string" Value="To Mkv;To Mkv (low quality);To Ogg;To Flac;To Wav;To Mp3;To Aac"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\ogg">
<RegistryValue Name="Presets" Type="string" Value="To Mp3;To Wav"/>
<RegistryValue Name="Presets" Type="string" Value="To Wav;To Mp3;To Aac"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\png">
<RegistryValue Name="Presets" Type="string" Value="To Jpg;To Ico (max 256x256)"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\tiff">
<RegistryValue Name="Presets" Type="string" Value="To Png;To Jpg;To Ico (max 256x256)"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\wav">
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Flac"/>
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Flac;To Mp3;To Aac"/>
</RegistryKey>
<RegistryKey Root="HKCU" Key="Software\FileConverter\wma">
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Wav"/>
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Wav;To Mp3;To Aac"/>
</RegistryKey>
</Component>
</ComponentGroup>
+7 -7
View File
@@ -1,11 +1,11 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
# GNU GENERAL PUBLIC LICENSE
## Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
## Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
@@ -68,7 +68,7 @@ patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
## TERMS AND CONDITIONS
0. Definitions.
@@ -618,9 +618,9 @@ an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
## END OF TERMS AND CONDITIONS
----
## How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
Binary file not shown.
Binary file not shown.
Binary file not shown.
+21 -73
View File
@@ -2,87 +2,35 @@
## Description
**File Converter** is a very simple tool which allows you to convert one or several file(s) from one format to another using the context menu in windows explorer.
This program uses [ffmpeg](https://www.ffmpeg.org/) as file conversion software.
You can convert files from formats **Aiff, Ape, Avi, Flac, M4a, Mp3, Mp4, Ogg, Wav, Wma** to formats **Mp3, Ogg, Wav, Flac**.
You can download it here: [www.file-converter.org](http://file-converter.org).
## Supported file formats
Category | Supported output formats | Compatible input formats
------------|---------------------------|----------------------------------------------------------------------------
Audio | flac, aac, ogg, mp3, wav | aiff, ape, avi, bik, cda, flac, flv, m4a, mkv, mov, mp3, mp4, ogg, wav, wma
Video | mkv | avi, bik, flv, mkv, mov
Image | png, jpg, ico | bmp, ico, jpg, jpeg, png, tiff
*Note: If your source file is a video, the conversion to an audio format will extract the audio part of the video.*
***Remove any previous installation of the application before installing the newer version.***
*Note 2: The mkv output file format encodes video using H.264 encoder for video and AAC encoder for audio.*
This application is under GPL version 3 licence.
For more informations check the LICENSE file in your installation folder or the [gnu website](http://www.gnu.org/licenses/gpl.html).
## Thanks
## Input file post conversion actions
File converter uses the following middlewares:
This actions allow you to chose what you want to do with your input files if the conversion succeed.
**ffmpeg** as file conversion software.
Thanks to ffmpeg devs for this awesome open source file conversion tool. [Web site link](https://www.ffmpeg.org/)
Action | Description
----------------------------|------------------------------------------------------------------------------------------------
**None** | Don't modify the input file. If the output file name conflict with the input, it will be renamed.
**Move in archive folder** | Move the input file in a folder named *Conversion Archives* if the conversion is a success.
**Delete** | Delete the input file if the conversion is a success (be careful no warning will be prompted).
**SharpShell** to easily create windows context menu extensions.
Thanks to Dave Kerr for his work on SharpShell. [CodePlex link](https://sharpshell.codeplex.com/)
## Output file path template
**Ripper** and **yeti.mmedia** for CD Audio extraction.
Thanks to Idael Cardoso for his work on CD Audio ripper. [Code project link](http://www.codeproject.com/Articles/5458/C-Sharp-Ripper)
This template allow you to define how you want to generate the output file path (depending on the input file path).
You have access to the following informations:
## License
Pattern | Description | Example (with input path: *C:\Music\Artist\Album\Song.wav*)
--------|-------------------------------|-----------------------------------------------------------------
(p) | Input file path | C:\Music\Artist\Album\
(f) | Input file name | Song
(o) | Output file format | mp3
(i) | Input file format | wav
(d0) | Input parent folder name | Album
(d1) | Input sub parent folder name | Artist
*Tips: You can use uppercase to retrieve caps lock informations. Example: (f) -> Default / (F) -> DEFAULT *
### Examples
Simple default template (just change the extension):
Input: C:\Music\Artist\Album\Song.wav
Template: (p)(f)
Generated output: C:\Music\Artist\Album\Song.mp3
File name customization:
Input: C:\Music\Artist\Album\Song.wav
Template: (p)(O)_(f) (from (i))
Generated output: C:\Music\Artist\Album\MP3_Song (from wav).mp3
File path customization:
Input: C:\Music\Artist\Album\Song.wav
Template: D:\(o)\(d1)\(f)
Generated output: D:\mp3\Artist\Song.mp3
## Change Log
v0.3
- New: Possibility to extract audio from videos.
- New: Support new input file formats: aiff, m4a, avi, mp4.
- New: Quality settings for Mp3 (Encoding mode vbr/cbr and bitrate).
- New: Quality settings for Ogg (Bitrate).
- New: Quality settings for Wav (bits per sample: 8, 16, 24 or 32).
- New: Add output file path template system.
- New: Add button to move up or down a preset.
- New: Add input files post conversion action (No action, move in archive folder or delete).
- New: Add categories on input file extensions.
- Fixed: Lose focus of main window don't terminate the application.
- Fixed: The application icon now have a correct resolution at any size.
- Tech: Add error codes on error messages.
v0.2
- New: Support new input file format: ape.
- New: Add notion of conversion preset (in order to customize the conversion possibilities).
- New: Add settings window to edit conversion presets.
- New: Add application icon.
- New: Customize application installer.
- New: Add diagnostic window to read the application logs.
v0.1
- New: Add decode support for file formats Mp3, Ogg, Wav, Flac, Wma
- New: Add encode support for file formats Mp3, Ogg, Wav, Flac
- New: UI to visualize the conversion progress
File Converter is licensed under the GPL version 3 License.
For more information check the LICENSE.md file in your installation folder or the [gnu website](http://www.gnu.org/licenses/gpl.html).
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 33 KiB