ios - 使用 ffmpeg,函数 av_find_input_format("avfoundation") 返回 null
问题描述
我在 iPad mini 4(型号 A1538)、iOS 11.2.6 中运行此代码
尝试通过 FFmpeg 录制音频。
av_register_all();
avcodec_register_all();
avdevice_register_all();
AVFormatContext *pFormatCtx = avformat_alloc_context();
AVDictionary* options = NULL;
av_dict_set(&options,"list_devices","true",0);
AVInputFormat *iformat = av_find_input_format("avfoundation");
printf("==AVFoundation Device Info===\n");
avformat_open_input(&pFormatCtx,"",iformat,&options);
printf("=============================\n");
if(avformat_open_input(&pFormatCtx,"0",iformat,NULL)!=0){
printf("Couldn't open input stream.\n");
return;
}
pFormatCtx
=NULL
和iformat
= NULL
。
为什么会发生这种情况,我错过了什么设置吗?
解决方案
inputContext = avformat_alloc_context();
AVDictionary* options = NULL;
av_dict_set(&options, "video_size","960x54", 0);
av_dict_set(&options, "r","30", 0);
AVInputFormat *iformat = av_find_input_format("avfoundation");
int ret = avformat_open_input(&inputContext,"0:0", iformat,&options);
AVFoundation 输入设备。AVFoundation 是 Apple 目前推荐的用于在 OSX >= 10.7 以及 iOS 上进行流抓取的框架。输入文件名必须以以下语法给出:-i "[[VIDEO]:[AUDIO]]"
推荐阅读
- python - django中的一对多关系-如何强制父母至少有一个孩子
- c# - Oracle 数据访问输出参数混淆
- c# - Windows 窗体 - 按 Enter 时添加行时出现问题
- c# - 在 CRM 中将附有注释的 Word 文档转换为 PDF
- reactjs - Recharts 堆叠区域显示错误的 yAxis 标签?
- c - 为什么我不能遍历这个堆栈?
- mysql - LUIS 到 MySQL 查询 - Azure 聊天机器人
- reactjs - 使用 Ant design getFieldDecorator 时触发其他验证消息而不是我的消息
- c# - 如何创建两个具有相同形式的设置?
- android-studio - android studio在哪里生成release和debug apk?