On Sat, Apr 10, 2010 at 10:37 AM, Bruce Wheaton <[email protected]> wrote: > On Apr 10, 2010, at 4:07 AM, Thomas Worth wrote: > >> I have a loop that decodes frames using avcodec_decode_video2(), and >> am spawning threads to convert the data put into the AVFrame struct >> and write it to disk. However, even though I allocated multiple >> structs to hold the picture data, frames are overwriting each other: > > Are you serializing access to the file? Possibly the frames are fine but all > the threads are doing overlapping writes to the file. > > Bruce
Yep. Each new thread gets its own AVFrame and unique file number. Its job is to write one frame to disk, using the passed AVFrame struct as its picture source. It uses the passed file number (from the main for loop) to serialize the output image sequence. So, each thread will only ever get one frame worth of data (the result from avcodec_decode_video2), making this problem seem impossible. However, I'm not sure how libavcodec handles this stuff internally so I'm not sure how to fix it. I noticed that allocating multiple AVFrame structures in an array doesn't make any difference versus just using the same struct over and over. Do I need to set up the program in such a way that the libav* libraries know I'm doing simultaneous (threaded) reads? _______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user
