解決方法:
AVDictionary* pOptions = NULL;
pFormatCtx->probesize = 500 * 1024;
pFormatCtx->max_analyze_duration = 8 * AV_TIME_BASE;
if (avformat_find_stream_info(pFormatCtx, NULL)<0) {
printf("Couldn't find stream information.\n");
return -1;
}
avformat_find_stream_info 的第二個參數不能設定空指針,否則會崩潰,原因如下:
http://blog.csdn.net/lanxiaziyi/article/details/71667267?locationNum=4&fps=1
av_register_all();
avformat_network_init();
url = "http://ltsbsy.qq.com/GB8lF6TL4NgUddNDzdolIN4HvPZ8zz5daxlsXsx5-6cZSDGZ6BCCX3rCl-gReh6iEaTVGJs0ZmqZVbOCYENLACEvBl-LtHkj-r6V9gAo4IcLvTrdg_yHcA/r0023flooix.320092.ts.m3u8?ver=4&sdtfrom=v4000&platform=10103&appver=5.0.2.4720";
//這個連結過一會兒就失效了
m_pFormatCtx = avformat_alloc_context();
AVDictionary *dic2 = NULL;
AVInputFormat *m_pInFmt = NULL;
int ret2 = avformat_open_input(&m_pFormatCtx, url.toLocal8Bit(), m_pInFmt, &dic2);
AVDictionary *dic3 = NULL;
ret3 = avformat_find_stream_info(m_pFormatCtx, &dic3);//這裡尋找流的資訊,會卡個1s左右,因為它在尋找流的資訊
然後 avformat_find_stream_info 就崩潰了
為什麼呢?
後來在以為大神的指導下,改為了
avformat_find_stream_info(m_pFormatCtx, NULL);
就OK了
以前以為傳入一個指向NULL的指針,和 NULL一樣,現在看來是不一樣的
具體的解釋,看這個函數的文檔就知道了
* @param options If non-NULL, an ic.nb_streams long array of pointers to
* dictionaries, where i-th member contains options for
* codec corresponding to i-th stream.
* On return each dictionary will be filled with options that were not found.