简体   繁体   English

C#-表达式编码器-无法捕获系统音频

[英]c# - expression encoder - does not capture system audio

I'm trying to capture my webcam and system audio using Expression Encoder, the webcam works fine but the system audio is just silent. 我正在尝试使用Expression Encoder捕获网络摄像头和系统音频,网络摄像头工作正常,但系统音频只是静音。

I followed the tutorial here: CodeProject Expression Encoder Tutorial but it isn't working for me properly. 我在这里遵循了该教程: CodeProject Expression Encoder教程,但是它不适用于我。

When I list the audio devices, "Speakers...", "Microphone..." and "Headphones..." are listed (as they are in Playback Devices in the system tray) but if I try and record from either Speakers or Headphones I get nothing (I get the mic audio fine if I select that one). 当我列出音频设备时,列出了“扬声器...”,“麦克风...”和“耳机...”(就像它们在系统托盘中的“播放设备”中一样),但是如果我尝试从两个扬声器中录制或耳机,我什么也没收到(如果选择该麦克风,我的麦克风音频会很好)。

Here is the code I'm using: 这是我正在使用的代码:

job = new LiveJob();

LiveDeviceSource lds = job.AddDeviceSource(ledv[0], leda[1]);

FileArchivePublishFormat fileOut = new FileArchivePublishFormat();
fileOut.OutputFileName = string.Format("C:\\Users\\user1\\Desktop\\testvideo-{0:yyyyMMdd_hhmmss}.wmv", DateTime.Now);

job.PublishFormats.Add(fileOut);

lds.PreviewWindow = new PreviewWindow(new System.Runtime.InteropServices.HandleRef(panel1, panel1.Handle));

job.StartEncoding();

job.ActivateSource(lds);

Does anyone have any idea why it doesn't record system audio? 有谁知道为什么不录制系统音频? Are there any other settings I need to mess with before it should work? 在工作之前,我还有其他设置需要弄乱吗?

Thanks for your time. 谢谢你的时间。

EDIT: 编辑:

I decided to print out job.CurrentAudioVolume when it is encoding to see if this ever changed but it always just sits at 0. If I change the audio device to the microphone, this value goes up when there is sound (as expected). 我决定在对其进行编码时打印job.CurrentAudioVolume,以查看它是否曾经改变过,但始终始终为0。如果我将音频设备更改为麦克风,则在有声音时(如预期的那样)该值会增加。 So it definitely looks like the SDK is unable to record my system audio (either from Speakers or Headphones). 因此,肯定看起来SDK无法记录我的系统音频(从扬声器或耳机)。

Okay I sorted it out with a bit of help from a colleague. 好吧,我在同事的帮助下进行了整理。

Basically Headphones/Speakers etc. are just output devices and so you need to install a loopback driver as an input device. 基本上,耳机/扬声器等只是输出设备,因此您需要安装回送驱动程序作为输入设备。

There's a free one on Sourceforge / Github that works great. Sourceforge / Github上有一个免费的,效果很好。 Just select it as the audio device. 只需选择它作为音频设备。

There is one small problem, I've got a "record"/"stop" button that calls job.StopEncoding(); 有一个小问题,我有一个“记录” /“停止”按钮,它调用job.StopEncoding();。 but with the loopback audio driver chosen StopEncoding() hangs the Window, I guess because the loopback driver doesn't get stopped properly, but if you call job.RemoveDeviceSource(deviceSource); 但是选择了环回音频驱动程序StopEncoding()会挂起Window,我想是因为环回驱动程序无法正确停止,但是如果您调用job.RemoveDeviceSource(deviceSource); after you call StopEncoding() and then re-add before the next StartEncoding() it works fine. 在您调用StopEncoding()然后在下一个StartEncoding()之前重新添加之后,它可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM