Skip to content

Commit

Permalink
Merged development into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Tichau committed Oct 30, 2016
2 parents 420e627 + 749c794 commit 64ace9c
Show file tree
Hide file tree
Showing 21 changed files with 138 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Application/FileConverter/Application.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public partial class Application : System.Windows.Application
{
Major = 1,
Minor = 2,
Patch = 0,
Patch = 1,
};

private readonly List<ConversionJob> conversionJobs = new List<ConversionJob>();
Expand Down
31 changes: 15 additions & 16 deletions Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ protected override void Initialize()

protected virtual void FillFFMpegArgumentsList()
{
// This option are necessary to be able to read metadata on Windows. src: http://jonhall.info/how_to/create_id3_tags_using_ffmpeg
const string metadataArgs = "-id3v2_version 3 -write_id3v1 1";

switch (this.ConversionPreset.OutputType)
{
case OutputType.Aac:
Expand All @@ -81,7 +84,7 @@ protected virtual void FillFFMpegArgumentsList()

// https://trac.ffmpeg.org/wiki/Encode/AAC
int audioEncodingBitrate = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.AudioBitrate);
string encoderArgs = $"-c:a aac -q:a {this.AACBitrateToQualityIndex(audioEncodingBitrate)} {channelArgs}";
string encoderArgs = $"-c:a aac -q:a {this.AACBitrateToQualityIndex(audioEncodingBitrate)} {channelArgs} {metadataArgs}";

string arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);

Expand All @@ -106,7 +109,7 @@ protected virtual void FillFFMpegArgumentsList()

// Compute final arguments.
string videoFilteringArgs = ConversionJob_FFMPEG.Encapsulate("-vf", transformArgs);
string encoderArgs = string.Format("-c:v mpeg4 -vtag xvid -qscale:v {0} {1} {2}", this.MPEG4QualityToQualityIndex(videoEncodingQuality), audioArgs, videoFilteringArgs);
string encoderArgs = $"-c:v mpeg4 -vtag xvid -qscale:v {this.MPEG4QualityToQualityIndex(videoEncodingQuality)} {audioArgs} {videoFilteringArgs} {metadataArgs}";
string arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);

this.ffmpegArgumentStringByPass.Add(new FFMpegPass(arguments));
Expand All @@ -119,7 +122,7 @@ protected virtual void FillFFMpegArgumentsList()
string channelArgs = ConversionJob_FFMPEG.ComputeAudioChannelArgs(this.ConversionPreset);

// http://taer-naguur.blogspot.fr/2013/11/flac-audio-encoding-with-ffmpeg.html
string encoderArgs = $"-compression_level 12 {channelArgs}";
string encoderArgs = $"-compression_level 12 {channelArgs} {metadataArgs}";
string arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);

this.ffmpegArgumentStringByPass.Add(new FFMpegPass(arguments));
Expand Down Expand Up @@ -198,11 +201,11 @@ protected virtual void FillFFMpegArgumentsList()
switch (encodingMode)
{
case EncodingMode.Mp3VBR:
encoderArgs = $"-codec:a libmp3lame -q:a {this.MP3VBRBitrateToQualityIndex(encodingQuality)} {channelArgs}";
encoderArgs = $"-codec:a libmp3lame -q:a {this.MP3VBRBitrateToQualityIndex(encodingQuality)} {channelArgs} {metadataArgs}";
break;

case EncodingMode.Mp3CBR:
encoderArgs = $"-codec:a libmp3lame -b:a {encodingQuality}k {channelArgs}";
encoderArgs = $"-codec:a libmp3lame -b:a {encodingQuality}k {channelArgs} {metadataArgs}";
break;

default:
Expand Down Expand Up @@ -231,7 +234,7 @@ protected virtual void FillFFMpegArgumentsList()
string audioArgs = "-an";
if (this.ConversionPreset.GetSettingsValue<bool>(ConversionPreset.ConversionSettingKeys.EnableAudio))
{
audioArgs = string.Format("-c:a aac -qscale:a {0}", this.AACBitrateToQualityIndex(audioEncodingBitrate));
audioArgs = $"-c:a aac -qscale:a {this.AACBitrateToQualityIndex(audioEncodingBitrate)} {metadataArgs}";
}

string encoderArgs = string.Format(
Expand All @@ -253,7 +256,7 @@ protected virtual void FillFFMpegArgumentsList()
string channelArgs = ConversionJob_FFMPEG.ComputeAudioChannelArgs(this.ConversionPreset);

int encodingQuality = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.AudioBitrate);
string encoderArgs = $"-vn -codec:a libvorbis -qscale:a {this.OGGVBRBitrateToQualityIndex(encodingQuality)} {channelArgs}";
string encoderArgs = $"-vn -codec:a libvorbis -qscale:a {this.OGGVBRBitrateToQualityIndex(encodingQuality)} {channelArgs} {metadataArgs}";
string arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);

this.ffmpegArgumentStringByPass.Add(new FFMpegPass(arguments));
Expand All @@ -273,14 +276,10 @@ protected virtual void FillFFMpegArgumentsList()
string audioArgs = "-an";
if (this.ConversionPreset.GetSettingsValue<bool>(ConversionPreset.ConversionSettingKeys.EnableAudio))
{
audioArgs = string.Format("-codec:a libvorbis -qscale:a {0}", this.OGGVBRBitrateToQualityIndex(audioEncodingBitrate));
audioArgs = $"-codec:a libvorbis -qscale:a {this.OGGVBRBitrateToQualityIndex(audioEncodingBitrate)}";
}

string encoderArgs = string.Format(
"-codec:v libtheora -qscale:v {0} {1} {2}",
this.OGVTheoraQualityToQualityIndex(videoEncodingQuality),
audioArgs,
videoFilteringArgs);
string encoderArgs = $"-codec:v libtheora -qscale:v {this.OGVTheoraQualityToQualityIndex(videoEncodingQuality)} {audioArgs} {videoFilteringArgs} {metadataArgs}";

string arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);

Expand Down Expand Up @@ -313,7 +312,7 @@ protected virtual void FillFFMpegArgumentsList()
string channelArgs = ConversionJob_FFMPEG.ComputeAudioChannelArgs(this.ConversionPreset);

EncodingMode encodingMode = this.ConversionPreset.GetSettingsValue<EncodingMode>(ConversionPreset.ConversionSettingKeys.AudioEncodingMode);
string encoderArgs = $"-acodec {this.WAVEncodingToCodecArgument(encodingMode)} {channelArgs}";
string encoderArgs = $"-acodec {this.WAVEncodingToCodecArgument(encodingMode)} {channelArgs} {metadataArgs}";
string arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);

this.ffmpegArgumentStringByPass.Add(new FFMpegPass(arguments));
Expand All @@ -331,11 +330,11 @@ protected virtual void FillFFMpegArgumentsList()
if (videoEncodingQuality == 63)
{
// Replace maximum quality settings by lossless compression.
encodingArgs = "-lossless 1";
encodingArgs = $"-lossless 1 {metadataArgs}";
}
else
{
encodingArgs = string.Format("-crf {0} -b:v 0", this.WebmQualityToCRF(videoEncodingQuality));
encodingArgs = $"-crf {this.WebmQualityToCRF(videoEncodingQuality)} -b:v 0 {metadataArgs}";
}

string transformArgs = ConversionJob_FFMPEG.ComputeTransformArgs(this.ConversionPreset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace FileConverter.ConversionJobs

public class ConversionJob_ImageMagick : ConversionJob
{
private const float BaseDpiForPdfConversion = 200f;

private bool isInputFilePdf;
private int pageCount;

Expand Down Expand Up @@ -83,7 +85,7 @@ private void ConvertPdf()
{
MagickReadSettings settings = new MagickReadSettings();

float dpi = 200f;
float dpi = BaseDpiForPdfConversion;
float scaleFactor = this.ConversionPreset.GetSettingsValue<float>(ConversionPreset.ConversionSettingKeys.ImageScale);
if (Math.Abs(scaleFactor - 1f) >= 0.005f)
{
Expand All @@ -93,7 +95,7 @@ private void ConvertPdf()
}

Debug.Log("Density: {0}dpi.", dpi);
settings.Density = new Density(dpi, dpi);
settings.Density = new Density(dpi);

this.UserState = Properties.Resources.ConversionStateReadDocument;

Expand Down Expand Up @@ -187,6 +189,8 @@ private void ConvertImage(MagickImage image, bool ignoreScale = false)
break;

case OutputType.Pdf:
Debug.Log("Density: {0}dpi.", BaseDpiForPdfConversion);
image.Density = new Density(BaseDpiForPdfConversion);
break;

case OutputType.Webp:
Expand Down
6 changes: 6 additions & 0 deletions Application/FileConverter/FileConverter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@
<ItemGroup>
<Resource Include="Resources\FileConverterUsage.gif" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Settings-Icon.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\WebSite-Icon.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /Y "$(SolutionDir)Middleware\ffmpeg\$(PlatformName)\ffmpeg.exe" "$(TargetDir)ffmpeg.exe"
Expand Down
9 changes: 9 additions & 0 deletions Application/FileConverter/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Application/FileConverter/Properties/Resources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ use maj for uppercase version</value>
<value>See change log ...</value>
</data>
<data name="Settings" xml:space="preserve">
<value>Settings</value>
<value>File Converter Settings</value>
</data>
<data name="SettingsButtonTitle" xml:space="preserve">
<value>Settings</value>
Expand Down Expand Up @@ -541,4 +541,7 @@ use maj for uppercase version</value>
<data name="ErrorMicrosoftWordIsNotAvailable" xml:space="preserve">
<value>Microsoft Word must be installed in order to convert Word documents.</value>
</data>
<data name="WebsiteButtonDescription" xml:space="preserve">
<value>Open File Converter website</value>
</data>
</root>
5 changes: 4 additions & 1 deletion Application/FileConverter/Properties/Resources.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ utilisez maj pour une version en majuscules</value>
<value>Voir les changements ...</value>
</data>
<data name="Settings" xml:space="preserve">
<value>Configuration</value>
<value>Configuration de File Converter</value>
</data>
<data name="SettingsButtonTitle" xml:space="preserve">
<value>Configuration</value>
Expand Down Expand Up @@ -559,4 +559,7 @@ utilisez maj pour une version en majuscules</value>
<data name="ErrorMicrosoftWordIsNotAvailable" xml:space="preserve">
<value>Microsoft Word doit être installé pour pouvoir convertir les documents Word.</value>
</data>
<data name="WebsiteButtonDescription" xml:space="preserve">
<value>Ouvrir le site web de File Converter</value>
</data>
</root>
3 changes: 3 additions & 0 deletions Application/FileConverter/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -541,4 +541,7 @@ use maj for uppercase version</value>
<data name="ErrorMicrosoftWordIsNotAvailable" xml:space="preserve">
<value>Microsoft Word must be installed in order to convert Word documents.</value>
</data>
<data name="WebsiteButtonDescription" xml:space="preserve">
<value>Open File Converter website</value>
</data>
</root>
Binary file modified Application/FileConverter/Resources/GitHub-Documentation-Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Application/FileConverter/Resources/GitHub-Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Application/FileConverter/Resources/GitHub-Issue-Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Application/FileConverter/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static void PostInstallationInitialization()
{
Settings.MigrateSettingsToCurrentVersion(userSettings);

Diagnostics.Debug.Log("File converter settings has been imported from version {0} to version {1}.", userSettings.SerializationVersion, Version);
Diagnostics.Debug.Log("File converter settings have been imported from version {0} to version {1}.", userSettings.SerializationVersion, Version);
userSettings.SerializationVersion = Version;
}

Expand Down Expand Up @@ -483,7 +483,7 @@ private void OnPropertyChanged([CallerMemberName] string propertyName = null)

private Settings Merge(Settings settings)
{
if (settings == null)
if (settings == null || settings.conversionPresets == null)
{
return this;
}
Expand Down
1 change: 0 additions & 1 deletion Application/FileConverter/Settings.default.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SerializationVersion="3">
<ApplicationLanguageName>fr</ApplicationLanguageName>
<ExitApplicationWhenConversionsFinished>true</ExitApplicationWhenConversionsFinished>
<DurationBetweenEndOfConversionsAndApplicationExit>3</DurationBetweenEndOfConversionsAndApplicationExit>
<MaximumNumberOfSimultaneousConversions>2</MaximumNumberOfSimultaneousConversions>
Expand Down
Loading

0 comments on commit 64ace9c

Please sign in to comment.