update
This commit is contained in:
parent
637e5b2969
commit
fefb3b8990
@ -23,6 +23,7 @@ namespace VideoConcat.Models
|
|||||||
private string _folderPath = "";
|
private string _folderPath = "";
|
||||||
private string _auditImagePath = "";
|
private string _auditImagePath = "";
|
||||||
private bool _canStart = false;
|
private bool _canStart = false;
|
||||||
|
private bool _isCanOperate=false;
|
||||||
private bool _isStart = false;
|
private bool _isStart = false;
|
||||||
private ObservableCollection<FolderInfo> _FolderInfos = [];
|
private ObservableCollection<FolderInfo> _FolderInfos = [];
|
||||||
private ObservableCollection<ConcatVideo> _concatVideos = [];
|
private ObservableCollection<ConcatVideo> _concatVideos = [];
|
||||||
@ -30,6 +31,17 @@ namespace VideoConcat.Models
|
|||||||
|
|
||||||
public static int Index = 0;
|
public static int Index = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public bool IsCanOperate
|
||||||
|
{
|
||||||
|
get => _isCanOperate;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_isCanOperate = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsStart
|
public bool IsStart
|
||||||
{
|
{
|
||||||
get => _isStart;
|
get => _isStart;
|
||||||
@ -93,10 +105,10 @@ namespace VideoConcat.Models
|
|||||||
{
|
{
|
||||||
public int Index { set; get; }
|
public int Index { set; get; }
|
||||||
public string FileName { set; get; } = "";
|
public string FileName { set; get; } = "";
|
||||||
public int Size { set; get; }
|
public string Size { set; get; } = "";
|
||||||
public double Seconds { set; get; }
|
public int Seconds { set; get; }
|
||||||
public int Status { set; get; }
|
public string Status { set; get; } = "";
|
||||||
public int Progress { set; get; }
|
public string Progress { set; get; } = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableCollection<FolderInfo> FolderInfos
|
public ObservableCollection<FolderInfo> FolderInfos
|
||||||
@ -207,6 +219,7 @@ namespace VideoConcat.Models
|
|||||||
{
|
{
|
||||||
CanStart = false;
|
CanStart = false;
|
||||||
}
|
}
|
||||||
|
IsCanOperate = !IsStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VideoModel()
|
public VideoModel()
|
||||||
|
|||||||
@ -8,6 +8,7 @@ using FFMpegCore;
|
|||||||
using FFMpegCore.Enums;
|
using FFMpegCore.Enums;
|
||||||
using static VideoConcat.Models.VideoModel;
|
using static VideoConcat.Models.VideoModel;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
namespace VideoConcat.ViewModels
|
namespace VideoConcat.ViewModels
|
||||||
{
|
{
|
||||||
@ -36,6 +37,7 @@ namespace VideoConcat.ViewModels
|
|||||||
ConcatVideos = [],
|
ConcatVideos = [],
|
||||||
MaxNum = 0,
|
MaxNum = 0,
|
||||||
CanStart = false,
|
CanStart = false,
|
||||||
|
IsStart = false,
|
||||||
|
|
||||||
BtnOpenFolderCommand = new Command()
|
BtnOpenFolderCommand = new Command()
|
||||||
{
|
{
|
||||||
@ -87,13 +89,14 @@ namespace VideoConcat.ViewModels
|
|||||||
VideoModel.Dispatcher.Invoke(() =>
|
VideoModel.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
VideoModel.ConcatVideos.Clear();
|
VideoModel.ConcatVideos.Clear();
|
||||||
|
VideoModel.IsStart = true;
|
||||||
});
|
});
|
||||||
MessageBox.Show("开始合并视频");
|
MessageBox.Show("开始合并视频");
|
||||||
if (Directory.Exists($"{VideoModel.FolderPath}\\output") == false)
|
if (Directory.Exists($"{VideoModel.FolderPath}\\output") == false)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory($"{VideoModel.FolderPath}\\output");
|
Directory.CreateDirectory($"{VideoModel.FolderPath}\\output");
|
||||||
}
|
}
|
||||||
VideoModel.IsStart = true;
|
|
||||||
//开始时间
|
//开始时间
|
||||||
DateTime startTime = DateTime.Now;
|
DateTime startTime = DateTime.Now;
|
||||||
|
|
||||||
@ -174,33 +177,16 @@ namespace VideoConcat.ViewModels
|
|||||||
string _tempFileName = $"{DateTime.Now:yyyyMMddHHmmss}{random.Next(100000, 999999)}.mp4";
|
string _tempFileName = $"{DateTime.Now:yyyyMMddHHmmss}{random.Next(100000, 999999)}.mp4";
|
||||||
string _outPutName = Path.Combine($"{VideoModel.FolderPath}", "output", _tempFileName); ;
|
string _outPutName = Path.Combine($"{VideoModel.FolderPath}", "output", _tempFileName); ;
|
||||||
|
|
||||||
//int _size = 0;
|
|
||||||
double _duration = 0;
|
|
||||||
|
|
||||||
var temporaryVideoParts = combination.Select(_ =>
|
var temporaryVideoParts = combination.Select((_videoPath) =>
|
||||||
{
|
{
|
||||||
string _tempPath = Path.GetDirectoryName(_) ?? "";
|
string _tempPath = Path.GetDirectoryName(_videoPath) ?? "";
|
||||||
|
|
||||||
IMediaAnalysis _mediaInfo =FFProbe.Analyse(_);
|
|
||||||
_duration += _mediaInfo.Duration.TotalSeconds;
|
|
||||||
|
|
||||||
|
|
||||||
//GlobalFFOptions.Current.TemporaryFilesFolder
|
//GlobalFFOptions.Current.TemporaryFilesFolder
|
||||||
return Path.Combine(_tempPath, $"{Path.GetFileNameWithoutExtension(_)}{FileExtension.Ts}");
|
return Path.Combine(_tempPath, $"{Path.GetFileNameWithoutExtension(_videoPath)}{FileExtension.Ts}");
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
|
||||||
bool _isSuccess = false;
|
bool _isSuccess = false;
|
||||||
VideoModel.Dispatcher.Invoke(() =>
|
|
||||||
{
|
|
||||||
VideoModel.ConcatVideos.Add(new ConcatVideo()
|
|
||||||
{
|
|
||||||
Index = VideoModel.ConcatVideos.Count + 1,
|
|
||||||
FileName = _tempFileName,
|
|
||||||
Size = 100,
|
|
||||||
Seconds = _duration,
|
|
||||||
Status = 1,
|
|
||||||
Progress = 100,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -219,6 +205,21 @@ namespace VideoConcat.ViewModels
|
|||||||
|
|
||||||
//bool _isSuccess = FFMpeg.Join(_outPutName, [.. combination]);
|
//bool _isSuccess = FFMpeg.Join(_outPutName, [.. combination]);
|
||||||
|
|
||||||
|
VideoModel.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
IMediaAnalysis _mediaInfo = FFProbe.Analyse(_outPutName);
|
||||||
|
FileInfo fileInfo = new(_outPutName);
|
||||||
|
|
||||||
|
VideoModel.ConcatVideos.Add(new ConcatVideo()
|
||||||
|
{
|
||||||
|
Index = VideoModel.ConcatVideos.Count + 1,
|
||||||
|
FileName = _tempFileName,
|
||||||
|
Size = $"{fileInfo.Length / 1024 / 1024}MB",
|
||||||
|
Seconds = ((int)_mediaInfo.Duration.TotalSeconds),
|
||||||
|
Status = _isSuccess ? "拼接成功" : "拼接失败",
|
||||||
|
Progress = "100%",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
if (_isSuccess && VideoModel.AuditImagePath != "")
|
if (_isSuccess && VideoModel.AuditImagePath != "")
|
||||||
|
|||||||
@ -38,12 +38,12 @@
|
|||||||
|
|
||||||
<Label VerticalAlignment="Center" Width="100" FontSize="16" Margin="5,2" BorderBrush="#7F7F7F" BorderThickness="2" Style="{StaticResource MaterialDesignLabel}" VerticalContentAlignment="Stretch">视频文件夹:</Label>
|
<Label VerticalAlignment="Center" Width="100" FontSize="16" Margin="5,2" BorderBrush="#7F7F7F" BorderThickness="2" Style="{StaticResource MaterialDesignLabel}" VerticalContentAlignment="Stretch">视频文件夹:</Label>
|
||||||
<TextBox Grid.Column="1" Width="500" Name="FoldPath" Text="{Binding VideoModel.FolderPath,Mode=TwoWay}" IsReadOnly="True" Margin="5,2" BorderBrush="#7F7F7F" BorderThickness="2" FontSize="16" VerticalContentAlignment="Center" materialDesign:HintAssist.Hint="选择视频主文件夹"/>
|
<TextBox Grid.Column="1" Width="500" Name="FoldPath" Text="{Binding VideoModel.FolderPath,Mode=TwoWay}" IsReadOnly="True" Margin="5,2" BorderBrush="#7F7F7F" BorderThickness="2" FontSize="16" VerticalContentAlignment="Center" materialDesign:HintAssist.Hint="选择视频主文件夹"/>
|
||||||
<Button Grid.Column="2" Width="100" Content="选 择" FontSize="16" Command="{Binding VideoModel.BtnOpenFolderCommand}" Background="#40568D" BorderBrush="#7F7F7F" BorderThickness="2" ToolTip="选择含有视频的主文件夹" Style="{StaticResource MaterialDesignRaisedButton}" Margin="5,2" />
|
<Button Grid.Column="2" Width="100" Content="选 择" FontSize="16" Command="{Binding VideoModel.BtnOpenFolderCommand}" Background="#40568D" BorderBrush="#7F7F7F" BorderThickness="2" ToolTip="选择含有视频的主文件夹" Style="{StaticResource MaterialDesignRaisedButton}" Margin="5,2" IsEnabled="{Binding VideoModel.IsCanOperate}"/>
|
||||||
<Label Grid.Row="1" Width="100" VerticalAlignment="Center" FontSize="16" Margin="5,2" BorderBrush="#7F7F7F" BorderThickness="2" Style="{StaticResource MaterialDesignLabel}" VerticalContentAlignment="Stretch">选择广审:</Label>
|
<Label Grid.Row="1" Width="100" VerticalAlignment="Center" FontSize="16" Margin="5,2" BorderBrush="#7F7F7F" BorderThickness="2" Style="{StaticResource MaterialDesignLabel}" VerticalContentAlignment="Stretch">选择广审:</Label>
|
||||||
<TextBox Grid.Row="1" Width="500" Grid.Column="1" Text="{Binding VideoModel.AuditImagePath,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" Margin="5,2" BorderBrush="#7F7F7F" BorderThickness="2" FontSize="16" VerticalContentAlignment="Center" ToolTip="请选择" materialDesign:HintAssist.Hint="请选择"/>
|
<TextBox Grid.Row="1" Width="500" Grid.Column="1" Text="{Binding VideoModel.AuditImagePath,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" Margin="5,2" BorderBrush="#7F7F7F" BorderThickness="2" FontSize="16" VerticalContentAlignment="Center" ToolTip="请选择" materialDesign:HintAssist.Hint="请选择"/>
|
||||||
<Button Grid.Row="1" Width="100" Grid.Column="2" Content="选择文件" FontSize="16" Command="{Binding VideoModel.BtnChooseAuditImageCommand}" Background="#E54858" BorderBrush="#7F7F7F" BorderThickness="2" ToolTip="选择广审" Style="{StaticResource MaterialDesignRaisedButton}" Margin="5,2"/>
|
<Button Grid.Row="1" Width="100" Grid.Column="2" Content="选择文件" FontSize="16" Command="{Binding VideoModel.BtnChooseAuditImageCommand}" Background="#E54858" BorderBrush="#7F7F7F" BorderThickness="2" ToolTip="选择广审" Style="{StaticResource MaterialDesignRaisedButton}" Margin="5,2" IsEnabled="{Binding VideoModel.IsCanOperate}"/>
|
||||||
<Label Grid.Row="1" Width="100" VerticalAlignment="Center" FontSize="16" Margin="5,2" BorderBrush="#7F7F7F" BorderThickness="2" Style="{StaticResource MaterialDesignLabel}" VerticalContentAlignment="Stretch">视频个数:</Label>
|
<Label Grid.Row="1" Width="100" VerticalAlignment="Center" FontSize="16" Margin="5,2" BorderBrush="#7F7F7F" BorderThickness="2" Style="{StaticResource MaterialDesignLabel}" VerticalContentAlignment="Stretch">视频个数:</Label>
|
||||||
<TextBox Grid.Row="1" Width="500" Grid.Column="1" Text="{Binding VideoModel.Num,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="5,2" BorderBrush="#7F7F7F" BorderThickness="2" FontSize="16" VerticalContentAlignment="Center" ToolTip="请输入合成视频个数" materialDesign:HintAssist.Hint="请输入拼接视频数目"/>
|
<TextBox Grid.Row="1" Width="500" Grid.Column="1" Text="{Binding VideoModel.Num,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="5,2" BorderBrush="#7F7F7F" BorderThickness="2" FontSize="16" VerticalContentAlignment="Center" ToolTip="请输入合成视频个数" materialDesign:HintAssist.Hint="请输入拼接视频数目" IsEnabled="{Binding VideoModel.IsCanOperate}"/>
|
||||||
<Button Grid.Row="1" Width="100" Grid.Column="2" Content="开始拼接" FontSize="16" Command="{Binding VideoModel.BtnStartVideoConcatCommand}" Background="#E54858" BorderBrush="#7F7F7F" BorderThickness="2" ToolTip="开始拼接视频" Style="{StaticResource MaterialDesignRaisedButton}" Margin="5,2" IsEnabled="{Binding VideoModel.CanStart}" Cursor="Hand"/>
|
<Button Grid.Row="1" Width="100" Grid.Column="2" Content="开始拼接" FontSize="16" Command="{Binding VideoModel.BtnStartVideoConcatCommand}" Background="#E54858" BorderBrush="#7F7F7F" BorderThickness="2" ToolTip="开始拼接视频" Style="{StaticResource MaterialDesignRaisedButton}" Margin="5,2" IsEnabled="{Binding VideoModel.CanStart}" Cursor="Hand"/>
|
||||||
|
|
||||||
<!--</Grid>-->
|
<!--</Grid>-->
|
||||||
@ -75,14 +75,14 @@
|
|||||||
<StackPanel MinHeight="200">
|
<StackPanel MinHeight="200">
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<DataGrid Grid.Row="1" ItemsSource="{Binding VideoModel.ConcatVideos}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" >
|
<DataGrid Grid.Row="1" ItemsSource="{Binding VideoModel.ConcatVideos}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True" >
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="序号" Binding="{Binding Index}" Width="*"></DataGridTextColumn>
|
<DataGridTextColumn Header="序号" Binding="{Binding Index}" Width="auto"></DataGridTextColumn>
|
||||||
<DataGridTextColumn Header="文件名" Binding="{Binding FileName}" Width="*"></DataGridTextColumn>
|
<DataGridTextColumn Header="文件名" Binding="{Binding FileName}" Width="auto"></DataGridTextColumn>
|
||||||
<DataGridTextColumn Header="大小" Binding="{Binding Size}" Width="*"></DataGridTextColumn>
|
<DataGridTextColumn Header="大小(MB)" Binding="{Binding Size}" Width="auto"></DataGridTextColumn>
|
||||||
<DataGridTextColumn Header="时长" Binding="{Binding Seconds}" Width="*"></DataGridTextColumn>
|
<DataGridTextColumn Header="时长(秒)" Binding="{Binding Seconds}" Width="auto"></DataGridTextColumn>
|
||||||
<DataGridTextColumn Header="进度" Binding="{Binding Progress}" Width="*"></DataGridTextColumn>
|
<DataGridTextColumn Header="进度" Binding="{Binding Progress}" Width="auto"></DataGridTextColumn>
|
||||||
<DataGridTextColumn Header="状态" Binding="{Binding Status}" Width="*"></DataGridTextColumn>
|
<DataGridTextColumn Header="状态" Binding="{Binding Status}" Width="auto"></DataGridTextColumn>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user