Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Say... what's the usual way of playina a .avi?

Credits go to Jonatan Hedborg, Kitty Cat, and ReyBrujo for helping out!
This thread is locked; no one can reply to it. rss feed Print
Say... what's the usual way of playina a .avi?
jaime barrachina
Member #6,780
January 2006
avatar

I suppose there's loads of methods of playing a video file, but has allegro got anything specific for this? What would be the best way of showing a short (like 2 minutes long) avi type file? Any suggestions out there?

"Under the sword lifted high There is hell making you tremble: But go ahead, And you have the land of bliss. - Miyamoto Musahshi"
"When all else fails, read the manual - Dad"

ReyBrujo
Moderator
January 2001
avatar

There used to be an add-on library, but I am not sure it is still developed. Better to use a MPEG file and KC's APEG instead.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Jonatan Hedborg
Member #4,886
July 2004
avatar

Correct me if im wrong, but isnt saying "I want to play an .avi" pretty much the same as saying "I want to play a movie file", as .avi is a container file which can have just about any format inside it (that is, any audio, video, subtitle and what not)?

There is a part of directX that can be used to play AVI's, if the user has the correct codecs installed. DirectShow i think?

Kitty Cat
Member #2,815
October 2002
avatar

Allegro has built-in support for playing FLI files. Though they are limited to 8bits-per-frame, don't contain audio, and don't compress well at all.

AllegAVI (I don't have a url handy, sorry) uses the Video for Windows codecs to play videos, which are rather outdated in favor of DirectShow codecs. It is also Windows-only, and in C++.

APEG (which I just updated) can handle MPEG-1 and Ogg (Vorbis audio and Theora video). It is in C, and should work on the same systems Allegro does. (Ogg Theora, btw, is comparible to DivX and XviD in size-vs-quality) :)

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

jaime barrachina
Member #6,780
January 2006
avatar

So, basically, there's no decent way of playing a video file in allegro, and my other options are APEG, AllegAVI and directX. Any more suggestions?

"Under the sword lifted high There is hell making you tremble: But go ahead, And you have the land of bliss. - Miyamoto Musahshi"
"When all else fails, read the manual - Dad"

Kitty Cat
Member #2,815
October 2002
avatar

Depends on what you mean by decent. APEG is quite flexible, and is able to use a modern format in a cross-platform manner. AllegAVI works as long as you have the proper VfW codecs and are in Windows using C++. And DirectX... well, I think I'll leave that one alone. ;)

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

jaime barrachina
Member #6,780
January 2006
avatar

Hum, if I'm aiming for simplicity, which one would you recommend? I must admit that AllegAvi non compatibility is a bummer... but I've looked at the code and it seems like something even I could folow.
I've downloaded the APEG files but there's so many things in there that i get lost quite easily ???
Have you got any manuals for the APEG project? Looks cool but I'm afraid I cant use it by myself, got to learn a lot fore that happens.

Well, still open to whatever suggestions that might come up.

"Under the sword lifted high There is hell making you tremble: But go ahead, And you have the land of bliss. - Miyamoto Musahshi"
"When all else fails, read the manual - Dad"

Kitty Cat
Member #2,815
October 2002
avatar

APEG is quite simple. It comes with an example program called exsimple, which shows one of the simplest methods to getting a video to play. Basically, just call
apeg_play_mpg(filename, screen, loop, NULL);
when in a graphics mode. It's just like Allegro's FLI API there.

Past that, you can use the non-blocking poll method.

// Open the file
APEG_STREAM *stream = apeg_open_stream(filename);

// Call this regularly to check if the video frame updated
// If it returns something other than APEG_OK, playback is stopped
apeg_advance_stream(stream, loop);

From here you can check if stream->frame_updated > 0, in which case there's a new frame in stream->bitmap for you to show (which you can blit to the screen, or wherever). Then when you're done with the file, call:
apeg_close_stream(stream);
So, a basic loop with this method would be:

1int w, h;
2APEG_STREAM *stream;
3 
4// Open the stream
5stream = apeg_open_stream(filename);
6if(!stream)
7 error();
8 
9// The actual view size may be different than the image size.
10// This gets the full size which we can use stretch_blit with
11apeg_get_video_size(stream, &w, &h);
12 
13// Loop through the stream
14while(apeg_advance_stream(stream, FALSE) == APEG_OK)
15{
16 // If the stream updated, blit it to the screen
17 if(stream->frame_updated > 0)
18 stretch_blit(stream->bitmap, screen, 0, 0, stream->w, stream->h, 0, 0, w, h);
19}
20 
21// Close the stream
22apeg_close_stream(stream);

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

jaime barrachina
Member #6,780
January 2006
avatar

Thank you, I'll get to work on it first thing tomorrow. Thank you every one for your help :)

"Under the sword lifted high There is hell making you tremble: But go ahead, And you have the land of bliss. - Miyamoto Musahshi"
"When all else fails, read the manual - Dad"

dudaskank
Member #561
July 2000
avatar

And there is MjpgAlleg too, in my signature, but it's a little old hehe, go for apeg or allegavi...

But, if you want to try my lib, you are welcome :)

Toque a balada do amor inabalável, eterna love song de nós dois
Eduardo "Dudaskank"
[ Home Page (ptbr) | Blog (ptbr) | Tetris 1.1 (ptbr) | Resta Um (ptbr) | MJpgAlleg 2.3 ]

Go to: