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

Stas Oskin stas.oskin
Sat Feb 10 23:16:38 CET 2007


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.

Thanks.




More information about the ffmpeg-devel mailing list