FFmpeg:协议不在白名单’文件’上!

我想从RTP流中读取,但是当我将“test.sdp”指定为avformat_open_input()我收到以下消息:

 [rtp @ 03928900] Protocol not on whitelist 'file'! Failed: cannot open input. avformat_open_input() fail: Invalid data found when processing input 

通常,如果我在控制台上使用-protocol_whitelist file,udp,rtp ,我会添加选项-protocol_whitelist file,udp,rtp ,它会正常工作。

所以我尝试了这个:

 AVDictionary *d = NULL; av_dict_set(&d, "protocol_whitelist", "file, udp, rtp", 0); ret = avformat_open_input(&inFormatCtx, filename, NULL, &d); 

但同样的消息仍然会出现。 有任何想法吗?

这很尴尬……

avformat_open_input失败,因为我有空格。 删除空格现在可以正常工作。

 av_dict_set(&d, "protocol_whitelist", "file,udp,rtp", 0); 

编辑 :这个答案适用于某些版本。 您应该使用avformat_open_input的options参数,如bot1131357的答案中所述


我对此并不完全确定,但我相信这些选项会进入AVFormatContext

 AVFormatContext* formatContext = avformat_alloc_context(); formatContext->protocol_whitelist = "file,udp,rtp"; if (avformat_open_input(&formatContext, uri.c_str(), NULL, NULL) != 0) { return EXIT_FAILURE; } 

看看这个变化的cvs日志: https : //ffmpeg.org/pipermail/ffmpeg-cvslog/2016-March/098694.html