Yes, I adapted your code in my project (running on Linux), and it worked fine!
Thx a lot! ps: I still think ffmpeg API should have something like a timeout check. Maybe as a field in AVInputFormat... 2011/2/16 Steffen Ebersbach <[email protected]>: > On 15.2.2011 16:19, Leandro Santiago wrote: >> >> Thx for your answer. >> >> Do you have any examples? Where need I use this callback? When I open >> the video? Which parameters are necessary to this function? I couldn't >> find much information searching on web. > > Hello, > > here is my code with the callback function to realize a timeout on > av_read_frame. It is written in C++ with Visual Studio in Windows, but with > a little change also usable in other systems. > > First you have to initialize the call back function in libav. At this time > libav call this function in blocking functions (av_read_frame) > > url_set_interrupt_cb(decode_interrupt_cb); > > The implementation of this function looks like that: > > LONGLONG timeout; //für decode_interuppt_cb > static int decode_interrupt_cb(void) > { > LARGE_INTEGER ptime; > QueryPerformanceCounter(&ptime); > if (ptime.QuadPart > timeout) //timeout arrived? > return 1; > //return 0 for no timeout > return 0; > } > > In the program every time i call a blocking function of libav I set a new > timeout (ptime): > > QueryPerformanceCounter(&ptime); > timeout = ptime.QuadPart + pfreq.QuadPart *5; //Timeout > res = av_read_frame(decforctx,&re_pkt); > > The QueryperformanceCounter is a 64 bit value of windows. The frequnecy > depends on the architecture of the pc, but is constant. I use it as a > relative time to define the timeout. The Callback function check the time > and decide to skip the function of libav. > > I hope the code helps you. > > Steffen > _______________________________________________ > libav-user mailing list > [email protected] > https://lists.mplayerhq.hu/mailman/listinfo/libav-user > _______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user
