[Ffmpeg-devel] Stream file handle hijacking by another thread

Michael Niedermayer michaelni
Sun Feb 11 01:53:48 CET 2007


Hi

On Sun, Feb 11, 2007 at 12:16:38AM +0200, Stas Oskin wrote:
> Hi.
> 
> I have several threads, each encoding to a separate file. I discovered
> a problem that might be a bug in libavcodec:
> When a thread opens new file and starts writing to it, another running
> thread occasionally looses it's own file handle, and begins writing to
> the new file as well.
> 
> Best example to describe it, is 2 threads recording 2 video feeds to 2
> video files. When the 2nd thread creates the file and begins writing
> to it, the 1st thread begins writing to this file as well (abandoning
> it's own file).
> 
> This problem worsens with increased number of CPU and threads. On my
> test system with 2 dual-core Opterons (4 virtual cpu), and 15
> concurrent threads, it happens almost every time a thread creates new
> file.
> 
> I have tried to resolve it by locking every libavcodec function I'm
> using, but this didn't help.
> 
> I also receive a lot of errors from av_write functions, probably
> because several threads are trying to write to the same file. There
> are no textual error messages from libavcodec.
> 
> I'll really appreciate anyone pointing me to any direction to resolve
> this problem.

did you compile lav* with --enable-pthreads ?

if above doesnt help try recompile libav* (and your application if needed)
with -D_REENTRANT -D_THREAD_SAFE

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070211/86edd97c/attachment.pgp>



More information about the ffmpeg-devel mailing list