Hi,
I want some help...
When I want to play a video file in my SDL code, what format is easiest to use. We are making a simple 2D-game in SDL for Windows and now it's time to do an intro. And we want to use a video file. But what format to use? avi,mpeg,mov,wmv? And does anyone know any example code or a tutorial?
Thanks!
Link

SMPEG is the MPEG animation player used by SDLBasic and it seems to be the only one for SDL. I tend to stay away from Windows-only file formats like .WMV since there's no way to port them to another platform without converting the files first. BTW: Why are you limiting yourself to Windows only when SDL will work on practically any operating system?

Once again Drew your attention to the needs of the forums are spot on. Great job. My only suggestion is to make a simple mpeg player that can pause, slow down, rewind and fast forward. Not that the documentation to do so isn't elsewhere but you know how lazy some of us are here and our aversion to using search engines.[wink]

Nice tutorial, Drew.I ran into the LGPL FFMPEG project, which unlike SMPEG is under active development and supports a whole bunch of modern codecs. While there is no direct support for SDL, there is a nice tutorial for the API. The tutorial includes code for decoding video into RGB images, from which you can create SDL surface with SDL_CreateRGBSurfaceFrom.If I get some free time, I might give it a try.

EDIT: I just found out that the FFMPEG project includes a program called ffplay, which is an SDL based video player. It seems to use SDL_DisplayYUVOverlay to output the video frame to the screen.

Original post by evillive2Once again Drew your attention to the needs of the forums are spot on. Great job. My only suggestion is to make a simple mpeg player that can pause, slow down, rewind and fast forward. Not that the documentation to do so isn't elsewhere but you know how lazy some of us are here and our aversion to using search engines.[wink]

By popular demand, here is a quick little wrapper that wraps most of all the needed functionality of SMPEG. It's everything in a header file, just so it's easy to work with and modify at first. Undoubtly it's not 100% complete or the best it could be, but it's definitly enough if you want to start easily working with MPEG files in SDL.

SDL_Movie.h

class SDL_Movie{private:// Surface for the main screen SDL_Surface *screen;

So basically, if you look though the key inputs, there is play, pause, stop, rewind, seek forward, and no seek backward yet because it doesn't seem to work. Bare minimal to work with this class is as follows:

// Create a movie variableSDL_Movie mov1;// Load a movie file, set the surface it should be rendered tomov1.Load( "demo.mpg", screen );// Start playback (only needs to be called once, NOT once per frame)mov1.Play();// Finally draw the movie (called every frame)mov1.Display();

And that's a wrap. I will probabally improive upon this a lot more and put it into a second tutorial when I next get time. This is just to get something out there for any interested, feel free to make your modifications as needed [wink]. So if there's any other requests with that project, just let me know!

Peregrin, that's a great find! The main problem I see with using SMPEG now is that it is under GLP, so you do have to release all your soruce code, which for something like E4E, it's not a bad thing, but if you wanted to make a game, then you'd not want to. If you don't beat me to it, I'll also take a look into using that program with SDL as well, for a LPGL alternative with more modern codecs would be great! [smile]

"But I, being poor, have only my dreams. I have spread my dreams under your feet; tread softly, because you tread on my dreams." - William Butler Yeats

Drew Benton is my idol! Seriously, where do you find the time to be this helpful? I have about 2-3 hours to myself a night and I get to read a bit here on the forums then go to bed so I can function at work the next day. My hat is off to you sir.