I tried to capture audio with 48 kHz in FFmpeg, the code as below:
AVInputFormat* ifmt = av_find_input_format("dshow");
CHECK_POINTER_RETURN_VALUE(ifmt, false)
pFmtCtx = avformat_alloc_context();
CHECK_POINTER_RETURN_VALUE(pFmtCtx, false)
AVDictionary *param = nullptr;
std::string sr = std::to_string(48000);
av_dict_set(¶m, "sample_rate",sr.c_str(), 0);
int error = avformat_open_input(&pFmtCtx, ffName.c_str(), ifmt, ¶m);
if (error != 0) {
char buf[2014];
av_strerror(error, buf, 1024);
LOG(ERROR)<<"open audio device failed,err is "<<buf;
return false;
}
but "avformat_open_input" return fail, err shows "I/O error", if the sample rate is 44100, all is OK.
Now FFmpeg doesn't support capturing 48 kHz audio?