[Libav-user] Interrupt network wait in av_read_frame() to seek

Andrey Utkin andrey.krieger.utkin at gmail.com
Tue Aug 28 20:47:56 CEST 2012

We implement a player using libavformat. Player reads MPEGTS streams
via protocols HLS and HTTP.
Application calls av_read_frame() as usual; note that this call is
blocking due to network delays.
Let's imagine that app has stuck inside av_read_frame() for long time,
and at this time user wants to seek on the stream to particular place.
It would be perfect to interrupt the read and proceed with seeking
immediately. What is elegant solution to do this without delay?
What we have thought about so far:
1. Interrupt the protocol reader using avio callback, and reopen the
stream. Not an option, huge delay for reopen.
2. Fire the interrupt using avio callback, and then proceed working on
opened stream. It is an abuse of interrupt callback concept and should
not work theoretically.
3. Non-blocking demuxing (*_FLAG_NONBLOCK). Seems under construction.
Don't see mentions of these flags neither in http protocol driver, nor
in hls, mpegts demuxers.
Andrey Utkin

More information about the Libav-user mailing list