FFMPEG获取音视频的设备列表
目录
FFMPEG获取音视频的设备列表
关键词由CSDN通过智能技术生成
命令行实现
FFMPEG可以直接通过命令行获取音视频设备列表,命令如下:
ffmpeg -list_devices true -f dshow -i dummy
执行结果如下图:
相关链接:
程序实现
#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;
}
执行结果如下图:
其它说明
- FFMPEG设置设备分辨率和帧率链接: