Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » char buffer to ALLEGRO_BITMAP

Credits go to Edgar Reynaldo and Matthew Leverton for helping out!
This thread is locked; no one can reply to it. rss feed Print
char buffer to ALLEGRO_BITMAP
tileproject
Member #14,888
January 2013

I'm trying to be able to play video (for a trailer). I'm not sure I want to move to 5.1 yet (plus no available packages for it yet) and wasn't sure on the ruling of whether the libraries/code/whatever that it uses for video rendering is completely open for commercial projects to use. So I went with: http://sourceforge.net/projects/libtheoraplayer/

I've got it set up, but the issue I'm running into now is how do I get the image to actually render. I read frame by frame, and call frame->getBuffer() which returns me a unsigned char pointer. This is the example I am kinda mimicking: http://sourceforge.net/p/libtheoraplayer/code/HEAD/tree/trunk/demos/av_player/av_player.cpp

It seems to load the video as it gives me the amount of frames in the clip. And it seems to loop through trying to draw them, but I never see anything drawn. Here is the code I'm calling (which is the main area that I have no clue if I'm doing this right):

#SelectExpand
1TheoraVideoFrame *frame = vidyaClip->getNextFrame(); 2if(frame) 3{ 4 // transfer the frame pixels to your display device, texure, graphical context or whatever you use. 5 ALLEGRO_FILE *file = al_open_memfile(frame->getBuffer(), sizeof(frame->getBuffer()), "r" ); 6 ALLEGRO_BITMAP *bitmapFrame = al_load_bitmap_f(file, ".png"); 7 al_draw_scaled_bitmap(bitmapFrame, 0, 0, al_get_bitmap_width(bitmapFrame), al_get_bitmap_height(bitmapFrame), 0, 0, WIDTH, HEIGHT, 0); 8 vidyaClip->popFrame(); // be sure to pop the frame from the frame queue when you're done 9}

Further down I'm doing the flip display, etc. Just to be aware, I've tried drawing other images right there in that spot and images all work fine. But not the video frames.

Also, I'm not sure if ".png" is right for al_load_bitmap_f. I just tried that out, but since I'm being given frame data, how would that even apply or how would I know what to use?

Maybe I'm doing this completely the wrong way, and if so, any help is appreciated. :D

-- Zyaga

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

tileproject
Member #14,888
January 2013

Is the player under a license that is fine for commercial use though? Cause the way it sounded from other places I read about ffmpeg or something, that isn't the case. And libtheoraplayer is under BSD license. Not too familiar with this type of stuff though.

And is 5.1 stable enough for commercial development? :x

Edit: It seems there is a 5.1.7 binary out at http://alleg.sourceforge.net/download.html Anyone know how stable that is?

-- Zyaga

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

The Allegro 5 license is basically a no warranty don't claim you wrote our stuff license, and there's some little blurb about bstrlib, but that's all. You have to see the libtheora license if you wanna know their policy.

And is 5.1.7 stable? Er, yes in the sense it is a snapshot that will never change. 5.1.x is a development WIP though, so you never know when things will change. For instance, muhkuh has been putting a bunch of work into the audio addon along with Peter Wang and things may change some. They do try to preserve backwards compatibility when possible.

And 5.1 has perks that 5.0 does not, like shaders and video. For video you can use ffmpeg as you discovered or you can use ogg and theora to play ogg movies.

Matthew Leverton
Supreme Loser
January 1999
avatar

And is 5.1 stable enough for commercial development?

The 5.1 branch is generally more stable in terms of runtime reliability than the 5.0 branch, although some of the newest features may not be quite ready.

The "unstable" is more descriptive of the API... functions that were introduced in 5.1 may be renamed or modified without regard to backward compatibility.

tileproject
Member #14,888
January 2013

Alright. I'll go ahead and try switching to 5.1.7 tonight. :)
And that's great news to hear, that unstable is more about the syntax of the API. Thats what kept me from moving to 5.1, the fact that I thought it was literally unstable. :P

-- Zyaga

Thomas Fjellstrom
Member #476
June 2000
avatar

I think this is why we used to use WIP rather than "unstable".

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

Go to: