问题
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