Browse Source

解决有时声音画面不同步的问题

解决偶发视频无法合并闪退问题
master
张剑 2 years ago
parent
commit
880ecc0f86

+ 2
- 2
XHWK.WKTool/App.config View File

@@ -9,8 +9,8 @@
9 9
     <!--参数是否加密 0不加密 1加密-->
10 10
     <add key="IsParameterEncryption" value="0" />
11 11
     <!--版本号-->
12
-    <add key="VersionCode" value="111" />
13
-    <add key="VersionName" value="3.2.2" />
12
+    <add key="VersionCode" value="112" />
13
+    <add key="VersionName" value="3.2.3" />
14 14
     <!--皮肤样式 0白 1蓝 2黑色 -->
15 15
     <add key="SkinStyle" value="0" />
16 16
     <!--是否输出视频记录日志:0否-->

+ 3
- 3
XHWK.WKTool/App.xaml.cs View File

@@ -532,7 +532,7 @@ namespace XHWK.WKTool
532 532
                     WKDataList = new List<Model_WKData>();
533 533
                 }
534 534
                 WKDataList.Add(WKData);
535
-                //string WkDateXmlStr = XmlUtilHelper.Serializer(typeof(Model_WKData), WKData);
535
+
536 536
                 string WkDateXmlStr = XmlUtilHelper.XmlSerialize(WKDataList);
537 537
                 string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/");
538 538
                 FileToolsCommon.CreateDirectory(SavePath);
@@ -597,7 +597,7 @@ namespace XHWK.WKTool
597 597
                     return;
598 598
                 }
599 599
                 FileToolsCommon.CreateDirectory(WKData.WkPath);
600
-                string SavePath = WKData.WkPath + "PageData.d";
600
+                string SavePath = WKData.WkPath + "PageData.xml";
601 601
                 FileToolsCommon.DeleteFile(SavePath);
602 602
                 string PageDataXmlStr = XmlUtilHelper.XmlSerialize(PageDrawList);
603 603
                 FileToolsCommon.WriteText(SavePath, PageDataXmlStr);
@@ -616,7 +616,7 @@ namespace XHWK.WKTool
616 616
             try
617 617
             {
618 618
                 PageDrawList = new List<Model_DrawData>();
619
-                string SavePath = WKData.WkPath + "PageData.d";
619
+                string SavePath = WKData.WkPath + "PageData.xml";
620 620
                 if (FileToolsCommon.IsExistFile(SavePath))
621 621
                 {
622 622
                     string PageDataXmlStr = FileToolsCommon.FileToString(SavePath);

+ 1
- 1
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs View File

@@ -277,7 +277,7 @@ namespace XHWK.WKTool
277 277
                         //创建文件夹
278 278
                         FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
279 279
                         FileToolsCommon.DeleteDirectory(wkpath + "temp");
280
-                        FileToolsCommon.DeleteDirectory(wkpath + "temprs");
280
+                        FileToolsCommon.DeleteDirectory(wkpath + "_temppath");
281 281
                     }
282 282
                     catch (Exception ex)
283 283
                     {

+ 2
- 5
XHWK.WKTool/MainWindow.xaml.cs View File

@@ -424,9 +424,6 @@ namespace XHWK.WKTool
424 424
                 if (Ofd.SelectedPath != "")
425 425
                 {
426 426
                     txbStoragePath.Content = Ofd.SelectedPath;
427
-                    //string ApplicationData = ZConfig.dataPath + "fileStorageAddress.txt";
428
-                    //string temp = ofd.SelectedPath;
429
-                    //System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
430 427
                 }
431 428
             }
432 429
         }
@@ -440,7 +437,7 @@ namespace XHWK.WKTool
440 437
         /// </param>
441 438
         private void btnOpen_Click(object sender, RoutedEventArgs e)
442 439
         {
443
-            System.Diagnostics.Process.Start(APP.WKData.WkPath);
440
+            Process.Start(APP.WKData.WkPath);
444 441
         }
445 442
 
446 443
         /// <summary>
@@ -2773,7 +2770,7 @@ namespace XHWK.WKTool
2773 2770
 
2774 2771
             new Thread(new ThreadStart(new Action(() =>
2775 2772
             {
2776
-                while (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath + "temprs/"))
2773
+                while (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath + "_temppath/"))
2777 2774
                 {
2778 2775
                     Thread.Sleep(100);
2779 2776
                 }

+ 121
- 103
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs View File

@@ -6,6 +6,7 @@ using System;
6 6
 using System.Drawing;
7 7
 using System.IO;
8 8
 using System.Threading;
9
+using System.Threading.Tasks;
9 10
 using System.Windows;
10 11
 using System.Windows.Forms;
11 12
 using System.Windows.Ink;
@@ -45,6 +46,8 @@ namespace XHWK.WKTool
45 46
         /// </summary>
46 47
         private string TempAudioPathName2;
47 48
 
49
+        private string temppath = APP.WKData.WkPath + "_temppath/";
50
+
48 51
         /// <summary>
49 52
         /// 视频信息
50 53
         /// </summary>
@@ -196,11 +199,12 @@ namespace XHWK.WKTool
196 199
         /// <summary>
197 200
         /// 设置录屏文件地址
198 201
         /// </summary>
199
-        private void SetUpVideoPathName()
202
+        private void SetSavePath()
200 203
         {
201 204
             string fileType = ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
202 205
             FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
203
-            FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temprs/");
206
+            FileToolsCommon.DeleteDirectory(temppath);
207
+            FileToolsCommon.CreateDirectory(temppath);
204 208
             VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + fileType;
205 209
             int num = 1;
206 210
             while (FileToolsCommon.IsExistFile(VideoSavePathName))
@@ -209,9 +213,9 @@ namespace XHWK.WKTool
209 213
                 VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏_" + num + "." + fileType;
210 214
             }
211 215
 
212
-            TempVideoPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏_" + num + ".avi";
213
-            TempAudioPathName1 = APP.WKData.WkPath + APP.WKData.WkName + "_录屏_" + num + "_1.mp3";
214
-            TempAudioPathName2 = APP.WKData.WkPath + APP.WKData.WkName + "_录屏_" + num + "_2.mp3";
216
+            TempVideoPathName = temppath + "_录屏_" + num + ".avi";
217
+            TempAudioPathName1 = temppath + "_麦克风_" + num + "_1.mp3";
218
+            TempAudioPathName2 = temppath + "_扬声器_" + num + "_2.mp3";
215 219
         }
216 220
 
217 221
         /// <summary>
@@ -226,7 +230,7 @@ namespace XHWK.WKTool
226 230
         private ZAudioRecordHelper helper2 = null;
227 231
 
228 232
         //桌面录制
229
-        private ZVideoRecordHelper helper3 = null;
233
+        private ZVideoRecordHelper helper0 = null;
230 234
 
231 235
         public IntPtr winHandle;// 当前窗体指针
232 236
 
@@ -235,7 +239,7 @@ namespace XHWK.WKTool
235 239
         /// </summary>
236 240
         /// <param name="sender"></param>
237 241
         /// <param name="e"></param>
238
-        private void BtnRecordingScreen_Click(object sender, RoutedEventArgs e)
242
+        private async void BtnRecordingScreen_Click(object sender, RoutedEventArgs e)
239 243
         {
240 244
             #region 防止连击
241 245
 
@@ -280,7 +284,7 @@ namespace XHWK.WKTool
280 284
                     VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType")),
281 285
                     WkType = Enum_WKVidetype.RecordingScreen
282 286
                 };
283
-                SetUpVideoPathName();
287
+                SetSavePath();
284 288
 
285 289
                 if (APP.W_CountdownWindow == null)
286 290
                 {
@@ -322,45 +326,44 @@ namespace XHWK.WKTool
322 326
 
323 327
                 #endregion 隐藏工具栏
324 328
 
325
-                helper1 = new ZAudioRecordHelper(TempAudioPathName1, ZAudioRecordHelper.RecordType.microphone);
326
-                helper2 = new ZAudioRecordHelper(TempAudioPathName2, ZAudioRecordHelper.RecordType.loudspeaker);
327
-
328
-                winHandle = new WindowInteropHelper(this).Handle;
329
-                var curScreen = Screen.FromHandle(winHandle);
330
-                int RecordWidth = curScreen.Bounds.Width;
331
-                int RecordHeight = curScreen.Bounds.Height;
332
-                helper3 = new ZVideoRecordHelper(TempVideoPathName, RecordWidth, RecordHeight);
333
-
334
-                new Thread(o =>
329
+                try
335 330
                 {
336
-                    Thread.Sleep(3000);
337
-                    Dispatcher.Invoke(() =>
338
-                    {
339
-                        _state = State.Start;
340
-                        helper1.StartRecordAudio();
341
-                        helper2.StartRecordAudio();
342
-                        helper3.StartRecordVideo();
343
-                    });
344
-
345
-                    Thread.Sleep(1000);
346
-
347
-                    Dispatcher.Invoke(() =>
348
-                    {
349
-                        k_hook.Start();//安装键盘钩子
350
-                    });
351
-                })
352
-                { IsBackground = true }.Start();
331
+                    // 视频
332
+                    winHandle = new WindowInteropHelper(this).Handle;
333
+                    var curScreen = Screen.FromHandle(winHandle);
334
+                    int RecordWidth = curScreen.Bounds.Width;
335
+                    int RecordHeight = curScreen.Bounds.Height;
336
+                    helper0 = new ZVideoRecordHelper(TempVideoPathName, RecordWidth, RecordHeight);
337
+
338
+                    // 麦克风
339
+                    helper1 = new ZAudioRecordHelper(TempAudioPathName1, ZAudioRecordHelper.RecordType.microphone);
340
+                    // 扬声器
341
+                    helper2 = new ZAudioRecordHelper(TempAudioPathName2, ZAudioRecordHelper.RecordType.loudspeaker);
342
+
343
+                    await Task.Delay(3000);
344
+                    APP.W_CountdownWindow.Hide();
345
+                    await Task.Delay(100);
346
+                    _state = State.Start;
347
+                    helper1.StartRecordAudio();
348
+                    helper2.StartRecordAudio();
349
+                    helper0.StartRecordVideo();
350
+                    k_hook.Start();//安装键盘钩子
351
+                }
352
+                catch (Exception)
353
+                {
354
+                    ExitByErr();
355
+                }
353 356
 
357
+                Console.WriteLine("TempVideoPathName:" + TempVideoPathName);
354 358
                 Console.WriteLine("TempAudioPathName1:" + TempAudioPathName1);
355 359
                 Console.WriteLine("TempAudioPathName2:" + TempAudioPathName2);
356
-                Console.WriteLine("TempVideoPathName:" + TempVideoPathName);
357 360
             }
358 361
             else if (_state == State.Start)
359 362
             {
360 363
                 _state = State.Pause;
361 364
                 helper1.PauseRecordAudio();
362 365
                 helper2.PauseRecordAudio();
363
-                helper3.PauseRecordVideo();
366
+                helper0.PauseRecordVideo();
364 367
                 BtnRecordingScreen.Visibility = Visibility.Visible;
365 368
                 BtnRecordingScreenPause.Visibility = Visibility.Collapsed;
366 369
             }
@@ -369,12 +372,49 @@ namespace XHWK.WKTool
369 372
                 _state = State.Start;
370 373
                 helper1.ResumeRecordAudio();
371 374
                 helper2.ResumeRecordAudio();
372
-                helper3.ResumeRecordVideo();
375
+                helper0.ResumeRecordVideo();
373 376
                 BtnRecordingScreen.Visibility = Visibility.Collapsed;
374 377
                 BtnRecordingScreenPause.Visibility = Visibility.Visible;
375 378
             }
376 379
         }
377 380
 
381
+        private void ExitByErr()
382
+        {
383
+            BtnRecordingScreen.ToolTip = "开始";
384
+            k_hook.Stop();
385
+            TxbTime.Content = "00:00";
386
+
387
+            if (APP.W_PracticeWindow != null)
388
+            {
389
+                if (APP.W_PracticeWindow.Visibility == Visibility.Visible)
390
+                {
391
+                    Owner = null;
392
+                    APP.W_PracticeWindow.ReturnPractice();
393
+                }
394
+            }
395
+
396
+            if (APP.W_XHMicroLessonSystemWindow == null)
397
+            {
398
+                APP.W_XHMicroLessonSystemWindow = new MainWindow();
399
+            }
400
+            APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
401
+
402
+            APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
403
+            APP.W_XHMicroLessonSystemWindow.Show();
404
+            End();
405
+            if (t != null)
406
+            {
407
+                t.Stop();
408
+                t = null;
409
+            }
410
+            helper0.StopRecordVideo();
411
+            helper1.StopRecordAudio();
412
+            helper2.StopRecordAudio();
413
+            FileToolsCommon.DeleteDirectory(temppath);
414
+            Click_stopRecordingScreen();
415
+            Hide();
416
+        }
417
+
378 418
         /// <summary>
379 419
         /// 停止录像
380 420
         /// </summary>
@@ -418,7 +458,7 @@ namespace XHWK.WKTool
418 458
                 APP.W_XHMicroLessonSystemWindow = new MainWindow();
419 459
             }
420 460
             APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
421
-            //APP.W_XHMicroLessonSystemWindow.InitPen();
461
+
422 462
             APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
423 463
             APP.W_XHMicroLessonSystemWindow.Show();
424 464
 
@@ -428,57 +468,61 @@ namespace XHWK.WKTool
428 468
                 t.Stop();
429 469
                 t = null;
430 470
                 Console.WriteLine("停止录制");
471
+                helper0.StopRecordVideo();
431 472
                 helper1.StopRecordAudio();
432 473
                 helper2.StopRecordAudio();
433
-                helper3.StopRecordVideo();
434 474
 
435 475
                 new Thread(new ThreadStart(new Action(() =>
436 476
                 {
437 477
                     FFMpegConverter ffMpeg = new FFMpegConverter();
438 478
 
439 479
                     FFMpegInput[] input = new FFMpegInput[] {
440
-                    new FFMpegInput(TempVideoPathName),
441
-                    new FFMpegInput(TempAudioPathName1),
442
-                    new FFMpegInput(TempAudioPathName1),
443
-                };
480
+                        new FFMpegInput(TempVideoPathName),
481
+                        new FFMpegInput(TempAudioPathName1),
482
+                        new FFMpegInput(TempAudioPathName2),
483
+                    };
444 484
 
445
-                    // 多路音频混音
446
-                    ffMpeg.ConvertMedia(
447
-                        input,
448
-                        VideoSavePathName,
449
-                        "mp4",
450
-                        new OutputSettings()
485
+                    try
486
+                    {
487
+                        // 多路音频混音
488
+                        ffMpeg.ConvertMedia(
489
+                            input,
490
+                            VideoSavePathName,
491
+                            "mp4",
492
+                            new OutputSettings()
493
+                            {
494
+                                CustomOutputArgs = "-filter_complex amix=inputs=2:duration=first:dropout_transition=2"
495
+                            }
496
+                        );
497
+                        //生成缩略图
498
+                        string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
499
+                        FileToolsCommon.CreateDirectory(ThumbnailPath);
500
+                        //缩略图存储位置
501
+                        string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
502
+
503
+                        VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
504
+                        VideoInfo.VideoPath = VideoSavePathName;
505
+                        VideoInfo.ThumbnailPath = ThumbnailPathName;
506
+                        APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName, 200, 130);
507
+                        VideoInfo.FileGuid = Guid.NewGuid().ToString();
508
+                        VideoInfo.IsUpload = false;
509
+                        VideoInfo.Uploaded = 0;
510
+                        if (!APP.VideoList.Exists(x => x.FileGuid == VideoInfo.FileGuid) || !APP.VideoList.Exists(x => x.VideoPath == VideoInfo.VideoPath))
451 511
                         {
452
-                            CustomOutputArgs = "-filter_complex amix=inputs=2:duration=first:dropout_transition=2"
512
+                            APP.VideoList.Add(VideoInfo);
513
+                            //保存数据
514
+                            APP.SaveWkData();
453 515
                         }
454
-                    );
455
-                    //生成缩略图
456
-                    string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
457
-                    FileToolsCommon.CreateDirectory(ThumbnailPath);
458
-                    //缩略图存储位置
459
-                    string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
460
-
461
-                    FileToolsCommon.DeleteFile(ThumbnailPathName);
462
-                    VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
463
-                    VideoInfo.VideoPath = VideoSavePathName;
464
-                    VideoInfo.ThumbnailPath = ThumbnailPathName;
465
-                    APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName, 200, 130);
466
-                    VideoInfo.FileGuid = Guid.NewGuid().ToString();
467
-                    VideoInfo.IsUpload = false;
468
-                    VideoInfo.Uploaded = 0;
469
-                    if (!APP.VideoList.Exists(x => x.FileGuid == VideoInfo.FileGuid) || !APP.VideoList.Exists(x => x.VideoPath == VideoInfo.VideoPath))
516
+                    }
517
+                    catch (Exception ex)
470 518
                     {
471
-                        APP.VideoList.Add(VideoInfo);
472
-                        //保存数据
473
-                        APP.SaveWkData();
519
+                        LogHelper.WriteErrLog("录屏保存" + ex.Message, ex);
474 520
                     }
475 521
 
476
-                    FileToolsCommon.DeleteFile(TempAudioPathName1);
477
-                    FileToolsCommon.DeleteFile(TempAudioPathName2);
478
-                    FileToolsCommon.DeleteFile(TempVideoPathName);
522
+                    FileToolsCommon.DeleteDirectory(temppath);
479 523
                 }))).Start();
480
-                Click_stopRecordingScreen();
481 524
             }
525
+            Click_stopRecordingScreen();
482 526
             Hide();
483 527
 
484 528
             SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
@@ -525,17 +569,11 @@ namespace XHWK.WKTool
525 569
                 #endregion 防止连击
526 570
 
527 571
                 string time = GetTimeStamp();
528
-                string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
529
-                if (!Directory.Exists(tempPath))
530
-                {
531
-                    Directory.CreateDirectory(tempPath);
532
-                }
572
+
533 573
                 try
534 574
                 {
535 575
                     Dispatcher.Invoke(() =>
536 576
                     {
537
-                        //borOne.Background = new SolidColorBrush(Colors.LightSkyBlue);
538
-                        //borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
539 577
                         if (APP.W_PracticeWindow == null)
540 578
                         {
541 579
                             APP.W_PracticeWindow = new PracticeWindow
@@ -545,10 +583,8 @@ namespace XHWK.WKTool
545 583
                                 Left = 0,
546 584
                                 Top = 0
547 585
                             };
548
-                            //practiceWin.Owner = this;
549 586
                         }
550
-                        //APP.W_PracticeWindow.InitPen();
551
-                        //APP.W_PracticeWindow.InitTQLPPen();
587
+
552 588
                         APP.W_PracticeWindow.Initialize();// imagePath);
553 589
                         flg = 11;
554 590
                         APP.W_PracticeWindow.Blue();
@@ -566,7 +602,6 @@ namespace XHWK.WKTool
566 602
                         Thread.Sleep(500);
567 603
                         Dispatcher.Invoke(() =>
568 604
                         {
569
-                            //Owner = APP.W_PracticeWindow;
570 605
                             Topmost = true;
571 606
                         });
572 607
                     }))).Start();
@@ -613,18 +648,6 @@ namespace XHWK.WKTool
613 648
             BtnPenBlue_CL.Visibility = Visibility.Visible;
614 649
             BtnPenRed_CL.Visibility = Visibility.Collapsed;
615 650
             string time = GetTimeStamp();
616
-            string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
617
-            if (!Directory.Exists(tempPath))
618
-            {
619
-                Directory.CreateDirectory(tempPath);
620
-            }
621
-
622
-            #region 录屏批注取消画笔
623
-
624
-            //string imagePath = Path.Combine(tempPath, time + ".jpg");
625
-            //ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
626
-
627
-            #endregion 录屏批注取消画笔
628 651
 
629 652
             try
630 653
             {
@@ -816,15 +839,10 @@ namespace XHWK.WKTool
816 839
             BtnPenBlue_CL.Visibility = Visibility.Collapsed;
817 840
             BtnPenRed_CL.Visibility = Visibility.Visible;
818 841
             string time = GetTimeStamp();
819
-            string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
820
-            if (!Directory.Exists(tempPath))
821
-            {
822
-                Directory.CreateDirectory(tempPath);
823
-            }
824 842
 
825 843
             #region 录屏批注取消画笔
826 844
 
827
-            string imagePath = Path.Combine(tempPath, time + ".jpg");
845
+            string imagePath = Path.Combine(temppath, time + ".jpg");
828 846
             ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
829 847
 
830 848
             #endregion 录屏批注取消画笔

+ 23
- 19
XHWK.WKTool/Utils/ZAudioRecordHelper.cs View File

@@ -22,31 +22,26 @@ namespace XHWK.WKTool.Utils
22 22
         }
23 23
 
24 24
         //录制的类型
25
-        RecordType _t = RecordType.microphone;
25
+        private RecordType _t = RecordType.microphone;
26 26
 
27
-        RecordState _state = RecordState.stop;
27
+        private RecordState _state = RecordState.stop;
28 28
 
29 29
         //录制麦克风的声音
30
-        WaveInEvent waveIn = null; //new WaveInEvent();
31
-                                   //录制扬声器的声音
32
-        WasapiLoopbackCapture capture = null; //new WasapiLoopbackCapture();
33
-                                              //生成音频文件的对象
34
-        WaveFileWriter writer = null;
30
+        private WaveInEvent waveIn = null; //new WaveInEvent();
35 31
 
36
-        string audioFile = "";
32
+        //录制扬声器的声音
33
+        private WasapiLoopbackCapture capture = null; //new WasapiLoopbackCapture();
34
+
35
+        //生成音频文件的对象
36
+        private WaveFileWriter writer = null;
37
+
38
+        private string audioFile = "";
37 39
 
38 40
         public ZAudioRecordHelper(string filePath, RecordType type)
39 41
         {
40 42
             _t = type;
41 43
             audioFile = filePath;
42
-        }
43
-
44
-        /// <summary>
45
-        /// 开始录制
46
-        /// </summary>
47
-        public void StartRecordAudio()
48
-        {
49
-            _state = RecordState.start;
44
+            _state = RecordState.pause;
50 45
             try
51 46
             {
52 47
                 if (_t == RecordType.microphone)
@@ -94,11 +89,19 @@ namespace XHWK.WKTool.Utils
94 89
                     capture.StartRecording();
95 90
                 }
96 91
             }
97
-            catch (Exception ex)
92
+            catch (Exception)
98 93
             {
99 94
             }
100 95
         }
101 96
 
97
+        /// <summary>
98
+        /// 开始录制
99
+        /// </summary>
100
+        public void StartRecordAudio()
101
+        {
102
+            _state = RecordState.start;
103
+        }
104
+
102 105
         /// <summary>
103 106
         /// 结束录制
104 107
         /// </summary>
@@ -210,7 +213,8 @@ namespace XHWK.WKTool.Utils
210 213
             }
211 214
             catch (Exception ex)
212 215
             {
213
-                if (mWriter != null) {
216
+                if (mWriter != null)
217
+                {
214 218
                     mWriter.Dispose();
215 219
                     mWriter = null;
216 220
                 }
@@ -220,4 +224,4 @@ namespace XHWK.WKTool.Utils
220 224
             return true;
221 225
         }
222 226
     }
223
-}
227
+}

+ 21
- 20
XHWK.WKTool/Utils/ZVideoRecordHelper.cs View File

@@ -8,7 +8,6 @@ namespace XHWK.WKTool.Utils
8 8
 {
9 9
     public class ZVideoRecordHelper
10 10
     {
11
-
12 11
         public enum RecordState
13 12
         {
14 13
             stop = 0,
@@ -16,21 +15,24 @@ namespace XHWK.WKTool.Utils
16 15
             pause = 2
17 16
         }
18 17
 
19
-        RecordState _state = RecordState.stop;
18
+        private RecordState _state = RecordState.stop;
19
+
20
+        private string _filePath = "";
21
+        private int _width = 0;
22
+        private int _height = 0;
20 23
 
21
-        string _filePath = "";
22
-        int _width = 0;
23
-        int _height = 0;
24 24
         //录制帧率
25
-        int _rate = 5;
25
+        private int _rate = 5;
26
+
26 27
         //录制质量
27
-        int _quality = 8;
28
-        bool _captureMouse = false;
28
+        private int _quality = 8;
29
+
30
+        private bool _captureMouse = false;
29 31
 
30 32
         private VideoFileWriter videoWriter = new VideoFileWriter();//视频写入
31 33
         private ScreenCaptureStream videoStreamer;//视频捕获
32 34
 
33
-        public ZVideoRecordHelper(string filePath, int width,int height,int rate = 5,int quality=8, bool captureMouse = false)
35
+        public ZVideoRecordHelper(string filePath, int width, int height, int rate = 5, int quality = 8, bool captureMouse = false)
34 36
         {
35 37
             _filePath = filePath;
36 38
             _width = width / 2 * 2;
@@ -38,14 +40,8 @@ namespace XHWK.WKTool.Utils
38 40
             _rate = rate;
39 41
             _quality = quality;
40 42
             _captureMouse = captureMouse;
41
-        }
42 43
 
43
-        /// <summary>
44
-        /// 开始录制
45
-        /// </summary>
46
-        public bool StartRecordVideo()
47
-        {
48
-            _state = RecordState.start;
44
+            _state = RecordState.pause;
49 45
             try
50 46
             {
51 47
                 // 打开写入
@@ -61,20 +57,25 @@ namespace XHWK.WKTool.Utils
61 57
                     );
62 58
                 }
63 59
 
64
-                System.Drawing.Rectangle rec = new System.Drawing.Rectangle(0,0,_width,_height);
60
+                System.Drawing.Rectangle rec = new System.Drawing.Rectangle(0, 0, _width, _height);
65 61
                 videoStreamer = new ScreenCaptureStream(rec, 1000 / _rate);//帧间隔需要和帧率关联,不然录的10秒视频文件不是10s
66 62
                 videoStreamer.NewFrame += VideoNewFrame;
67 63
                 videoStreamer.Start();
68 64
             }
69 65
             catch (Exception ex)
70 66
             {
71
-                return false;
72 67
             }
68
+        }
73 69
 
70
+        /// <summary>
71
+        /// 开始录制
72
+        /// </summary>
73
+        public bool StartRecordVideo()
74
+        {
75
+            _state = RecordState.start;
74 76
             return true;
75 77
         }
76 78
 
77
-
78 79
         [DllImport("user32.dll")]
79 80
         private static extern bool GetCursorInfo(out CURSORINFO pci);
80 81
 
@@ -154,4 +155,4 @@ namespace XHWK.WKTool.Utils
154 155
             _state = RecordState.start;
155 156
         }
156 157
     }
157
-}
158
+}

+ 4
- 4
XHWK.WKTool/system/FFMpeg.cs View File

@@ -594,7 +594,7 @@ namespace Common.system
594 594
             }
595 595
             else
596 596
             {
597
-                if (!FileToolsCommon.IsExistFile(Path + "temprs/filelist.d"))
597
+                if (!FileToolsCommon.IsExistFile(Path + "_temppath/filelist.d"))
598 598
                 {
599 599
                     return;
600 600
                 }
@@ -611,7 +611,7 @@ namespace Common.system
611 611
             }
612 612
             else
613 613
             {
614
-                myProcess.StartInfo.Arguments = "-f concat  -safe 0 -i " + Path + "temprs/filelist.d -c copy " + FilePath;
614
+                myProcess.StartInfo.Arguments = "-f concat  -safe 0 -i " + Path + "_temppath/filelist.d -c copy " + FilePath;
615 615
             }
616 616
             if (OutputVideoLog)
617 617
             {
@@ -654,7 +654,7 @@ namespace Common.system
654 654
             }
655 655
             else
656 656
             {
657
-                FileToolsCommon.DeleteDirectory(Path + "temprs/");
657
+                FileToolsCommon.DeleteDirectory(Path + "_temppath/");
658 658
             }
659 659
         }
660 660
 
@@ -754,7 +754,7 @@ namespace Common.system
754 754
             string Path = FileToolsCommon.GetDirectoryName(FilePath);
755 755
             //Path.GetFileName(FilePath);//获取文件名
756 756
             string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
757
-            string tempFilePath = Path + "temprs/";
757
+            string tempFilePath = Path + "_temppath/";
758 758
             //创建临时目录
759 759
             FileToolsCommon.CreateDirectory(tempFilePath);
760 760
             //创建记录文件

+ 1
- 1
星火微课/星火微课-正式.iss View File

@@ -3,7 +3,7 @@
3 3
 
4 4
 #define MyAppName "星火微课"  
5 5
 #define MyAppDir "xhwk"
6
-#define MyAppVersion "3.2.2"
6
+#define MyAppVersion "3.2.3"
7 7
 #define MyAppPublisher "河南星火燎原软件科技有限公司"
8 8
 #define MyAppURL "http://www.xhkjedu.com/"
9 9
 #define MySourcePath "D:\Project\CSharp\xhwkclient\XHWK.WKTool\bin\x86\Debug\"

Loading…
Cancel
Save