Skip to content

Commit

Permalink
更新到.NET8,更新了所有Nuget;去除了WindowsAPICodePack的依赖,改为.NET8自带的文件选取器
Browse files Browse the repository at this point in the history
  • Loading branch information
autodotua committed Dec 11, 2023
1 parent 66c4b4d commit eaf007b
Show file tree
Hide file tree
Showing 17 changed files with 7,077 additions and 4,176 deletions.
10 changes: 4 additions & 6 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@

### 准备工作

1. 确保安装了 .NET 6 SDK:
1. 确保安装了 .NET 8 SDK:
2. 确保安装了npm(Node.js):
3. 确保在根目录下(与ReadMe同级目录)的 `bin`目录中放置了ffmpeg二进制文件(shared版):[下载](https://www.ffmpeg.org/download.html) 。共有三个exe文件和若干个dll文件。
3. 确保在根目录下(与ReadMe同级目录)的 `bin`目录中放置了ffmpeg二进制文件(shared版):[下载](https://www.ffmpeg.org/download.html) 。共有三个exe文件和若干个dll文件。已测试版本:6.1
4. 若要使用媒体信息查询功能,应在根目录(与ReadMe同级目录)下的 `bin`目录中放置了MediaInfo CLI可执行文件(如`MediaInfo.exe`):[下载](https://mediaarea.net/en/MediaInfo/Download)
5. 若要使用编码测试功能,应在根目录(与ReadMe同级目录)下的 `bin`目录中放置了测试视频 `test.mp4`和VMAF模型([下载](https://github.com/Netflix/vmaf/blob/master/model/vmaf_v0.6.1.json)。选取的视频宜为4K分辨率,30秒以上的长度。

Expand All @@ -48,9 +48,7 @@
参数:

- -w:生成Web(Web、WebAPI、Host)
- -d:生成WPF(标准)
- -s:生成WPF(主执行文件为单文件,需要Runtime)
- -f:生成WPF(包含框架,运行前无需单独安装.NET6 Desktop Runtime)
- -d:生成WPF(标准、单文件、自包含)

若提示`无法加载文件 ******.ps1,因为在此系统中禁止执行脚本`,需要首先在管理员模式下运行PowerShell并执行 `set-executionpolicy remotesigned`,然后按Y确认。
生成文件位于 `Generation/Publish`下,其中 `WebPackage`为Web部署包,`WPF`为桌面程序。
Expand All @@ -60,7 +58,7 @@
1. 进入 `Generation/Publish/WebPackage`
2. 编辑 `api``appsettings.json`,主要修改 `InputDir``OutputDir`项,指定输入和输出目录。其它修改项详见文件内的注释。
3. 在合适的位置新建一个网站文件夹,将 `Generation/Publish/WebPackage`内的所有内容复制到新建的文件夹之中。
4. 确保安装了DotNET 6 Hosting Bundle,并在Windows中启用了IIS。
4. 确保安装了DotNET 8 Hosting Bundle,并在Windows中启用了IIS。
5. 在IIS中新建网站,指定物理目录为之前新建的目录。右键其中的api目录,设置为虚拟应用程序。
6. 运行Host的exe,然后打开设置的url即可使用。

Expand Down
8 changes: 4 additions & 4 deletions SimpleFFmpegGUI.Core/SimpleFFmpegGUI.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>SimpleFFmpegGUI</RootNamespace>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
Expand All @@ -16,10 +16,10 @@

<ItemGroup>
<PackageReference Include="FFMpegCore" Version="5.1.0" />
<PackageReference Include="Mapster" Version="7.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.4" />
<PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="7.0.0" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions SimpleFFmpegGUI.Host/SimpleFFmpegGUI.Host.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>SimpleFFmpegGUI</RootNamespace>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
Expand All @@ -22,8 +22,8 @@
<PackageReference Include="FubarDev.FtpServer.FileSystem.DotNet" Version="3.1.2" />
<PackageReference Include="JKang.IpcServiceFramework.Hosting.NamedPipe" Version="3.1.0" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Mapster" Version="7.3.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down
81 changes: 81 additions & 0 deletions SimpleFFmpegGUI.WPF/FileDialogExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using Microsoft.Win32;
using System.Linq;
using System.Text;
using System.Windows;

namespace SimpleFFmpegGUI.WPF
{
public static class FileDialogExtension
{
/// <summary>
/// 满足条件是加入文件筛选器
/// </summary>
/// <param name="filter"></param>
/// <param name="b"></param>
/// <param name="display"></param>
/// <param name="extensions"></param>
/// <returns></returns>
public static T AddFilterIf<T>(this T dialog, bool b, string display, params string[] extensions) where T : FileDialog
{
if (b)
{
return AddFilter(dialog, display, extensions);
}
return dialog;
}
public static T AddFilter<T>(this T dialog, string display, params string[] extensions) where T : FileDialog
{
StringBuilder filter = new StringBuilder(dialog.Filter);
if (filter.Length > 0)
{
filter.Append('|');
}
filter.Append(display);
filter.Append('|');
filter.Append(string.Join(';', extensions.Select(p => "*." + p)));
dialog.Filter = filter.ToString();
return dialog;
}

public static T AddAllFilesFilter<T>(this T dialog, string display = "所有文件") where T : FileDialog
{
StringBuilder filter = new StringBuilder(dialog.Filter);
if (filter.Length > 0)
{
filter.Append('|');
}
filter.Append(display);
filter.Append("|*.*");
dialog.Filter = filter.ToString();
return dialog;
}

public static string GetPath(this FileDialog dialog, Window owner)
{
if ((owner == null ? dialog.ShowDialog() : dialog.ShowDialog(owner)) == true)
{
return dialog.FileName;
}
return null;
}

public static string[] GetPaths(this OpenFileDialog dialog, Window owner)
{
dialog.Multiselect = true;
if ((owner == null ? dialog.ShowDialog() : dialog.ShowDialog(owner)) == true)
{
return dialog.FileNames;
}
return null;
}

public static string GetPath(this OpenFolderDialog dialog, Window owner)
{
if ((owner == null ? dialog.ShowDialog() : dialog.ShowDialog(owner)) == true)
{
return dialog.FolderName;
}
return null;
}
}
}
1 change: 0 additions & 1 deletion SimpleFFmpegGUI.WPF/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static Microsoft.WindowsAPICodePack.Shell.PropertySystem.SystemProperties.System;
using Task = System.Threading.Tasks.Task;

namespace SimpleFFmpegGUI.WPF
Expand Down
2 changes: 0 additions & 2 deletions SimpleFFmpegGUI.WPF/Pages/FFmpegOutputPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using FzLib.WPF;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.WindowsAPICodePack.Dialogs;
using Microsoft.WindowsAPICodePack.FzExtension;
using SimpleFFmpegGUI.Dto;
using SimpleFFmpegGUI.Manager;
using SimpleFFmpegGUI.Model;
Expand Down
6 changes: 4 additions & 2 deletions SimpleFFmpegGUI.WPF/Pages/MediaInfoPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using FzLib;
using FzLib.WPF;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.WindowsAPICodePack.FzExtension;
using Microsoft.Win32;
using SimpleFFmpegGUI.Dto;
using SimpleFFmpegGUI.Manager;
using SimpleFFmpegGUI.Model;
Expand Down Expand Up @@ -87,7 +87,9 @@ protected override void OnDrop(DragEventArgs e)

private void Button_Click(object sender, RoutedEventArgs e)
{
string path = new FileFilterCollection().AddAll().CreateOpenFileDialog().SetParent(this.GetWindow()).GetFilePath();
var dialog = new OpenFileDialog().AddAllFilesFilter();

string path = dialog.GetPath(this.GetWindow());
if (path != null)
{
ViewModel.FilePath = path;
Expand Down
11 changes: 7 additions & 4 deletions SimpleFFmpegGUI.WPF/Pages/PresetsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using FzLib.WPF;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.WindowsAPICodePack.FzExtension;
using Microsoft.Win32;
using ModernWpf.FzExtension.CommonDialog;
using Newtonsoft.Json;
using SimpleFFmpegGUI.Manager;
Expand All @@ -29,6 +29,7 @@
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CommonDialog = ModernWpf.FzExtension.CommonDialog.CommonDialog;

namespace SimpleFFmpegGUI.WPF.Pages
{
Expand Down Expand Up @@ -78,7 +79,9 @@ private async void DeleteButton_Click(object sender, RoutedEventArgs e)

private void ExportButton_Click(object sender, RoutedEventArgs e)
{
var path = new FileFilterCollection().Add("配置文件", "json").CreateSaveFileDialog().SetParent(this.GetWindow()).SetDefault("FFmpeg工具箱 预设.json").GetFilePath();
var dialog = new SaveFileDialog().AddFilter("配置文件", "json");
dialog.FileName = "FFmpeg工具箱 预设.json";
string path = dialog.GetPath(this.GetWindow());
if (path != null)

{
Expand All @@ -90,9 +93,9 @@ private void ExportButton_Click(object sender, RoutedEventArgs e)

private async void ImportButton_Click(object sender, RoutedEventArgs e)
{
var path = new FileFilterCollection().Add("配置文件", "json").CreateOpenFileDialog().SetParent(this.GetWindow()).GetFilePath();
var dialog = new OpenFileDialog().AddFilter("配置文件", "json");
string path = dialog.GetPath(this.GetWindow());
if (path != null)

{
try
{
Expand Down
7 changes: 3 additions & 4 deletions SimpleFFmpegGUI.WPF/Pages/SettingPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Enterwell.Clients.Wpf.Notifications;
using FzLib;
using FzLib.WPF;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.WindowsAPICodePack.Dialogs;
using Microsoft.WindowsAPICodePack.FzExtension;
using Microsoft.Win32;
using SimpleFFmpegGUI.Dto;
using SimpleFFmpegGUI.Manager;
using SimpleFFmpegGUI.Model;
Expand Down Expand Up @@ -89,8 +89,7 @@ private void CommandBar_MouseEnter(object sender, MouseEventArgs e)

private void BrowseSpecialDirPathButton_Click(object sender, RoutedEventArgs e)
{
CommonOpenFileDialog dialog = new CommonOpenFileDialog();
var path = dialog.GetFolderPath();
var path = new OpenFolderDialog().GetPath(this.GetWindow());
if (path != null)
{
ViewModel.DefaultOutputDirSpecialDirPath = path;
Expand Down
16 changes: 8 additions & 8 deletions SimpleFFmpegGUI.WPF/Panels/FileIOPanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Mapster;
using Microsoft.DotNet.PlatformAbstractions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.WindowsAPICodePack.FzExtension;
using Microsoft.Win32;
using ModernWpf.FzExtension.CommonDialog;
using SimpleFFmpegGUI.Manager;
using SimpleFFmpegGUI.Model;
Expand All @@ -31,6 +31,7 @@
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CommonDialog = ModernWpf.FzExtension.CommonDialog.CommonDialog;
using Path = System.IO.Path;

namespace SimpleFFmpegGUI.WPF.Panels
Expand Down Expand Up @@ -263,7 +264,8 @@ public void AddInput()

public void BrowseAndAddInput()
{
string path = new FileFilterCollection().AddAll().CreateOpenFileDialog().SetParent(this.GetWindow()).GetFilePath();
var dialog = new OpenFileDialog().AddAllFilesFilter();
string path = dialog.GetPath(this.GetWindow());
if (path != null)
{
var input = new InputArgumentsDetail();
Expand Down Expand Up @@ -384,11 +386,9 @@ protected override void OnDrop(DragEventArgs e)
private async void BrowseFileButton_Click(object sender, RoutedEventArgs e)
{
var input = (sender as FrameworkElement).DataContext as InputArgumentsDetail;
string path = new FileFilterCollection()
.AddAll()
.CreateOpenFileDialog()
.SetParent(this.GetWindow())
.GetFilePath();

var dialog = new OpenFileDialog().AddAllFilesFilter();
string path = dialog.GetPath(this.GetWindow());
if (path != null)
{
if (input.Image2)
Expand All @@ -411,7 +411,7 @@ private async void BrowseFileButton_Click(object sender, RoutedEventArgs e)

private void BrowseOutputFileButton_Click(object sender, RoutedEventArgs e)
{
string path = new FileFilterCollection().CreateOpenFileDialog().SetParent(this.GetWindow()).GetFolderPath();
string path = new OpenFolderDialog().GetPath(this.GetWindow());
if (path != null)
{
ViewModel.OutputDir = path;
Expand Down
1 change: 0 additions & 1 deletion SimpleFFmpegGUI.WPF/Panels/PresetsPanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Mapster;
using Microsoft.DotNet.PlatformAbstractions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.WindowsAPICodePack.FzExtension;
using ModernWpf.FzExtension.CommonDialog;
using SimpleFFmpegGUI.Manager;
using SimpleFFmpegGUI.Model;
Expand Down
11 changes: 3 additions & 8 deletions SimpleFFmpegGUI.WPF/SimpleFFmpegGUI.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.18362.0</TargetFramework>
<TargetFramework>net8.0-windows10.0.18362.0</TargetFramework>
<UseWPF>true</UseWPF>
<RootNamespace>SimpleFFmpegGUI.WPF</RootNamespace>
<SatelliteResourceLanguages>zh-cn</SatelliteResourceLanguages>
Expand All @@ -21,12 +21,10 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Mapster" Version="7.3.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="ModernWpfUI" Version="0.9.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft-WindowsAPICodePack-Core" Version="1.1.4" />
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.4" />
<PackageReference Include="zgabi.FFME.Windows" Version="6.0.2" />
</ItemGroup>

Expand All @@ -47,9 +45,6 @@
<Reference Include="ModernWpf.FzExtension">
<HintPath>..\libs\ModernWpf.FzExtension.dll</HintPath>
</Reference>
<Reference Include="WindowsAPICodePack.FzExtension">
<HintPath>..\libs\WindowsAPICodePack.FzExtension.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 8 additions & 4 deletions SimpleFFmpegGUI.WPF/TestWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using FzLib;
using FzLib.WPF;
using FzLib.WPF.Converters;
using Microsoft.WindowsAPICodePack.Dialogs;
using Microsoft.WindowsAPICodePack.FzExtension;
using Microsoft.Win32;
using ModernWpf.Controls;
using ModernWpf.FzExtension.CommonDialog;
using SimpleFFmpegGUI.FFmpegLib;
Expand All @@ -25,6 +25,7 @@
using static SimpleFFmpegGUI.WPF.Model.PerformanceTestLine;
using static SimpleFFmpegGUI.WPF.TestWindowViewModel;
using static System.Net.Mime.MediaTypeNames;
using CommonDialog = ModernWpf.FzExtension.CommonDialog.CommonDialog;

namespace SimpleFFmpegGUI.WPF
{
Expand All @@ -46,7 +47,8 @@ public TestWindow(TestWindowViewModel viewModel)

private void BrowseTestVideoButton_Click(object sender, RoutedEventArgs e)
{
string path = new FileFilterCollection().Add("视频", "mp4", "mov", "mkv", "avi").CreateOpenFileDialog().GetFilePath();
var dialog = new OpenFileDialog().AddFilter("视频", "mp4", "mov", "mkv", "avi");
string path = dialog.GetPath(this);
if (path != null)
{
ViewModel.TestVideo = path;
Expand Down Expand Up @@ -242,7 +244,9 @@ private void CreateTestItemsDataGrid()

private void ExportButton_Click(object sender, RoutedEventArgs e)
{
string path = new FileFilterCollection().Add("CSV表格", "csv").CreateSaveFileDialog().SetDefault("编码测试结果").GetFilePath();
var dialog = new SaveFileDialog().AddFilter("CSV表格", "csv");
dialog.FileName = "编码测试结果.csv";
string path = dialog.GetPath(this);
if (path == null)
{
return;
Expand Down
Loading

0 comments on commit eaf007b

Please sign in to comment.