Video Playback Help...
Video Playback Help...
Hi, I need to add some video playback to my app... Very simple, just a rolling credits vid that plays at the end...
What is the easiest way to do this...? I'm using C and not C++ so could anyone point me at any libraries I need to download and a straight forward example of doing it in C...
I'm hopeing I just need to drop in some .h and .c files in my folder and link to them, svn some component down from the net and grab some converter to change my vid into the correct format and i'm away... Tell me it's that simple...
Like I say, I don't care which format... I just want the easiest to use...
Thanks for your help,
ADePSP
What is the easiest way to do this...? I'm using C and not C++ so could anyone point me at any libraries I need to download and a straight forward example of doing it in C...
I'm hopeing I just need to drop in some .h and .c files in my folder and link to them, svn some component down from the net and grab some converter to change my vid into the correct format and i'm away... Tell me it's that simple...
Like I say, I don't care which format... I just want the easiest to use...
Thanks for your help,
ADePSP
For scrolling credits, don't use a video, use a static image and scroll that from top of the screen to bottom (or whatever direction you want). It saves memory, is faster and a thousand times easier to implement than video playback. There's no way of just including a header and linking a lib, then have instant video playback. Video playback is much much more than loading a image and display it.
As I already told you, the currently simplest approach at some animated video playback is probably the library from Kojima. Though it does not provide very good compression ratios, it's very easy to use if you have just some basic image displaying knowledge.
As I already told you, the currently simplest approach at some animated video playback is probably the library from Kojima. Though it does not provide very good compression ratios, it's very easy to use if you have just some basic image displaying knowledge.
Thanks, that sounds like a good idea... The reason I wanted video really is i'm making a series of tutorials based on what i've learned in the last two weeks making this app for all the new people who recently downgraded (like myself) and have found it very hard to find straight forward examples and help aimed at them (and obviously video playback would be a nice one to include)...Raphael wrote:For scrolling credits, don't use a video, use a static image and scroll that from top of the screen to bottom (or whatever direction you want). It saves memory, is faster and a thousand times easier to implement than video playback. There's no way of just including a header and linking a lib, then have instant video playback. Video playback is much much more than loading a image and display it.
As I already told you, the currently simplest approach at some animated video playback is probably the library from Kojima. Though it does not provide very good compression ratios, it's very easy to use if you have just some basic image displaying knowledge.
Cheers man, the scrolling image should work perfectly for my current needs...
ADe
There must be mate mustn't there...? I suspect nobody has written an include to wrap it all up... or nobody has posted one anywhere...adrahil wrote:Isn't there a way with sceVideo*/vshBridge* yet for direct video playing from file?Raphael wrote:There's no way of just including a header and linking a lib, then have instant video playback.
No. There are functions that decode a stream into an RGB framebuffer (the ones from MagiKs PMF player) but you still need to read in the file correctly and provide the buffers timed correctly to the decoder function, as well as handle the display update. All the basic functionality for loading the needed prx's, setting up the decoder and decoding single frames is inside the avc.c file in PMP Mod AVC.adrahil wrote:Isn't there a way with sceVideo*/vshBridge* yet for direct video playing from file?Raphael wrote:There's no way of just including a header and linking a lib, then have instant video playback.
You can write your own file reader and buffer feeder then you get the single header include out-of-the-box playback.
Well, Raphael, your idea sounded great but as soon as I load my image, 480x1923 at only 29K it crashes the PSP...
Any idea why...? Not like it's a big file...?????
Here is the VERY cut down code I was using missing all the other stuff and it came down to the fact that loadImage crashes with that file...??????
Here's the basic credits.png I was using as an example...????
http://www.cheatsync.net/credits.png
Little help...
ADe
Any idea why...? Not like it's a big file...?????
Here is the VERY cut down code I was using missing all the other stuff and it came down to the fact that loadImage crashes with that file...??????
Code: Select all
void ShowScreen_Credits() {
Image* background;
char buffer[200];
sprintf(buffer, "images/credits.png");
background = loadImage(buffer); // crashes here
freeImage(background);
}
http://www.cheatsync.net/credits.png
Little help...
ADe
-
- Posts: 197
- Joined: Fri Jul 01, 2005 2:50 am
@Jim, i've got 77K png files I load without problem and your ratio sounds like a major exageration there... I load whole piles of True Type font text over that also without a single problem...
@AnonymousTipster, The 77K png file (mentioned above) screen I load as a background that works perfectly is 480x272 and also loads without any problems what so ever...
I believe the height of the image is too much for the function to deal with so i'll probably have to split the png into 480x272 images and half way through loading one, load the next and so forth... What a pain in the ass this is... Oh for a library and code like this,
Somebody must have something like this... If not, why the hell not...?
ADe
@AnonymousTipster, The 77K png file (mentioned above) screen I load as a background that works perfectly is 480x272 and also loads without any problems what so ever...
I believe the height of the image is too much for the function to deal with so i'll probably have to split the png into 480x272 images and half way through loading one, load the next and so forth... What a pain in the ass this is... Oh for a library and code like this,
Code: Select all
void ShowScreen_Credits() {
int i;
mpeg* MyVid;
char filename[200];
sprintf(filename,"myvideo.mpeg");
MyVid = MPEG_LOAD(filename);
MPEG_PLAY(MyVid);
while (1) {
if (MPEG_ATENDOFSTREAM(MyVid) == 1) {
break;
}
for (i=0; i<5; i++) {
sceDisplayWaitVblankStart();
}
}
MPEG_FREE(MyVid);
}
ADe
The png isn't compressed anymore when loaded into ram, so Jim isn't exaggerating. 480x1923x32bit = 3692160byte = 3.6MB, and that won't fit in VRAM for sure. I doubt though that your loading function crashes, but your program crashes when you try to actually draw that big image, since graphics.c uses the gu for some of the image drawing, and the gu is restricted to 512x512 pixel images max. There are some ways around though.ADePSP wrote:@Jim, i've got 77K png files I load without problem and your ratio sounds like a major exageration there... I load whole piles of True Type font text over that also without a single problem...
Either write your own simple and dirty image blitter. Should be pretty straightforward and there are dozens of tutorials on generic blitters out there.
Some pseudo code anyway:
Code: Select all
function blit( source, sx, sy, sw, sh, sdw, dest, dx, dy, ddw )
source += sx + sy*sdw
dest += dx + dy*ddw
for y = 0 to sh
for x=0 to sw
dest++ = source++
source += sdw
dest += ddw
With this you can load your 480x1923 image normally, and then just set the source rect you want to blit accordingly.
Code: Select all
for loop=0 to maxloops
pos += 1
if pos > img.height-272
height = img.height-pos
else
height = 272
blit( img, 0, pos, 480, height, dest, 0, 0 )
I said no, so why don't you get it? Don't insist so much on other people doing the hard work for you and make it fool-proof, just so you can use everything without a hassle. If you really want something special done, then give it a try to learn yourself to do it.Somebody must have something like this... If not, why the hell not...?Code: Select all
void ShowScreen_Credits() { int i; mpeg* MyVid; char filename[200]; sprintf(filename,"myvideo.mpeg"); MyVid = MPEG_LOAD(filename); MPEG_PLAY(MyVid); while (1) { if (MPEG_ATENDOFSTREAM(MyVid) == 1) { break; } for (i=0; i<5; i++) { sceDisplayWaitVblankStart(); } } MPEG_FREE(MyVid); }
ADe
You won't be getting anywhere if you don't take the effort to dive into something complex to understand it yourself.
Programming is not like playing LEGO.
I know, i'm actually a 29 year old software developer and have programmed for 8 years but mainly work at high levels like Visual Basic, Java, .net, asp and PHP projects and mainly writing components and web stuff... This low level stuff wasn't in the training program but doesn't look as hard as it's made out to be...Raphael wrote:The png isn't compressed anymore when loaded into ram, so Jim isn't exaggerating. 480x1923x32bit = 3692160byte = 3.6MB, and that won't fit in VRAM for sure. I doubt though that your loading function crashes, but your program crashes when you try to actually draw that big image, since graphics.c uses the gu for some of the image drawing, and the gu is restricted to 512x512 pixel images max. There are some ways around though.ADePSP wrote:@Jim, i've got 77K png files I load without problem and your ratio sounds like a major exageration there... I load whole piles of True Type font text over that also without a single problem...
Either write your own simple and dirty image blitter. Should be pretty straightforward and there are dozens of tutorials on generic blitters out there.
Some pseudo code anyway:parameters sx, sy, sw, sh set the source rect you want to draw, sdw and ddw are the buffer widths of source and dest. dx and dy set the position where the image should be blitted to.Code: Select all
function blit( source, sx, sy, sw, sh, sdw, dest, dx, dy, ddw ) source += sx + sy*sdw dest += dx + dy*ddw for y = 0 to sh for x=0 to sw dest++ = source++ source += sdw dest += ddw
With this you can load your 480x1923 image normally, and then just set the source rect you want to blit accordingly.The other way using gu is pretty much alike, just that you increase the texture pointer to the starting pos before you send it to the gu.Code: Select all
for loop=0 to maxloops pos += 1 if pos > img.height-272 height = img.height-pos else height = 272 blit( img, 0, pos, 480, height, dest, 0, 0 )
I said no, so why don't you get it? Don't insist so much on other people doing the hard work for you and make it fool-proof, just so you can use everything without a hassle. If you really want something special done, then give it a try to learn yourself to do it.Somebody must have something like this... If not, why the hell not...?Code: Select all
void ShowScreen_Credits() { int i; mpeg* MyVid; char filename[200]; sprintf(filename,"myvideo.mpeg"); MyVid = MPEG_LOAD(filename); MPEG_PLAY(MyVid); while (1) { if (MPEG_ATENDOFSTREAM(MyVid) == 1) { break; } for (i=0; i<5; i++) { sceDisplayWaitVblankStart(); } } MPEG_FREE(MyVid); }
ADe
You won't be getting anywhere if you don't take the effort to dive into something complex to understand it yourself.
Programming is not like playing LEGO.
I'll check over your blit ideas and see what I can do with that (thanks man) and by the way I already increased the flib includes (that someone bothered to make to help others use fonts easily) so it works 10x faster by loading the .ttf files into memory before rendering them...
I just expected after comming to the homebrew scene so late that a lot of the hard work would already have been done i.e. includes and tutorials made available for others to use... Seems not...
...By the way, programming is exactly like LEGO... You normally just keep building on top of more and more complicated structures... Seems a shame all we have to work with here is individual bricks and the odd small wall...? :D
ADe
Actually, most of the *really* hard work has already been done. There wouldn't be any possibility to write anything for us, if the guys here didn't take the effort to reverse engineer the whole SDK (apart from very few things which aren't found yet). I wouldn't say learning to use the sceMpeg functions to get video playback is really hard. It may take some time, but it's not something one couldn't do if he really wanted.ADePSP wrote: I just expected after comming to the homebrew scene so late that a lot of the hard work would already have been done i.e. includes and tutorials made available for others to use... Seems not...
Fitting such stuff into such High-Level fool-proof but totally limited interfaces just to make every noob happy isn't something I'd like to do, and I could imagine others being my opinion there too.
Well, I suppose LEGO to be something were you have tons of blocks lying around you, which someone magically has created before, then you just pick the one's you want and stiff them together and they magically fit....By the way, programming is exactly like LEGO... You normally just keep building on top of more and more complicated structures... Seems a shame all we have to work with here is individual bricks and the odd small wall...? :D
ADe
In programming it's not possible to use every code snippet from others this way. You either need to understand why and how the other's code works and fit it to your program (thus theoretically enabling you to recreate the code yourself) or just completely write everything on your own and make it fit thereby.
Well, actually at high-level programming it's more like that (since the APIs control all the connection of different code parts), so maybe that's the reason you're insisting on such a video playback solution ;)
I myself pretty much hate having to stick to the ways others thought how programming parts should communicate. I found much of ugly implementations (I only say Windows API) which led me back to lower level programming and PSP is very nice in this manner :)
Just wanted to say thanks to those who helped... I got my credits screen working by loading in 5 (count them) png files into memory and the scrolling them up using the following code...
Thanks people...
Not sure why I could load 5 screens in at the start with no problem but to load one big pic with all of them in causes a crash but nevermind... This works...
ADe
Thanks people...
Code: Select all
void ShowScreen_Credits() {
waitForButtonRelease(0);
int i = 0;
SceCtrlData pad;
Image* background[5];
char buffer[200];
int numScreens = 5;
int current = 0;
int next = 1;
int currentY = 0;
int nextY = 272;
sprintf(buffer, "images/credits_blank.png");
background[0] = loadImage(buffer);
sprintf(buffer, "images/credits1.png");
background[1] = loadImage(buffer);
sprintf(buffer, "images/credits2.png");
background[2] = loadImage(buffer);
sprintf(buffer, "images/credits3.png");
background[3] = loadImage(buffer);
background[4] = background[0];
while (next < numScreens) {
blitAlphaImageToScreen(0,currentY,480,272-currentY,background[current],0,0);
if (nextY < 272) {
blitAlphaImageToScreen(0,0,480,272-nextY,background[next],0,nextY);
}
flipScreen();
sceKernelDelayThread(1200);
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons != 0) {
break;
}
for (i=0; i<2; i++) {
sceDisplayWaitVblankStart();
}
currentY++;
nextY--;
if (nextY == 0) {
current++;
next++;
currentY = 1;
nextY = 271;
}
}
blitAlphaImageToScreen(0,0,480,272,background[0],0,0);
flipScreen();
waitForButtonRelease(0);
freeImage(background[0]);
freeImage(background[1]);
freeImage(background[2]);
freeImage(background[3]);
}
ADe
I've done scrolling credits lots of times (I love the hollywood feel of it) and I've never needed movies or images. What I suggest doing is, writing a font renderer, be it truefront or bitmap based(I used bitmap personally) and then just write a simple credits system that scrolls the text up and down and clips them.
The upside of this is you can add fx, or scale the fonts based on screen position to give it a more dynamic feel.
just an idea.
The upside of this is you can add fx, or scale the fonts based on screen position to give it a more dynamic feel.
just an idea.