FFmpeg: Protocol not on whitelist 'file'!

丶灬走出姿态 提交于 2019-12-07 11:24:16

问题


I want to read from an RTP stream, but when I specify "test.sdp" to avformat_open_input() I get this message:

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

Normally if I were using ffplay on the console, I would add the option -protocol_whitelist file,udp,rtp and it would work fine.

So I tried this:

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

But the same message still pops up. Any ideas?


回答1:


This is awkward...

avformat_open_input failed because I have white spaces. Removing the whitespaces now work.

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



回答2:


EDIT: This answer works up to some version. You should use the options parameter of avformat_open_input as described in bot1131357's answer


I'm not totally sure about this, but I believe this options go into the 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;
}

Take a look at the cvs log of this change: https://ffmpeg.org/pipermail/ffmpeg-cvslog/2016-March/098694.html



来源:https://stackoverflow.com/questions/39380730/ffmpeg-protocol-not-on-whitelist-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!