How to Reproduce video with Allegro 5
AMCerasoli

The addons created for Allegro 4 doesn't work with Allegro 5...

AlleAVI
APEG

I have being trying to figure it out how to reproduce video on my game but i have not the enough knowledge to do so...

Libraries that seems to work are OpenCV, FFmpeg, Libxine. But the BIG problem is that I don't know how to compile them or integrate it to use it with Allegro 5... There is no manual, everyone thinks that you suppose to know that step, and I barely could compile Allegro 5 and at the end I had to use the Binaries because the Text Addon wasn't working (wasn't there)...

So let's try to everyone put a little bit of information here about what you know, to see if we can reproduce a video on Allegro 5, and then I'm going to make a video tutorial ( in english and spanish one like this www.cerebrospain.com/allegro ) I need to translate it to english but I have no time now but I'm going to do it...

Problem Solved
Thanks To:

Itachihro
Matthew Leverton
Thomas Fjellstrom

Evert

everyone thinks that you suppose to know that step

I don't think anyone thinks that.
I have no idea how you'd play back a video (never looked into that really), but for making an addon, you can just copy one of the existing ones and hack it until it does something, then make it do what you want it to do. That's the way I do it. ;)
That said, we should probably have an addon template to help people get started. I don't have time to make one right now.

AMCerasoli

People that wants to make a real game to use it in his portfolio needs to reproduce someway a video or a secuense of images one followed by other, generally in poorly designed games for the presentation you create an animation with allegro itself, moving objects (images) around and creating some particle FX... But for serious games you should be able to use an external program to create an animation (Ex: for the first menu) and use it as background... Without the possibility to do this, there is no way that games could look professional or at least semi-professional, obviously this is not the only reason to have a video addon in Allegro5, but I think is the most important.

using "frames = load_bitmap ("1.bmp")" is too slow to use it in a loop, loading each image of your sequence to an ALLEGRO_BITMAP is unthinkable.

I am saying all this supposing that the person has the knowledge to split each frame of a movie, but if a person doesn't that would complicate even more the proses to him...

I have seems a lot of commercial games out there that are really bad, but they managed to sell them thanks to they presentation (and/or) animations.

In addition, if you're creating a game and you need help from other (Ex: a graphic designer) you should let him create the animation with whatever software, and you just import it to Allegro5...

Evert said:

you can just copy one of the existing ones and hack it until it does something

Thanks for you answer Evert, but I am (like other people) interesting in spend our time in actually creating a game, and not trying to make something work... In addition to your comment about "I don't think anyone thinks that." I would love to see if you can find me a good tutorial doesn't have to be videotutorial, about the installation of Allegro5, that everyone would be able to understand with just knowledge abut C++, I know a lot of C++ but I don't know about compilers, I know a lot of Classes and OOP, but I don't know how works "CMakeLists" or the "mingw32-make Install" ... And a think that most people neither...

There is where Allegro is failing, it suppose to be a library to make things easier, but is not taking into account that the first proces is too complicated, so people that actually has all this knowledge probably are not using Allegro but other libraris like Direct3D or more powerfull libraris that have a more stable bases.

Evert

EVERT

It's Evert. My name isn't an acronym, so it's not spelled in all-caps.

Quote:

There is where Allegro is failing, it suppose to be a library to make things easier, but is not taking into account that the first proces is too complicated, so people that actually has all this knowledge probably are not using Allegro but other libraris like Direct3D or more powerfull libraris that have a more stable bases.

It takes time to make such documentation and to make such addons. In case you've missed it, Allegro 5 itself is just about at a point where it's ready. These things will improve over time, but it takes effort (also on the part of the community).

Elias
Evert said:

It takes time to make such documentation and to make such addons. In case you've missed it, Allegro 5 itself is just about at a point where it's ready. These things will improve over time, but it takes effort (also on the part of the community).

Yes, as I said already somewhere, I've been working on an ffmpeg addon. But probably someone else will beat me to creating a video addon as I'm somewhat out of time right now.

AMCerasoli

Elias How did you compile FFmpeg?

I know nothing about "./configure" and all that stuff

Thomas Fjellstrom

I know nothing about "./configure" and all that stuff

You're going to have to learn if you want to do this sort of thing.

Elias

Oh yeah, it took me several weeks to get it somewhat working - so I'd suggest not using ffmpeg to be honest :P

Peter Wang

Point out a single game on the Allegro depot that has a decent video and we'll talk.

Alternatively, point out an "indie" game (not using Allegro) with a decent video.

Alternatively, show us an example of a decent video, from your portfolio.

23yrold3yrold

I am forced to agree; there's kind of a condescending tone for not using video, when I honestly can't think of the last game I played that used it. It was a fad that pretty much disappeared when in-game engines could produce proper cinema scenes (which is 90% of what video is good for in a video game). I work for a video game company and have a hand in reviewing applicants, and I can tell you we don't care if you know how to embed video. We care you can make a game.

AMCerasoli

Don't think in videos like a cinematographic professional scenes, but like a sequence of images... how do you load for example 300 frames and display them consecutively... doesn't matters what the video is about or the quality of it...

Point out a single game on the Allegro depot that has a decent video and we'll talk.

Alternatively, point out an "indie" game (not using Allegro) with a decent video.

Alternatively, show us an example of a decent video, from your portfolio.

You are telling me that since there is not a game with a good video, Allegro shouldn't have a video addon? nor the possibility to reproduce videos?

And you are telling me that if I don't have in my portfolio a decent vidio Allegro shouldn't have a video addon?

I think that if you don't have anything proactive to say is better to be quiet...

Attached there is a video file which I would love to use it as background in my main menu... I did it with Blender, and I'm able to have the images individually 100 images to be exact... but i'm trying to find out how to do it...

I am forced to agree; there's kind of a condescending tone for not using video, when I honestly can't think of the last game I played that used it

Tell me a game without video please.

Arthur Kalliokoski

The only "videos" I've seen were a crude series of maybe 8 to 20 images shown in sequence on an in-game TV in "Redneck Rampage" and "Max Payne".

Itachihro

that's how I would do it if you have the images individually:
call all of the images something like img_1, img_2 and so on.
put it in a directory with the name of the video.
inside of the video directory, put a file containing meta information like the number of images (and possibly other fancy stuff).
Inside of your logic (for example in the logic loop of a menu class) put an option to display a video instead of an image. Instead of a file name pass the name of the directory together with the option.
Load the meta file, check the number of images. Load all images (cause they all have similar names, you can use sprintf_s or a stringstream to dynamically create the filenames) in a vector or an array (or any other data structure with random access).
Instead of displaying your normal background image, display an image from your container. The index is determined by however you determine the current time.

I hope that's understandable, cause it's simple enough. I mean, a video program would do basically the same thing, just much fancier.

(btw, if you are going to use more than one video, creating a video class or a video header (if you're using c) would probably be a good idea instead of doing changes in all of your display loops).

Matthew Leverton

You are telling me that since there is not a game with a good video, Allegro shouldn't have a video addon?

Not at all.

Allegro developers are people just like you. If somebody writes a good, cross-platform video addon, then I'm sure it would be included. But if the only people who want the feature are people who cannot code it themselves, then it's not likely it will ever get added.

That's just the nature of free, open source software. Nobody has any incentive to write things specifically for you or anybody else. Okay, there's the warm and fuzzy feeling some people get, but that wears off after a few minutes.

Edit:

I took your video file, exported 100 frames, and tried this:

#SelectExpand
1#include <allegro5/allegro.h> 2#include <allegro5/allegro_image.h> 3#include <allegro5/allegro_primitives.h> 4#include <stdio.h> 5#include <string.h> 6 7int main() 8{ 9 ALLEGRO_DISPLAY *d; 10 ALLEGRO_BITMAP *frames[100]; 11 ALLEGRO_TIMER *timer; 12 ALLEGRO_EVENT_QUEUE *queue; 13 ALLEGRO_EVENT event; 14 15 int i; 16 int frame = 0; 17 18 al_init(); 19 al_init_image_addon(); 20 al_init_primitives_addon(); 21 22 d = al_create_display(384, 216); 23 24 for (i = 0; i < 100; ++i) 25 { 26 char filename[16]; 27 sprintf(filename, "bg%d.jpg", i + 1); 28 frames[i] = al_load_bitmap(filename); 29 if (!frames[i]) 30 return -1; 31 } 32 33 timer = al_create_timer(1.0 / 15.0); 34 queue = al_create_event_queue(); 35 al_register_event_source(queue, al_get_timer_event_source(timer)); 36 al_register_event_source(queue, al_get_display_event_source(d)); 37 al_start_timer(timer); 38 39 while (true) 40 { 41 al_wait_for_event(queue, &event); 42 if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE) 43 { 44 break; 45 } 46 else if (event.type == ALLEGRO_EVENT_TIMER) 47 { 48 if (++frame == 100) frame = 0; 49 al_draw_bitmap(frames[frame], 0, 0, 0); 50 al_draw_line(0, 0, 384, 216, al_map_rgb_f(1,0,0), 2); 51 al_draw_line(384, 0, 0, 216, al_map_rgb_f(1,0,0), 2); 52 al_flip_display(); 53 } 54 } 55 56 return 0; 57}

Works good enough. (Make sure to clean up the bitmaps when you are done.) It was 1MB in size for grainy JPEGs. Obviously for long videos, this isn't a good solution.

23yrold3yrold

Tell me a game without video please.

... Really? The only game I've played in 5 years that had video cinemas is World of Warcraft, and I think there were a couple in Starcraft II. And again, no one cares about full motion video in your portfolio. It's not why we're hiring you (unless you're an artist).

Itachihro

It's not why we're hiring you (unless you're an artist).

That too. I don't see how having videos in your background is a core feature that would make a difference in any way. Sure, it looks cool and stuff, but in the end people don't really pay too much attention to those, and I've never seen anyone complain that he misses cg movies in a game.

23yrold3yrold

My point is we'll look at it and think "Oh, he knows how to use a video library", which is what's he's asking for here. And we'll do it subconsciously, because we're paying more attention to things that matter, like collision detection and frame rate and things you actually programmed.

I don't care if you want to name games that use video or not because I don't want to derail your thread or seem like I'm trolling (although you're being awfully rude to some fairly major contributors to the library). I'm just saying, as someone who works in the industry and sees programming applications/portfolios/tests on a semi-regular basis, whether your portfolio has video or not is our least concern.

You are telling me that since there is not a game with a good video, Allegro shouldn't have a video addon?

He's telling you it's not a library basic feature, because, well, it's not a game basic feature. Why bloat the library with something almost no one will use or is using? If the community wants it, the community will make an add-on. If no one makes an add-on, no one wanted it very badly, now did they?

AMCerasoli

Finally thanks once more time Matthew Leverton. That is what I needed, you have just open my mind, that is collaborating with the community. That is an start point. What is the next step now?

What happens if this information remains here without a improvement? nothing that is what happens, so what is my duty now has a member of the community?

I have just received a valuable information from Matthew... But that information is encrypted... Encrypted?? yes, I understand it because I use Allegro and because I am on this now, lets say that what I have just received are the materials, because this is not the Matthews problem, he just gave me the materials, I can use it in my game or application but as a member of this community I can't let die this info, so with this materials I am going to build a peace of floor, so the next person that encounters the same problem won't have the necessity to start at the start point, I have my own web page and going to use it, The problem actually is that this info might look too stupid to be posted somewhere else... And I am saying this because I have never find this kind of info outside of forums and stuff like that...

I know must of you are saying OMG, but I knew that... there is nothing new... and that is problem, for me is new, and for other potential user too...

To me right now that piece of code is helpful but for others don't so I'm going to change that... and that's all what you need to do, you don't have to spend a weak creating a tutorial about the entire allegro library just explain how you managed to do something, but explain it well, don't just put your game there and wait to people learn from it, Because I learned allegro in a lot of time but I know that if I had the time to create a tutorial about all that I know someone could learn it in half time I did or even less without all the problems I had.

Because when you want to create something you want to learn the enough info, why do I need to learn everything about MinGW or command lines to compile Allegro5? I know that is a free library such as SDL and OpenGL and G2D and so on... But the community must spend more time in creating DOCS so Allegro is going to growth faster, because even with this poorly documentations Allegro is intuitive and powerful...

To use it in your portfolio was an example, I'm already on a project and I need to finish the game. Thanks anyway, and sorry if I have been too rude...

Trent Gamblin

I think Peter's point is that you haven't even shown that you have any reasonable amount of work done on a game let alone adding video to it. Maybe you have, but in general a lot of people start of making a game by trying to gather all of the libraries they need instead of coding/creating the important stuff first. For example, some people will make releases of a game starting at when you have a bitmap sliding around on flat ground, or spend many hours coming up with a logo for their company that has no games yet (and they're always fugly btw).

kazzmir

Because when you want to create something you want to learn the enough info, why do I need to learn everything about MinGW or command lines to compile Allegro5?

Well technically you can just use the precompiled versions of allegro5. I think there are links in the RC threads for precompiled versions. I've never used them myself but supposedly you just download them and link to the libraries.

To the larger point about creating documentation for beginners -- I think thats a great idea and as someone who has done a lot of work on game engines I am guilty of not providing much information to the community on how I did it. I'll think about writing some stuff over time.

Sort of tangential, but writing a game engine in Allegro5/SDL is a crapload of work and it might be easier for you to use some existing engine (even if its not C++). Especially if you are just learning how to create games, using such a low level library will only add to your frustrations. Maybe start with flash or html5?

StevenVI
kazzmir said:

Maybe start with flash or html5?

Writing a proper game engine in Flash is no easier (or harder) than it is in Allegro, though you'll have a much wider audience. I can't comment on HTML5, but is that even standardized yet?

Edit: Though with Flash you can embed video easier, which seems to be the killer feature desired by the OP.

Goalie Ca

If somebody writes a good, cross-platform video addon

I'll look into that. I have a lot of experience with designing and using video codecs and I worked on the audio/image addon back in the day. Anyone want to help? AMCERASOLI, I'm looking at you ;)

Mostly, I'm interested in people helping with the API, docs, etc. This codec will be streaming but is there interest in loading an entire sample at once? What are the use cases?

IonBlade

... Really? The only game I've played in 5 years that had video cinemas is World of Warcraft, and I think there were a couple in Starcraft II. And again, no one cares about full motion video in your portfolio. It's not why we're hiring you (unless you're an artist).

Pretty much every game I've played in the past 5 years has had cinema files. Whether they're used for the background of a menu, an intro, a cutscene, or whatever. Every single game that comes in a box on my desk in front of me uses video files. Street Fighter 4, LittleBigPlanet, Final Fantasy VII-VIII-IX-X-X2-XII-XIII (everything past 6, basically), and many games that use their in-engine graphics to render out a video file so the framerate won't dive for specific cutscenes.

These are the games using Bink alone: http://www.radgametools.com/binkgames.htm#games

Bioshock, Gears of War, Call of Duty, Guitar Hero, Tomb Raider, Diablo, Elder Scrolls, the list goes on. And that's just Bink... many people use their own stuff, or some other lib. A video addon would be a very helpful thing for people looking to atleast emulate these experiences with Allegro.

Elias

Alternatively, point out an "indie" game (not using Allegro) with a decent video.

Our IPhone game (sword of fargoal) has cinematics all over the place and for the non-IPhone ports we show them with ffmpeg. That's the only reason I personally worked on that addon - I'd never have touched it otherwise :)

(Our videos have no audio in them so all I use ffmpeg for is stream the current frame into an ALLEGRO_BITMAP. The hard part when I tried to make it into a video addon however was dealing with audio sync.)

AMCerasoli

#SelectExpand
1int x = 1; 2 3 for (i = 0; i < 100; ++i) 4 { 5 char filename[16]; 6 sprintf(filename, "bg%d.jpg", i + 1); 7 frames[i] = al_load_bitmap(filename); 8 if (!frames[i]) 9 return -1; 10 }

Hey the problem here as you might know is that I am using UTF-8 encoding http://www.allegro.cc/forums/thread/605769 ... And the sprintf string functions only work with ASCII or character sets that extend ASCII in a compatible manner such as ISO-8859-1; multibyte ASCII-compatible character sets such as UTF-8 will work with the caveat that string "length" is to be interpreted as the count of bytes in the string rather than the count of Unicode characters. Wikipedia

I was trying to use wchar_t and swprintf inside wchar.h.

But then I can't convert from wchar_t to char to use al_load_bitmap(const char *filename) ... What a problem... :o

Itachihro

How about using stringstreams instead of sprintf?

Thomas Fjellstrom

It would probably be best to just not use non ASCII characters in filenames.

23yrold3yrold
IonBlade said:

Final Fantasy VII-VIII-IX-X-X2-XII-XIII (everything past 6, basically)

Part of the reason why FF has become such a running joke as more of an interactive movie than a game and why VI was considered by many to be the last "good" one. :) Anyway, I'm sure a lot of games use video, I guess they aren't games I've been playing (or I've been skipping the videos).

EDIT: Typo'ed my Roman Numeral. :P

Thomas Fjellstrom

Part of the reason why FF has become such a running joke as more of an interactive movie than a game and why IV was considered by many to be the last "good" one.

I think you mean VI. >:(

AMCerasoli

It would probably be best to just not use non ASCII characters in filenames.

No actually the problem isn't at loading the files because as you can see i just let the name that Matthew gave me (bg1.jpg) is good would be background 1..2.. and so on...

and those are perfectly ANSCII... The problem is that all my environment is encoded in UTF-8.. and sprintf is waiting for just ANSCII encoding... so when I send from my program (Code::Block which is using UTF-8) "bg%d.jpg" it send it encoded in UTF-8 and sprintf doesn't know how to interpret it... That is what I think is happening.

When I change the encoding option to ISO-8859-1 in CODE::BLOCKS works but then I can't use Ñ or ¿ with al_draw_text

Thomas Fjellstrom

and those are perfectly ANSCII... The problem is that all my environment is encoded in UTF-8.. and sprintf is waiting for just ANSCII encoding... so when I send from my program (Code::Block which is using UTF-8) "bg%d.jpg" it send it encoded in UTF-8 and sprintf doesn't know how to interpret it... That is what I think is happening.

I thought you knew, but the first 128 characters in UTF-8 are ASCII. Any ASCII string encodes to itself when put into UTF-8.

Quote:

When I change the encoding option to ISO-8859-1 in CODE::BLOCKS works but then I can't use Ñ or ¿ with al_draw_text

Those aren't part of ASCII either.

AMCerasoli

Oh YHEA!!! now is working... I don't know what was doing wrong...

And yes I knew that Thomas
But before was giving me an error... and the strange thing is when I change to ISO works... then I change back to UTF thinking in that, that is true that UTF is identical at the first 128 characters, so the problem must be another thing, but this time it work......................................................................................................................................

I don't want to close CODE::BLOCK or turn off my PC until I finish my project ahahahaha

Bob

But the community must spend more time in creating DOCS so Allegro is going to growth faster, because even with this poorly documentations Allegro is intuitive and powerful...

The best introductory documentation is written by newbies to the tools: No prior knowledge, and few assumptions.

The documentation for OpenGL produced by the nice people in the Khronos group is all detailed specification. I can guarantee you will not learn to begin writing OpenGL applications from those documents.

Instead, the users of such libraries typically build their own documentation (books, tutorials, examples, and so on) to guide beginners and show them how to get started.

If you feel like the Allegro documentation in insufficient in any way, or too complicated / obtuse / difficult to follow, then by all means, please either submit a patch to fix the official documentation, contact the authors of external documents, or just write your own. This is no different than SDL, G2D, OpenGL, and the Windows API.

Quote:

Because when you want to create something you want to learn the enough info, why do I need to learn everything about MinGW or command lines to compile Allegro5?

Learning about the compiler you are using is important. The compiler is the major tool you'll be using. Most of your time will be spent trying to get the tool in question to do what you meant it to do, by figuring out how to tell it to do what you wanted.

It's important to know the abstraction layer above and at least one abstraction layer below the one you are using. It gives you a much better understanding of the tools at your disposal, and how to wield them to maximize your efficiency.

Do you need to know the necessary command line to build an application or library? Yes.
Do you need to know the internals of GCC's lexical parser? Probably not.

Ariesnl

Didn't Allegro have FLIC once ?

AMCerasoli
Bob said:

If you feel like the Allegro documentation in insufficient in any way, or too complicated / obtuse / difficult to follow, then by all means, please either submit a patch to fix the official documentation, contact the authors of external documents, or just write your own. This is no different than SDL, G2D, OpenGL, and the Windows API.

You can count on it Bob... I am going to make Tutorials and Video Tutorials so easy to understand that people is going to think that Allegro is for kids.

I am still noob, but it take me a long time to get here, And I don't consider myself a slow learner <<< I don't know if i can say that :-X ... But the poor info cause this second effects on people...

I going to do the next tutorials because i know how...

- Installing Allegro: Already Done but must be improved because if installing allegro was a kick on my balls installing Zlib is even more painful... and without that I couldn't use the text addon (TTF)..

- Copy and paste the binaries: To get allegro ready to work in just a minute which i'm going to recommend to people if I don't find out how to install Zlib

- Using Timers
- Drawing images: is too easy to make a whole tutorial but some tricks would help.
- Drawing Text: Solve problem with ASNCII and UTF-8 with CODE::BLOCK
- Bounding Box collision detection
- How to reproduce a sequence of images (just learned)
- Keyboard / mouse

I think that when someone get this, and understand it very well is able to do everything... And I'm not saying that this tutorials doesn't exist but to my are too precarious...

Thomas Fjellstrom
Quote:

going to do the next tutorials because i know how...

If you have the time, would you be willing to help out with the tutorials on the wiki? It doesn't seem like we have a good tut or explanation of how to install Allegro 5 from normal release packages. We do however have a few on how to build Allegro 5 from svn, you could base anything you add to the wiki on those :)

Also I do have a few basic Allegro 5 tutorials up there too.

AMCerasoli

If you have the time, would you be willing to help out with the tutorials on the wiki?

Of course I will!. To be honest I didn't know that those tutorials exist, I get tired to search for tutorials even for the 4.0 version was a little bit difficult... But anyway things must change now, I see those tutorials were created recently?...

If I had those when I start... :-[

But I already found things that I don't like too much (Just to keep it in order) on the wiki page like this:

{"name":"menuwiki2.gif","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/c\/fc75186aa088ae8b09f6dee22ce69c3c.gif","w":682,"h":378,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/c\/fc75186aa088ae8b09f6dee22ce69c3c"}menuwiki2.gif
{"name":"menuwiki3.gif","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/e\/de06dba09b8ac68e8cd7bba9508aec4e.gif","w":682,"h":378,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/e\/de06dba09b8ac68e8cd7bba9508aec4e"}menuwiki3.gif

I will keep this web page in mind...

EDIT: OMG I can actually modify the page without any permission??? ;D ;D ;D ahahahaha that is amazing...

Thread #605880. Printed from Allegro.cc