mirror of
https://github.com/leiurayer/downkyi.git
synced 2024-04-21 12:41:55 +00:00
Merge commit 'refs/pull/512/head' of https://github.com/leiurayer/downkyi into v1.5.x
This commit is contained in:
@@ -37,5 +37,21 @@ namespace DownKyi.Utils
|
||||
return showDialog == true ? dialog.FileName : "";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 选择多个视频dialog
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string[] SelectMultiVideoFile()
|
||||
{
|
||||
// 选择文件
|
||||
var dialog = new Microsoft.Win32.OpenFileDialog
|
||||
{
|
||||
Filter = "mp4 (*.mp4)|*.mp4",
|
||||
Multiselect = true
|
||||
};
|
||||
var showDialog = dialog.ShowDialog();
|
||||
return showDialog == true ? dialog.FileNames : new string[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,25 @@ namespace DownKyi.ViewModels.Toolbox
|
||||
|
||||
#region 页面属性申明
|
||||
|
||||
private string videoPath;
|
||||
public string VideoPath
|
||||
private string videoPathsStr;
|
||||
public string VideoPathsStr
|
||||
{
|
||||
get { return videoPath; }
|
||||
set { SetProperty(ref videoPath, value); }
|
||||
get => videoPathsStr;
|
||||
set
|
||||
{
|
||||
SetProperty(ref videoPathsStr, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string[] videoPaths;
|
||||
public string[] VideoPaths
|
||||
{
|
||||
get => videoPaths;
|
||||
set
|
||||
{
|
||||
videoPaths = value;
|
||||
VideoPathsStr = string.Join(Environment.NewLine, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string status;
|
||||
@@ -38,7 +52,7 @@ namespace DownKyi.ViewModels.Toolbox
|
||||
{
|
||||
#region 属性初始化
|
||||
|
||||
VideoPath = string.Empty;
|
||||
VideoPaths = new string[0];
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -60,7 +74,7 @@ namespace DownKyi.ViewModels.Toolbox
|
||||
return;
|
||||
}
|
||||
|
||||
VideoPath = DialogUtils.SelectVideoFile();
|
||||
VideoPaths = DialogUtils.SelectMultiVideoFile();
|
||||
}
|
||||
|
||||
// 提取音频事件
|
||||
@@ -78,24 +92,27 @@ namespace DownKyi.ViewModels.Toolbox
|
||||
return;
|
||||
}
|
||||
|
||||
if (VideoPath == "")
|
||||
if (VideoPaths.Length <= 0)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipNoSeletedVideo"));
|
||||
return;
|
||||
}
|
||||
|
||||
// 音频文件名
|
||||
string audioFileName = VideoPath.Remove(VideoPath.Length - 4, 4) + ".aac";
|
||||
Status = string.Empty;
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// 执行提取音频程序
|
||||
isExtracting = true;
|
||||
FFmpegHelper.ExtractAudio(VideoPath, audioFileName, new Action<string>((output) =>
|
||||
foreach (var item in VideoPaths)
|
||||
{
|
||||
Status += output + "\n";
|
||||
}));
|
||||
// 音频文件名
|
||||
string audioFileName = item.Remove(item.Length - 4, 4) + ".aac";
|
||||
// 执行提取音频程序
|
||||
FFmpegHelper.ExtractAudio(item, audioFileName, new Action<string>((output) =>
|
||||
{
|
||||
Status += output + "\n";
|
||||
}));
|
||||
}
|
||||
isExtracting = false;
|
||||
});
|
||||
}
|
||||
@@ -115,30 +132,34 @@ namespace DownKyi.ViewModels.Toolbox
|
||||
return;
|
||||
}
|
||||
|
||||
if (VideoPath == "")
|
||||
if (VideoPaths.Length <= 0)
|
||||
{
|
||||
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipNoSeletedVideo"));
|
||||
return;
|
||||
}
|
||||
|
||||
// 视频文件名
|
||||
string videoFileName = VideoPath.Remove(VideoPath.Length - 4, 4) + "_onlyVideo.mp4";
|
||||
Status = string.Empty;
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// 执行提取视频程序
|
||||
isExtracting = true;
|
||||
FFmpegHelper.ExtractVideo(VideoPath, videoFileName, new Action<string>((output) =>
|
||||
foreach (var item in VideoPaths)
|
||||
{
|
||||
Status += output + "\n";
|
||||
}));
|
||||
// 视频文件名
|
||||
string videoFileName = item.Remove(item.Length - 4, 4) + "_onlyVideo.mp4";
|
||||
// 执行提取视频程序
|
||||
FFmpegHelper.ExtractVideo(item, videoFileName, new Action<string>((output) =>
|
||||
{
|
||||
Status += output + "\n";
|
||||
}));
|
||||
}
|
||||
isExtracting = false;
|
||||
});
|
||||
}
|
||||
|
||||
// Status改变事件
|
||||
private DelegateCommand<object> statusCommand;
|
||||
|
||||
public DelegateCommand<object> StatusCommand => statusCommand ?? (statusCommand = new DelegateCommand<object>(ExecuteStatusCommand));
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled">
|
||||
<Grid Margin="50,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="150" />
|
||||
<RowDefinition Height="200" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
@@ -28,11 +28,11 @@
|
||||
<TextBlock VerticalAlignment="Center" Text="{DynamicResource VideoFilePath}" />
|
||||
<TextBox
|
||||
Width="300"
|
||||
Height="20"
|
||||
Height="50"
|
||||
Margin="0,10,10,10"
|
||||
VerticalContentAlignment="Center"
|
||||
IsReadOnly="True"
|
||||
Text="{Binding VideoPath, Mode=TwoWay}" />
|
||||
Text="{Binding VideoPathsStr, Mode=TwoWay}" />
|
||||
|
||||
<Button
|
||||
Width="75"
|
||||
|
||||
Reference in New Issue
Block a user