Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Video

This thread is locked; no one can reply to it. rss feed Print
Video
angeru
Member #7,401
June 2006

In first place i wish to apologize for my very bad english

I wrote a program that plays a video in a loop and the program freezes after a 2 or 3 hours

Someone can help me?

This is the code

int reproduce_video(char video[])
{
estado(2);
APEG_STREAM *stream;
int showed = 0, skipped = 0;
float speed_mult;
int x_off, y_off;
int ret;
bool primero=true;
stream = apeg_open_stream(video, 1);
if(!stream)
{
//ERROR AL ABRIR EL VIDEO
return -1;
}else{


stream->timer = -1;

while((ret = apeg_advance_stream(stream, FALSE)) == APEG_OK )
{
++showed;
stretch_blit(stream->bitmap, screen, 0, 0, stream->w, stream->h,0,0,800,600);
}

apeg_set_stream_rate(stream, 0.0);

apeg_close_stream(stream);
}
}

LennyLen
Member #5,313
December 2004
avatar

Same code, formatted:

1int reproduce_video(char video[])
2{
3 estado(2);
4 APEG_STREAM *stream;
5 int showed = 0, skipped = 0;
6 float speed_mult;
7 int x_off, y_off;
8 int ret;
9 bool primero=true;
10 stream = apeg_open_stream(video, 1);
11
12 if(!stream)
13 {
14 //ERROR AL ABRIR EL VIDEO
15 return -1;
16 }
17 else
18 {
19 
20 stream->timer = -1;
21 
22 
23 while((ret = apeg_advance_stream(stream, FALSE)) == APEG_OK )
24 {
25 ++showed;
26 stretch_blit(stream->bitmap, screen, 0, 0, stream->w, stream->h,0,0,800,600);
27 }
28
29 apeg_set_stream_rate(stream, 0.0);
30 apeg_close_stream(stream);
31 }
32
33}

angeru
Member #7,401
June 2006

Thanks, next time i will write the code formatted

Kitty Cat
Member #2,815
October 2002
avatar

Can you use a debugger to find out where it freezes? Perhaps using the debug version of the lib?

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Escalona
Member #7,400
June 2006

the program fails after 2 or 3 hours working, thats how i cant debug the program. What can you say me about debug version of APEG Library? How can i use it? thanks...

aclaration: im not angeru, im working with him in the same project thats all ;)

Arthur Kalliokoski
Second in Command
February 2005
avatar

Fails after many hours? That sounds like a memory leak, in other words, you're creating bitmaps over and over without destroying any, or similar. Maybe you can get another program (such as top or the windows task manager) to display memory while your program runs, if the available memory constantly shrinks, that must be it. When it's run out of memory altogether it crashes.

They all watch too much MSNBC... they get ideas.

Kitty Cat
Member #2,815
October 2002
avatar

Which version of APEG do you have? Are you playing an MPEG or Ogg file? Given that you're not playing it in a loop, some variables may be overflowing somewhere.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

angeru
Member #7,401
June 2006

Arthur Kalliokoski: I think that is the problem, but I canĀ“t find where is the problem
Kitty Cat: apeg version: 1.0, and is playing a little mpeg

Kitty Cat
Member #2,815
October 2002
avatar

If the video's short, there's no way that loop should play for 2 to 3 hours. You're passing FALSE to the loop parameter, so it'll quit when it gets to the end.

Could you try using the newest version on the website (see my sig)? In that version, you should find a cbuild.c file. Replace it with this one:
http://svn.tomasu.org/index.cgi/cbuild/checkout/trunk/cbuild.c

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

angeru
Member #7,401
June 2006

I use FALSE in the loop parameter because the loop that calls the reproduce_video function (play_video in spanish) is in another function. The loop calls reproduce_video and another functions, When I see the freezes I remove the other functions and only keep reproduce_video and the programs freezes again.

I'll try with the newest version

PD: My english is very very very baaaaad :-[ :P

PPD: I try and also freezes with the new version

Go to: