2016-09-08 20 views
4

我想從一個RTP流中讀取,但是當我指定「test.sdp」以avformat_open_input()我得到這個消息:FFmpeg:協議不在白名單'文件'上!

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

通常情況下,如果我用ffplay在控制檯上,我想補充的選項-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); 

但同樣的消息仍然彈出。有任何想法嗎?

回答

3

這是尷尬...

avformat_open_input因爲我有空白空間而失敗。刪除空白現在工作。

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

這實際上並不適用於我......這是你做的唯一改變嗎? – Nitay

+1

是的。如果您查看調試,則將「inFormatCtx-> protocol_whitelist」設置爲「file,udp,rtp」。你能解釋更多關於它如何不適合你的嗎? – bot1131357

+0

當我在字典中設置了protocol_whitelist時,我仍然得到'Protocol not whitelist'錯誤。可能是版本問題?無論如何 - 它現在適用於我們兩個人,所以一切都很好:) – Nitay

0

編輯:此答案適用某些版本。您應該使用avformat_open_input的選項參數作爲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

+0

感謝您的幫助!你的方法也起作用。然而,源代碼有關protocol_whitelist的說法:*由用戶通過AVOptions設置(** NO直接訪問**)*,因此我決定現在使用Dictionary方法。 – bot1131357