[Ffmpeg-devel] how to compile output_example.c (fwd)

Turbo sandeep_kr
Sun Aug 6 17:15:18 CEST 2006

I have found a workaround.
I have decided not to use the new swscale functions and stick with the old 
img_convert function. The program is compiling succesfully now.
But when I ran it is displayed "[mpeg @ 0x83cf008]buffer underflow" 
hundreds of times.
So, after checking past archives I found that (AVFormatContext 
*)ac->max_delay has to be set. I set that to 0.7.
But still that message is coming but only around 20 times.
However the ouput video file plays fine in mplayer.
Is there any problem? or should I ignore those buffer underflow messages?

I do know everything, just not all at once. It's a virtual memory problem.
Home Page : http://students.iiit.ac.in/~sandeep_kr
Blog : http://sandy007smarty.blogspot.com

---------- Forwarded message ----------
Date: Sun, 6 Aug 2006 16:38:40 +0530 (IST)
From: Turbo <sandeep_kr at students.iiit.net>
To: FFMpeg development discussions and patches <ffmpeg-devel at mplayerhq.hu>
Subject: Re: [Ffmpeg-devel] how to compile output_example.c

Thanx for the quick reply.

On Sun, 6 Aug 2006, Luca Abeni wrote:

> Hello,
> On Sun, 2006-08-06 at 15:08 +0530, Turbo wrote:
>> The ffmpeg installation automatically compiles output_example.c and
>> generates the executable output_example.
>> But I have made a few changes into the source code and want to compile it
>> standalone. How to do it?
> does "make output_example" work?
It works on the original output_example.c present in cvs.
I think i will have to clarify a few things. I have tried converting the 
output_example.c code into a simpler API using classes. I had this API working 
very well with ffmpeg-0.4.9pre1-release. But now I tried changing it to make it 
work with the latest CVS version. I incorporated some of the easy changes like 
removing & operator from some places and changing . to -> and chamging 
frame_rate to time_base.den, etc.
Line 337 to 347 of the latest output_example.c were not present in old one. I 
added these lines. they are:-
337:if (img_convert_ctx == NULL) {
338:                img_convert_ctx = sws_getContext(c->width, c->height,
339:                                                 PIX_FMT_YUV420P,
340:                                                 c->width, c->height,
341:                                                 c->pix_fmt,
342:                                                 sws_flags, NULL, NULL, 
343:                if (img_convert_ctx == NULL) {
344:                    fprintf(stderr, "Cannot initialize the conversion 
345:                    exit(1);
346:                }
347:            }

Also line 349 is now :-
sws_scale(img_convert_ctx, tmp_picture->data, tmp_picture->linesize, 0, 
c->height, picture->data, picture->linesize);

instead of the old one where we had a call to img_convert()
I incorporated all these changes. But then the compiler is reporting 
sws_getContext and sws_scale as undefined while linking.
My API is in videoIO.h and videoIO.cpp and my main program is in 
Below is my Makefile:-
GCC = g++ -Wall -g
INCLUDES = -I /usr/local/include/ffmpeg/
LIBS = -lavformat -lavcodec -lavutil -lm -lz -ldl
all : example_copy
example_copy : example_copy.cpp videoIO.o
 	$(GCC) -o example_copy example_copy.cpp videoIO.o $(INCLUDES) $(LIBS)
videoIO.o : videoIO.cpp videoIO.h
 	$(GCC) -c -o videoIO.o videoIO.cpp $(INCLUDES)

>> I tried doing:-
>> g++ -Wall -g -o output_example output_example.cpp -I
>> /usr/local/include/ffmpeg/ -lavformat -lavcodec
>> -lavutil -lm -lz -ldl
> Why are you using g++ instead of gcc? Which kind of changes did you
> apply to the code?
Explained above
>> But I am getting these errors:-
>> undefined reference to `sws_getContext(int, int, int, int, int, int, int,
>> void*, void*, double*)'
>> and
>> undefined reference to `sws_scale(SwsContext*, unsigned char**, int*, int,
>> int, unsigned char**, int*)'
> Are you sure that the avcodec, avformat, and avutil libraries that you
> are trying to link are really the latest one from svn? (maybe they are
> coming from a previous installation?)
I think I am using the latest svn. How to make sure?

Should I attach my code? Its almost same as output_example.c and you wouldn't 
have to spend much time on it.

I do know everything, just not all at once. It's a virtual memory problem.
Home Page : http://students.iiit.ac.in/~sandeep_kr
Blog : http://sandy007smarty.blogspot.com

More information about the ffmpeg-devel mailing list