Video with SDL/OpenGL

Hi,
I want to develop code to play AVIs within my SDL-based application,
which uses OpenGL for all graphics. I understand that TextureMaps are
the way to go, and have learned a lot from NeHe’s tutorial on this
subject (Lesson 35). But Nehe’s code is quite Windows-dependent,
particularly in that it uses the Video for Windows library, and I am
working exclusively with Linux. I have downloaded the source for the
avifile package, but I find it a bit daunting, and anyway it doesn’t use
OpenGL (as far as I can tell). My plan was to look at how avifile reads
AVIs, and attempt to adapt it for my purposes. But before heading down
that rather rocky trail, I thought I’d check first to see if there might
be an easier path. Are there some code examples that I should know
about?

thanks
Gib–

Gib Bogle @Gib_Bogle
1/44 Arthur St Tel: (64-9) 525-6878
Ellerslie, N.Z. Fax: (64-9) 525-6878

is AVI an immutable requirement?

if not, then consider using MPEG content which, I think,
is more desirable because the format is less platform-specific
and is well supported in SGL with the smpeg library.On Sat, 2002-06-29 at 15:07, Gib Bogle wrote:

Hi,
I want to develop code to play AVIs within my SDL-based application,
which uses OpenGL for all graphics. I understand that TextureMaps are
the way to go, and have learned a lot from NeHe’s tutorial on this
subject (Lesson 35). But Nehe’s code is quite Windows-dependent,
particularly in that it uses the Video for Windows library, and I am
working exclusively with Linux. I have downloaded the source for the
avifile package, but I find it a bit daunting, and anyway it doesn’t use
OpenGL (as far as I can tell). My plan was to look at how avifile reads
AVIs, and attempt to adapt it for my purposes. But before heading down
that rather rocky trail, I thought I’d check first to see if there might
be an easier path. Are there some code examples that I should know
about?

thanks
Gib


Gib Bogle bogle at ihug.co.nz
1/44 Arthur St Tel: (64-9) 525-6878
Ellerslie, N.Z. Fax: (64-9) 525-6878


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

if not, then consider using MPEG content which, I think,
is more desirable because the format is less platform-specific
and is well supported in SGL with the smpeg library.

If nothing else, look at the glmovie.c source in smpeg to see how to get
from a YUV overlay to a GL surface.

–ryan.

Message: 41

if not, then consider using MPEG content which, I think,
is more desirable because the format is less platform-specific
and is well supported in SGL with the smpeg library.

If nothing else, look at the glmovie.c source in smpeg to see how to get
from a YUV overlay to a GL surface.

Ryan, I have installed smpeg-0.4.4 and studied the test program
glmovie.c. But when I run this program I get very strange behaviour.
I’m hoping that someone here can explain what is happening.

When I play an MPEG-1 file (./glmovie test.mpg) I do not see anything
related to the content in this mpg file. Instead I see a fixed image,
which happens to correspond to the bitmap of the NeHe logo, such as is
used in lesson06, which I was running yesterday. In other words glmovie
is somehow locating the bitmap, which apparently still resides in RAM
somewhere, probably on the graphics card. It is opening the mpg file
and returning correct mpeg_info.width and .height, but displaying
something else. BTW, plaympeg plays the file OK.

My machine is a P4 with a GeForce4 Ti4400 graphics card.

Before getting stuck into trying to debug this, since I’m not familiar
yet with OpenGL I thought I’d check here to see if this behaviour has
been seen before.

thanks
Gib> Date: Sat, 29 Jun 2002 03:42:42 -0400 (EDT)

From: “Ryan C. Gordon”
To: “sdl at libsdl.org
Subject: Re: [SDL] Video with SDL/OpenGL
Reply-To: sdl at libsdl.org

Gib Bogle wrote:

When I play an MPEG-1 file (./glmovie test.mpg) I do not see anything
related to the content in this mpg file. Instead I see a fixed image,
which happens to correspond to the bitmap of the NeHe logo, such as is
used in lesson06, which I was running yesterday. In other words glmovie
is somehow locating the bitmap, which apparently still resides in RAM
somewhere, probably on the graphics card. It is opening the mpg file
and returning correct mpeg_info.width and .height, but displaying
something else. BTW, plaympeg plays the file OK.

this could be related to a nonfunctional glTexSubImage2D perhaps…
I’ve seen many a movie player use that function, even though it isn’t supported on every gfx card…
mplayer has multiple methods of playing through OpenGL for just this reason…–
-==-
Jon Atkins
http://jonatkins.org/

Gib Bogle wrote:

When I play an MPEG-1 file (./glmovie test.mpg) I do not see anything
related to the content in this mpg file. Instead I see a fixed image,
which happens to correspond to the bitmap of the NeHe logo, such as is
used in lesson06, which I was running yesterday. In other words glmovie
is somehow locating the bitmap, which apparently still resides in RAM
somewhere, probably on the graphics card. It is opening the mpg file
and returning correct mpeg_info.width and .height, but displaying
something else. BTW, plaympeg plays the file OK.

this could be related to a nonfunctional glTexSubImage2D perhaps…
I’ve seen many a movie player use that function, even though it isn’t
supported on every gfx card…
mplayer has multiple methods of playing through OpenGL for just this
reason…

So, outside of visual observation how would the mpeg player know that
glTexSubImage2D() is not working?

If the function does not operate as advertised, then that OpenGL driver is
not compliant… (as if that matters in the big scheme).

Does one have to perform some glTexSubImage2D() operation, render the
texture, read it back in and THEN test to see if the glTexSubImage2D()
performed? (cuss deleted.)

-BlakeFrom: “Jonathan Atkins” :

It gets even worse.
I’ve got an implementation on my laptop which is quite buggy (it advertises
itself as being OpenGL 2.03… go figure). TexSubImage only fails after the
texture you’re trying to access has been used in rendering at least once.
This is an SiS on-board chip in a laptop BTW. My bug report seems to have
been ignored completely :confused:

cu,
NicolaiAm Dienstag, 2. Juli 2002 16:41 schrieb Blake Senftner:

So, outside of visual observation how would the mpeg player know that
glTexSubImage2D() is not working?

If the function does not operate as advertised, then that OpenGL driver is
not compliant… (as if that matters in the big scheme).

Does one have to perform some glTexSubImage2D() operation, render the
texture, read it back in and THEN test to see if the glTexSubImage2D()
performed? (cuss deleted.)

Hi Gib,
This sounds like a similar problem to I was having with porting the
GLMovie demo to Pascal.

Try moving the function call “glmpeg_update” so that it is the last
thing called in side the main loop ( just after the SDL_Delay call ).
ie something like this…

while( SMPEG_status( mpeg ) == SMPEG_PLAYING )
{
SDL_Event event;

 while ( SDL_PollEvent(&event) )
 {
   switch (event.type)
   {
     case SDL_KEYDOWN:
             if ( event.key.keysym.sym == SDLK_ESCAPE ) {
                 SMPEG_stop( mpeg );
             }
             break;
     case SDL_MOUSEBUTTONDOWN:
     case SDL_QUIT:
             SMPEG_stop( mpeg );
             break;
   }
 }
 SDL_Delay(100);
 glmovie_quit( surface, 0, 0, 0, 0 ); // <--- Add this call here to 

see what happens.
}

When I did this the video plays. Does it does so for you?

L8R,

Dominique Louis.

Gib Bogle wrote:>>Message: 41

Date: Sat, 29 Jun 2002 03:42:42 -0400 (EDT)
From: “Ryan C. Gordon”
To: “sdl at libsdl.org
Subject: Re: [SDL] Video with SDL/OpenGL
Reply-To: sdl at libsdl.org

if not, then consider using MPEG content which, I think,
is more desirable because the format is less platform-specific
and is well supported in SGL with the smpeg library.

If nothing else, look at the glmovie.c source in smpeg to see how to get
from a YUV overlay to a GL surface.

Ryan, I have installed smpeg-0.4.4 and studied the test program
glmovie.c. But when I run this program I get very strange behaviour.
I’m hoping that someone here can explain what is happening.

When I play an MPEG-1 file (./glmovie test.mpg) I do not see anything
related to the content in this mpg file. Instead I see a fixed image,
which happens to correspond to the bitmap of the NeHe logo, such as is
used in lesson06, which I was running yesterday. In other words glmovie
is somehow locating the bitmap, which apparently still resides in RAM
somewhere, probably on the graphics card. It is opening the mpg file
and returning correct mpeg_info.width and .height, but displaying
something else. BTW, plaympeg plays the file OK.

My machine is a P4 with a GeForce4 Ti4400 graphics card.

Before getting stuck into trying to debug this, since I’m not familiar
yet with OpenGL I thought I’d check here to see if this behaviour has
been seen before.

thanks
Gib


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


http://www.DelphiGamer.com := for all your Object Pascal game
development needs;
http://www.delphi-jedi.org/Jedi:TEAM_SDL_HOME := Home of JEDI-SDL;
Cross-platform game development with Pascal, has never been easier.

Ahh, I must personally thank SiS for being complete idiots then, and for
making my life just that much more enjoyable as an OpenGL developer.

I’ll have to be sure to send them something nice for the holidays, like a
large cluebat or two (or ten…) On second thought, why wait? It’s the
thought that counts. =)

(FWIW, apparently SiS chipsets work with DarkPlaces, which does some very
interesting glTexSubImage2D stuff…)On Tue, Jul 02, 2002 at 05:08:29PM +0200, Nicolai Haehnle wrote:

It gets even worse.
I’ve got an implementation on my laptop which is quite buggy (it advertises
itself as being OpenGL 2.03… go figure). TexSubImage only fails after the
texture you’re trying to access has been used in rendering at least once.
This is an SiS on-board chip in a laptop BTW. My bug report seems to have
been ignored completely :confused:


Joseph Carter No conceit in my family

  • BenC wonders why he has upgraded to 3.3.5-1 before teh X maintainer

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020702/a574c671/attachment.pgp

Message: 35
Organization: Savage Software Solutions

Hi Gib,
This sounds like a similar problem to I was having with porting the
GLMovie demo to Pascal.

Try moving the function call “glmpeg_update” so that it is the last
thing called in side the main loop ( just after the SDL_Delay call ).
ie something like this…

while( SMPEG_status( mpeg ) == SMPEG_PLAYING )
{
SDL_Event event;

 while ( SDL_PollEvent(&event) )
 {
   switch (event.type)
   {
     case SDL_KEYDOWN:
             if ( event.key.keysym.sym == SDLK_ESCAPE ) {
                 SMPEG_stop( mpeg );
             }
             break;
     case SDL_MOUSEBUTTONDOWN:
     case SDL_QUIT:
             SMPEG_stop( mpeg );
             break;
   }
 }
 SDL_Delay(100);
 glmovie_quit( surface, 0, 0, 0, 0 ); // <--- Add this call here to

see what happens.
}

When I did this the video plays. Does it does so for you?

(Of course you meant to add glmpeg_update(), not glmovie_quit()). Yes,
this change makes it play. But it is excruciatingly slow - about 1
fps. So now one puzzle is replaced by another. Just when I’d posted a
message about the speed of Linux/SDL/OpenGL, I now find something that
is unusably sluggish. plaympeg plays the video at its original 352x240
resolution, while glmovie is stretching it onto a 640x480 res screen. I
really need to find out what is slowing glmovie down so much, because in
my application I will be playing video onto arbitrarily oriented OpenGL
surfaces, i.e. I will not be able to map video pixels 1-to-1 to screen
pixels.

Gib> Date: Tue, 02 Jul 2002 16:44:26 +0100

From: Dominique Louis
To: sdl at libsdl.org
Subject: Re: [SDL] Video with SDL/OpenGL
Reply-To: sdl at libsdl.org

Hi Gib,
Sorry, Yes I meant glmpeg_update. Cut and paste is evil sometimes.

Which goes to show that the callback function specified in…
SMPEG_setdisplay( mpeg, surface, NULL, glmpeg_update );
is not working or being called correctly.

This was what my post was about last week but have not received any
response.

L8R,

Dominique.

Gib Bogle wrote:>>Message: 35

Date: Tue, 02 Jul 2002 16:44:26 +0100
From: Dominique Louis
Organization: Savage Software Solutions
To: sdl at libsdl.org
Subject: Re: [SDL] Video with SDL/OpenGL
Reply-To: sdl at libsdl.org

Hi Gib,
This sounds like a similar problem to I was having with porting the
GLMovie demo to Pascal.

Try moving the function call “glmpeg_update” so that it is the last
thing called in side the main loop ( just after the SDL_Delay call ).
ie something like this…

while( SMPEG_status( mpeg ) == SMPEG_PLAYING )
{
SDL_Event event;

while ( SDL_PollEvent(&event) )
{
  switch (event.type)
  {
    case SDL_KEYDOWN:
            if ( event.key.keysym.sym == SDLK_ESCAPE ) {
                SMPEG_stop( mpeg );
            }
            break;
    case SDL_MOUSEBUTTONDOWN:
    case SDL_QUIT:
            SMPEG_stop( mpeg );
            break;
  }
}
SDL_Delay(100);
glmovie_quit( surface, 0, 0, 0, 0 ); // <--- Add this call here to

see what happens.
}

When I did this the video plays. Does it does so for you?

(Of course you meant to add glmpeg_update(), not glmovie_quit()). Yes,
this change makes it play. But it is excruciatingly slow - about 1
fps. So now one puzzle is replaced by another. Just when I’d posted a
message about the speed of Linux/SDL/OpenGL, I now find something that
is unusably sluggish. plaympeg plays the video at its original 352x240
resolution, while glmovie is stretching it onto a 640x480 res screen. I
really need to find out what is slowing glmovie down so much, because in
my application I will be playing video onto arbitrarily oriented OpenGL
surfaces, i.e. I will not be able to map video pixels 1-to-1 to screen
pixels.

Gib


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


http://www.DelphiGamer.com := for all your Object Pascal game
development needs;
http://www.delphi-jedi.org/Jedi:TEAM_SDL_HOME := Home of JEDI-SDL;
Cross-platform game development with Pascal, has never been easier.