我想记录与ffmpeg后,整个桌面,包括音频。我想让它自动为我找到录音设备。
我正在使用MMDeviceEnumerator。
我尝试的所有其他方法返回空列表返回0音频设备。我用naudio和ffmpeg试过了
public Form1()
{
InitializeComponent();
InitializeRecordingIndicator();
MMDeviceEnumerator enumerator = new MMDeviceEnumerator();
foreach (MMDevice device in enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.All))
{
StreamWriter w = new StreamWriter(@"d:\audiodev.txt", true);
cmbAudioDevices.Items.Add(device.FriendlyName);
w.WriteLine(device.FriendlyName + " " + device.State);
w.Close();
}
}
这是我系统中所有音频设备的列表。但它们都不存在或被禁用。而且我的电脑上有音频,我可以听到游戏视频任何东西。
那么我会从这个列表中选择什么作为录制pc输出音频的音频设备呢?或者也许我需要找另一种方法来找到正确的音频设备?
Front Green In (Realtek(R) Audio) NotPresent
Rear (Realtek(R) Audio) NotPresent
Center (Realtek(R) Audio) NotPresent
Microphone (Realtek(R) Audio) NotPresent
Rear Grey In (Realtek(R) Audio) NotPresent
Side (Realtek(R) Audio) NotPresent
Internal AUX Jack (NVIDIA High Definition Audio) NotPresent
Internal AUX Jack (High Definition Audio Device) NotPresent
Internal AUX Jack (High Definition Audio Device) NotPresent
Rear Pink In (Realtek(R) Audio) NotPresent
Internal AUX Jack (NVIDIA High Definition Audio) NotPresent
Internal AUX Jack (High Definition Audio Device) NotPresent
Internal AUX Jack (NVIDIA High Definition Audio) NotPresent
Front (Realtek(R) Audio) NotPresent
Rear Orange In (Realtek(R) Audio) NotPresent
Line In (Realtek(R) Audio) NotPresent
Front Pink In (Realtek(R) Audio) NotPresent
Line In (Realtek(R) Audio) Unplugged
Internal AUX Jack (High Definition Audio Device) NotPresent
Internal AUX Jack (High Definition Audio Device) NotPresent
Microphone (Realtek(R) Audio) Unplugged
Subwoofer (Realtek(R) Audio) NotPresent
Rear Black In (Realtek(R) Audio) NotPresent
Stereo Mix (Realtek(R) Audio) Disabled
Rear Green In (Realtek(R) Audio) NotPresent
Microphone (Realtek(R) Audio) NotPresent
Rear Blue In (Realtek(R) Audio) NotPresent
Front Green In (Realtek(R) Audio) NotPresent
Rear (Realtek(R) Audio) NotPresent
Center (Realtek(R) Audio) NotPresent
Microphone (Realtek(R) Audio) NotPresent
Rear Grey In (Realtek(R) Audio) NotPresent
Side (Realtek(R) Audio) NotPresent
Internal AUX Jack (NVIDIA High Definition Audio) NotPresent
Internal AUX Jack (High Definition Audio Device) NotPresent
Internal AUX Jack (High Definition Audio Device) NotPresent
Rear Pink In (Realtek(R) Audio) NotPresent
Internal AUX Jack (NVIDIA High Definition Audio) NotPresent
Internal AUX Jack (High Definition Audio Device) NotPresent
Internal AUX Jack (NVIDIA High Definition Audio) NotPresent
Front (Realtek(R) Audio) NotPresent
Rear Orange In (Realtek(R) Audio) NotPresent
Line In (Realtek(R) Audio) NotPresent
Front Pink In (Realtek(R) Audio) NotPresent
Line In (Realtek(R) Audio) Unplugged
Internal AUX Jack (High Definition Audio Device) NotPresent
Internal AUX Jack (High Definition Audio Device) NotPresent
Microphone (Realtek(R) Audio) Unplugged
Subwoofer (Realtek(R) Audio) NotPresent
Rear Black In (Realtek(R) Audio) NotPresent
Stereo Mix (Realtek(R) Audio) Disabled
Rear Green In (Realtek(R) Audio) NotPresent
Microphone (Realtek(R) Audio) NotPresent
Rear Blue In (Realtek(R) Audio) NotPresent
Front Green In (Realtek(R) Audio) NotPresent
Rear (Realtek(R) Audio) NotPresent
Center (Realtek(R) Audio) NotPresent
Microphone (Realtek(R) Audio) NotPresent
Rear Grey In (Realtek(R) Audio) NotPresent
Side (Realtek(R) Audio) NotPresent
Internal AUX Jack (NVIDIA High Definition Audio) NotPresent
Internal AUX Jack (High Definition Audio Device) NotPresent
Internal AUX Jack (High Definition Audio Device) NotPresent
Rear Pink In (Realtek(R) Audio) NotPresent
Internal AUX Jack (NVIDIA High Definition Audio) NotPresent
Internal AUX Jack (High Definition Audio Device) NotPresent
Internal AUX Jack (NVIDIA High Definition Audio) NotPresent
Front (Realtek(R) Audio) NotPresent
Rear Orange In (Realtek(R) Audio) NotPresent
Line In (Realtek(R) Audio) NotPresent
Front Pink In (Realtek(R) Audio) NotPresent
Line In (Realtek(R) Audio) Unplugged
Internal AUX Jack (High Definition Audio Device) NotPresent
Internal AUX Jack (High Definition Audio Device) NotPresent
Microphone (Realtek(R) Audio) Unplugged
Subwoofer (Realtek(R) Audio) NotPresent
Rear Black In (Realtek(R) Audio) NotPresent
Stereo Mix (Realtek(R) Audio) Disabled
Rear Green In (Realtek(R) Audio) NotPresent
Microphone (Realtek(R) Audio) NotPresent
Rear Blue In (Realtek(R) Audio) NotPresent
这是我如何尝试与naudio,但它没有工作,它没有找到任何东西。:
using NAudio.Wave;
...
// Enumerate and list audio input devices
var devices = WaveInEvent.DeviceCount;
for (int deviceId = 0; deviceId < devices; deviceId++)
{
var deviceInfo = WaveInEvent.GetCapabilities(deviceId);
Console.WriteLine($"Device ID: {deviceId}, Name: {deviceInfo.ProductName}");
}
在此之前,我尝试了ffmpeg,但它也没有返回任何东西:
public static class FFmpegHelper
{
public static string[] GetAudioCaptureDevices()
{
string ffmpegPath = @"C:\path\to\ffmpeg.exe";
Process process = new Process();
process.StartInfo.FileName = ffmpegPath;
process.StartInfo.Arguments = "-list_devices true -f dshow -i dummy";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
process.WaitForExit();
string output = process.StandardError.ReadToEnd();
string[] lines = output.Split('\n');
var devices = lines.Where(line => line.Contains("audio")).Select(line => line.Trim()).ToArray();
return devices;
}
}
使用它:
var audioDevices = FFmpegHelper.GetAudioCaptureDevices();
1条答案
按热度按时间pb3s4cty1#
你的问题中有很多问题。首先,你需要重新阅读你自己的问题,看看它是否传达了你的意图。据我所知,您希望找到系统上的所有音频输出设备。并且您想要从这些输出设备录制音频输出。你的ffmpeg应该能用。但你做得很奇怪。
为什么要查看StandardError的输出?我觉得你不应该专门过滤“音频”这个词
试试这个
它会给予你这样的输出