update
This commit is contained in:
parent
ffcfff68ec
commit
77ee5390b7
@ -25,7 +25,7 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<Label Content="生成视频的个数:" VerticalContentAlignment="Center" BorderThickness="1" Padding="5,0,5,0"></Label>
|
<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" />
|
<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">
|
<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"/>
|
<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.IO;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
@ -11,21 +13,54 @@ namespace VideoConcat
|
|||||||
public partial class Video : Window
|
public partial class Video : Window
|
||||||
{
|
{
|
||||||
public string text = "";
|
public string text = "";
|
||||||
|
public FileSystemInfo[]? Floders { get; set; }
|
||||||
|
public string[] Heads = [];
|
||||||
|
public string[] Tails = [];
|
||||||
|
public string[] Middles = [];
|
||||||
|
|
||||||
|
public DirectoryInfo? Path { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public Video()
|
public Video()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Check_Folder();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Button_Click(object sender, RoutedEventArgs e)
|
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;
|
startButton.IsEnabled = false;
|
||||||
|
|
||||||
|
Array.ForEach(array: Middles, s =>
|
||||||
|
{
|
||||||
|
WriteTxt(s);
|
||||||
|
});
|
||||||
|
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
|
||||||
for (int i = 0; i <= 100; i++)
|
|
||||||
|
for (int i = 0; i <= count; i++)
|
||||||
{
|
{
|
||||||
System.Windows.Application.Current.Dispatcher.Invoke(() =>
|
System.Windows.Application.Current.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
@ -54,34 +89,44 @@ namespace VideoConcat
|
|||||||
{
|
{
|
||||||
|
|
||||||
string currentPath = Directory.GetCurrentDirectory();
|
string currentPath = Directory.GetCurrentDirectory();
|
||||||
DirectoryInfo? parentPathInfo = Directory.GetParent(currentPath);
|
Path = Directory.GetParent(currentPath);
|
||||||
if (parentPathInfo == null)
|
if (Path == null)
|
||||||
{
|
{
|
||||||
WriteTxt("获取相关视频文件目录失败!");
|
WriteTxt("获取相关视频文件目录失败!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WriteTxt("当前目录为:" + parentPathInfo.FullName);
|
WriteTxt("当前目录为:" + Path.FullName);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Boolean hasHead = false;
|
Boolean hasHead = false;
|
||||||
Boolean hasTail = false;
|
Boolean hasTail = false;
|
||||||
|
|
||||||
DirectoryInfo dirD = parentPathInfo as DirectoryInfo;
|
DirectoryInfo dirD = Path as DirectoryInfo;
|
||||||
FileSystemInfo[] folders = dirD.GetDirectories();//获取文件夹下所有文件和文件夹
|
//获取文件夹下所有文件夹
|
||||||
|
Floders = dirD.GetDirectories();
|
||||||
|
|
||||||
//对单个FileSystemInfo进行判断,如果是文件夹则进行递归操作
|
//对单个FileSystemInfo进行判断,如果是文件夹则进行递归操作
|
||||||
|
|
||||||
foreach (FileSystemInfo folder in folders)
|
foreach (FileSystemInfo folder in Floders)
|
||||||
{
|
{
|
||||||
WriteTxt($"{folder.Name}");
|
WriteTxt($"{folder.Name}");
|
||||||
|
|
||||||
if (folder.Name == "head")
|
if (folder.Name == "head")
|
||||||
{
|
{
|
||||||
hasHead = true;
|
hasHead = true;
|
||||||
|
Heads = GetAllVideos($"{Path}\\{folder.Name}");
|
||||||
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (folder.Name == "tail")
|
if (folder.Name == "tail")
|
||||||
{
|
{
|
||||||
hasTail = true;
|
hasTail = true;
|
||||||
|
Tails = GetAllVideos($"{Path}\\{folder.Name}");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Middles = Middles.Concat(GetAllVideos($"{Path}\\{folder.Name}")).ToArray();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!hasHead)
|
if (!hasHead)
|
||||||
{
|
{
|
||||||
@ -106,5 +151,10 @@ namespace VideoConcat
|
|||||||
outputTxt.Text = text;
|
outputTxt.Text = text;
|
||||||
scrowText.ScrollToEnd();
|
scrowText.ScrollToEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string[] GetAllVideos(string path)
|
||||||
|
{
|
||||||
|
return Directory.GetFiles(path, "*.mp4", SearchOption.AllDirectories);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user