Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » How to Reproduce video with Allegro 5

This thread is locked; no one can reply to it. rss feed Print
 1   2 
How to Reproduce video with Allegro 5
AMCerasoli
Member #11,955
May 2010
avatar

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
Member #794
November 2000
avatar

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
Member #11,955
May 2010
avatar

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
Member #794
November 2000
avatar

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
Member #358
May 2000

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.

--
"Either help out or stop whining" - Evert

AMCerasoli
Member #11,955
May 2010
avatar

Elias How did you compile FFmpeg?

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

Thomas Fjellstrom
Member #476
June 2000
avatar

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.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Elias
Member #358
May 2000

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

--
"Either help out or stop whining" - Evert

Peter Wang
Member #23
April 2000

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
Member #1,134
March 2001
avatar

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.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

AMCerasoli
Member #11,955
May 2010
avatar

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
Second in Command
February 2005
avatar

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".

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

Itachihro
Member #12,001
May 2010

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
Supreme Loser
January 1999
avatar

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
Member #1,134
March 2001
avatar

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).

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Itachihro
Member #12,001
May 2010

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
Member #1,134
March 2001
avatar

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?

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

AMCerasoli
Member #11,955
May 2010
avatar

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
Member #261
April 2000
avatar

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
Member #1,786
December 2001
avatar

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
Member #562
July 2000
avatar

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.

__________________________________________________
Skoobalon Software
[ Lander! v2.5 ] [ Zonic the Hog v1.1 ] [ Raid 2 v1.0 ]

Goalie Ca
Member #2,579
July 2002
avatar

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?

-------------
Bah weep granah weep nini bong!

IonBlade
Member #3,521
May 2003
avatar

... 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.

------

"I've got to choose my words carefully so that I'm not misunderstood, but I think there are fewer developers around today who think about making a good game. As a creator, I find that sad..." - Hideo Kojima

Elias
Member #358
May 2000

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.)

--
"Either help out or stop whining" - Evert

AMCerasoli
Member #11,955
May 2010
avatar

#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

 1   2 


Go to: