视频采集的时候,windows环境下,deviceName怎么获取,AVInputFormat怎么设置

来源:9-9 实战从视频设备上采集数据1

江南烟雨梦

2023-04-28

void VideoCapture()
{
	int ret = 0;
	char error[1024];
	AVFormatContext* fmt_ctx = nullptr;		//格式化I/O上下文
	AVDictionary* options = nullptr;
	const char* deviceName = "0";
	av_dict_set(&options, "video_size","640*480", 0);
	av_dict_set(&options, "framerate", "640*480", 0);

	//1,注册设备
	avdevice_register_all();

	//2,设置采样方式
	const AVInputFormat* iformat = av_find_input_format("avfoundation");

	//3,打开音频设备
	ret = avformat_open_input(&fmt_ctx, deviceName, iformat, &options);

deviceName 设置为“0”或者本地相机设备名”ntegrated Camera“,在avformat_open_input中,一直返回-2,const AVInputFormat* iformat = av_find_input_format(“avfoundation”);这里采样方式设置的是“video4linux2”还是什么?

写回答

1回答

李超

2023-04-29

-f dshow “video=xxxx",注意如果你的设备名是中文,需要用utf-8编码

0
0

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

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

2317 学习 · 813 问题

查看课程