CSCore loopback recording when muted

天大地大妈咪最大 提交于 2019-12-11 13:25:30

问题


I'm using CSCore.WasapiLoopbackCapture to record system sound. But when there is no sound in system, it doesn't record at all! For instance, while playing music and recording it, the output file's duration is less than the track's. I want it to continue recording even when there is no sound in the system but I didn't find any property to control this behavior. Here is my code snippet:

WasapiCapture waveLoop = new WasapiLoopbackCapture();
waveLoop.Initialize();
waveLoop.DataAvailable += waveLoop_DataAvailable;
waveLoop.Stopped += waveLoop_Stopped;
waveLoop.Start();

回答1:


There is no "nice" solution for your "problem". But your problem already got described here:

Another oddity is that WASAPI will only push data down to the render endpoint when there are active streams. When nothing is playing, there is nothing to capture.

That means that there is nothing you can do against that behavior. If there is nothing playing, nothing will be captured. The easiest solution is:

But my particular favorite way of handling this is to run silence.exe. That way there are never any "nothing is playing" glitches, because there's always something playing.

So just make sure your application or any other application plays silence. That would be a way to make sure that your application records silence instead of interrupting the capture.



来源:https://stackoverflow.com/questions/24135557/cscore-loopback-recording-when-muted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!