[Libav-user] Is packing reading can really work in a separate thread?

Max Vlasov max.vlasov at gmail.com
Thu Jul 2 19:41:04 CEST 2015


Hi,

I have a code when packets is cached using a separately working thread. It
reads a number of packets in advance and gives them to decoder when it
needed them. I made sure that seek operations and av_read_frame are
mutually exclusive and basically everything worked. For testing purposes I
also sometimes use another object that always reads packet in the main
decoding thread (sequential).

But once threading failed when I needed seeking to the end of an mp3 file
(avformat_seek_file with a very big requested timestamp). Sequential one
always worked (allowed reading at least one packet after this operation)
while the threading one sometimes allowed, sometimes not. Incidentally, a
trick with calling avio_flush after the seek operation helped this
particular problem (the threading one now always allows reading at least
one packet after the big seek), but I started notice visual artifacts with
some videos, so looks like avio_flush is not a correct call after all.

So, is there universal (with any demuxer) approach with making packet
reader working in a thread while keeping the the stream/seek state in
correct state?

Thanks in advance

Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20150702/616ca402/attachment.html>


More information about the Libav-user mailing list