目录

FFMPEG获取音视频的设备列表

FFMPEG获取音视频的设备列表

https://img-home.csdnimg.cn/images/20240715101418.png

关键词由CSDN通过智能技术生成

命令行实现

FFMPEG可以直接通过命令行获取音视频设备列表,命令如下:

ffmpeg -list_devices true -f dshow -i dummy

执行结果如下图:

https://i-blog.csdnimg.cn/blog_migrate/eda9066388d66dae5f1e46f94fb029af.png

相关链接:

程序实现

#include <iostream>

extern "C" 
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
#include <libswscale/swscale.h>
#include <libavdevice/avdevice.h>
}

#pragma comment(lib, "avcodec.lib")
#pragma comment(lib, "avformat.lib")
#pragma comment(lib, "avutil.lib")
#pragma comment(lib, "swscale.lib")
#pragma comment(lib, "avdevice.lib")

using namespace std;

void showDevice()
{
	AVFormatContext* pFormat = avformat_alloc_context();
	AVDictionary *dict = NULL;
	av_dict_set(&dict, "list_devices", "true", 0);
	AVInputFormat* fmt = av_find_input_format("dshow");
	avformat_open_input(&pFormat, "video=dummy", fmt, &dict);
}

void showOption()
{
	AVFormatContext* pFormat = avformat_alloc_context();
	AVDictionary* dict = NULL;
	av_dict_set(&dict, "list_options", "true", 0);
	AVInputFormat* fmt = av_find_input_format("dshow");
	avformat_open_input(&pFormat, "video=Integrated Camera", fmt, &dict);

}


int main()
{
	av_register_all();
	avdevice_register_all();

	cout << "device list:" << endl;
	showDevice();

	cout << "device option:" << endl;
	showOption();

	return 0;
}

执行结果如下图:

https://i-blog.csdnimg.cn/blog_migrate/0956879fad220413cebce5118c0c4b4e.png

其它说明

  • FFMPEG设置设备分辨率和帧率链接: