update
This commit is contained in:
parent
ffcfff68ec
commit
77ee5390b7
@ -25,7 +25,7 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Content="生成视频的个数:" VerticalContentAlignment="Center" BorderThickness="1" Padding="5,0,5,0"></Label>
|
||||
<TextBox Grid.Column="1" wd:TextBoxHelper.AllowOnlyNumericInput="True" wd:TextBoxHelper.MinValue="1" ></TextBox>
|
||||
<TextBox Grid.Column="1" wd:TextBoxHelper.MinValue="1" x:Name="videoCount" ></TextBox>
|
||||
<Button Grid.Column="2" Content="开始拼接" Click="Button_Click" x:Name="startButton" />
|
||||
<ScrollViewer Grid.Row="1" Grid.ColumnSpan="3" VerticalScrollBarVisibility="Auto" x:Name="scrowText" Margin="0,10,0,0">
|
||||
<TextBlock Text="" x:Name="outputTxt" OverridesDefaultStyle="True" TextWrapping="Wrap"/>
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using Microsoft.Win32;
|
||||
using Microsoft.Expression.Drawing.Core;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Win32;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
|
||||
@ -11,21 +13,54 @@ namespace VideoConcat
|
||||
public partial class Video : Window
|
||||
{
|
||||
public string text = "";
|
||||
public FileSystemInfo[]? Floders { get; set; }
|
||||
public string[] Heads = [];
|
||||
public string[] Tails = [];
|
||||
public string[] Middles = [];
|
||||
|
||||
public DirectoryInfo? Path { get; set; }
|
||||
|
||||
|
||||
public Video()
|
||||
{
|
||||
InitializeComponent();
|
||||
Check_Folder();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private async void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
int count = 0;
|
||||
try
|
||||
{
|
||||
count = int.Parse(videoCount.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
MessageBox.Show("请输入正确的数字");
|
||||
return;
|
||||
}
|
||||
|
||||
WriteTxt($"生成视频的个数:{videoCount.Text} 个");
|
||||
|
||||
Check_Folder();
|
||||
|
||||
|
||||
startButton.IsEnabled = false;
|
||||
|
||||
Array.ForEach(array: Middles, s =>
|
||||
{
|
||||
WriteTxt(s);
|
||||
});
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
|
||||
for (int i = 0; i <= 100; i++)
|
||||
|
||||
for (int i = 0; i <= count; i++)
|
||||
{
|
||||
System.Windows.Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
@ -54,34 +89,44 @@ namespace VideoConcat
|
||||
{
|
||||
|
||||
string currentPath = Directory.GetCurrentDirectory();
|
||||
DirectoryInfo? parentPathInfo = Directory.GetParent(currentPath);
|
||||
if (parentPathInfo == null)
|
||||
Path = Directory.GetParent(currentPath);
|
||||
if (Path == null)
|
||||
{
|
||||
WriteTxt("获取相关视频文件目录失败!");
|
||||
return;
|
||||
}
|
||||
WriteTxt("当前目录为:" + parentPathInfo.FullName);
|
||||
WriteTxt("当前目录为:" + Path.FullName);
|
||||
try
|
||||
{
|
||||
Boolean hasHead = false;
|
||||
Boolean hasTail = false;
|
||||
|
||||
DirectoryInfo dirD = parentPathInfo as DirectoryInfo;
|
||||
FileSystemInfo[] folders = dirD.GetDirectories();//获取文件夹下所有文件和文件夹
|
||||
//对单个FileSystemInfo进行判断,如果是文件夹则进行递归操作
|
||||
DirectoryInfo dirD = Path as DirectoryInfo;
|
||||
//获取文件夹下所有文件夹
|
||||
Floders = dirD.GetDirectories();
|
||||
|
||||
foreach (FileSystemInfo folder in folders)
|
||||
//对单个FileSystemInfo进行判断,如果是文件夹则进行递归操作
|
||||
|
||||
foreach (FileSystemInfo folder in Floders)
|
||||
{
|
||||
WriteTxt($"{folder.Name}");
|
||||
|
||||
if (folder.Name == "head")
|
||||
{
|
||||
hasHead = true;
|
||||
Heads = GetAllVideos($"{Path}\\{folder.Name}");
|
||||
continue;
|
||||
|
||||
}
|
||||
if (folder.Name == "tail")
|
||||
{
|
||||
hasTail = true;
|
||||
Tails = GetAllVideos($"{Path}\\{folder.Name}");
|
||||
continue;
|
||||
}
|
||||
|
||||
Middles = Middles.Concat(GetAllVideos($"{Path}\\{folder.Name}")).ToArray();
|
||||
|
||||
}
|
||||
if (!hasHead)
|
||||
{
|
||||
@ -106,5 +151,10 @@ namespace VideoConcat
|
||||
outputTxt.Text = text;
|
||||
scrowText.ScrollToEnd();
|
||||
}
|
||||
|
||||
public static string[] GetAllVideos(string path)
|
||||
{
|
||||
return Directory.GetFiles(path, "*.mp4", SearchOption.AllDirectories);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user