[Ffmpeg-devel] Random crashes when using libavcodec in different threads

Bernhard Prell bernhard.prell
Mon Jul 25 13:57:56 CEST 2005

Dear ffmpeg-Gurus,

I'm trying too integrate/use libavcodec in my own program and got it working 
as long it's running "alone". That means I'm using multiple threads to encode 
different movies (to *.vob) on a smp system. (I'm _not_ interested in 
accelerating the encoding of a _single_ movie by using the 
multi-thread-capabilities of ffmpeg!)

Problem: My program crashes randomly at the beginning when I'm for example 
using libav* in two threads. Then one of the threads dies in 
"ff_estimate_p_frame_motion" and the other was for example in 
"MPV_common_init_mmx" or "ff_dct_sse2" or "dsputil_init_pix_mmx".
Maybe it's somehow mmx, sse*- register-save/restore related?
The threads are of course completely independent of each other, everyone has 
it's own set of context-variables etc. It should be comparable to starting to 
processes of ffmpeg at nearly the same time. The crash seems to get  
extremely more unlikely if the threads don't start at the "same" time but for 
example 500 ms later. But I don't think that's a real solution, it just makes 
it less likely to crash. (Although I haven't seen a crash since this 

My question: Is there anything that I can/should lock before calling a certain 
av_* function? Can somebody explain what might be a problem? Sorry, if I gave 
you too few info.

Thank you very much in advance,


More information about the ffmpeg-devel mailing list