LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Using ffmpeg (libavcodec and libavformat) libraries... (https://www.linuxquestions.org/questions/programming-9/using-ffmpeg-libavcodec-and-libavformat-libraries-347250/)

_UnPrEdictAbLe_ 07-27-2005 07:03 AM

Using ffmpeg (libavcodec and libavformat) libraries...
 
Hi,
I am working on some code which uses ffmpeg sourcecode. To compile it I use
Code:

g++ -g -O3 -Wall -g -I. -I./ -I./libavcodec -I./libavformat -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -c -o output_example.o output_example.cpp

g++ -Wl,--warn-common -rdynamic -g  -o output_example output_example.o -L./libavformat -lavformat -L./libavcodec -lavcodec -lm -lz -ldl robovision.o -ljpeg

I seriously do not know what it all means, but I am compiling my code(robovision.cpp,robovision.h and output_example.cpp) by putting it in the directory containing the sourcecode of ffmpeg-0.4.8. This means that inspite of my code being only 3 files, I have to mess up with a thousand more files...

The only place where ffmpeg is used is in output_example.cpp
Code:

#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <math.h>
#include <string.h>
#include <time.h>
#ifndef M_PI
#define M_PI 3.1415926535897931
#endif

#include "libavformat/avformat.h"
#include "robovision.h"

/* 10 FPS */
#define STREAM_FRAME_RATE 10 
/*..... and so on.......*/

When I checked my system for ffmpeg.. it had ffmpeg-0.4.9-0.2.20050427.2.fc4 installed already. Can I do something to use the library installed in the system and thus reduce the mess in which I am. Please reply asap.

Regards,
Unpredictable.

acid_kewpie 07-27-2005 07:13 AM

installing in the same directory as the FFMPEG source?? :confused: erm.. why?

you need to have the matching -devel rpm for any package against which you need to compile software. you won't need the source code. just install it, compile your software in a dedicated directory somewhere, and as long as you've installed the necessary packages and your include parameters for gcc are correct it will find the ffmpeg headers just fine.

_UnPrEdictAbLe_ 07-27-2005 07:49 AM

Thanks for the reply acid. I figured out that myself just now. I installed ffmpeg-devel.

And now I use these commands to compile...
g++ -g -O3 -Wall -g -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -c -o robovision.o robovision.cpp
g++ -g -O3 -Wall -g -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -c -o output_example.o output_example.cpp

g++ -Wl,--warn-common -rdynamic -g -o output_example output_example.o -lavformat -lavcodec -lavcodec -lm -lz -ldl robovision.o -ljpeg

and #include <ffmpeg/avformat.h> in the output_example.cpp file and it works just fine. I really don't know how to make a makefile. If you could make a makefile out of these random commands so that it compiles only when required and only the components which are changed, then please do it for me.

Regards,
Anurag.


All times are GMT -5. The time now is 03:27 PM.