Browse Source

Merge remote-tracking branch 'origin/zyy' into zhangxueyang

tags/录制修改前
zhangxueyang 4 years ago
parent
commit
fae26e576d

+ 132
- 31
Common/system/FFMpeg.cs View File

17
     /// </summary>
17
     /// </summary>
18
     public class FFMpeg
18
     public class FFMpeg
19
     {
19
     {
20
-        Process myProcess = null;
20
+        public Process myProcess = null;
21
         /// <summary>
21
         /// <summary>
22
         /// ffmpeg输出日志文件地址  每个文件2MB左右
22
         /// ffmpeg输出日志文件地址  每个文件2MB左右
23
         /// </summary>
23
         /// </summary>
28
         /// <param name="FilePath">文件存储路径</param>
28
         /// <param name="FilePath">文件存储路径</param>
29
         public void StartRecordingVideo(string FilePath)
29
         public void StartRecordingVideo(string FilePath)
30
         {
30
         {
31
+            while (myProcess != null)
32
+            {
33
+                Thread.Sleep(100);
34
+            }
31
             //路径
35
             //路径
32
-            string Path = FileToolsCommon.GetDirectoryName(FilePath) + @"\";
36
+            string Path = FileToolsCommon.GetDirectoryName(FilePath);
33
             string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
37
             string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
34
             //文件保存路径
38
             //文件保存路径
35
             string PathName = GetFilePathName(FilePath);
39
             string PathName = GetFilePathName(FilePath);
36
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
40
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
37
-            Debug.WriteLine(KillProcessArray.Length.ToString());
38
             foreach (var KillProcess in KillProcessArray)
41
             foreach (var KillProcess in KillProcessArray)
39
             {
42
             {
40
                 KillProcess.Kill();
43
                 KillProcess.Kill();
95
         /// <param name="Mp3Path">MP3音频位置</param>
98
         /// <param name="Mp3Path">MP3音频位置</param>
96
         public void StartRecordingAudio(string Mp3Path)
99
         public void StartRecordingAudio(string Mp3Path)
97
         {
100
         {
101
+            while (myProcess != null)
102
+            {
103
+                Thread.Sleep(100);
104
+            }
105
+            //文件保存路径
106
+            string PathName = GetFilePathName(Mp3Path);
98
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
107
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
99
-            Debug.WriteLine(KillProcessArray.Length.ToString());
100
             foreach (var KillProcess in KillProcessArray)
108
             foreach (var KillProcess in KillProcessArray)
101
             {
109
             {
102
                 KillProcess.Kill();
110
                 KillProcess.Kill();
107
             string MicrophoneName = GetMicrophone();
115
             string MicrophoneName = GetMicrophone();
108
             if (string.IsNullOrWhiteSpace(MicrophoneName))
116
             if (string.IsNullOrWhiteSpace(MicrophoneName))
109
             {
117
             {
110
-                myProcess.StartInfo.Arguments = "-f dshow -i audio=\"virtual-audio-capturer\" " + Mp3Path;
118
+                myProcess.StartInfo.Arguments = "-f dshow -i audio=\"virtual-audio-capturer\" " + PathName;
111
             }
119
             }
112
             else
120
             else
113
             {
121
             {
114
                 myProcess.StartInfo.Arguments = "-f dshow -i audio=\"virtual-audio-capturer\"  -f dshow -i audio=\"" +
122
                 myProcess.StartInfo.Arguments = "-f dshow -i audio=\"virtual-audio-capturer\"  -f dshow -i audio=\"" +
115
-                        MicrophoneName + "\" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 " + Mp3Path;
123
+                        MicrophoneName + "\" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 " + PathName;
116
             }
124
             }
117
             myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
125
             myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
118
             myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
126
             myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
127
         /// <summary>
135
         /// <summary>
128
         /// 暂停录制
136
         /// 暂停录制
129
         /// </summary>
137
         /// </summary>
130
-        public void SuspendFFmpeg()
138
+        public bool SuspendFFmpeg()
131
         {
139
         {
132
-            if (myProcess == null)
133
-                return;
134
-            myProcess.StandardInput.WriteLine("q");//在这个进程的控制台中模拟输入q,用于暂停录制
135
-            myProcess.Close();//关闭进程
136
-            myProcess.Dispose();//释放资源
140
+            if (myProcess != null)
141
+            {
142
+                myProcess.StandardInput.WriteLine("q");//在这个进程的控制台中模拟输入q,用于暂停录制
143
+                myProcess.Close();//关闭进程
144
+                myProcess.Dispose();//释放资源
145
+            }
146
+            #region 进程是否已经释放
147
+            bool IsRunning = true;
148
+            while (IsRunning)
149
+            {
150
+                IsRunning = false;
151
+                Process[] ProcessArray = Process.GetProcessesByName("ffmpeg");
152
+                foreach (var KillProcess in ProcessArray)
153
+                {
154
+                    IsRunning = true;
155
+                    Thread.Sleep(100);
156
+                }
157
+            }
158
+            #endregion
137
             myProcess = null;
159
             myProcess = null;
160
+            return true;
138
             //myProcess.Kill();
161
             //myProcess.Kill();
139
         }
162
         }
140
 
163
 
142
         /// 停止录制并合成文件
165
         /// 停止录制并合成文件
143
         /// </summary>
166
         /// </summary>
144
         /// <param name="FilePath">文件存储路径 必须与开始时的路径完全一致</param>
167
         /// <param name="FilePath">文件存储路径 必须与开始时的路径完全一致</param>
145
-        public void StopFFmpeg(string FilePath)
168
+        public bool StopFFmpeg(string FilePath)
146
         {
169
         {
147
             //文件完整路径
170
             //文件完整路径
148
-            if (myProcess == null)
149
-                return;
150
-            myProcess.StandardInput.WriteLine("q");//在这个进程的控制台中模拟输入q,用于暂停录制
151
-            myProcess.Close();//关闭进程
152
-            myProcess.Dispose();//释放资源
171
+            if (myProcess != null)
172
+            {
173
+                myProcess.StandardInput.WriteLine("q");//在这个进程的控制台中模拟输入q,用于暂停录制
174
+                myProcess.Close();//关闭进程
175
+                myProcess.Dispose();//释放资源
176
+            }
177
+            #region 进程是否已经释放
178
+            bool IsRunning = true;
179
+            while (IsRunning)
180
+            {
181
+                IsRunning = false;
182
+                Process[] ProcessArray = Process.GetProcessesByName("ffmpeg");
183
+                foreach (var KillProcess in ProcessArray)
184
+                {
185
+                    IsRunning = true;
186
+                    Thread.Sleep(100);
187
+                }
188
+            }
189
+            #endregion
153
             myProcess = null;
190
             myProcess = null;
154
             Thread t1 = new Thread(MergeVideoOrAudio);
191
             Thread t1 = new Thread(MergeVideoOrAudio);
155
             t1.Start(FilePath);
192
             t1.Start(FilePath);
193
+            return true;
156
             //文件合成
194
             //文件合成
157
         }
195
         }
158
 
196
 
167
         /// <param name="VideoHeight">视频高度</param>
205
         /// <param name="VideoHeight">视频高度</param>
168
         public void SynthesisVideo(string ImageListPath, string Mp3Path, string VideoSavePath, int Frequency, int VideoWidth, int VideoHeight)
206
         public void SynthesisVideo(string ImageListPath, string Mp3Path, string VideoSavePath, int Frequency, int VideoWidth, int VideoHeight)
169
         {
207
         {
170
-            Thread thread = new Thread(delegate ()
208
+            new Thread(new ThreadStart(new Action(() =>
171
             {
209
             {
172
-                //// 允许不同线程间的调用
173
-                //Control.CheckForIllegalCrossThreadCalls = false;
174
                 Thread.Sleep(500);
210
                 Thread.Sleep(500);
211
+                while (myProcess != null)
212
+                {
213
+                    Thread.Sleep(100);
214
+                }
175
                 string Extension = FileToolsCommon.GetIOExtension(VideoSavePath);//扩展名
215
                 string Extension = FileToolsCommon.GetIOExtension(VideoSavePath);//扩展名
176
                 Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
216
                 Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
177
-                Debug.WriteLine(KillProcessArray.Length.ToString());
217
+                //Debug.WriteLine(KillProcessArray.Length.ToString());
178
                 foreach (var KillProcess in KillProcessArray)
218
                 foreach (var KillProcess in KillProcessArray)
179
                 {
219
                 {
180
                     KillProcess.Kill();
220
                     KillProcess.Kill();
220
                 myProcess.WaitForExit();           //阻塞等待进程结束
260
                 myProcess.WaitForExit();           //阻塞等待进程结束
221
                 myProcess.Close();                 //关闭进程
261
                 myProcess.Close();                 //关闭进程
222
                 myProcess.Dispose();               //释放资源
262
                 myProcess.Dispose();               //释放资源
223
-                                                   //生成视频后删除图片保存列表
224
-                FileToolsCommon.DeleteDirectory(ImageListPath);
225
-            });
263
+                #region 进程是否已经释放
264
+                bool IsRunning = true;
265
+                while (IsRunning)
266
+                {
267
+                    IsRunning = false;
268
+                    Process[] ProcessArray = Process.GetProcessesByName("ffmpeg");
269
+                    foreach (var KillProcess in ProcessArray)
270
+                    {
271
+                        IsRunning = true;
272
+                        Thread.Sleep(100);
273
+                    }
274
+                }
275
+                #endregion
276
+                myProcess = null;
277
+                //生成视频后删除图片和音频保存列表
278
+                //FileToolsCommon.DeleteDirectory(ImageListPath);
279
+                //FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(Mp3Path));
280
+
281
+                //Dispatcher.Invoke(() =>
282
+                //{
283
+                //});
284
+                //// 允许不同线程间的调用
285
+                //Control.CheckForIllegalCrossThreadCalls = false;
286
+            }))).Start();
226
         }
287
         }
227
 
288
 
228
         /// <summary>
289
         /// <summary>
229
         /// 视频音频合成
290
         /// 视频音频合成
230
         /// </summary>
291
         /// </summary>
231
         /// <param name="FilePath">存储路径</param>
292
         /// <param name="FilePath">存储路径</param>
232
-        void MergeVideoOrAudio(object FilePathobj)
293
+        public void MergeVideoOrAudio(object FilePathobj)
233
         {
294
         {
234
-            Thread.Sleep(500);
295
+            //new Thread(new ThreadStart(new Action(() =>
296
+            //{
297
+            //Dispatcher.Invoke(() =>
298
+            //{
299
+            //});
300
+            //}))).Start();
301
+
302
+            while (myProcess != null)
303
+            {
304
+                Thread.Sleep(100);
305
+            }
235
             //路径
306
             //路径
236
             string FilePath = (string)FilePathobj;
307
             string FilePath = (string)FilePathobj;
237
-            string Path = FileToolsCommon.GetDirectoryName(FilePath) + @"\";
308
+            string Path = FileToolsCommon.GetDirectoryName(FilePath);
238
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
309
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
239
-            Debug.WriteLine(KillProcessArray.Length.ToString());
240
             foreach (var KillProcess in KillProcessArray)
310
             foreach (var KillProcess in KillProcessArray)
241
             {
311
             {
242
                 KillProcess.Kill();
312
                 KillProcess.Kill();
256
             myProcess.WaitForExit();           //阻塞等待进程结束
326
             myProcess.WaitForExit();           //阻塞等待进程结束
257
             myProcess.Close();                 //关闭进程
327
             myProcess.Close();                 //关闭进程
258
             myProcess.Dispose();               //释放资源
328
             myProcess.Dispose();               //释放资源
329
+            #region 进程是否已经释放
330
+            bool IsRunning = true;
331
+            while (IsRunning)
332
+            {
333
+                IsRunning = false;
334
+                Process[] ProcessArray = Process.GetProcessesByName("ffmpeg");
335
+                foreach (var KillProcess in ProcessArray)
336
+                {
337
+                    IsRunning = true;
338
+                    Thread.Sleep(100);
339
+                }
340
+            }
341
+            #endregion
342
+            myProcess = null;
259
         }
343
         }
260
 
344
 
261
         /// <summary>
345
         /// <summary>
266
         string GetFilePathName(string FilePath)
350
         string GetFilePathName(string FilePath)
267
         {
351
         {
268
             //路径
352
             //路径
269
-            string Path = FileToolsCommon.GetDirectoryName(FilePath) + @"\";
353
+            string Path = FileToolsCommon.GetDirectoryName(FilePath);
270
             //Path.GetFileName(FilePath);//获取文件名
354
             //Path.GetFileName(FilePath);//获取文件名
271
             string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
355
             string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
272
             string tempFilePath = Path + "temp/";
356
             string tempFilePath = Path + "temp/";
295
         /// <param name="ImagePath">图片地址</param>
379
         /// <param name="ImagePath">图片地址</param>
296
         public void GenerateThumbnails(string VideoPath, string ImagePath)
380
         public void GenerateThumbnails(string VideoPath, string ImagePath)
297
         {
381
         {
382
+            while (myProcess != null)
383
+            {
384
+                Thread.Sleep(100);
385
+            }
298
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
386
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
299
-            Debug.WriteLine(KillProcessArray.Length.ToString());
300
             foreach (var KillProcess in KillProcessArray)
387
             foreach (var KillProcess in KillProcessArray)
301
             {
388
             {
302
                 KillProcess.Kill();
389
                 KillProcess.Kill();
317
             myProcess.WaitForExit();           //阻塞等待进程结束
404
             myProcess.WaitForExit();           //阻塞等待进程结束
318
             myProcess.Close();                 //关闭进程
405
             myProcess.Close();                 //关闭进程
319
             myProcess.Dispose();               //释放资源
406
             myProcess.Dispose();               //释放资源
407
+            #region 进程是否已经释放
408
+            bool IsRunning = true;
409
+            while (IsRunning)
410
+            {
411
+                IsRunning = false;
412
+                Process[] ProcessArray = Process.GetProcessesByName("ffmpeg");
413
+                foreach (var KillProcess in ProcessArray)
414
+                {
415
+                    IsRunning = true;
416
+                    Thread.Sleep(100);
417
+                }
418
+            }
419
+            #endregion
420
+            myProcess = null;
320
         }
421
         }
321
 
422
 
322
         /// <summary>
423
         /// <summary>

+ 2
- 1
Common/system/FileToolsCommon.cs View File

70
             ErrMessage = "";
70
             ErrMessage = "";
71
             try
71
             try
72
             {
72
             {
73
+                FilePathName = GetLegalPath(FilePathName);
73
                 FilePath = GetDirectoryName(FilePathName);
74
                 FilePath = GetDirectoryName(FilePathName);
74
                 FileName = GetIOFileName(FilePathName);
75
                 FileName = GetIOFileName(FilePathName);
75
             }
76
             }
671
         /// <param name="filePath">文件的绝对路径</param>          
672
         /// <param name="filePath">文件的绝对路径</param>          
672
         public static string GetDirectoryName(string filePath)
673
         public static string GetDirectoryName(string filePath)
673
         {
674
         {
674
-            string DirectoryName = (System.IO.Path.GetDirectoryName(filePath) + "\\").Replace("\\", "/");
675
+            string DirectoryName = (System.IO.Path.GetDirectoryName(filePath+ "\\") ).Replace("\\", "/");
675
             return DirectoryName;
676
             return DirectoryName;
676
         }
677
         }
677
         #endregion
678
         #endregion

+ 40
- 41
Common/system/ImageHelper.cs View File

85
         /// <returns></returns>
85
         /// <returns></returns>
86
         public static BitmapImage GetScreenshot(Rectangle ScreenSize, string ImageSavePath, long level = -1)
86
         public static BitmapImage GetScreenshot(Rectangle ScreenSize, string ImageSavePath, long level = -1)
87
         {
87
         {
88
-            try
89
-            {
90
-                System.Drawing.Size bounds = PrimaryScreen.DESKTOP;
91
-                //if (string.IsNullOrEmpty(ImageSavePath))
92
-                //{
93
-                //    ImageSavePath = GetTempImagePath();//如果为空则指定临时存储路径
94
-                //}
95
-                double scaleWidth = (bounds.Width * 1.0) / SystemParameters.PrimaryScreenWidth;
96
-                double scaleHeight = (bounds.Height * 1.0) / SystemParameters.PrimaryScreenHeight;
97
-                int width = bounds.Width;
98
-                int height = bounds.Height;
99
-                if (ScreenSize.Size != new System.Drawing.Size(0, 0))
100
-                {
101
-                    width = (int)(ScreenSize.Size.Width * scaleWidth);
102
-                    height = (int)(ScreenSize.Size.Height * scaleHeight);
103
-                }
104
-                int l = (int)(ScreenSize.X * scaleWidth);
105
-                int t = (int)(ScreenSize.Y * scaleHeight);
106
-                //if (_Bitmap != null)
107
-                //{
108
-                //    _Bitmap.Dispose();
109
-                //}
110
-                Bitmap _Bitmap = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
111
-                using (Graphics g = Graphics.FromImage(_Bitmap))
112
-                {
113
-                    g.CopyFromScreen(l, t, 0, 0, _Bitmap.Size, CopyPixelOperation.SourceCopy);
114
-                    Compress(_Bitmap, ImageSavePath, level);
115
-                }
116
-                Uri uri = new Uri(ImageSavePath, UriKind.Absolute);
117
-                BitmapImage bimg = new BitmapImage(uri);
118
-                GC.Collect();
119
-                return bimg;
120
-            }
121
-            catch (Exception ex)
122
-            {
123
-                LogHelper.WriteErrLog("【截图】(GetBitmapSource)截图失败," + ex.Message, ex);
124
-                return null;
125
-            }
88
+            //try
89
+            //{
90
+            //    System.Drawing.Size bounds = PrimaryScreen.DESKTOP;
91
+            //    //if (string.IsNullOrEmpty(ImageSavePath))
92
+            //    //{
93
+            //    //    ImageSavePath = GetTempImagePath();//如果为空则指定临时存储路径
94
+            //    //}
95
+            //    double scaleWidth = (bounds.Width * 1.0) / SystemParameters.PrimaryScreenWidth;
96
+            //    double scaleHeight = (bounds.Height * 1.0) / SystemParameters.PrimaryScreenHeight;
97
+            //    int width = bounds.Width;
98
+            //    int height = bounds.Height;
99
+            //    if (ScreenSize.Size != new System.Drawing.Size(0, 0))
100
+            //    {
101
+            //        width = (int)(ScreenSize.Size.Width * scaleWidth);
102
+            //        height = (int)(ScreenSize.Size.Height * scaleHeight);
103
+            //    }
104
+            //    int l = (int)(ScreenSize.X * scaleWidth);
105
+            //    int t = (int)(ScreenSize.Y * scaleHeight);
106
+            //    //if (_Bitmap != null)
107
+            //    //{
108
+            //    //    _Bitmap.Dispose();
109
+            //    //}
110
+            //    Bitmap _Bitmap = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
111
+            //    using (Graphics g = Graphics.FromImage(_Bitmap))
112
+            //    {
113
+            //        g.CopyFromScreen(l, t, 0, 0, _Bitmap.Size, CopyPixelOperation.SourceCopy);
114
+            //        Compress(_Bitmap, ImageSavePath, level);
115
+            //    }
116
+            //    Uri uri = new Uri(ImageSavePath, UriKind.Absolute);
117
+            //    BitmapImage bimg = new BitmapImage(uri);
118
+            //    GC.Collect();
119
+            //    return bimg;
120
+            //}
121
+            //catch (Exception ex)
122
+            //{
123
+            //    //LogHelper.WriteErrLog("【截图】(GetBitmapSource)截图失败," + ex.Message, ex);
124
+            return null;
125
+            //}
126
         }
126
         }
127
 
127
 
128
         //private static Bitmap _Bitmap = null;
128
         //private static Bitmap _Bitmap = null;
164
         {
164
         {
165
             if (level <= -1)
165
             if (level <= -1)
166
             {
166
             {
167
-                int ImageCompressionLevel = int.Parse(ConfigurationManager.AppSettings["ImageCompressionLevel"]);
167
+                int ImageCompressionLevel = int.Parse(FileToolsCommon.GetConfigValue("ImageCompressionLevel"));
168
                 level = ImageCompressionLevel;
168
                 level = ImageCompressionLevel;
169
             }
169
             }
170
             Stream s = new FileStream(destFile, FileMode.Create);
170
             Stream s = new FileStream(destFile, FileMode.Create);
336
         #endregion 图片压缩
336
         #endregion 图片压缩
337
 
337
 
338
         #region 截屏指定UI控件
338
         #region 截屏指定UI控件
339
-
340
         /// <summary>
339
         /// <summary>
341
         /// 保存图片
340
         /// 保存图片
342
         /// </summary>
341
         /// </summary>
344
         /// <param name="filePathName">图片保存地址 命名 1.png</param>
343
         /// <param name="filePathName">图片保存地址 命名 1.png</param>
345
         /// <param name="width">保存宽</param>
344
         /// <param name="width">保存宽</param>
346
         /// <param name="height">保存高</param>
345
         /// <param name="height">保存高</param>
347
-        private void SaveUIToImage(FrameworkElement ui, string filePathName, int width, int height)
346
+        public static void SaveUIToImage(FrameworkElement ui, string filePathName, int width, int height)
348
         {
347
         {
349
             try
348
             try
350
             {
349
             {

+ 3
- 3
XHWK.Model/Model_Video.cs View File

7
     {
7
     {
8
         private string _videPath;
8
         private string _videPath;
9
         private string _thumbnailPath;
9
         private string _thumbnailPath;
10
-        private Emum_VideoType _videoType;
10
+        private Enum_VideoType _videoType;
11
         private Enum_WKVidetype _wkType;
11
         private Enum_WKVidetype _wkType;
12
         private string _RSTime;
12
         private string _RSTime;
13
         private string _videoSize;
13
         private string _videoSize;
22
         /// <summary>
22
         /// <summary>
23
         /// 视频类型
23
         /// 视频类型
24
         /// </summary>
24
         /// </summary>
25
-        public Emum_VideoType VideoType { get => _videoType; set => _videoType = value; }
25
+        public Enum_VideoType VideoType { get => _videoType; set => _videoType = value; }
26
         /// <summary>
26
         /// <summary>
27
         /// 微课类型
27
         /// 微课类型
28
         /// </summary>
28
         /// </summary>
39
     /// <summary>
39
     /// <summary>
40
     /// 视频格式类型
40
     /// 视频格式类型
41
     /// </summary>
41
     /// </summary>
42
-    public enum Emum_VideoType
42
+    public enum Enum_VideoType
43
     {
43
     {
44
         MP4 = 1,
44
         MP4 = 1,
45
         FlV = 2,
45
         FlV = 2,

+ 2
- 2
XHWK.Model/Model_WKData.cs View File

7
         private string _wkName;
7
         private string _wkName;
8
         private List<Model_Video> _videoList;
8
         private List<Model_Video> _videoList;
9
         private string _wkPath;
9
         private string _wkPath;
10
-        private string _wkDateTime;
10
+        private string _wkCreateDateTime;
11
         private string _drawDataPath;
11
         private string _drawDataPath;
12
         /// <summary>
12
         /// <summary>
13
         /// 微课名
13
         /// 微课名
24
         /// <summary>
24
         /// <summary>
25
         /// 微课时间
25
         /// 微课时间
26
         /// </summary>
26
         /// </summary>
27
-        public string WkDateTime { get => _wkDateTime; set => _wkDateTime = value; }
27
+        public string WkCreateDateTime { get => _wkCreateDateTime; set => _wkCreateDateTime = value; }
28
         /// <summary>
28
         /// <summary>
29
         /// 画板数据存储路径
29
         /// 画板数据存储路径
30
         /// </summary>
30
         /// </summary>

+ 4
- 0
XHWK.WKTool/App.config View File

10
     <add key="VideoSavePath" value="D:\星火微课" />
10
     <add key="VideoSavePath" value="D:\星火微课" />
11
     <!--视频格式 1、MP4 2、FlV 3、AVI-->
11
     <!--视频格式 1、MP4 2、FlV 3、AVI-->
12
     <add key="VideoType" value="1" />
12
     <add key="VideoType" value="1" />
13
+    <!--图片压缩质量-->
14
+    <add key="ImageCompressionLevel" value="50"/>
15
+    <!--用户名-->
13
     <add key="userName" value="" />
16
     <add key="userName" value="" />
17
+    <!--记住密码-->
14
     <add key="isRemind" value="" />
18
     <add key="isRemind" value="" />
15
   </appSettings>
19
   </appSettings>
16
 </configuration>
20
 </configuration>

+ 5
- 8
XHWK.WKTool/App.cs View File

26
         /// </summary>
26
         /// </summary>
27
         public static Model_WKData WKData = null;
27
         public static Model_WKData WKData = null;
28
         /// <summary>
28
         /// <summary>
29
-        /// 讲解名称
30
-        /// </summary>
31
-        public static string WkName = null;
32
-        /// <summary>
33
-        /// 微课保存路径
34
-        /// </summary>
35
-        public static string WkSavePath = null;
36
-        /// <summary>
37
         /// 主页面
29
         /// 主页面
38
         /// </summary>
30
         /// </summary>
39
         public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
31
         public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
40
         /// <summary>
32
         /// <summary>
33
+        /// 录屏工具
34
+        /// </summary>
35
+        public static FFMpeg FFmpeg = new FFMpeg();
36
+        /// <summary>
41
         /// 开始录像
37
         /// 开始录像
42
         /// </summary>
38
         /// </summary>
43
         public static CountdownWindow W_CountdownWindow = null;
39
         public static CountdownWindow W_CountdownWindow = null;
69
         {
65
         {
70
             // 定义Application对象作为整个应用程序入口
66
             // 定义Application对象作为整个应用程序入口
71
             Application app = new Application();
67
             Application app = new Application();
68
+            WKData = new Model_WKData();
72
             //app.DispatcherUnhandledException += MyApp_DispatcherUnhandledException;
69
             //app.DispatcherUnhandledException += MyApp_DispatcherUnhandledException;
73
             CreateAMicroLessonWindow win = new CreateAMicroLessonWindow();
70
             CreateAMicroLessonWindow win = new CreateAMicroLessonWindow();
74
             app.Run(win);
71
             app.Run(win);

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

34
         /// <param name="e"></param>
34
         /// <param name="e"></param>
35
         private void BtnDown_Click(object sender, RoutedEventArgs e)
35
         private void BtnDown_Click(object sender, RoutedEventArgs e)
36
         {
36
         {
37
-
37
+            System.Environment.Exit(0);
38
         }
38
         }
39
         /// <summary>
39
         /// <summary>
40
         /// 浏览
40
         /// 浏览
76
                 System.Windows.MessageBox.Show("路径不可为空!");
76
                 System.Windows.MessageBox.Show("路径不可为空!");
77
                 return;
77
                 return;
78
             }
78
             }
79
-            if (!FileToolsCommon.IsLegalPath(txbExplainName.Text.Trim(), out string ErrMessage))
80
-            {
81
-                System.Windows.MessageBox.Show(ErrMessage);
82
-            }
83
-            string PathName = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/";
84
-            if (FileToolsCommon.IsExistDirectory(PathName))
79
+            //if (!FileToolsCommon.IsLegalPath(txbStoragePath.Text.Trim(), out string ErrMessage))
80
+            //{
81
+            //    System.Windows.MessageBox.Show(ErrMessage);
82
+            //    return;
83
+            //}
84
+            APP.WKData.WkPath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/";
85
+            if (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath))
85
             {
86
             {
86
                 //微课已存在
87
                 //微课已存在
87
                 MessageBoxResult dr = System.Windows.MessageBox.Show("讲解已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
88
                 MessageBoxResult dr = System.Windows.MessageBox.Show("讲解已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
88
                 if (dr == MessageBoxResult.OK)
89
                 if (dr == MessageBoxResult.OK)
89
                 {
90
                 {
90
-                    FileToolsCommon.DeleteDirectory(PathName);
91
+                    FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
91
                 }
92
                 }
92
                 else
93
                 else
93
                 {
94
                 {
96
             }
97
             }
97
             #endregion
98
             #endregion
98
             //创建文件夹
99
             //创建文件夹
99
-            FileToolsCommon.CreateDirectory(PathName);
100
+            FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
100
             //存储文件
101
             //存储文件
101
             FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Text);
102
             FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Text);
102
-            APP.WkName = txbExplainName.Text;
103
-            APP.WkSavePath = PathName;
104
-            FileToolsCommon.CreateDirectory(APP.WkSavePath);
103
+            APP.WKData.WkName = txbExplainName.Text;
104
+            APP.WKData.WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
105
             if (APP.W_XHMicroLessonSystemWindow == null)
105
             if (APP.W_XHMicroLessonSystemWindow == null)
106
             {
106
             {
107
                 APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
107
                 APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();

+ 2
- 2
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml View File

74
             <TextBlock Grid.Row="1" Text="01:35" FontSize="23" Foreground="#FFFFFF" Margin="30,50,0,0"/>
74
             <TextBlock Grid.Row="1" Text="01:35" FontSize="23" Foreground="#FFFFFF" Margin="30,50,0,0"/>
75
             <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,15,0">
75
             <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,15,0">
76
                 <Button x:Name="BtnRecordingScreen"  Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,0,15,0" Click="BtnRecordingScreen_Click">
76
                 <Button x:Name="BtnRecordingScreen"  Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,0,15,0" Click="BtnRecordingScreen_Click">
77
-                    <Image Source="./Images/Toobar25.png"/>
77
+                    <Image x:Name="ImgRecordingScreen" Source="./Images/Toobar25.png"/>
78
                 </Button>
78
                 </Button>
79
                 <Button x:Name="BtnStopRecordingScreen" Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,0,15,0" Click="BtnStopRecordingScreen_Click">
79
                 <Button x:Name="BtnStopRecordingScreen" Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,0,15,0" Click="BtnStopRecordingScreen_Click">
80
-                    <Image Source="./Images/Toobar14.png"/>
80
+                    <Image x:Name="ImgEndRecordingScreen" Source="./Images/Toobar14.png"/>
81
                 </Button>
81
                 </Button>
82
                 <Button  Cursor="Hand" x:Name="btnBrush" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,0,10,0" Click="BtnBrush_Click">
82
                 <Button  Cursor="Hand" x:Name="btnBrush" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,0,10,0" Click="BtnBrush_Click">
83
                     <Image Source="./Images/Toobar8.png"/>
83
                     <Image Source="./Images/Toobar8.png"/>

+ 53
- 52
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs View File

2
 
2
 
3
 using System;
3
 using System;
4
 using System.Windows;
4
 using System.Windows;
5
-
5
+using System.Windows.Media.Imaging;
6
 using XHWK.Model;
6
 using XHWK.Model;
7
 
7
 
8
 namespace XHWK.WKTool
8
 namespace XHWK.WKTool
16
         /// <summary>
16
         /// <summary>
17
         /// 视频存储路径
17
         /// 视频存储路径
18
         /// </summary>
18
         /// </summary>
19
-        string RSPath;
19
+        string RecordingPath;
20
         /// <summary>
20
         /// <summary>
21
-        /// 是否正在录制
21
+        /// 视频保存名称
22
         /// </summary>
22
         /// </summary>
23
-        bool IsStartRS = false;
23
+        string VideoSavePathName;
24
         /// <summary>
24
         /// <summary>
25
-        /// 是否暂停
25
+        /// 是否首次录屏
26
         /// </summary>
26
         /// </summary>
27
-        bool IsSuspend = true;
27
+        bool IsFirstRS = true;
28
         /// <summary>
28
         /// <summary>
29
-        /// 录屏
29
+        /// 是否暂停
30
         /// </summary>
30
         /// </summary>
31
-        FFMpeg Ffmpeg = null;
31
+        bool IsSuspend = true;
32
         #endregion
32
         #endregion
33
 
33
 
34
         #region 初始化
34
         #region 初始化
46
         {
46
         {
47
             //隐藏画笔工具栏
47
             //隐藏画笔工具栏
48
             BtnToolbarDown_Click(null, null);
48
             BtnToolbarDown_Click(null, null);
49
-            IsStartRS = false;
50
-            IsSuspend = true;
51
-            RSPath = null;
52
-            if (Ffmpeg == null)
53
-            {
54
-                Ffmpeg = new FFMpeg();
55
-            }
56
         }
49
         }
57
         #endregion
50
         #endregion
58
 
51
 
59
         #region 录制
52
         #region 录制
60
         /// <summary>
53
         /// <summary>
61
-        /// 停止录像
62
-        /// </summary>
63
-        /// <param name="sender"></param>
64
-        /// <param name="e"></param>
65
-        private void BtnStopRecordingScreen_Click(object sender, RoutedEventArgs e)
66
-        {
67
-            if (APP.W_XHMicroLessonSystemWindow == null)
68
-            {
69
-                APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
70
-            }
71
-            APP.W_XHMicroLessonSystemWindow.Show();
72
-            try
73
-            {
74
-                Ffmpeg.StopFFmpeg(RSPath);
75
-            }
76
-            catch (Exception ex)
77
-            {
78
-                MessageBox.Show(ex.Message);
79
-            }
80
-            IsStartRS = false;
81
-            Hide();
82
-        }
83
-        /// <summary>
84
         /// 开始或暂停录制
54
         /// 开始或暂停录制
85
         /// </summary>
55
         /// </summary>
86
         /// <param name="sender"></param>
56
         /// <param name="sender"></param>
89
         {
59
         {
90
             if (IsSuspend)
60
             if (IsSuspend)
91
             {
61
             {
92
-                if(IsStartRS)
62
+                if(IsFirstRS)
93
                 {
63
                 {
64
+                    RecordingPath = APP.WKData.WkPath;
65
+                    //FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
66
+                    FileToolsCommon.CreateDirectory(RecordingPath);
67
+                    VideoSavePathName = RecordingPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
68
+                    if (FileToolsCommon.IsExistFile(VideoSavePathName))
69
+                    {
70
+                        MessageBoxResult dr = System.Windows.MessageBox.Show("已存在录屏是否覆盖?", "提示", MessageBoxButton.OKCancel);
71
+                        if (dr == MessageBoxResult.OK)
72
+                        {
73
+                            FileToolsCommon.DeleteFile(VideoSavePathName);
74
+                        }
75
+                        else
76
+                        {
77
+                            return;
78
+                        }
79
+                    }
80
+                    IsFirstRS = false;
94
                 }
81
                 }
95
-                //timer = new DispatcherTimer();
96
-                //timer.Interval = TimeSpan.FromMilliseconds(1000);
97
-                //timer.Tick += Timer_Tick;//你的事件
98
-                //dt = Convert.ToDateTime("2020-01-01 00:00:00");
99
-                //FileToolsCommon.DeleteDirectory(RSPath);
100
                 IsSuspend = false;
82
                 IsSuspend = false;
101
-                IsStartRS = true;
102
-                BtnRecordingScreen.Content = "暂停录制";
83
+                ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
103
                 try
84
                 try
104
                 {
85
                 {
105
-                    RSPath = APP.WkSavePath;
106
-                    FileToolsCommon.CreateDirectory(RSPath);
107
-                    RSPath += "." + ((Emum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
108
-                    Ffmpeg.StartRecordingVideo(RSPath);
86
+                    APP.FFmpeg.StartRecordingVideo(VideoSavePathName);
109
                 }
87
                 }
110
                 catch (Exception ex)
88
                 catch (Exception ex)
111
                 {
89
                 {
115
             else
93
             else
116
             {
94
             {
117
                 IsSuspend = true;
95
                 IsSuspend = true;
96
+                ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
118
                 try
97
                 try
119
                 {
98
                 {
120
-                    Ffmpeg.SuspendFFmpeg();
121
-                    Ffmpeg.StopFFmpeg(RSPath);
99
+                    APP.FFmpeg.SuspendFFmpeg();
122
                 }
100
                 }
123
                 catch (Exception ex)
101
                 catch (Exception ex)
124
                 {
102
                 {
126
                 }
104
                 }
127
             }
105
             }
128
         }
106
         }
107
+        /// <summary>
108
+        /// 停止录像
109
+        /// </summary>
110
+        /// <param name="sender"></param>
111
+        /// <param name="e"></param>
112
+        private void BtnStopRecordingScreen_Click(object sender, RoutedEventArgs e)
113
+        {
114
+            if (APP.W_XHMicroLessonSystemWindow == null)
115
+            {
116
+                APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
117
+            }
118
+            APP.W_XHMicroLessonSystemWindow.Show();
119
+            try
120
+            {
121
+                APP.FFmpeg.StopFFmpeg(VideoSavePathName);
122
+            }
123
+            catch (Exception ex)
124
+            {
125
+                MessageBox.Show(ex.Message);
126
+            }
127
+            IsFirstRS = true;
128
+            Hide();
129
+        }
129
         #endregion
130
         #endregion
130
 
131
 
131
         #region 画笔相关
132
         #region 画笔相关

+ 2
- 2
XHWK.WKTool/XHMicroLessonSystemWindow.xaml View File

68
                             <TextBlock Text="导入" FontSize="14" Foreground="#FFFFFF" HorizontalAlignment="Center"/>
68
                             <TextBlock Text="导入" FontSize="14" Foreground="#FFFFFF" HorizontalAlignment="Center"/>
69
                         </StackPanel>
69
                         </StackPanel>
70
                     </Button>
70
                     </Button>
71
-                    <Button Cursor="Hand" x:Name="btnRecord" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="60,0,30,0" Click="BtnRecord_Click">
71
+                    <Button Cursor="Hand" x:Name="BtnRecord" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="60,0,30,0" Click="BtnRecord_Click">
72
                         <StackPanel Orientation="Vertical">
72
                         <StackPanel Orientation="Vertical">
73
                             <Image x:Name="ImgRecord" Source="./Images/microLessonSystem_14.png"/>
73
                             <Image x:Name="ImgRecord" Source="./Images/microLessonSystem_14.png"/>
74
                             <Image x:Name="ImgRecordTwo" Source="./Images/microLessonSystem_13.png" Visibility="Collapsed"/>
74
                             <Image x:Name="ImgRecordTwo" Source="./Images/microLessonSystem_13.png" Visibility="Collapsed"/>
122
                 </StackPanel>
122
                 </StackPanel>
123
             </Grid>
123
             </Grid>
124
             <!--主内容-->
124
             <!--主内容-->
125
-            <Grid Grid.Row="1" x:Name="gridMain"  Margin="20,0,20,0" Background="#FFFFFF" Height="793.700787401575" Width="1142.51968503937" Visibility="Visible">
125
+            <Grid Grid.Row="1" x:Name="GridMain"  Margin="20,0,20,0" Background="#FFFFFF" Height="793.700787401575" Width="1142.51968503937" Visibility="Visible">
126
                 <Grid.RowDefinitions>
126
                 <Grid.RowDefinitions>
127
                     <RowDefinition Height="auto"/>
127
                     <RowDefinition Height="auto"/>
128
                 </Grid.RowDefinitions>
128
                 </Grid.RowDefinitions>

+ 165
- 2
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

14
 using System.Windows.Media;
14
 using System.Windows.Media;
15
 using System.Windows.Media.Imaging;
15
 using System.Windows.Media.Imaging;
16
 
16
 
17
+using XHWK.Model;
18
+
17
 namespace XHWK.WKTool
19
 namespace XHWK.WKTool
18
 {
20
 {
19
     /// <summary>
21
     /// <summary>
53
         /// </summary>
55
         /// </summary>
54
         public void Initialize()
56
         public void Initialize()
55
         {
57
         {
58
+
56
             //创建 DrawingAttributes 类的一个实例  
59
             //创建 DrawingAttributes 类的一个实例  
57
             drawingAttributes = new DrawingAttributes();
60
             drawingAttributes = new DrawingAttributes();
58
             //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用  
61
             //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用  
183
         /// <param name="e"></param>
186
         /// <param name="e"></param>
184
         private void BtnSave_Click(object sender, RoutedEventArgs e)
187
         private void BtnSave_Click(object sender, RoutedEventArgs e)
185
         {
188
         {
186
-            gridMain.Visibility = Visibility.Visible;
189
+            GridMain.Visibility = Visibility.Visible;
187
             gridSetUp.Visibility = Visibility.Collapsed;
190
             gridSetUp.Visibility = Visibility.Collapsed;
188
         }
191
         }
189
         /// <summary>
192
         /// <summary>
193
         /// <param name="e"></param>
196
         /// <param name="e"></param>
194
         private void BtnSetUp_Click(object sender, RoutedEventArgs e)
197
         private void BtnSetUp_Click(object sender, RoutedEventArgs e)
195
         {
198
         {
196
-            gridMain.Visibility = Visibility.Collapsed;
199
+            GridMain.Visibility = Visibility.Collapsed;
197
             gridSetUp.Visibility = Visibility.Visible;
200
             gridSetUp.Visibility = Visibility.Visible;
198
         }
201
         }
199
         /// <summary>
202
         /// <summary>
427
                 }
430
                 }
428
             }
431
             }
429
         }
432
         }
433
+        #region 录制窗口
434
+
430
         /// <summary>
435
         /// <summary>
431
         /// 录制窗口内容
436
         /// 录制窗口内容
432
         /// </summary>
437
         /// </summary>
439
                 Login();
444
                 Login();
440
                 return;
445
                 return;
441
             }
446
             }
447
+
448
+        }
449
+        /// <summary>
450
+        /// 视频保存路径
451
+        /// </summary>
452
+        string RecordingPath;
453
+        /// <summary>
454
+        /// 图片保存路径
455
+        /// </summary>
456
+        string ImgPath;
457
+        /// <summary>
458
+        /// 音频保存路径名
459
+        /// </summary>
460
+        string AudioPathName;
461
+        /// <summary>
462
+        /// 视频保存路径名
463
+        /// </summary>
464
+        string VideoSavePathName;
465
+        /// <summary>
466
+        /// 暂停录制
467
+        /// </summary>
468
+        bool IsSuspendR = true;
469
+        /// <summary>
470
+        /// 是否首次录制
471
+        /// </summary>
472
+        bool IsFirstR = true;
473
+        /// <summary>
474
+        /// 图片
475
+        /// </summary>
476
+        int ImgNum = 0;
477
+        /// <summary>
478
+        /// 是否开始截图计数
479
+        /// </summary>
480
+        bool IsStartCount = false;
481
+
482
+        /// <summary>
483
+        /// 开始录制和暂停录制
484
+        /// </summary>
485
+        void StartRecord()
486
+        {
487
+            if (IsSuspendR)
488
+            {
489
+                if (IsFirstR)//是否第一次录制  初始化录制
490
+                {
491
+                    RecordingPath = APP.WKData.WkPath;
492
+                    ImgPath = APP.WKData.WkPath+"temp/Image/";
493
+                    AudioPathName = APP.WKData.WkPath + "temp/audio/";
494
+                    FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
495
+                    FileToolsCommon.CreateDirectory(RecordingPath);
496
+                    FileToolsCommon.CreateDirectory(ImgPath);
497
+                    FileToolsCommon.CreateDirectory(AudioPathName);
498
+                    AudioPathName += APP.WKData.WkName+".MP3";
499
+                    VideoSavePathName = RecordingPath + APP.WKData.WkName+"_录制."+ ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
500
+                    if(FileToolsCommon.IsExistFile(VideoSavePathName))
501
+                    {
502
+
503
+                    }
504
+                    IsFirstR = false;
505
+                    ImgNum = 0;
506
+                    new Thread(new ThreadStart(new Action(() =>
507
+                    {
508
+                        while (true)
509
+                        {
510
+                            Thread.Sleep(200);
511
+                            if (IsStartCount)
512
+                            {
513
+                                ImgNum++;
514
+                                Dispatcher.Invoke(() =>
515
+                                {
516
+                                    string FilePathName = ImgPath + ImgNum + ".png";
517
+                                    ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)GridMain.ActualWidth, (int)GridMain.ActualHeight);
518
+                                });
519
+                            }
520
+                        }
521
+                    }))).Start();
522
+                }
523
+                //继续录制
524
+                IsSuspendR = false;
525
+                //BtnRecording.Content = "暂停录制";
526
+                ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_23.png"));
527
+                try
528
+                {
529
+                    APP.FFmpeg.StartRecordingAudio(AudioPathName);
530
+                    new Thread(new ThreadStart(new Action(() =>
531
+                    {
532
+                        Thread.Sleep(1000);
533
+                        //Dispatcher.Invoke(() =>
534
+                        //{
535
+                            IsStartCount = true;
536
+                        //});
537
+                    }))).Start();
538
+                }
539
+                catch (Exception ex)
540
+                {
541
+                    System.Windows.MessageBox.Show(ex.Message);
542
+                }
543
+            }
544
+            else
545
+            {
546
+                //暂停
547
+                IsSuspendR = true;
548
+                ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
549
+                try
550
+                {
551
+                    APP.FFmpeg.SuspendFFmpeg();
552
+                    new Thread(new ThreadStart(new Action(() =>
553
+                    {
554
+                        while (APP.FFmpeg.myProcess != null)
555
+                        {
556
+                            Thread.Sleep(100);
557
+                        }
558
+                        IsStartCount = false;
559
+                    }))).Start();
560
+                }
561
+                catch (Exception ex)
562
+                {
563
+                    System.Windows.MessageBox.Show(ex.Message);
564
+                }
565
+            }
442
         }
566
         }
567
+        /// <summary>
568
+        /// 停止录制并生成录制文件
569
+        /// </summary>
570
+        void EndRecord()
571
+        {
572
+            IsFirstR = true;
573
+            IsSuspendR = true;
574
+            ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
575
+            try
576
+            {
577
+                APP.FFmpeg.StopFFmpeg(AudioPathName);
578
+                new Thread(new ThreadStart(new Action(() =>
579
+                {
580
+                    while (APP.FFmpeg.myProcess != null)
581
+                    {
582
+                        Thread.Sleep(100);
583
+                    }
584
+                    Dispatcher.Invoke(() =>
585
+                    {
586
+                        IsStartCount = false;
587
+                    });
588
+                }))).Start();
589
+
590
+                new Thread(new ThreadStart(new Action(() =>
591
+                {
592
+                    while (APP.FFmpeg.myProcess != null)
593
+                    {
594
+                        Thread.Sleep(100);
595
+                    }
596
+                }))).Start();
597
+                APP.FFmpeg.SynthesisVideo(ImgPath, AudioPathName, VideoSavePathName, 5, (int)GridMain.ActualWidth, (int)GridMain.ActualHeight);
598
+            }
599
+            catch (Exception ex)
600
+            {
601
+                System.Windows.MessageBox.Show(ex.Message);
602
+            }
603
+        }
604
+        #endregion
605
+
443
         /// <summary>
606
         /// <summary>
444
         /// 停止录制窗口内容
607
         /// 停止录制窗口内容
445
         /// </summary>
608
         /// </summary>

Loading…
Cancel
Save