<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Oct 8, 2013, at 12:05 PM, James Board <<a href="mailto:jpboard2@yahoo.com">jpboard2@yahoo.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; position: static; z-index: auto; "><div>I want to create several pthreads in a C++ program (assuming you can call</div><div>libav routines from a C++ program) that each call libav subroutines.  <br></div></div></div></blockquote><div><br></div>Well, yes, you can call C from a C++ app. You need to mark the headers as C when you include them, but that's about it.</div><div><br><blockquote type="cite"><div><div style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; position: static; z-index: auto; "><div style="font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal; ">Are the libav subroutines  thread-safe?  Specifically,</div><div>can several pthreads open the same AVI file and decode different video</div><div>frames concurrently?</div></div></div></blockquote><div><br></div><div>No, not really. At least, you'd have to lock the access entirely, which would make it sequential. You can use each context in one thread, and there are a few overall functions that need locking, such as choosing the right codecs for a file.</div><br><blockquote type="cite"><div><div style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; position: static; z-index: auto; "><div><br></div><div style="font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal; ">I'm doing this so I can write a real-time video
 that</div><div>can play the video forward and backwards, and the multiple threads will</div><div>help decode and process each frame quickly so there will be no delay when</div><div>I step through the video.</div></div></div></blockquote><br></div><div>Most codecs are multi-threaded by now - so there already are threads running to decode frames. You can set the number of threads you want a codec to use when you open it.</div><div><br></div><div>There's a number of other things you could do... multiple codecs open etc. But with codecs that need B and P frames, you pretty much have to decode in order anyway, and file access is always going to be one at a time.</div><div><br></div><div>It sounds like you're trying to solve a problem that you don't have yet. Start with the basics - just getting going from a cold start in ffmpeg is enough trouble for most people, without trying to get clever.</div><div><br></div><div>Bruce</div><div><br></div><div><br></div><div><br></div><br></body></html>