pFormatCtx = avformat_alloc_context();
AVDictionary* options = NULL;
av_dict_set(&options, "rtsp_transport", "tcp", 0);
ret = avformat_open_input(&pFormatCtx, cFullPath, 0, &options);
AVDictionary* options = nullptr;
av_dict_set(&options, "rtsp_transport", "udp", 0); //以udp方式打开,如果以tcp方式打开将udp替换为tcp
av_dict_set(&options, "stimeout", "3000000", 0); //设置超时断开连接时间
设置解码为264格式:
//添加这句话AVInputFormat* iformat=av_find_input_format("h264");(因为我的视频时H.264压缩的,
iformat为空,则会报异常:1094995529。
这句话为强制指定视频的输入格式。估计我的视频压缩不标准导致了pFormatCtx无法获取正确的AVInputFormat)
int errocode=avformat_open_input(&pFormatCtx,filepath,iformat,NULL);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)