<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"><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.<br clear="none"></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">Well, thanks for the help, but actually this isn't true.  I tried this with the demuxing.c example and that didn't work.<br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;
 background-color: transparent; font-style: normal;"><br>>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 style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">Actually I have already wasted several weeks or months of coding time doing what you suggested: assume ffmpeg/libav works the way you want it, then start coding.  I think it's better to ask up front if libav is threadsafe before I spend a week implementing a multi-threaded app and then find out it can't possibly work because ffmpeg and libav are not thread-safe.</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;
 background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">I want to have multiple threads decoding different parts of the AVI file concurrently.  No encoding will occur.  Seems like it should be thread-safe.  But I'd like to know for sure before I start coding.  That's all.  Ask questions first, code later.  That stops me from complaining when libav doesn't do what I want.  I'll just choose another route.</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida
 Grande,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="display: block;" class="yahoo_quoted"> <br> <br> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On , Bruce Wheaton <bruce@spearmorgan.com> wrote:<br> </font> </div>  <div class="y_msg_container"><div id="yiv3076803796"><div><div><div>On Oct 8, 2013, at 12:05 PM, James Board <<a rel="nofollow" shape="rect" ymailto="mailto:jpboard2@yahoo.com" target="_blank" href="mailto:jpboard2@yahoo.com">jpboard2@yahoo.com</a>> wrote:</div><br class="yiv3076803796Apple-interchange-newline" clear="none"><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;"><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 clear="none"></div></div></div></blockquote><div><br clear="none"></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 clear="none"><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;"><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 clear="none"></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><div class="yiv3076803796yqt2178940347" id="yiv3076803796yqtfd69708"><br clear="none"><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;"><div><br clear="none"></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></div><br clear="none"></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 clear="none"></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 clear="none"></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
 clear="none"></div><div>Bruce</div><div class="yiv3076803796yqt2178940347" id="yiv3076803796yqtfd74218"><div><br clear="none"></div><div><br clear="none"></div><div><br clear="none"></div><br clear="none"></div></div></div><br>_______________________________________________<br clear="none">Libav-user mailing list<br clear="none"><a shape="rect" ymailto="mailto:Libav-user@ffmpeg.org" href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br clear="none"><a shape="rect" href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><div class="yqt2178940347" id="yqtfd33330"><br clear="none"></div><br><br></div>  </div> </div>  </div> </div></body></html>