guojing
guojing

Reputation: 79

Using ffmpeg, the function av_find_input_format("avfoundation") return null

I run this code in iPad mini 4 (Model A1538), iOS 11.2.6

Try to record audio by 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, and iformat = NULL.

Why should this happen, did I missed anything to set?

Upvotes: 0

Views: 1731

Answers (1)

Sico2 Sico
Sico2 Sico

Reputation: 11

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 input device. AVFoundation is the currently recommended framework by Apple for streamgrabbing on OSX >= 10.7 as well as on iOS. The input filename has to be given in the following syntax: -i "[[VIDEO]:[AUDIO]]"

Upvotes: 1

Related Questions