SDL surface to AVI

Hello,

I’m programming an application in Microsoft Visual C/C++ with SDL in 2D.

I need to capture the surface video to an avi file.

I know that with SaveBMP function i could save every frame to a file and
then use another program to encode it as a movie. However, the performance
is terrible and i have limited time to processing.
I also know the function SDL_SaveBMP_RW that would allow me to save a
surface to a seekable SDL data source (memory or file) and then I could use
an AVI Generator
Classhttp://www.conestogac.on.ca/~set/courses/year2/multi/avi.html
for
create the avi video, but I had problems implementing this option, mainly
because I do not know how to implement properly SDL_SaveBMP_RW and there is
little documentation.

Someone could help me with this option, or perhaps going the other way?

Thanks,–
I?aki Cormenzana M?ndez

Computer Science Deliriums.
http://www.proxxo.com.ar

You could use libavcodec. For the reverse of what you want, a SDL
video player, there is an excellent tutorial here:
http://dranger.com/ffmpeg/

And here is some sample code that shows how to encode video:
http://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/api-example_8c-source.html

To match input data for the “static void video_encode_example
http://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/api-example_8c.html#7bdd752f30f32edeb0da5ef57c77d9e9(const
char *filename)” sources, one would need to access the SDL_Surface pixel
data and convert each RGB pixel into YCrCb (YUV) color space (see
http://www.fourcc.org/fccyvrgb.php).

Hope that helps,
–AndreasOn 9/13/10 1:39 PM, I?aki wrote:

Hello,

I’m programming an application in Microsoft Visual C/C++ with SDL in 2D.

I need to capture the surface video to an avi file.

I know that with SaveBMP function i could save every frame to a file
and then use another program to encode it as a movie. However, the
performance is terrible and i have limited time to processing.
I also know the function SDL_SaveBMP_RW that would allow me to save
a surface to a seekable SDL data source (memory or file) and then I
could use an AVI Generator Class
http://www.conestogac.on.ca/~set/courses/year2/multi/avi.html for
create the avi video, but I had problems implementing this option,
mainly because I do not know how to implement properly
SDL_SaveBMP_RW and there is little documentation.

Someone could help me with this option, or perhaps going the other way?

Thanks,


I?aki Cormenzana M?ndez

Computer Science Deliriums.
http://www.proxxo.com.ar


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I’m Sorry, but I do not really understand your answer.
I dont understand how I should do to take the image (surface) drawn with SDL
and add it as FRAME to the
function “static void video_encode_example(const char *filename)”.

Here is my code:

                     // Drawing image captured by camera
                      for (e=0;e<480;e++)

{
for (d=0;d<640;d++)
{
rgb=(int)(p+d+e640);
color=SDL_MapRGB(surface->format,rgb,rgb,rgb);
PutPixelPan(d,e,color);
}
}

                           //Drawing pointer with SDL

linehPan(xscr-4,yscr,10,2,Rojo);
linevPan(xscr,yscr-4,10,2,Rojo);
//SDL screen update
SDL_UpdateRect(surface, 0, 0, 640, 480);

  •                         /*  Now I would like to add this image
    

(surface) as a frame of an AVI file*

  •                        Something like this?*
                         SDL_RWops* dst = SDL_AllocRW();
         SDL_SaveBMP_RW(surface, dst, 3);
    
  •                        **then** I could use an **AVI Generator
    

Class*http://www.conestogac.on.ca/~set/courses/year2/multi/avi.html

  • for create the avi video?*
  •                        or maybe use *"static void
    

video_encode_examplehttp://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/api-example_8c.html#7bdd752f30f32edeb0da5ef57c77d9e9
(const char filename)"? *
*
*

  •                          */*
    

Thanks

On Mon, Sep 13, 2010 at 9:37 PM, Andreas Schiffler wrote:

You could use libavcodec. For the reverse of what you want, a SDL video
player, there is an excellent tutorial here: http://dranger.com/ffmpeg/

And here is some sample code that shows how to encode video:

http://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/api-example_8c-source.html

To match input data for the “static void video_encode_examplehttp://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/api-example_8c.html#7bdd752f30f32edeb0da5ef57c77d9e9
(const char *filename)” sources, one would need to access the SDL_Surface
pixel data and convert each RGB pixel into YCrCb (YUV) color space (see
http://www.fourcc.org/fccyvrgb.php).

Hope that helps,
–Andreas

On 9/13/10 1:39 PM, I?aki wrote:

Hello,

I’m programming an application in Microsoft Visual C/C++ with SDL in 2D.

I need to capture the surface video to an avi file.

I know that with SaveBMP function i could save every frame to a file and
then use another program to encode it as a movie. However, the performance
is terrible and i have limited time to processing.
I also know the function SDL_SaveBMP_RW that would allow me to save a
surface to a seekable SDL data source (memory or file) and then I could
use an AVI Generator Classhttp://www.conestogac.on.ca/~set/courses/year2/multi/avi.html for
create the avi video, but I had problems implementing this option, mainly
because I do not know how to implement properly SDL_SaveBMP_RW and there is
little documentation.

Someone could help me with this option, or perhaps going the other way?

Thanks,


I?aki Cormenzana M?ndez

Computer Science Deliriums.
http://www.proxxo.com.ar


SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


I?aki Cormenzana M?ndez

Computer Science Deliriums.
http://www.proxxo.com.ar