diff --git a/Common/Tools/VideoCombine.cs b/Common/Tools/VideoCombine.cs index 1ea7b03..cf80b6e 100644 --- a/Common/Tools/VideoCombine.cs +++ b/Common/Tools/VideoCombine.cs @@ -8,7 +8,7 @@ namespace VideoConcat.Common.Tools { internal class VideoCombine { - static void GenerateCombinations(List> videoLists, int index, List currentCombination, List> result) + public static void GenerateCombinations(List> videoLists, int index, List currentCombination, List> result) { if (index == videoLists.Count) { diff --git a/Models/VideoModel.cs b/Models/VideoModel.cs index f1caaf2..e37b457 100644 --- a/Models/VideoModel.cs +++ b/Models/VideoModel.cs @@ -36,6 +36,8 @@ namespace VideoConcat.Models { public DirectoryInfo DirectoryInfo{set;get;} public int Num { set; get; } + + public List VideoPaths { set; get; } } public ObservableCollection FolderInfos diff --git a/VideoConcat.csproj b/VideoConcat.csproj index a35f01c..5669104 100644 --- a/VideoConcat.csproj +++ b/VideoConcat.csproj @@ -11,9 +11,13 @@ + + + + diff --git a/ViewModels/VideoViewModel.cs b/ViewModels/VideoViewModel.cs index 68c9434..f8d62a2 100644 --- a/ViewModels/VideoViewModel.cs +++ b/ViewModels/VideoViewModel.cs @@ -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> combinations = []; + List currentCombination = []; + List> videoLists = []; + + + VideoModel.FolderInfos.ForEach(folderInfo => + { + videoLists.Add(folderInfo.VideoPaths); + }); + + VideoCombine.GenerateCombinations(videoLists, 0, currentCombination, combinations); + + int combinationIndex = 1; + foreach (List 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(files) }); } VideoModel.UpdateSum(); } diff --git a/ffmpeg.config.json b/ffmpeg.config.json new file mode 100644 index 0000000..f0b0751 --- /dev/null +++ b/ffmpeg.config.json @@ -0,0 +1,4 @@ +{ + "BinaryFolder": "./", + "TemporaryFilesFolder": "./tmp" +} \ No newline at end of file