设置回调,每次 av_read_frame 前刷新时间
static int InterruptFouction(void *theTimeSpec)
{
if (!theTimeSpec) {
return 0;
}
std::cout << "InterruptFouction called~!" << std::endl;
time_t mtime;
time(&mtime);
time_t *t = (time_t*)theTimeSpec;
if( ( mtime - *t ) > 5) {
return 1;
}
return 0;
}
time_t TimeNow;
m_pFmtCtx->interrupt_callback.callback = InterruptFouction;
m_pFmtCtx->interrupt_callback.opaque = &TimeNow;
while(isRunning){
time(&TimeNow);
ret = av_read_frame(m_pFmtCtx, m_pAVPacket);
if ( ret == 0 ) {
// to do something
} else {
break;
}
}