From d00b3a414b53032bffb1465f45eaf4f58860f498 Mon Sep 17 00:00:00 2001 From: xiang Date: Thu, 31 Oct 2024 22:44:48 +0800 Subject: [PATCH] update --- Video.xaml.cs | 72 +++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/Video.xaml.cs b/Video.xaml.cs index 33a5cc0..cd9eee5 100644 --- a/Video.xaml.cs +++ b/Video.xaml.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using System.IO; using System.Windows; +using static System.Net.WebRequestMethods; namespace VideoConcat { @@ -9,15 +10,14 @@ namespace VideoConcat /// public partial class Video : Window { - public string text = ""; + public string text = "", outPut = ""; public FileSystemInfo[]? Floders { get; set; } public string[] Heads = []; public string[] Tails = []; - public string[][] Middles = []; + public List Middles = []; public DirectoryInfo? Path { get; set; } - public Video() { InitializeComponent(); @@ -45,49 +45,41 @@ namespace VideoConcat Check_Folder(); - + MakeOutPutDir(); startButton.IsEnabled = false; - Array.ForEach(array: Middles, s => - { - WriteTxt(s); - }); - var dateStart = DateTime.Now; //记录用时的起始时间 - - List> fpList = new List>(); - foreach (var item in await MockIOPerformanceAsync) + + + await Task.Run(async () => { - var dateEnd = DateTime.Now; - var timeSpan = dateEnd - dateStart;//记录开票用时 - DebugText += item + " " + timeSpan.TotalSeconds + "\r\n"; + var dateStart = DateTime.Now; //记录用时的起始时间 - } - - - await Task.Run(() => - { for (int i = 0; i <= count; i++) - { - System.Windows.Application.Current.Dispatcher.Invoke(() => - { - processVideoBar.Dispatcher.Invoke(() => - { - processVideoBar.Value = i; - }); - outputTxt.Dispatcher.Invoke(new Action(() => - { - WriteTxt("正在生成第" + i + "个视频"); - })); - }); - System.Threading.Thread.Sleep(50); + + { + + await MockIOPerformanceAsync(Middles[i]); + //System.Windows.Application.Current.Dispatcher.Invoke(() => + //{ + // processVideoBar.Dispatcher.Invoke(() => + // { + // processVideoBar.Value = i; + + // }); + // outputTxt.Dispatcher.Invoke(new Action(() => + // { + // WriteTxt("正在生成第" + i + "个视频"); + // })); + //}); + //System.Threading.Thread.Sleep(50); } startButton.Dispatcher.Invoke(() => @@ -95,6 +87,9 @@ namespace VideoConcat startButton.IsEnabled = true; }); + var dateEnd = DateTime.Now; + var timeSpan = dateEnd - dateStart;//记录开票用时 + });//ProcessVideo.RunTask(processVideoBar, startButton) } @@ -138,7 +133,8 @@ namespace VideoConcat continue; } - Middles = Middles.Concat(GetAllVideos($"{Path}\\{folder.Name}")).ToArray(); + string[] files = GetAllVideos($"{Path}\\{folder.Name}"); + Middles.Add(files); } if (!hasHead) @@ -150,6 +146,10 @@ namespace VideoConcat { WriteTxt("存在名称为tail的文件夹,将作为视频结尾!"); } + + Middles.Insert(0, Heads); + Middles.Add(Tails); + } catch (Exception ex) { @@ -238,7 +238,7 @@ namespace VideoConcat public void MakeOutPutDir() { - string outPut = $"{Path}\\output"; + outPut = $"{Path}\\output"; if (!Directory.Exists(outPut)) { @@ -246,7 +246,7 @@ namespace VideoConcat } } - public static async Task> MockIOPerformanceAsync(List ls) + public static async Task> MockIOPerformanceAsync(string[] ls) { List lss = new List(); List tasks = new List();