vs2017打开音频设备时报错
来源:6-8 打开音频设备

慕沐4514409
2021-03-09
void ffmpegTest()
{
//audio format context
//save whole audio context information
AVFormatContext *avfcontext;
//save error information
char errorinfo[1024];
AVDictionary *options = NULL;
// ret < 0 represent failing to open device
int ret = 0;
//the order to list local device
//or to use device manager to find local device
//ffmpeg -list_devices true -f dshow -i dummy
//format for mac : [[video device] : [ audio device]]
//format for windows : [video[or audio]=麦克风(Realtek(R) Audio)]
//need to format devicename to utf-8
char devicename[] = "audio=麦克风阵列(Realtek High Definition Audio)";
//register all audio device
avdevice_register_all();
//get audio input format
/*
avfoundation: mac
dshow: windows
alsa: linux
*/
AVInputFormat *aviformat= av_find_input_format("dshow");
/*
open audio input stream
@param AVFormatContext :
@param char url : open audio from url
@param AVInputFormat :
@param AVDictionary : argument to control device property
*/
//open
if ((ret = avformat_open_input(&avfcontext, devicename, aviformat, &options)) < 0)
{
av_strerror(ret,errorinfo,1024);
printf("Failed to open audio device,[%d]%s\n", ret, errorinfo);
return;
}
}
写回答
3回答
-
李超
2021-10-31
参考我上传的例子程序
00 -
truedei
2021-10-30
请问解决了吗00 -
李超
2021-03-10
应该是你的设备名没用utf-8编码导致的
062021-03-14
相似问题