This commit is contained in:
xiang 2025-01-12 00:17:40 +08:00
parent 949deef9e4
commit d1787dc7e6
5 changed files with 42 additions and 3 deletions

View File

@ -8,7 +8,7 @@ namespace VideoConcat.Common.Tools
{
internal class VideoCombine
{
static void GenerateCombinations(List<List<string>> videoLists, int index, List<string> currentCombination, List<List<string>> result)
public static void GenerateCombinations(List<List<string>> videoLists, int index, List<string> currentCombination, List<List<string>> result)
{
if (index == videoLists.Count)
{

View File

@ -36,6 +36,8 @@ namespace VideoConcat.Models
{
public DirectoryInfo DirectoryInfo{set;get;}
public int Num { set; get; }
public List<string> VideoPaths { set; get; }
}
public ObservableCollection<FolderInfo> FolderInfos

View File

@ -11,9 +11,13 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FFMpegCore" Version="5.1.0" />
<PackageReference Include="log4net" Version="3.0.2" />
<PackageReference Include="MaterialDesignXaml.DialogsHelper" Version="1.0.4" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="System.IO.Pipelines" Version="9.0.0" />
<PackageReference Include="System.Text.Encodings.Web" Version="9.0.0" />
<PackageReference Include="System.Text.Json" Version="9.0.0" />
<PackageReference Include="WPFDevelopers" Version="0.0.0.1" />
</ItemGroup>

View File

@ -11,7 +11,8 @@ using MessageBox = System.Windows.MessageBox;
using System.ComponentModel;
using VideoConcat.Common.Tools;
using System.IO;
using static VideoConcat.Models.VideoModel;
using Microsoft.Expression.Drawing.Core;
using FFMpegCore;
namespace VideoConcat.ViewModels
{
@ -51,6 +52,34 @@ namespace VideoConcat.ViewModels
DoExcue = obj =>
{
LogUtils.Info("开始合并视频");
List<List<string>> combinations = [];
List<string> currentCombination = [];
List<List<string>> videoLists = [];
VideoModel.FolderInfos.ForEach(folderInfo =>
{
videoLists.Add(folderInfo.VideoPaths);
});
VideoCombine.GenerateCombinations(videoLists, 0, currentCombination, combinations);
int combinationIndex = 1;
foreach (List<string> combination in combinations)
{
Console.Write($"组合 {combinationIndex++}: ");
foreach (string video in combination)
{
Console.Write(video + " ");
}
Console.WriteLine();
FFMpeg.Join("./1.mp4",combination.ToArray());
}
Console.WriteLine($"总共有 {combinations.Count} 种拼接方案。");
}
};
}
@ -69,7 +98,7 @@ namespace VideoConcat.ViewModels
string[] files = Directory.GetFiles(Folder.FullName, "*.mp4");
LogUtils.Info($"{Folder.Name}下有{files.Length}个视频文件");
VideoModel.FolderInfos.Add(new FolderInfo { DirectoryInfo = Folder, Num = files.Length });
VideoModel.FolderInfos.Add(new VideoModel.FolderInfo { DirectoryInfo = Folder, Num = files.Length, VideoPaths = new List<string>(files) });
}
VideoModel.UpdateSum();
}

4
ffmpeg.config.json Normal file
View File

@ -0,0 +1,4 @@
{
"BinaryFolder": "./",
"TemporaryFilesFolder": "./tmp"
}