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

参考我上传的例子程序

0
0

truedei

2021-10-30

请问解决了吗
下载视频          
0
0

李超

2021-03-10

应该是你的设备名没用utf-8编码导致的

0
6
李超
那还是找不到设备名呀
2021-03-14
共6条回复

音视频小白系统入门课 音视频基础+ffmpeg原理

掌握音视频采集、编解码、RTMP传输协议等核心基础

2318 学习 · 813 问题

查看课程