When I was using this ffmpeg API interface, I found that when avformat_open_input opens an invalid network url (a network url that does not exist a stream), the function avformat_open_input will always block, but when I set a timeout, it runs for a while, and it succeeds After opening a network stream, the timeout expires and becomes blocked again. Why is this?
AVDictionary *options = YNULL;
av_dict_set(&options, "timeout", "100000", 0); //us
char buf[] = "";
int err_code = avformat_open_input(&pThis->m_pAvFormatContext, pThis->m_strFileName.c_str(), YNULL, &options);
av_strerror(err_code, buf, 1024);
if(err_code != 0)
{
printf("Couldn't open stream (%s): %d(%s)\n",pThis->m_strFileName.c_str(), err_code, buf);
pThis->m_bStreamHaveOpened = YFALSE;
}
else
{
printf("Open sucessfully! stream (%s): %d(%s)\n",pThis->m_strFileName.c_str(), err_code, buf);
pThis->m_bStreamHaveOpened = YTRUE;
}