|
@@ -1,6 +1,7 @@
|
1
|
1
|
using System;
|
2
|
2
|
using System.Collections.Generic;
|
3
|
3
|
using System.Diagnostics;
|
|
4
|
+using System.Text;
|
4
|
5
|
using System.Threading;
|
5
|
6
|
|
6
|
7
|
using VisioForge.Shared.NAudio.CoreAudioApi;
|
|
@@ -99,7 +100,7 @@ namespace Common.system
|
99
|
100
|
}
|
100
|
101
|
if (IsRecordMicrophone)
|
101
|
102
|
{
|
102
|
|
- MicrophoneName = GetMicrophone();
|
|
103
|
+ MicrophoneName = GetInDeviceFull();
|
103
|
104
|
if (!string.IsNullOrWhiteSpace(MicrophoneName))
|
104
|
105
|
{
|
105
|
106
|
MicrophoneStr = "-f dshow -i audio=\"" + MicrophoneName + "\" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 ";
|
|
@@ -108,7 +109,7 @@ namespace Common.system
|
108
|
109
|
switch (Extension.ToUpper())
|
109
|
110
|
{
|
110
|
111
|
case ".MP4":
|
111
|
|
- myProcess.StartInfo.Arguments = SpeakerStr + MicrophoneStr + " -f gdigrab -i desktop -pix_fmt yuv420p -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -acodec aac " + PathName;
|
|
112
|
+ myProcess.StartInfo.Arguments = SpeakerStr + MicrophoneStr + " -f gdigrab -i desktop -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -acodec aac " + PathName;
|
112
|
113
|
//myProcess.StartInfo.Arguments = SpeakerStr + MicrophoneStr + " -f dshow -i video=\"screen-capture-recorder\" -pix_fmt yuv420p -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -acodec aac " + PathName;
|
113
|
114
|
//if (string.IsNullOrWhiteSpace(MicrophoneName))
|
114
|
115
|
//{
|
|
@@ -122,7 +123,7 @@ namespace Common.system
|
122
|
123
|
break;
|
123
|
124
|
case ".AVI":
|
124
|
125
|
case ".FLV":
|
125
|
|
- myProcess.StartInfo.Arguments = SpeakerStr + MicrophoneStr + " -f gdigrab -i desktop -pix_fmt yuv420p -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -acodec aac -f " + Extension.ToLower().Replace(".", "") + " " + PathName;
|
|
126
|
+ myProcess.StartInfo.Arguments = SpeakerStr + MicrophoneStr + " -f gdigrab -i desktop -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -acodec aac -f " + Extension.ToLower().Replace(".", "") + " " + PathName;
|
126
|
127
|
//if (string.IsNullOrWhiteSpace(MicrophoneName))
|
127
|
128
|
//{
|
128
|
129
|
// myProcess.StartInfo.Arguments = "-f dshow -i video=\"screen-capture-recorder\" -f dshow -i audio=\"virtual-audio-capturer\" -vcodec libx264 -acodec libmp3lame -r 15 -crf 22 -f " + Extension.ToLower() + " " + PathName; //ffmpeg的参数
|
|
@@ -134,9 +135,10 @@ namespace Common.system
|
134
|
135
|
//}
|
135
|
136
|
break;
|
136
|
137
|
default:
|
137
|
|
- myProcess.StartInfo.Arguments = SpeakerStr + MicrophoneStr + " -f gdigrab -i desktop -pix_fmt yuv420p -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -acodec aac " + PathName;
|
|
138
|
+ myProcess.StartInfo.Arguments = SpeakerStr + MicrophoneStr + " -f gdigrab -i desktop -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -acodec aac " + PathName;
|
138
|
139
|
break;
|
139
|
140
|
}
|
|
141
|
+ LogHelper.WriteInfoLog("【录屏】:"+myProcess.StartInfo.Arguments);
|
140
|
142
|
myProcess.StartInfo.UseShellExecute = false; //不使用操作系统外壳程序启动
|
141
|
143
|
myProcess.StartInfo.RedirectStandardError = true; //重定向标准错误输出
|
142
|
144
|
myProcess.StartInfo.CreateNoWindow = true; //不显示程序窗口
|
|
@@ -192,7 +194,7 @@ namespace Common.system
|
192
|
194
|
if (StartRecordAudio(audioMicrophonePath))
|
193
|
195
|
{
|
194
|
196
|
IsRecordMicrophone = true;
|
195
|
|
- MicrophoneName = GetMicrophone();
|
|
197
|
+ MicrophoneName = GetInDeviceFull();
|
196
|
198
|
}
|
197
|
199
|
else
|
198
|
200
|
{
|
|
@@ -226,6 +228,7 @@ namespace Common.system
|
226
|
228
|
MicrophoneName + "\" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 " + PathName;
|
227
|
229
|
}
|
228
|
230
|
}
|
|
231
|
+ LogHelper.WriteInfoLog("【录音】:" + myProcess.StartInfo.Arguments);
|
229
|
232
|
myProcess.StartInfo.UseShellExecute = false; //不使用操作系统外壳程序启动
|
230
|
233
|
myProcess.StartInfo.RedirectStandardError = true; //重定向标准错误输出
|
231
|
234
|
myProcess.StartInfo.CreateNoWindow = true; //不显示程序窗口
|
|
@@ -788,14 +791,14 @@ namespace Common.system
|
788
|
791
|
}
|
789
|
792
|
|
790
|
793
|
/// <summary>
|
791
|
|
- /// 获取麦克风列表
|
|
794
|
+ /// 获取声音输入设备完整名称
|
792
|
795
|
/// </summary>
|
793
|
|
- public List<string> GetMicrophoneList()
|
|
796
|
+ /// <returns></returns>
|
|
797
|
+ public static string GetInDeviceFull()
|
794
|
798
|
{
|
795
|
|
- List<string> devs = new List<string>();
|
796
|
|
-
|
797
|
|
- MMDeviceEnumerator enumberator = new MMDeviceEnumerator();
|
798
|
|
- MMDeviceCollection deviceCollection = enumberator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.All);
|
|
799
|
+ List<string> devices = new List<string>();
|
|
800
|
+ var enumberator = new MMDeviceEnumerator();
|
|
801
|
+ var deviceCollection = enumberator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.All);
|
799
|
802
|
for (int waveInDevice = 0; waveInDevice < WaveIn.DeviceCount; waveInDevice++)
|
800
|
803
|
{
|
801
|
804
|
WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
|
|
@@ -803,20 +806,58 @@ namespace Common.system
|
803
|
806
|
{
|
804
|
807
|
try
|
805
|
808
|
{
|
806
|
|
-
|
807
|
809
|
if (device.FriendlyName.StartsWith(deviceInfo.ProductName))
|
808
|
810
|
{
|
809
|
|
- devs.Add(device.FriendlyName);
|
|
811
|
+ devices.Add(device.FriendlyName);
|
810
|
812
|
break;
|
811
|
813
|
}
|
812
|
814
|
}
|
813
|
|
- catch (Exception)
|
|
815
|
+ catch (Exception ex)
|
814
|
816
|
{
|
815
|
|
-
|
|
817
|
+ continue;
|
|
818
|
+ }
|
|
819
|
+ }
|
|
820
|
+ }
|
|
821
|
+ if (devices.Count > 0)
|
|
822
|
+ {
|
|
823
|
+ byte[] buffer = Encoding.UTF8.GetBytes(devices[0]);
|
|
824
|
+ string MicrophoneName = Encoding.UTF8.GetString(buffer); // 统一使用UTF-8
|
|
825
|
+ return MicrophoneName;
|
|
826
|
+ }
|
|
827
|
+ else
|
|
828
|
+ {
|
|
829
|
+ return "";
|
|
830
|
+ }
|
|
831
|
+ }
|
|
832
|
+ /// <summary>
|
|
833
|
+ /// 获取声音输入设备完整名称
|
|
834
|
+ /// </summary>
|
|
835
|
+ /// <returns></returns>
|
|
836
|
+ public List<string> GetInDeviceListFull()
|
|
837
|
+ {
|
|
838
|
+ List<string> devices = new List<string>();
|
|
839
|
+ var enumberator = new MMDeviceEnumerator();
|
|
840
|
+ var deviceCollection = enumberator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.All);
|
|
841
|
+ for (int waveInDevice = 0; waveInDevice < WaveIn.DeviceCount; waveInDevice++)
|
|
842
|
+ {
|
|
843
|
+ WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
|
|
844
|
+ foreach (MMDevice device in deviceCollection)
|
|
845
|
+ {
|
|
846
|
+ try
|
|
847
|
+ {
|
|
848
|
+ if (device.FriendlyName.StartsWith(deviceInfo.ProductName))
|
|
849
|
+ {
|
|
850
|
+ devices.Add(device.FriendlyName);
|
|
851
|
+ break;
|
|
852
|
+ }
|
|
853
|
+ }
|
|
854
|
+ catch (Exception ex)
|
|
855
|
+ {
|
|
856
|
+ continue;
|
816
|
857
|
}
|
817
|
858
|
}
|
818
|
859
|
}
|
819
|
|
- return devs;
|
|
860
|
+ return devices;
|
820
|
861
|
}
|
821
|
862
|
|
822
|
863
|
/// <summary>
|