|
@@ -1,4 +1,6 @@
|
1
|
|
-using Aspose.Slides;
|
|
1
|
+using Accord.Video.FFMPEG;
|
|
2
|
+
|
|
3
|
+using Aspose.Slides;
|
2
|
4
|
using Aspose.Words.Saving;
|
3
|
5
|
|
4
|
6
|
using ComeCapture;
|
|
@@ -545,22 +547,7 @@ namespace XHWK.WKTool
|
545
|
547
|
{
|
546
|
548
|
MessageWindow.Show("当前正在录制,请先停止录制。");
|
547
|
549
|
return;
|
548
|
|
- //MessageBoxResult dr = MessageWindow.Show("当前正在录制,是否停止录制?", "提示", MessageBoxButton.OKCancel);
|
549
|
|
- //if (dr == MessageBoxResult.OK)
|
550
|
|
- //{
|
551
|
|
- // APP.SaveWkData();
|
552
|
|
- // APP.SaveDraw();
|
553
|
|
- // BtnStop_Click(null, null);
|
554
|
|
- // while (!IsFirstR)
|
555
|
|
- // {
|
556
|
|
- // Thread.Sleep(100);
|
557
|
|
- // }
|
558
|
|
- // System.Environment.Exit(0);
|
559
|
|
- //}
|
560
|
|
- //else
|
561
|
|
- //{
|
562
|
|
- // return;
|
563
|
|
- //}
|
|
550
|
+
|
564
|
551
|
}
|
565
|
552
|
}
|
566
|
553
|
|
|
@@ -3196,15 +3183,7 @@ namespace XHWK.WKTool
|
3196
|
3183
|
|
3197
|
3184
|
#region 变量
|
3198
|
3185
|
|
3199
|
|
- /// <summary>
|
3200
|
|
- /// 视频保存路径
|
3201
|
|
- /// </summary>
|
3202
|
|
- //string RecordingPath;
|
3203
|
|
- /// <summary>
|
3204
|
|
- /// 图片保存路径
|
3205
|
|
- /// </summary>
|
3206
|
|
- private string ImgPath;
|
3207
|
|
-
|
|
3186
|
+
|
3208
|
3187
|
/// <summary>
|
3209
|
3188
|
/// 音频保存路径名
|
3210
|
3189
|
/// </summary>
|
|
@@ -3230,10 +3209,7 @@ namespace XHWK.WKTool
|
3230
|
3209
|
/// </summary>
|
3231
|
3210
|
private bool IsFirstR = true;
|
3232
|
3211
|
|
3233
|
|
- /// <summary>
|
3234
|
|
- /// 图片
|
3235
|
|
- /// </summary>
|
3236
|
|
- private List<string> RsImgName = null;
|
|
3212
|
+
|
3237
|
3213
|
|
3238
|
3214
|
/// <summary>
|
3239
|
3215
|
/// 是否开始截图计数
|
|
@@ -3285,36 +3261,10 @@ namespace XHWK.WKTool
|
3285
|
3261
|
if (!APP.CheckScreenCapturerRecorder())
|
3286
|
3262
|
{
|
3287
|
3263
|
MessageWindow.Show("使用此功能需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
|
3288
|
|
- APP.InstallScreenCapturerRecorder();
|
|
3264
|
+ //APP.InstallScreenCapturerRecorder();
|
3289
|
3265
|
return;
|
3290
|
3266
|
}
|
3291
|
3267
|
|
3292
|
|
- #region 限制只允许录制一个录屏 废弃
|
3293
|
|
-
|
3294
|
|
- //string RecordScreenPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
|
3295
|
|
- //if (FileToolsCommon.IsExistFile(RecordScreenPathName))
|
3296
|
|
- //{
|
3297
|
|
- // MessageBoxResult dr = MessageWindow.Show("已存在录屏,是否覆盖?", "提示", MessageBoxButton.OKCancel);
|
3298
|
|
- // if (dr == MessageBoxResult.OK)
|
3299
|
|
- // {
|
3300
|
|
- // try
|
3301
|
|
- // {
|
3302
|
|
- // FileToolsCommon.DeleteFile(RecordScreenPathName);
|
3303
|
|
- // APP.VideoList.RemoveAll(x => x.VideoPath == RecordScreenPathName);
|
3304
|
|
- // }
|
3305
|
|
- // catch (Exception ex)
|
3306
|
|
- // {
|
3307
|
|
- // LogHelper.WriteErrLog("【录屏】(BtnRecordingScreen_Click)无法移除视频," + ex.Message, ex);
|
3308
|
|
- // }
|
3309
|
|
- // }
|
3310
|
|
- // else
|
3311
|
|
- // {
|
3312
|
|
- // return;
|
3313
|
|
- // }
|
3314
|
|
- //}
|
3315
|
|
-
|
3316
|
|
- #endregion 限制只允许录制一个录屏 废弃
|
3317
|
|
-
|
3318
|
3268
|
k_hook.Stop();
|
3319
|
3269
|
if (APP.W_ScreenRecordingToolbarWindow == null)
|
3320
|
3270
|
{
|
|
@@ -3392,7 +3342,7 @@ namespace XHWK.WKTool
|
3392
|
3342
|
IsPressButton = true;
|
3393
|
3343
|
new Thread(new ThreadStart(new Action(() =>
|
3394
|
3344
|
{
|
3395
|
|
- Thread.Sleep(500);
|
|
3345
|
+ Thread.Sleep(3000);
|
3396
|
3346
|
IsPressButton = false;
|
3397
|
3347
|
}))).Start();
|
3398
|
3348
|
}
|
|
@@ -3403,7 +3353,7 @@ namespace XHWK.WKTool
|
3403
|
3353
|
if (!APP.CheckScreenCapturerRecorder())
|
3404
|
3354
|
{
|
3405
|
3355
|
MessageWindow.Show("使用此功能需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
|
3406
|
|
- APP.InstallScreenCapturerRecorder();
|
|
3356
|
+ //APP.InstallScreenCapturerRecorder();
|
3407
|
3357
|
return;
|
3408
|
3358
|
}
|
3409
|
3359
|
if (APP.PageContextData.currpage > 0)
|
|
@@ -3443,7 +3393,6 @@ namespace XHWK.WKTool
|
3443
|
3393
|
if (APP.FFmpeg.StartRecordSpeakerAudio(audioSpeakerPath))
|
3444
|
3394
|
{
|
3445
|
3395
|
APP.FFmpeg.StopRecordAudio(2);
|
3446
|
|
- //Thread.Sleep(500);
|
3447
|
3396
|
//麦克风
|
3448
|
3397
|
if (APP.FFmpeg.StartRecordAudio(audioMicrophonePath))
|
3449
|
3398
|
{
|
|
@@ -3527,12 +3476,7 @@ namespace XHWK.WKTool
|
3527
|
3476
|
}
|
3528
|
3477
|
}
|
3529
|
3478
|
|
3530
|
|
- /// <summary>
|
3531
|
|
- /// 设置录屏文件地址
|
3532
|
|
- /// </summary>
|
3533
|
|
- private void SetUpVideoPathName()
|
3534
|
|
- {
|
3535
|
|
- }
|
|
3479
|
+ private VideoFileWriter videoWriter = new VideoFileWriter();//视频写入
|
3536
|
3480
|
|
3537
|
3481
|
/// <summary>
|
3538
|
3482
|
/// 开始录制和暂停录制
|
|
@@ -3552,14 +3496,15 @@ namespace XHWK.WKTool
|
3552
|
3496
|
WkType = Enum_WKVidetype.RecordingLessons
|
3553
|
3497
|
};
|
3554
|
3498
|
|
3555
|
|
- ImgPath = APP.WKData.WkPath + "temp/Image/";
|
|
3499
|
+
|
3556
|
3500
|
AudioPathName = APP.WKData.WkPath + "temp/audio/";
|
3557
|
3501
|
FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
|
3558
|
3502
|
FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
|
3559
|
|
- FileToolsCommon.CreateDirectory(ImgPath);
|
|
3503
|
+
|
3560
|
3504
|
FileToolsCommon.CreateDirectory(AudioPathName);
|
3561
|
3505
|
AudioPathName += APP.WKData.WkName + ".MP3";
|
3562
|
3506
|
VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制." + VideoInfo.VideoType.ToString();
|
|
3507
|
+
|
3563
|
3508
|
VideoSynthesisPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制Syn." + VideoInfo.VideoType.ToString();
|
3564
|
3509
|
int num = 1;
|
3565
|
3510
|
while (FileToolsCommon.IsExistFile(VideoSavePathName))
|
|
@@ -3568,6 +3513,22 @@ namespace XHWK.WKTool
|
3568
|
3513
|
VideoSynthesisPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制Syn_" + num + "." + VideoInfo.VideoType.ToString();
|
3569
|
3514
|
num++;
|
3570
|
3515
|
}
|
|
3516
|
+ int RsW = (int)(GridMain.ActualWidth * (PrimaryScreen.DpiX / 96f) / 2) * 2;
|
|
3517
|
+ int RsH = (int)(GridMain.ActualHeight * (PrimaryScreen.DpiY / 96f) / 2) * 2;
|
|
3518
|
+
|
|
3519
|
+ Console.WriteLine("RsW:"+ RsW+ " RsH:"+ RsH);
|
|
3520
|
+
|
|
3521
|
+ lock (this)
|
|
3522
|
+ {
|
|
3523
|
+ videoWriter.Open(
|
|
3524
|
+ VideoSynthesisPathName,
|
|
3525
|
+ RsW,
|
|
3526
|
+ RsH,
|
|
3527
|
+ 5,
|
|
3528
|
+ VideoCodec.MPEG4,
|
|
3529
|
+ RsW * RsH * 10
|
|
3530
|
+ );
|
|
3531
|
+ }
|
3571
|
3532
|
|
3572
|
3533
|
#region 禁用按钮
|
3573
|
3534
|
|
|
@@ -3606,12 +3567,10 @@ namespace XHWK.WKTool
|
3606
|
3567
|
{
|
3607
|
3568
|
APP.W_CountdownWindow = new CountdownWindow();
|
3608
|
3569
|
APP.W_CountdownWindow.Initialize();
|
3609
|
|
- //APP.W_CountdownWindow.Topmost = true;
|
3610
|
3570
|
}
|
3611
|
3571
|
else
|
3612
|
3572
|
{
|
3613
|
3573
|
APP.W_CountdownWindow.Initialize();
|
3614
|
|
- //APP.W_CountdownWindow.Topmost = true;
|
3615
|
3574
|
}
|
3616
|
3575
|
APP.W_CountdownWindow.Show();
|
3617
|
3576
|
});
|
|
@@ -3619,15 +3578,12 @@ namespace XHWK.WKTool
|
3619
|
3578
|
#endregion 录像倒计时
|
3620
|
3579
|
|
3621
|
3580
|
IsFirstR = false;
|
3622
|
|
- RsImgName = new List<string>();
|
|
3581
|
+
|
3623
|
3582
|
SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
|
3624
|
3583
|
///启动截图
|
3625
|
3584
|
timer = new System.Threading.Timer(new TimerCallback(Timer_Elapsed), null, 0, 20);
|
3626
|
3585
|
}
|
3627
|
3586
|
|
3628
|
|
- //继续录制
|
3629
|
|
- //IsSuspendR = false;
|
3630
|
|
- //BtnRecording.Content = "暂停录制";
|
3631
|
3587
|
Dispatcher.Invoke(() =>
|
3632
|
3588
|
{
|
3633
|
3589
|
TxbType.Text = "准备录制";
|
|
@@ -3652,8 +3608,7 @@ namespace XHWK.WKTool
|
3652
|
3608
|
}
|
3653
|
3609
|
Recorddt = DateTime.Now;
|
3654
|
3610
|
IsStartCount = true;
|
3655
|
|
- //Stack();
|
3656
|
|
- //timer.Start();
|
|
3611
|
+
|
3657
|
3612
|
});
|
3658
|
3613
|
}
|
3659
|
3614
|
catch (Exception ex)
|
|
@@ -3664,15 +3619,13 @@ namespace XHWK.WKTool
|
3664
|
3619
|
else if (Type == 2)
|
3665
|
3620
|
{
|
3666
|
3621
|
//暂停
|
3667
|
|
- //IsSuspendR = true;
|
3668
|
3622
|
Dispatcher.Invoke(() =>
|
3669
|
3623
|
{
|
3670
|
3624
|
TxbType.Text = "暂停中";
|
3671
|
3625
|
BtnRecord.Visibility = Visibility.Visible;
|
3672
|
3626
|
BtnRecordSuspend.Visibility = Visibility.Collapsed;
|
3673
|
3627
|
});
|
3674
|
|
- //TimeOut();
|
3675
|
|
-
|
|
3628
|
+
|
3676
|
3629
|
#region 2秒内不可点击
|
3677
|
3630
|
|
3678
|
3631
|
//new Thread(new ThreadStart(new Action(() =>
|
|
@@ -3695,14 +3648,13 @@ namespace XHWK.WKTool
|
3695
|
3648
|
try
|
3696
|
3649
|
{
|
3697
|
3650
|
APP.FFmpeg.SuspendFFmpeg();
|
3698
|
|
- //new Thread(new ThreadStart(new Action(() =>
|
3699
|
|
- //{
|
|
3651
|
+
|
3700
|
3652
|
while (APP.FFmpeg.myProcess != null)
|
3701
|
3653
|
{
|
3702
|
3654
|
Thread.Sleep(100);
|
3703
|
3655
|
}
|
3704
|
3656
|
IsStartCount = false;
|
3705
|
|
- //}))).Start();
|
|
3657
|
+
|
3706
|
3658
|
}
|
3707
|
3659
|
catch (Exception ex)
|
3708
|
3660
|
{
|
|
@@ -3714,264 +3666,7 @@ namespace XHWK.WKTool
|
3714
|
3666
|
}
|
3715
|
3667
|
}
|
3716
|
3668
|
|
3717
|
|
- /// <summary>
|
3718
|
|
- /// 开始录制和暂停录制
|
3719
|
|
- /// </summary>
|
3720
|
|
- private void StartRecordOld(int Type)
|
3721
|
|
- {
|
3722
|
|
- if (Type == 1)
|
3723
|
|
- {
|
3724
|
|
- if (IsFirstR)//是否第一次录制 初始化录制
|
3725
|
|
- {
|
3726
|
|
- #region 检测麦克风扬声器是否可用
|
3727
|
|
-
|
3728
|
|
- string AudioPath = FileToolsCommon.GetFileAbsolutePath("/temp/audio/");
|
3729
|
|
- FileToolsCommon.CreateDirectory(AudioPath);
|
3730
|
|
- string audioSpeakerPath = AudioPath + "adoS" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".m";
|
3731
|
|
- string audioMicrophonePath = AudioPath + "adoM" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".m";
|
3732
|
|
- try
|
3733
|
|
- {
|
3734
|
|
- FileToolsCommon.DeleteFile(audioSpeakerPath);
|
3735
|
|
- FileToolsCommon.DeleteFile(audioMicrophonePath);
|
3736
|
|
- }
|
3737
|
|
- catch (Exception)
|
3738
|
|
- {
|
3739
|
|
- }
|
3740
|
|
- //扬声器
|
3741
|
|
- if (APP.FFmpeg.StartRecordSpeakerAudio(audioSpeakerPath))
|
3742
|
|
- {
|
3743
|
|
- APP.FFmpeg.StopRecordAudio(2);
|
3744
|
|
- //Thread.Sleep(500);
|
3745
|
|
- //麦克风
|
3746
|
|
- if (APP.FFmpeg.StartRecordAudio(audioMicrophonePath))
|
3747
|
|
- {
|
3748
|
|
- }
|
3749
|
|
- else
|
3750
|
|
- {
|
3751
|
|
- //无法录制麦克风
|
3752
|
|
- MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制麦克风,是否继续?", "消息提示", MessageBoxButton.OKCancel);
|
3753
|
|
- if (Res == MessageBoxResult.Cancel)
|
3754
|
|
- {
|
3755
|
|
- return;
|
3756
|
|
- }
|
3757
|
|
- }
|
3758
|
|
- APP.FFmpeg.StopRecordAudio(1);
|
3759
|
|
- }
|
3760
|
|
- else
|
3761
|
|
- {
|
3762
|
|
- //无法录制扬声器音频
|
3763
|
|
- MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制音频,是否继续?", "消息提示", MessageBoxButton.OKCancel);
|
3764
|
|
- if (Res == MessageBoxResult.Cancel)
|
3765
|
|
- {
|
3766
|
|
- return;
|
3767
|
|
- }
|
3768
|
|
- }
|
3769
|
|
-
|
3770
|
|
- #endregion 检测麦克风扬声器是否可用
|
3771
|
|
-
|
3772
|
|
- //电子版切换笔模式
|
3773
|
|
- deviceHand();
|
3774
|
|
- //TxbTime.Visibility = Visibility.Visible;
|
3775
|
|
- //ImgLZImg.Visibility = Visibility.Visible;
|
3776
|
|
-
|
3777
|
|
- VideoInfo = new Model_Video
|
3778
|
|
- {
|
3779
|
|
- VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType")),
|
3780
|
|
- WkType = Enum_WKVidetype.RecordingLessons
|
3781
|
|
- };
|
3782
|
|
-
|
3783
|
|
- ImgPath = APP.WKData.WkPath + "temp/Image/";
|
3784
|
|
- AudioPathName = APP.WKData.WkPath + "temp/audio/";
|
3785
|
|
- FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
|
3786
|
|
- FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
|
3787
|
|
- FileToolsCommon.CreateDirectory(ImgPath);
|
3788
|
|
- FileToolsCommon.CreateDirectory(AudioPathName);
|
3789
|
|
- AudioPathName += APP.WKData.WkName + ".MP3";
|
3790
|
|
- VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制." + VideoInfo.VideoType.ToString();
|
3791
|
|
- VideoSynthesisPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制Syn." + VideoInfo.VideoType.ToString();
|
3792
|
|
- int num = 1;
|
3793
|
|
- while (FileToolsCommon.IsExistFile(VideoSavePathName))
|
3794
|
|
- {
|
3795
|
|
- VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制_" + num + "." + VideoInfo.VideoType.ToString();
|
3796
|
|
- VideoSynthesisPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制Syn_" + num + "." + VideoInfo.VideoType.ToString();
|
3797
|
|
- num++;
|
3798
|
|
- }
|
3799
|
|
-
|
3800
|
|
- #region 禁用按钮
|
3801
|
|
-
|
3802
|
|
- BtnPrint.IsEnabled = false;
|
3803
|
|
- BtnScreenshot.IsEnabled = false;
|
3804
|
|
- BtnImport.IsEnabled = false;
|
3805
|
|
- BtnScreenRecording.IsEnabled = false;
|
3806
|
|
- BtnUpload.IsEnabled = false;
|
3807
|
|
- BtnSetUp.IsEnabled = false;
|
3808
|
|
- BtnDevice.IsEnabled = false;
|
3809
|
|
- BtnLoginType.IsEnabled = false;
|
3810
|
|
- blackboard_canvas.Visibility = Visibility.Visible;//zxyceshi
|
3811
|
|
-
|
3812
|
|
- //myblackboard = new BlackboardNew(blackboard_canvas);
|
3813
|
|
- //DataContext = APP.pageData;
|
3814
|
|
- //drawingAttributes = new DrawingAttributes();
|
3815
|
|
- ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
|
3816
|
|
- ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
|
3817
|
|
- //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
|
3818
|
|
- //blackboard_canvas.UseCustomCursor = true;
|
3819
|
|
- //drawingAttributes.FitToCurve = true;
|
3820
|
|
- //drawingAttributes.IgnorePressure = false;
|
3821
|
|
- //drawingAttributes.Width = PenSize;
|
3822
|
|
- //drawingAttributes.Height = PenSize;
|
3823
|
|
- //drawingAttributes.Color = Color;
|
3824
|
|
- //blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
|
3825
|
|
-
|
3826
|
|
- #endregion 禁用按钮
|
3827
|
|
-
|
3828
|
|
- #region 设置录制大小
|
3829
|
|
-
|
3830
|
|
- //gridActWidth = (int)GridMain.ActualWidth==0?1276: (int)GridMain.ActualWidth;
|
3831
|
|
- //gridActHeight = (int)GridMain.ActualHeight==0?898: (int)GridMain.ActualHeight;
|
3832
|
|
- gridActWidth = (int)(GridMain.ActualWidth * (PrimaryScreen.DpiX / 96f));
|
3833
|
|
- gridActHeight = (int)(GridMain.ActualHeight * (PrimaryScreen.DpiY / 96f));
|
3834
|
|
- gridActWidth = gridActWidth % 2 > 0 ? gridActWidth - 1 : gridActWidth;
|
3835
|
|
- gridActHeight = gridActHeight % 2 > 0 ? gridActHeight - 1 : gridActHeight;
|
3836
|
|
-
|
3837
|
|
- #endregion 设置录制大小
|
3838
|
|
-
|
3839
|
|
- #region 录像倒计时
|
3840
|
|
-
|
3841
|
|
- if (APP.W_CountdownWindow == null)
|
3842
|
|
- {
|
3843
|
|
- APP.W_CountdownWindow = new CountdownWindow();
|
3844
|
|
- APP.W_CountdownWindow.Initialize();
|
3845
|
|
- //APP.W_CountdownWindow.Topmost = true;
|
3846
|
|
- }
|
3847
|
|
- else
|
3848
|
|
- {
|
3849
|
|
- APP.W_CountdownWindow.Initialize();
|
3850
|
|
- //APP.W_CountdownWindow.Topmost = true;
|
3851
|
|
- }
|
3852
|
|
- APP.W_CountdownWindow.Show();
|
3853
|
|
-
|
3854
|
|
- #endregion 录像倒计时
|
3855
|
|
-
|
3856
|
|
- IsFirstR = false;
|
3857
|
|
- RsImgName = new List<string>();
|
3858
|
|
- SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
|
3859
|
|
- //TxbTime.Visibility = Visibility.Visible;
|
3860
|
|
- //ImgLZImg.Visibility = Visibility.Visible;
|
3861
|
|
- ///启动截图
|
3862
|
|
- timer = new System.Threading.Timer(new TimerCallback(Timer_Elapsed), null, 0, 20);
|
3863
|
|
- //{
|
3864
|
|
- // AutoReset = true//设置是否执行System.Timers.Timer.Elapsed事件
|
3865
|
|
- //};//设置执行一次(false)还是一直执行(true)
|
3866
|
|
- //timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
|
3867
|
|
- //timer.Enabled = true; //启动计时器
|
3868
|
|
- }
|
3869
|
|
-
|
3870
|
|
- //继续录制
|
3871
|
|
- //IsSuspendR = false;
|
3872
|
|
- //BtnRecording.Content = "暂停录制";
|
3873
|
|
- TxbType.Text = "准备录制";
|
3874
|
|
- BtnRecord.Visibility = Visibility.Collapsed;
|
3875
|
|
- BtnRecordSuspend.Visibility = Visibility.Visible;
|
3876
|
|
-
|
3877
|
|
- #region 4秒内不可点击
|
3878
|
|
-
|
3879
|
|
- //new Thread(new ThreadStart(new Action(() =>
|
3880
|
|
- //{
|
3881
|
|
- // Dispatcher.Invoke(() =>
|
3882
|
|
- // {
|
3883
|
|
- // BtnRecord.IsEnabled = false;
|
3884
|
|
- // btnStop.IsEnabled = false;
|
3885
|
|
- // ImgStop.Visibility = Visibility.Visible;
|
3886
|
|
- // ImgStopTwo.Visibility = Visibility.Collapsed;
|
3887
|
|
- // });
|
3888
|
|
- //}))).Start();
|
3889
|
|
- new Thread(new ThreadStart(new Action(() =>
|
3890
|
|
- {
|
3891
|
|
- //Thread.Sleep(4000);
|
3892
|
|
- Dispatcher.Invoke(() =>
|
3893
|
|
- {
|
3894
|
|
- BtnRecord.IsEnabled = true;
|
3895
|
|
- BtnStop.IsEnabled = true;
|
3896
|
|
- });
|
3897
|
|
- }))).Start();
|
3898
|
|
-
|
3899
|
|
- #endregion 4秒内不可点击
|
3900
|
|
-
|
3901
|
|
- try
|
3902
|
|
- {
|
3903
|
|
- new Thread(new ThreadStart(new Action(() =>
|
3904
|
|
- {
|
3905
|
|
- Thread.Sleep(1000);
|
3906
|
|
- bool IsRecordingSound = FileToolsCommon.GetConfigValue("IsRecordingSound") == "1";
|
3907
|
|
- bool IsRecordingMicrophone = FileToolsCommon.GetConfigValue("IsRecordingMicrophone") == "1";
|
3908
|
|
- IsRecordAudio = APP.FFmpeg.StartRecordingAudio(AudioPathName, out string ErrMessage, IsRecordingSound, IsRecordingMicrophone, APP.MicrophoneName);
|
3909
|
|
- Thread.Sleep(1000);
|
3910
|
|
- Dispatcher.Invoke(() =>
|
3911
|
|
- {
|
3912
|
|
- TxbType.Text = "正在录制";
|
3913
|
|
- if (!IsRecordAudio)
|
3914
|
|
- {
|
3915
|
|
- MessageWindow.Show(ErrMessage);
|
3916
|
|
- }
|
3917
|
|
- Recorddt = DateTime.Now;
|
3918
|
|
- IsStartCount = true;
|
3919
|
|
- //Stack();
|
3920
|
|
- //timer.Start();
|
3921
|
|
- });
|
3922
|
|
- }))).Start();
|
3923
|
|
- }
|
3924
|
|
- catch (Exception ex)
|
3925
|
|
- {
|
3926
|
|
- MessageWindow.Show(ex.Message);
|
3927
|
|
- }
|
3928
|
|
- }
|
3929
|
|
- else if (Type == 2)
|
3930
|
|
- {
|
3931
|
|
- //暂停
|
3932
|
|
- //IsSuspendR = true;
|
3933
|
|
- TxbType.Text = "暂停中";
|
3934
|
|
- BtnRecord.Visibility = Visibility.Visible;
|
3935
|
|
- BtnRecordSuspend.Visibility = Visibility.Collapsed;
|
3936
|
|
- //TimeOut();
|
3937
|
|
-
|
3938
|
|
- #region 2秒内不可点击
|
3939
|
|
-
|
3940
|
|
- new Thread(new ThreadStart(new Action(() =>
|
3941
|
|
- {
|
3942
|
|
- Dispatcher.Invoke(() =>
|
3943
|
|
- {
|
3944
|
|
- BtnRecord.IsEnabled = false;
|
3945
|
|
- BtnStop.IsEnabled = false;
|
3946
|
|
- });
|
3947
|
|
- Thread.Sleep(2000);
|
3948
|
|
- Dispatcher.Invoke(() =>
|
3949
|
|
- {
|
3950
|
|
- BtnRecord.IsEnabled = true;
|
3951
|
|
- BtnStop.IsEnabled = true;
|
3952
|
|
- });
|
3953
|
|
- }))).Start();
|
3954
|
|
-
|
3955
|
|
- #endregion 2秒内不可点击
|
3956
|
|
-
|
3957
|
|
- try
|
3958
|
|
- {
|
3959
|
|
- APP.FFmpeg.SuspendFFmpeg();
|
3960
|
|
- new Thread(new ThreadStart(new Action(() =>
|
3961
|
|
- {
|
3962
|
|
- while (APP.FFmpeg.myProcess != null)
|
3963
|
|
- {
|
3964
|
|
- Thread.Sleep(100);
|
3965
|
|
- }
|
3966
|
|
- IsStartCount = false;
|
3967
|
|
- }))).Start();
|
3968
|
|
- }
|
3969
|
|
- catch (Exception ex)
|
3970
|
|
- {
|
3971
|
|
- MessageWindow.Show(ex.Message);
|
3972
|
|
- }
|
3973
|
|
- }
|
3974
|
|
- }
|
|
3669
|
+
|
3975
|
3670
|
|
3976
|
3671
|
/// <summary>
|
3977
|
3672
|
/// 记录上次截图时间
|
|
@@ -3989,12 +3684,13 @@ namespace XHWK.WKTool
|
3989
|
3684
|
DateTime dt = DateTime.Now;
|
3990
|
3685
|
TimeSpan ts = dt.Subtract(Recorddt);//时间差
|
3991
|
3686
|
double tsmi = ts.TotalMilliseconds;
|
3992
|
|
- if (tsmi > 200.0)
|
|
3687
|
+ if (tsmi >= 200.0)
|
3993
|
3688
|
{
|
3994
|
3689
|
Recorddt = Recorddt.AddMilliseconds(200);
|
3995
|
|
- Thread thread = new Thread(RecordSaveImage);
|
3996
|
|
- //开启线程
|
3997
|
|
- thread.Start();
|
|
3690
|
+
|
|
3691
|
+ ThreadPool.QueueUserWorkItem(o=> {
|
|
3692
|
+ RecordSaveImage();
|
|
3693
|
+ });
|
3998
|
3694
|
}
|
3999
|
3695
|
}
|
4000
|
3696
|
}
|
|
@@ -4008,28 +3704,22 @@ namespace XHWK.WKTool
|
4008
|
3704
|
{
|
4009
|
3705
|
if (IsStartCount)
|
4010
|
3706
|
{
|
4011
|
|
- string FilePathName = ImgPath + RsImgName.Count + ".png";
|
4012
|
|
- RsImgName.Add(FilePathName);
|
4013
|
|
-
|
|
3707
|
+
|
4014
|
3708
|
#region 设置大小
|
4015
|
3709
|
|
4016
|
|
- double RsW = (int)(GridMain.ActualWidth * (PrimaryScreen.DpiX / 96f));
|
4017
|
|
- double RsH = (int)(GridMain.ActualHeight * (PrimaryScreen.DpiY / 96f));
|
4018
|
|
- if (RsW > 1266)
|
4019
|
|
- {
|
4020
|
|
- double Proportion = RsH / RsW;
|
4021
|
|
- RsW = 1266;
|
4022
|
|
- RsH = RsW * Proportion;
|
4023
|
|
- RsH = ((int)RsH) % 2 > 0 ? (int)RsH - 1 : (int)RsH;
|
4024
|
|
- //RsH = 898;
|
4025
|
|
- }
|
4026
|
|
-
|
|
3710
|
+ int RsW = (int)(GridMain.ActualWidth * (PrimaryScreen.DpiX / 96f) / 2)*2;
|
|
3711
|
+ int RsH = (int)(GridMain.ActualHeight * (PrimaryScreen.DpiY / 96f) / 2) *2;
|
|
3712
|
+
|
4027
|
3713
|
#endregion 设置大小
|
4028
|
3714
|
|
4029
|
3715
|
Dispatcher.Invoke(() =>
|
4030
|
3716
|
{
|
4031
|
3717
|
//保存图片
|
4032
|
|
- ImageHelper.SaveUI2(GridMain, FilePathName, gridActWidth, gridActHeight, (int)RsW, (int)RsH);
|
|
3718
|
+
|
|
3719
|
+ Bitmap bm = ImageHelper.SaveUI2Bitmap(GridMain, RsW, RsH);
|
|
3720
|
+
|
|
3721
|
+ videoWriter.WriteVideoFrame(bm);
|
|
3722
|
+ bm.Dispose();
|
4033
|
3723
|
|
4034
|
3724
|
SRTime = SRTime.AddMilliseconds(200);
|
4035
|
3725
|
|
|
@@ -4095,163 +3785,104 @@ namespace XHWK.WKTool
|
4095
|
3785
|
|
4096
|
3786
|
#endregion 清空画板数据
|
4097
|
3787
|
|
4098
|
|
- //根据录制时间长度确定是否保存
|
4099
|
|
- if (SRTime.Hour > 0 || SRTime.Minute > 0 || SRTime.Second > 3)
|
|
3788
|
+ Dispatcher.Invoke(() =>
|
4100
|
3789
|
{
|
4101
|
|
- #region 2秒内不可点击
|
|
3790
|
+ BtnRecord.IsEnabled = false;
|
|
3791
|
+ BtnStop.IsEnabled = false;
|
|
3792
|
+ BtnScreenRecording.IsEnabled = false;
|
|
3793
|
+ });
|
4102
|
3794
|
|
4103
|
|
- Dispatcher.Invoke(() =>
|
4104
|
|
- {
|
4105
|
|
- BtnRecord.IsEnabled = false;
|
4106
|
|
- BtnStop.IsEnabled = false;
|
4107
|
|
- BtnScreenRecording.IsEnabled = false;
|
4108
|
|
- });
|
|
3795
|
+ //缩略图
|
|
3796
|
+ string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
|
|
3797
|
+ FileToolsCommon.CreateDirectory(ThumbnailPath);
|
|
3798
|
+ //缩略图存储位置
|
|
3799
|
+ string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
|
|
3800
|
+ try
|
|
3801
|
+ {
|
|
3802
|
+ APP.FFmpeg.StopFFmpeg(AudioPathName);
|
|
3803
|
+ }
|
|
3804
|
+ catch (Exception ex)
|
|
3805
|
+ {
|
|
3806
|
+ LogHelper.WriteErrLog("【录制停止】:录音生成失败," + ex.Message, ex);
|
|
3807
|
+ }
|
|
3808
|
+ IsStartCount = false;
|
|
3809
|
+ //停止截图
|
|
3810
|
+ while (APP.FFmpeg.myProcess != null)
|
|
3811
|
+ {
|
|
3812
|
+ Thread.Sleep(100);
|
|
3813
|
+ }
|
|
3814
|
+ Dispatcher.Invoke(() =>
|
|
3815
|
+ {
|
|
3816
|
+ timer.Change(-1, 0);
|
|
3817
|
+ timer.Dispose();
|
4109
|
3818
|
|
4110
|
|
- #endregion 2秒内不可点击
|
|
3819
|
+ videoWriter.Close();
|
4111
|
3820
|
|
4112
|
|
- //缩略图
|
4113
|
|
- string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
|
4114
|
|
- FileToolsCommon.CreateDirectory(ThumbnailPath);
|
4115
|
|
- //缩略图存储位置
|
4116
|
|
- string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
|
4117
|
|
- try
|
4118
|
|
- {
|
4119
|
|
- APP.FFmpeg.StopFFmpeg(AudioPathName);
|
4120
|
|
- }
|
4121
|
|
- catch (Exception ex)
|
4122
|
|
- {
|
4123
|
|
- LogHelper.WriteErrLog("【录制停止】:合并音频你文件失败," + ex.Message, ex);
|
4124
|
|
- }
|
4125
|
|
- IsStartCount = false;
|
4126
|
|
- //停止截图
|
4127
|
|
- while (APP.FFmpeg.myProcess != null)
|
4128
|
|
- {
|
4129
|
|
- Thread.Sleep(100);
|
4130
|
|
- }
|
4131
|
|
- Dispatcher.Invoke(() =>
|
4132
|
|
- {
|
4133
|
|
- timer.Change(-1, 0);
|
4134
|
|
- timer.Dispose();
|
4135
|
|
- //End();
|
4136
|
|
- TxbTime.Text = "00:00";
|
4137
|
|
- //TxbTime.Visibility = Visibility.Hidden;
|
4138
|
|
- //ImgLZImg.Visibility = Visibility.Hidden;
|
4139
|
|
- //TxbType.Visibility = Visibility.Visible;
|
4140
|
|
- TxbType.Text = "保存中";
|
4141
|
|
- });
|
4142
|
|
- //new Thread(new ThreadStart(new Action(() =>
|
4143
|
|
- //{
|
4144
|
|
- //判断音频是否存在 判断音频临时文件夹是否存在
|
4145
|
|
- if (IsRecordAudio)
|
4146
|
|
- {
|
4147
|
|
- if (!FileToolsCommon.IsExistFile(AudioPathName))
|
4148
|
|
- {
|
4149
|
|
- Thread.Sleep(100);
|
4150
|
|
- }
|
4151
|
|
- if (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(AudioPathName) + "temp/"))
|
4152
|
|
- {
|
4153
|
|
- Thread.Sleep(100);
|
4154
|
|
- }
|
4155
|
|
- }
|
4156
|
|
- else
|
4157
|
|
- {
|
4158
|
|
- //没有录制音频
|
4159
|
|
- AudioPathName = null;
|
4160
|
|
- }
|
4161
|
|
- //合成视频
|
4162
|
|
- bool SynRes = APP.FFmpeg.SynthesisVideo(ImgPath, AudioPathName, VideoSynthesisPathName, 5, gridActWidth, gridActHeight, out string ErrMessage);
|
4163
|
|
- //}))).Start();
|
4164
|
|
- //new Thread(new ThreadStart(new Action(() =>
|
4165
|
|
- //{
|
4166
|
|
- if (!SynRes)
|
4167
|
|
- {
|
4168
|
|
- Dispatcher.Invoke(() =>
|
4169
|
|
- {
|
4170
|
|
- MessageWindow.Show("录制失败," + ErrMessage);
|
4171
|
|
- BtnRecord.IsEnabled = true;
|
4172
|
|
- BtnStop.IsEnabled = false;
|
4173
|
|
- BtnPrint.IsEnabled = false;
|
4174
|
|
- BtnScreenRecording.IsEnabled = true;
|
4175
|
|
- TxbType.Text = "准备就绪";
|
4176
|
|
- BtnRecord.Visibility = Visibility.Visible;
|
4177
|
|
- BtnRecordSuspend.Visibility = Visibility.Collapsed;
|
4178
|
|
- });
|
4179
|
|
- return;
|
4180
|
|
- }
|
4181
|
|
- Dispatcher.Invoke(() =>
|
4182
|
|
- {
|
4183
|
|
- TxbType.Text = "转码中";
|
4184
|
|
- });
|
4185
|
|
- while (!FileToolsCommon.IsExistFile(VideoSynthesisPathName))
|
|
3821
|
+ TxbTime.Text = "00:00";
|
|
3822
|
+
|
|
3823
|
+ TxbType.Text = "保存中";
|
|
3824
|
+ });
|
|
3825
|
+
|
|
3826
|
+ //判断音频是否存在 判断音频临时文件夹是否存在
|
|
3827
|
+ if (IsRecordAudio)
|
|
3828
|
+ {
|
|
3829
|
+ if (!FileToolsCommon.IsExistFile(AudioPathName))
|
4186
|
3830
|
{
|
4187
|
3831
|
Thread.Sleep(100);
|
4188
|
3832
|
}
|
4189
|
|
- while (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(VideoSynthesisPathName) + "temp/"))
|
|
3833
|
+ if (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(AudioPathName) + "temp/"))
|
4190
|
3834
|
{
|
4191
|
3835
|
Thread.Sleep(100);
|
4192
|
3836
|
}
|
4193
|
|
- FileToolsCommon.DeleteFile(ThumbnailPathName);
|
4194
|
|
- VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
4195
|
|
- Thread.Sleep(500);
|
4196
|
|
- //VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
|
4197
|
|
- VideoInfo.VideoPath = VideoSavePathName;
|
4198
|
|
- VideoInfo.ThumbnailPath = ThumbnailPathName;
|
4199
|
|
- //生成缩略图
|
4200
|
|
- bool ThuRes = APP.FFmpeg.GenerateThumbnails(VideoSynthesisPathName, ThumbnailPathName, 200, 130);
|
4201
|
|
- Thread.Sleep(500);
|
4202
|
|
-
|
4203
|
|
- APP.FFmpeg.VideoTranscode(VideoSynthesisPathName, VideoSavePathName, gridActWidth, gridActHeight);
|
4204
|
|
- VideoInfo.FileGuid = Guid.NewGuid().ToString();
|
4205
|
|
- VideoInfo.IsUpload = false;
|
4206
|
|
- VideoInfo.Uploaded = 0;
|
4207
|
|
- //VideoInfo.Savefolder = APP.UserInfo.Schoolid + "/resource";
|
4208
|
|
- if (!APP.VideoList.Exists(x => x.FileGuid == VideoInfo.FileGuid) || !APP.VideoList.Exists(x => x.VideoPath == VideoInfo.VideoPath))
|
4209
|
|
- {
|
4210
|
|
- APP.VideoList.Add(VideoInfo);
|
4211
|
|
- //保存数据
|
4212
|
|
- APP.SaveWkData();
|
4213
|
|
- }
|
4214
|
|
- IsFirstR = true;
|
4215
|
|
- Dispatcher.Invoke(() =>
|
4216
|
|
- {
|
4217
|
|
- BtnRecord.IsEnabled = true;
|
4218
|
|
- BtnStop.IsEnabled = false;
|
4219
|
|
- BtnPrint.IsEnabled = false;
|
4220
|
|
- BtnScreenRecording.IsEnabled = true;
|
4221
|
|
- TxbType.Text = "准备就绪";
|
4222
|
|
- BtnRecord.Visibility = Visibility.Visible;
|
4223
|
|
- BtnRecordSuspend.Visibility = Visibility.Collapsed;
|
4224
|
|
- });
|
4225
|
3837
|
}
|
4226
|
3838
|
else
|
4227
|
3839
|
{
|
4228
|
|
- APP.FFmpeg.SuspendFFmpeg();
|
4229
|
|
- IsStartCount = false;
|
4230
|
|
- timer.Change(-1, 0);
|
4231
|
|
- timer.Dispose();
|
4232
|
|
- IsFirstR = true;
|
4233
|
|
- IsStartCount = false;
|
4234
|
|
- //停止截图
|
4235
|
|
- while (APP.FFmpeg.myProcess != null)
|
4236
|
|
- {
|
4237
|
|
- Thread.Sleep(100);
|
4238
|
|
- }
|
4239
|
|
- Dispatcher.Invoke(() =>
|
4240
|
|
- {
|
4241
|
|
- BtnRecord.IsEnabled = true;
|
4242
|
|
- BtnStop.IsEnabled = false;
|
4243
|
|
- BtnPrint.IsEnabled = false;
|
4244
|
|
- BtnScreenRecording.IsEnabled = true;
|
4245
|
|
- MessageWindow.Show("录制时间过短,请重新录制!");
|
4246
|
|
- TxbType.Text = "准备就绪";
|
4247
|
|
- BtnRecord.Visibility = Visibility.Visible;
|
4248
|
|
- BtnRecordSuspend.Visibility = Visibility.Collapsed;
|
4249
|
|
- TxbTime.Text = "00:00";
|
4250
|
|
- //TxbTime.Visibility = Visibility.Hidden;
|
4251
|
|
- //ImgLZImg.Visibility = Visibility.Hidden;
|
4252
|
|
- });
|
|
3840
|
+ //没有录制音频
|
|
3841
|
+ AudioPathName = null;
|
4253
|
3842
|
}
|
4254
|
|
- //List<Model_Video> VideoList
|
|
3843
|
+ //合成视频
|
|
3844
|
+ Dispatcher.Invoke(() =>
|
|
3845
|
+ {
|
|
3846
|
+ TxbType.Text = "转码中";
|
|
3847
|
+ });
|
|
3848
|
+
|
|
3849
|
+ while (!FileToolsCommon.IsExistFile(VideoSynthesisPathName))
|
|
3850
|
+ {
|
|
3851
|
+ Thread.Sleep(100);
|
|
3852
|
+ }
|
|
3853
|
+
|
|
3854
|
+ FileToolsCommon.DeleteFile(ThumbnailPathName);
|
|
3855
|
+ VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
3856
|
+ VideoInfo.VideoPath = VideoSavePathName;
|
|
3857
|
+ VideoInfo.ThumbnailPath = ThumbnailPathName;
|
|
3858
|
+ Console.WriteLine("生成缩略图");
|
|
3859
|
+ //生成缩略图
|
|
3860
|
+ bool ThuRes = APP.FFmpeg.GenerateThumbnails(VideoSynthesisPathName, ThumbnailPathName, 200, 130);
|
|
3861
|
+ Thread.Sleep(500);
|
|
3862
|
+ Console.WriteLine("合并音视频 gridActWidth:"+ gridActWidth+ " gridActHeight:"+ gridActHeight);
|
|
3863
|
+
|
|
3864
|
+ APP.FFmpeg.VideoAudioMerge(VideoSynthesisPathName, AudioPathName, VideoSavePathName, gridActWidth, gridActHeight);
|
|
3865
|
+ VideoInfo.FileGuid = Guid.NewGuid().ToString();
|
|
3866
|
+ VideoInfo.IsUpload = false;
|
|
3867
|
+ VideoInfo.Uploaded = 0;
|
|
3868
|
+
|
|
3869
|
+ if (!APP.VideoList.Exists(x => x.FileGuid == VideoInfo.FileGuid) || !APP.VideoList.Exists(x => x.VideoPath == VideoInfo.VideoPath))
|
|
3870
|
+ {
|
|
3871
|
+ APP.VideoList.Add(VideoInfo);
|
|
3872
|
+ //保存数据
|
|
3873
|
+ APP.SaveWkData();
|
|
3874
|
+ }
|
|
3875
|
+ IsFirstR = true;
|
|
3876
|
+ Dispatcher.Invoke(() =>
|
|
3877
|
+ {
|
|
3878
|
+ BtnRecord.IsEnabled = true;
|
|
3879
|
+ BtnStop.IsEnabled = false;
|
|
3880
|
+ BtnPrint.IsEnabled = false;
|
|
3881
|
+ BtnScreenRecording.IsEnabled = true;
|
|
3882
|
+ TxbType.Text = "准备就绪";
|
|
3883
|
+ BtnRecord.Visibility = Visibility.Visible;
|
|
3884
|
+ BtnRecordSuspend.Visibility = Visibility.Collapsed;
|
|
3885
|
+ });
|
4255
|
3886
|
}
|
4256
|
3887
|
catch (Exception ex)
|
4257
|
3888
|
{
|