I use ffmpeg to decode RTSP video.It likes that: When it\'s on the end of file,it block in the av_read_frame() for a long time,why?
This problem come because av_read_frame() stuck in network infinite loop I got the same problem then I have used interrupt call back please refer the sample code
First initialize your context and set interrupt call back
AVFormatContext *_formatCtx;
//Initialize format context
_formatCtx=avformat_alloc_context();
//Initialize intrrupt callback
AVIOInterruptCB icb={interruptCallBack,(__bridge void *)(self)};
_formatCtx->interrupt_callback=icb;
now handle the interrupt in your callback
int interruptCallBack(void *ctx){
//once your preferred time is out you can return 1 and exit from the loop
if(timeout){
//exit
return 1;
}
//continue
return 0;
}