diff --git a/Video.xaml.cs b/Video.xaml.cs index 5b12e03..e77f8b8 100644 --- a/Video.xaml.cs +++ b/Video.xaml.cs @@ -19,6 +19,7 @@ namespace VideoConcat public partial class Video : Window { public string text = "", outPut = ""; + static int totalVideoCount = 0; public Dictionary videoFolders = []; @@ -56,11 +57,18 @@ namespace VideoConcat return; } - - WriteTxt($"生成视频的个数:{GenerateVideoCount} 个"); + totalVideoCount = 0; Check_Folder(); + WriteTxt($"最多可生成视频个数为{totalVideoCount}个"); + + if (GenerateVideoCount > totalVideoCount) + { + WriteTxt($"生成视频个数不能超过{totalVideoCount}个"); + return; + } + MakeOutPutDir(); @@ -91,6 +99,7 @@ namespace VideoConcat private void Check_Folder() { + WriteTxt("开始检测视频文件路径"); DirectoryInfo? directory = Directory.GetParent(ParentPath); if (directory == null) { @@ -107,20 +116,32 @@ namespace VideoConcat try { int k = 1; - for (int i = 100; i >0; i--) + for (int i = 1; i < 100; i++) { var folder = string.Format("{0:D2}", i); string currentFolderPath = $"{Path}\\{folder}"; if (Directory.Exists(currentFolderPath)) { + + string[] videos = GetAllVideos(currentFolderPath); if (videos.Length > 0) { + if(totalVideoCount == 0) + { + totalVideoCount = 1; + } + WriteTxt($"检测到视频文件夹:{folder},视频个数:{videos.Length}"); + totalVideoCount *= videos.Length; videoFolders.Add(k, videos); AllPublicCombinVideos.Add(k, new A()); k++; } + else + { + WriteTxt($"视频文件夹【{folder}】未发现MP4格式视频文件"); + } } } @@ -230,6 +251,10 @@ namespace VideoConcat { List lss = []; List tasks = []; + Random rd = new(); + + ls = [.. ls.OrderBy(x => rd.Next())]; + foreach (var item in ls) {