Re: [Libav-user] Is libav thread-safe?

2013-10-09 Thread James Board
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.


Well, thanks for the help, but actually this isn't true.  I tried this with the 
demuxing.c example and that didn't work.


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.

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.

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.





On , Bruce Wheaton br...@spearmorgan.com wrote:
 
On Oct 8, 2013, at 12:05 PM, James Board jpboa...@yahoo.com wrote:

I want to create several pthreads in a C++ program (assuming you can call
libav routines from a C++ program) that each call libav subroutines.  

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.


Are the libav subroutines  thread-safe?  Specifically,
can several pthreads open the same AVI file and decode different video
frames concurrently?

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.




I'm doing this so I can write a real-time video that
can play the video forward and backwards, and the multiple threads will
help decode and process each frame quickly so there will be no delay when
I step through the video.

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.

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.

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.

Bruce




___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


Re: [Libav-user] Compile with g++

2013-10-09 Thread James Board
That's an example program written in C. There's nothing in the actual 
codebase (as opposed to the examples) that doesn't work in C++.

Yes, I know it's a program written in C.  As I stated before, I only used that 
example because everyone here already has a copy of it.  The alternative would 
be for me to post my lengthy C++ code, which uses lots of thrid-part libraries, 
which nobody will be able to compile anyway).

When I compile demuxing.c with g++ it gives me the same errors as when I add 
libav calls to my C++ app and then try to compile that with g++.  So, if we can 
figure out why demuxing.c won't compile with g++, then we will probably figure 
out why my C++ app won't compile with g++.  




On Tuesday, October 8, 2013 9:25 PM, Bruce Wheaton br...@spearmorgan.com 
wrote:
 
On Oct 8, 2013, at 11:12 AM, James Board jpboa...@yahoo.com wrote:


I tried exactly that with the demuxing.c example.  When I try to compile
it with the C++ compiler, I get errors.  When I compile with the C compiler,
no errors.  What do I need to do to get demuxing.c to compile with the C++
compiler in Linux?
 

That's an example program written in C. There's nothing in the actual codebase 
(as opposed to the examples) that doesn't work in C++.

Compile a C example as C. 

Bruce

___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


Re: [Libav-user] Compile with g++

2013-10-09 Thread James Board
demuxing.c is a C program, if you want to compile it 
with C++ (why?) you will have to convert it to C++, 
just as with any other C program.

Yes, I know it's a program written in C.  As I stated before, I only used 
that example because everyone here already has a copy of it.  The 
alternative would be for me to post my lengthy C++ code, which uses lots of 
third-party libraries, which nobody will be able to compile anyway). 

When I compile demuxing.c with g++ it gives me the same errors as when I add 
libav calls to my C++ app and then try to compile that with g++.  So, if we can 
figure out why demuxing.c won't compile with g++, then we will 
probably figure out why my C++ app won't compile with g++.  


(Nothing about this is FFmpeg specific.)


This is the libav mailing list, not the fmpeg mailing list  The issue is
how to add libav calls to a c++ program.

Carl Eugen



On , James Board jpboa...@yahoo.com wrote:
 
That's an example program written in C. There's nothing in the actual 
codebase (as opposed to the examples) that doesn't work in C++.

Yes, I know it's a program written in C.  As I stated before, I only used that 
example because everyone here already has a copy of it.  The alternative would 
be for me to post my lengthy C++ code, which uses lots of thrid-part libraries, 
which nobody will be able to compile anyway).

When I compile demuxing.c with g++ it gives me the same errors as when I add 
libav calls to my C++ app and then try to compile that with g++.  So, if we can 
figure out why demuxing.c won't compile with g++, then we will probably figure 
out why my C++ app won't compile with g++.  




On Tuesday, October 8, 2013 9:25 PM, Bruce Wheaton br...@spearmorgan.com 
wrote:
 
On Oct 8, 2013, at 11:12 AM, James Board jpboa...@yahoo.com wrote:


I tried exactly that with the demuxing.c example.  When I try to compile
it with the C++ compiler, I get errors.  When I compile with the C compiler,
no errors.  What do I need to do to get demuxing.c to compile with the C++
compiler in Linux?
 

That's an example program written in C. There's nothing in the actual codebase 
(as opposed to the examples) that doesn't work in C++.

Compile a C example as C. 

Bruce

___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


Re: [Libav-user] Is libav thread-safe?

2013-10-09 Thread Paul B Mahol
On 10/9/13, James Board jpboa...@yahoo.com wrote:
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.


 Well, thanks for the help, but actually this isn't true.  I tried this with
 the demuxing.c example and that didn't work.


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.

 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.

 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.


If you use different AVCodecContext it should be fine, otherwise it will crash.
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


Re: [Libav-user] Compile with g++

2013-10-09 Thread Carl Eugen Hoyos
James Board jpboard2@... writes:

 (Nothing about this is FFmpeg specific.)
 
 This is the libav mailing list, not the fmpeg 
 mailing list

This is a mailing list about FFmpeg (that is why 
it is hosted on the FFmpeg server). Questions 
about how to convert a C program (that allows 
implicit type conversions which is why FFmpeg 
- and demuxing.c - does not contain explicit 
type conversions) into a C++ program (which 
needs explicit conversions) is not completely 
appropriate here afaict.

Carl Eugen

___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


Re: [Libav-user] Compile with g++

2013-10-09 Thread Mihai Chindea
this is actually a FFmpeg e-mail list ..
for multithreaded implementations you should have a look at 
av_lockmgr_register()

Mihai,

demuxing.c is a C program, if you want to compile it 
with C++ (why?) you will have to convert it to C++, 
just as with any other C program.


Yes, I know it's a program written in C.  As I stated before, I only used that 
example because everyone here already has a copy of it.  The alternative would 
be for me to post my lengthy C++ code, which uses lots of third-party 
libraries, which nobody will be able to compile anyway). 

When I compile demuxing.c with g++ it gives me the same errors as when I add 
libav calls to my C++ app and then try to compile that with g++.  So, if we can 
figure out why demuxing.c won't compile with g++, then we will probably figure 
out why my C++ app won't compile with g++.  



(Nothing about this is FFmpeg specific.)



This is the libav mailing list, not the fmpeg mailing list  The issue is
how to add libav calls to a c++ program.

Carl Eugen



On , James Board jpboa...@yahoo.com wrote:

That's an example program written in C. There's nothing in the actual codebase 
(as opposed to the examples) that doesn't work in C++.


Yes, I know it's a program written in C.  As I stated before, I only used that 
example because everyone here already has a copy of it.  The alternative would 
be for me to post my lengthy C++ code, which uses lots of thrid-part libraries, 
which nobody will be able to compile anyway).


When I compile demuxing.c with g++ it gives me the same errors as when I add 
libav calls to my C++ app and then try to compile that with g++.  So, if we can 
figure out why demuxing.c won't compile with g++, then we will probably figure 
out why my C++ app won't compile with g++.  




On Tuesday, October 8, 2013 9:25 PM, Bruce Wheaton br...@spearmorgan.com 
wrote:

On Oct 8, 2013, at 11:12 AM, James Board jpboa...@yahoo.com wrote:


I tried exactly that with the demuxing.c example.  When I try to compile
it with the C++ compiler, I get errors.  When I compile with the C compiler,
no errors.  What do I need to do to get demuxing.c to compile with the C++
compiler in Linux?
 


That's an example program written in C. There's nothing in the actual codebase 
(as opposed to the examples) that doesn't work in C++.


Compile a C example as C. 


Bruce



___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user 
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


Re: [Libav-user] Compile with g++

2013-10-09 Thread Vitsas Nikolaos

On Wed, 9 Oct 2013 07:29:52 -0700 (PDT)
 James Board jpboa...@yahoo.com wrote:


This is a mailing list about FFmpeg (that is why 
it is hosted on the FFmpeg server). Questions 
about how to convert a C program (that allows 
implicit type conversions which is why FFmpeg 
- and demuxing.c - does not contain explicit 
type conversions) into a C++ program (which 
needs explicit conversions) is not completely 
appropriate here afaict.


Really?  The title of the mailing list is Libav-user@ffmpeg.org.
I'm asking whether libav can be used in C++ programs, if anyone
uses libav in C++ programs, and what I need to do in order to
use libav in C++ programs.  How can that be inappropriate?

Anyway, don't bother.  I give up.  You win.


You just need to wrap all you libav includes in extern C { }, like 
this


 #ifdef __cplusplus

 extern C {
 #include libavutil/avutil.h
 #include libavutil/mathematics.h
 #include libavutil/imgutils.h
 #include libavutil/samplefmt.h
 #include libavutil/time.h
 #include libavcodec/avcodec.h
 #include libavformat/avformat.h
 #include libswscale/swscale.h
 }

 #endif // __cplusplus

 As for UINT64_C you can do this

 #ifndef INT64_C
 #define INT64_C(c) (c ## LL)
 #define UINT64_C(c) (c ## ULL)
 #endif // INT64_C

I' m using libav in many of my projects which include other third 
party libraries. The above are the only things required.

___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


Re: [Libav-user] Compile with g++

2013-10-09 Thread Carl Eugen Hoyos
Michael Chisholm chisholm@... writes:

 So my point to all this is, the ffmpeg-2.0.1 headers 
 aren't completely C++-friendly

I don't think this is correct as such:
The headers are neither C++-friendly nor C++-unfriendly, 
they are simply C headers and exactly the same 
limitations apply than when using any other (non-trivial) 
C headers from a C++ program.

The fact that some explicit casting is necessary 
in C++ is completely orthogonal to the C++- 
friendliness of the FFmpeg headers afaict.

Do I understand correctly that you cannot use the 
av_ts2timestr() macro from C++ but that it is not 
used inside of FFmpeg in a way that makes using 
one of the libraries or one of the headers 
impossible?
(If you know how to fix it, consider sending a 
patch, assuming it does not slow down the macro 
for C, such a change is useful imo.)

Carl Eugen

___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


[Libav-user] Extract frames in raw RGB formats

2013-10-09 Thread Amir Hossein Rouhi
Hi
I am wondering if anyone can help me how can i use ffmpeg to extract frames
in raw RGB image forma. The following code does not work:
ffmpeg -i foo.mp4 -r 1 -s 320x240 -f image2 foo-%03d.rgb
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user