[Ffmpeg-devel] Using avcodec threaded help request

Scott Harper orcein
Tue Mar 27 06:14:40 CEST 2007


Hello,

I'm using libav* for my program which needs to have multiple video  
files open and running simultaneously, and I have everything working  
very nicely threaded with only one video file open (one thread reads  
packets and places them in queues, a trick learned from ffplay, one  
thread decodes audio and plays that using SDL, and the other is the  
main thread which handles drawing the video).  I have it set up so  
that each video file has its own reading/enqueueing thread.  Audio is  
necessarily accessed by another thread, and the drawing is all  
gathered from a third thread.

The problem I'm encountering is when trying to decode from multiple  
videos at the same time.  The videos play for a fraction of a second  
and then either the whole app freezes (some kind of thread-lock?) or  
only one of the videos decodes correctly while the other constantly  
reports errors when trying to decode.

I read that libav* is generally considered non-thread-safe, and found  
a file called "pthreads.c", which looks promising, but I cannot seem  
to find an example program using it, nor can I seem to determine the  
proper means of use just by reading the code.

If someone could offer a description of pthreads' usage or show me to  
a working example I would be very appreciative! ^_^

Thanks,
-- Scott




More information about the ffmpeg-devel mailing list