From 1952c18e308978bd9bd443ccbd78d5100749b29e Mon Sep 17 00:00:00 2001 From: tacheometry <39647014+tacheometry@users.noreply.github.com> Date: Tue, 26 Mar 2024 03:59:58 +0200 Subject: [PATCH 1/5] Try some cuda stuff --- .../FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs index cb9f3b3..64d8bec 100644 --- a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs +++ b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs @@ -265,13 +265,13 @@ namespace FileConverter.ConversionJobs } string encoderArgs = string.Format( - "-c:v libx264 -preset {0} -crf {1} {2} {3}", + "-c:v h264_nvenc -preset {0} -crf {1} {2} {3}", this.H264EncodingSpeedToPreset(videoEncodingSpeed), this.H264QualityToCRF(videoEncodingQuality), audioArgs, videoFilteringArgs); - string arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs); + string arguments = string.Format("-n -stats -hwaccel cuda -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs); this.ffmpegArgumentStringByPass.Add(new FFMpegPass(arguments)); } From 5f7bcadb83c94bd188b4dad7c7c9d7422651da74 Mon Sep 17 00:00:00 2001 From: tacheometry <39647014+tacheometry@users.noreply.github.com> Date: Tue, 26 Mar 2024 16:10:01 +0200 Subject: [PATCH 2/5] Add setting for hardware acceleration mode --- .../FileConverter/FileConverter.csproj | 923 +++++++++--------- Application/FileConverter/Helpers.cs | 6 + Application/FileConverter/Settings.cs | 16 + .../HardwareAccelerationModeToString.cs | 27 + .../ViewModels/SettingsViewModel.cs | 11 + .../Resources/ConversionPresetTemplates.xaml | 1 + .../FileConverter/Views/SettingsWindow.xaml | 11 + 7 files changed, 534 insertions(+), 461 deletions(-) create mode 100644 Application/FileConverter/ValueConverters/HardwareAccelerationModeToString.cs diff --git a/Application/FileConverter/FileConverter.csproj b/Application/FileConverter/FileConverter.csproj index afbc645..c8bc975 100644 --- a/Application/FileConverter/FileConverter.csproj +++ b/Application/FileConverter/FileConverter.csproj @@ -1,452 +1,453 @@ - - - - - Debug - AnyCPU - {D27A76D2-43E4-43CC-9DA3-334B0B46F4E5} - WinExe - Properties - FileConverter - FileConverter - v4.8 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - - - - AnyCPU - true - full - false - bin\Debug\ - TRACE;DEBUG - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - x64 - bin\x64\Debug\ - TRACE;DEBUG - - - x64 - bin\x64\Release\ - - - Resources\ApplicationIcon.ico - - - true - bin\x86\Debug\ - TRACE;DEBUG;BUILD32 - full - x86 - prompt - MinimumRecommendedRules.ruleset - true - - - bin\x86\Release\ - TRACE;BUILD32 - true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset - true - - - - ..\..\packages\CommunityToolkit.Mvvm.8.2.2\lib\netstandard2.0\CommunityToolkit.Mvvm.dll - - - ..\..\packages\Magick.NET-Q16-AnyCPU.13.5.0\lib\netstandard20\Magick.NET-Q16-AnyCPU.dll - True - - - ..\..\packages\Magick.NET.Core.13.5.0\lib\netstandard20\Magick.NET.Core.dll - True - - - ..\..\Middleware\Markdown.Xaml.dll - - - ..\..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll - - - ..\..\packages\Microsoft.Extensions.DependencyInjection.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll - - - ..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - - ..\..\packages\Microsoft.Office.Interop.Excel.15.0.4795.1000\lib\net20\Microsoft.Office.Interop.Excel.dll - True - - - ..\..\packages\Microsoft.Office.Interop.PowerPoint.12.0.4518.1014\lib\net20\Microsoft.Office.Interop.PowerPoint.dll - True - - - ..\..\packages\Microsoft.Office.Interop.Word.15.0.4797.1003\lib\net20\Microsoft.Office.Interop.Word.dll - True - - - ..\..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.77\lib\net462\Microsoft.Xaml.Behaviors.dll - - - ..\..\packages\Office.12.0.0\lib\net40\Office.dll - True - - - - False - ..\..\Middleware\Ripper.dll - - - ..\..\packages\SharpShell.2.7.2\lib\net40-client\SharpShell.dll - - - - ..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll - - - ..\..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll - - - - - - ..\..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll - - - - ..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll - - - ..\..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll - - - ..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll - - - - - - - 4.0 - - - - - - - - ..\..\packages\WpfAnimatedGif.2.0.2\lib\net40\WpfAnimatedGif.dll - - - ..\..\Middleware\yeti.mmedia.dll - - - - - MSBuild:Compile - Designer - - - - ConversionJobControl.xaml - - - - EncodingQualitySliderControl.xaml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Resources.en.resx - True - True - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HelpWindow.xaml - - - DiagnosticsWindow.xaml - - - - - - SettingsWindow.xaml - - - - UpgradeWindow.xaml - - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - Application.xaml - Code - - - - - - MainWindow.xaml - Code - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - - - - true - - - Code - true - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - - - - - - PublicResXFileCodeGenerator - Resources.en.Designer.cs - - - - - - - PublicResXFileCodeGenerator - Resources.Designer.cs - Designer - - - - - - - - Designer - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - Designer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {0c44ca69-42d6-4357-bdfd-83069d1aba2f} - FileConverterExtension - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + AnyCPU + {D27A76D2-43E4-43CC-9DA3-334B0B46F4E5} + WinExe + Properties + FileConverter + FileConverter + v4.8 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + + + + AnyCPU + true + full + false + bin\Debug\ + TRACE;DEBUG + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + x64 + bin\x64\Debug\ + TRACE;DEBUG + + + x64 + bin\x64\Release\ + + + Resources\ApplicationIcon.ico + + + true + bin\x86\Debug\ + TRACE;DEBUG;BUILD32 + full + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + TRACE;BUILD32 + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + + ..\..\packages\CommunityToolkit.Mvvm.8.2.2\lib\netstandard2.0\CommunityToolkit.Mvvm.dll + + + ..\..\packages\Magick.NET-Q16-AnyCPU.13.5.0\lib\netstandard20\Magick.NET-Q16-AnyCPU.dll + True + + + ..\..\packages\Magick.NET.Core.13.5.0\lib\netstandard20\Magick.NET.Core.dll + True + + + ..\..\Middleware\Markdown.Xaml.dll + + + ..\..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\..\packages\Microsoft.Extensions.DependencyInjection.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll + + + ..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\..\packages\Microsoft.Office.Interop.Excel.15.0.4795.1000\lib\net20\Microsoft.Office.Interop.Excel.dll + True + + + ..\..\packages\Microsoft.Office.Interop.PowerPoint.12.0.4518.1014\lib\net20\Microsoft.Office.Interop.PowerPoint.dll + True + + + ..\..\packages\Microsoft.Office.Interop.Word.15.0.4797.1003\lib\net20\Microsoft.Office.Interop.Word.dll + True + + + ..\..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.77\lib\net462\Microsoft.Xaml.Behaviors.dll + + + ..\..\packages\Office.12.0.0\lib\net40\Office.dll + True + + + + False + ..\..\Middleware\Ripper.dll + + + ..\..\packages\SharpShell.2.7.2\lib\net40-client\SharpShell.dll + + + + ..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + ..\..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll + + + + + + ..\..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + + + + + 4.0 + + + + + + + + ..\..\packages\WpfAnimatedGif.2.0.2\lib\net40\WpfAnimatedGif.dll + + + ..\..\Middleware\yeti.mmedia.dll + + + + + MSBuild:Compile + Designer + + + + ConversionJobControl.xaml + + + + EncodingQualitySliderControl.xaml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Resources.en.resx + True + True + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + HelpWindow.xaml + + + DiagnosticsWindow.xaml + + + + + + SettingsWindow.xaml + + + + UpgradeWindow.xaml + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + + + + MainWindow.xaml + Code + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + + true + + + Code + true + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + + + PublicResXFileCodeGenerator + Resources.en.Designer.cs + + + + + + + PublicResXFileCodeGenerator + Resources.Designer.cs + Designer + + + + + + + + Designer + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {0c44ca69-42d6-4357-bdfd-83069d1aba2f} + FileConverterExtension + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + copy /Y "$(SolutionDir)Middleware\ffmpeg\ffmpeg.exe" "$(TargetDir)ffmpeg.exe" copy /Y "$(SolutionDir)Middleware\gs\gsdll64.dll" "$(TargetDir)gsdll64.dll" copy /Y "$(SolutionDir)Middleware\gs\gswin64c.exe" "$(TargetDir)gswin64c.exe" @@ -454,22 +455,22 @@ copy /Y "$(ProjectDir)Settings.default.xml" "$(TargetDir)Settings.default.xml" robocopy $(TargetDir) $(TargetDir)\Languages "$(TargetName).resources.dll" /CREATE /S /XD Languages /IS /IT /NFL /NDL /NJH /NJS /NC /NS /NP if %25errorlevel%25 leq 1 exit 0 else exit %25errorlevel%25 robocopy $(TargetDir) $(TargetDir)\Languages "$(TargetName).resources.dll" /MOVE /S /XD Languages /XL /IS /IT /NFL /NDL /NJH /NJS /NC /NS /NP -if %25errorlevel%25 leq 1 exit 0 else exit %25errorlevel%25 - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - +if %25errorlevel%25 leq 1 exit 0 else exit %25errorlevel%25 + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + --> \ No newline at end of file diff --git a/Application/FileConverter/Helpers.cs b/Application/FileConverter/Helpers.cs index c86ca27..0b24bd9 100644 --- a/Application/FileConverter/Helpers.cs +++ b/Application/FileConverter/Helpers.cs @@ -349,5 +349,11 @@ namespace FileConverter public const string Misc = "Misc"; } + + public enum HardwareAccelerationMode + { + Off, + CUDA + } } } \ No newline at end of file diff --git a/Application/FileConverter/Settings.cs b/Application/FileConverter/Settings.cs index 4259a9f..84e8f1b 100644 --- a/Application/FileConverter/Settings.cs +++ b/Application/FileConverter/Settings.cs @@ -22,6 +22,7 @@ namespace FileConverter private CultureInfo applicationLanguage; private int maximumNumberOfSimultaneousConversions; private bool copyFilesInClipboardAfterConversion = false; + private Helpers.HardwareAccelerationMode hardwareAccelerationMode = Helpers.HardwareAccelerationMode.Off; public ConversionPreset GetPresetFromName(string presetName) { @@ -220,6 +221,21 @@ namespace FileConverter this.copyFilesInClipboardAfterConversion = value; this.OnPropertyChanged(); } + } + + [XmlElement] + public Helpers.HardwareAccelerationMode HardwareAccelerationMode + { + get + { + return this.hardwareAccelerationMode; + } + + set + { + this.hardwareAccelerationMode = value; + this.OnPropertyChanged(); + } } public void OnDeserializationComplete() { diff --git a/Application/FileConverter/ValueConverters/HardwareAccelerationModeToString.cs b/Application/FileConverter/ValueConverters/HardwareAccelerationModeToString.cs new file mode 100644 index 0000000..865084e --- /dev/null +++ b/Application/FileConverter/ValueConverters/HardwareAccelerationModeToString.cs @@ -0,0 +1,27 @@ +// License: http://www.gnu.org/licenses/gpl.html GPL version 3. + +namespace FileConverter.ValueConverters +{ + using System; + using System.Globalization; + using System.Windows.Data; + + public class HardwareAccelerationModeToString : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + switch (value) { + case Helpers.HardwareAccelerationMode.Off: + return "Off"; + case Helpers.HardwareAccelerationMode.CUDA: + return "Nvidia (CUDA)"; + } + return "Unknown"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Application/FileConverter/ViewModels/SettingsViewModel.cs b/Application/FileConverter/ViewModels/SettingsViewModel.cs index 6e616a6..0b201e5 100644 --- a/Application/FileConverter/ViewModels/SettingsViewModel.cs +++ b/Application/FileConverter/ViewModels/SettingsViewModel.cs @@ -47,6 +47,7 @@ namespace FileConverter.ViewModels private ListCollectionView outputTypes; private CultureInfo[] supportedCultures; + private Helpers.HardwareAccelerationMode[] hardwareAccelerationModes = { Helpers.HardwareAccelerationMode.Off, Helpers.HardwareAccelerationMode.CUDA }; public event Action OnPresetCreated; public event Action OnFolderCreated; @@ -232,6 +233,16 @@ namespace FileConverter.ViewModels } } + public Helpers.HardwareAccelerationMode[] HardwareAccelerationModes + { + get => this.hardwareAccelerationModes; + set + { + this.hardwareAccelerationModes = value; + this.OnPropertyChanged(); + } + } + public ListCollectionView OutputTypes { get => this.outputTypes; diff --git a/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml b/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml index 38f767a..98ddf1e 100644 --- a/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml +++ b/Application/FileConverter/Views/Resources/ConversionPresetTemplates.xaml @@ -20,6 +20,7 @@ + diff --git a/Application/FileConverter/Views/SettingsWindow.xaml b/Application/FileConverter/Views/SettingsWindow.xaml index 019b13b..478148e 100644 --- a/Application/FileConverter/Views/SettingsWindow.xaml +++ b/Application/FileConverter/Views/SettingsWindow.xaml @@ -369,6 +369,7 @@ +