AudioRecorder
AudioRecorder copied to clipboard
Cannot open audio stream...
Hi, and thanks for making this code available. I am trying to use it to record from the microphone port, and i am getting an error.
When i add:
if (deviceName == "") {
deviceName = DS_GetDefaultDevice("a");
if (deviceName == "") {
throw std::runtime_error("Fail to get default audio device, maybe no microphone.");
}
}
deviceName = "audio=" + deviceName;
std::cout << deviceName << std::endl;
it preints:
audio=Microphone (Realtek Audio)
which is as expected.
but the next section:
AVInputFormat *inputFormat = av_find_input_format("dshow");
ret = avformat_open_input(&audioInFormatCtx, deviceName.c_str(), inputFormat, &options);
if (ret != 0) {
std::cout << ret << std::endl;
throw std::runtime_error("Couldn't open input audio stream.");
}
I get the following:
[dshow @ 0000023160812b40] Could not run graph (sometimes caused by a device already in use by other application)
-5
[ERROR] Couldn't open input audio stream.
When i use, for example, the default windows voice recorder application, it records fine from teh same port and device.
What could be causing this?
Thank you.
it works fine to me...
Does it just error when run the main1() in main.cpp?
or you just call the function? (in this case you need to call avdevice_register_all(); at first)