SDL 1.3 + FFMpeg + MFC

Hello,

I’m very new to SDL and FFMpeg and i am trying to write an application using MFC that will make use of FFMpeg and SDL v1.3. One of my requirements for this application is multiple video windows, which, from what i’ve read, is supported in v1.3.

To start, i was able to create a small application using SDL v1.2 and the WINDOWID hack to create a small single windows video application using FFMpeg.

However, i am a bit lost with SDL v1.3. I have figured out how to create an application with a MFC dialog and then, using SDL_CreateWindowFrom(), fill that window with a colored rectangle using SDL (using Renderers). This is about as far as i can seem to get. I cannot figure out how to get the FFMpeg decoded video into the SDL window.

Does anyone have any advice or examples on how this can be done? Any help would be much appreciated.

Thanks very much!

Does anyone have any advice or examples on how this can be done? Any help

would be much appreciated.

As far as I know SDL overlays are still a work in progress in SDL 1.3, so u
should configure avformat to give u a RGB surface and blit that surface to
your rectangle.–
Bye,
Gabry

Thanks very much for the reply. Do happen to have any samples or examples of how this is done?

If i am using my own windows, do i still make a call to SDL_SetVideoMode() to create my surface or will a call to SDL_CreateRGBSurface() suffice?

My general understanding is that i will create my window SDL_CreateWindowFrom() using my MFC created hWnd, then create a surface with the Rect of that window. I will then use FFMpeg to get my frames, convert the frames to RGB and then BLIT them onto the surface? Is this correct? How does one Blit the RGB surface to the Rect. Will SDL_BlitSurface() work or is there a better way. If using SDL_BlitSurface() do i need multiple surfaces to call SDL_BlitSurface(), and if so, how do i create the surfaces correctly?

My apologies for the various questions. This is all very new to me.

Thanks again!

Thanks very much for the reply. Do happen to have any samples or examples of

how this is done?

Not the 100% of it, I’ve an example of player based on avcodec but for SDL
1.2

If i am using my own windows, do i still make a call to SDL_SetVideoMode()
to create my surface or will a call to SDL_CreateRGBSurface() suffice?

SDL_CreateRGBSurfaceFrom should be better in this situation. Maybe u can
also use a SDL_Texture, but I don’t know how well the OpenGL backend will
work in a multiple windows enviroment.

My general understanding is that i will create my window
SDL_CreateWindowFrom() using my MFC created hWnd, then create a surface with
the Rect of that window. I will then use FFMpeg to get my frames, convert
the frames to RGB and then BLIT them onto the surface?

I cannot help you with this, maybe someone else on the list can, because SDL
1.3 is not yet well documented and I’ve not yet tried to integrate it in a
gui enviroment.

I think SDL_CreateWindowFrom() is the equivalent of SDL_WINDOWID=
/ SDL_SetVideoMode(X,Y,0, flags) you’d use on SDL 1.2 to get control of a
window.

Is this correct? How does one Blit the RGB surface to the Rect. Will
SDL_BlitSurface() work or is there a better way. If using SDL_BlitSurface()
do i need multiple surfaces to call SDL_BlitSurface(), and if so, how do i
create the surfaces correctly?

I’ll do it this way:

Get your AVPicture allocated with his buffers, and size (this may occur to
the first iframe you decode or may be already available as soon as u
initialize the decoder depending the codec you are using).

Once you have an AVPicture with valid datas, create a RGB surface with the
exact pixel and size of the AVPicture, you’ll find that width may not be the
one of the movie and that your surface may be BGR, RGB, BGRA, ARGB…

To create the surface use SDL_CreateRGBSurfaceFrom and use the AVPicture
buffer as “source”.

Then blit the surface to your screen, if the format is different SDL will
take care of converting it to the correct pixel format of your windows.–
Ing. Gabriele Greco, DARTS Engineering
Tel: +39-0105761240 Fax: +39-0105760224
s-mail: Via G.T. Invrea 14 - 16129 GENOVA (ITALY)