It is currently Wed Nov 22, 2017 10:28 pm

All times are UTC - 5 hours




 Page 1 of 1 [ 22 posts ] 
Author Message
 Post subject: using sound and intro/outro video for games
PostPosted: Tue Apr 29, 2008 5:20 am 

Joined: Fri Jan 04, 2008 2:11 pm
Posts: 72
I'd like some vmk's on integrating sound in the game engine...using directsound or opensource api's like openal even better if we write our own sound api...and a way to show intro/outro/in-game videos in the game engine


Offline
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 5:40 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Sound & Music VMK's I can do. I have them written on my list.

Video playback is a bit trickier. I've tried a number of ways to get videos to stream into the game engine but I haven't had much luck in this working. The only option for videos that I can think of is to use a 3rd party tool like bink but unfortunately that option is not free.

Hey, if someone can get videos to work in the game engine, I'll give them a reward!


Last edited by Marek on Tue Apr 29, 2008 10:09 am, edited 1 time in total.

Offline
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 8:48 am 

Joined: Sat Jun 23, 2007 7:56 pm
Posts: 145
What exactly do you mean by getting video to work?

Do you mean playing cut-scenes or making them render on a quad in the scene like on a billboard?

A list of requirements might be nice so I or we can see exactly what is wanted and if it can be done.


Offline
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 9:33 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
What I was trying to do is load an AVI file and have the graphics rendered on a quad while at the same time stream audio to the speakers so that sounds and music is synchronized with the visual output.

I wanted to wrap all of this up into a nice class that would be similar to the GeometryFlatGrid class. You could specify the video's filename in the constructor and then do things like:

GeometryVideo myVideo("video.avi");

myVideo.play(fCurrentTime);
myVideo.pause(bOn);
myVideo.stop();


Offline
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 9:39 am 

Joined: Sat Jun 23, 2007 7:56 pm
Posts: 145
Ok, that clears things up a bit.

Quick Idea - (dont know much about the AVI format) Is there are way to get an offset which says eg frame X is from YYY to ZZZ in the file.

Have to give this more thought :wink:


Offline
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 10:08 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
there is an OpenGL tutorial here that shows how to load an AVI file. You can use that as a starting point.


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Apr 30, 2008 2:42 am 

Joined: Fri Apr 25, 2008 6:12 pm
Posts: 32
But that video si simple....I mean no sound and mpg encoder
what we need is some custom video format easy to decode
Bink video is example...


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Apr 30, 2008 4:16 am 

Joined: Sat Jun 23, 2007 7:56 pm
Posts: 145
I'll come back to this feature once I've done a rewrite (which am doing at the moment to get a higher frame rate using more features of opengl eg vertex buffers etc)

But it would be easier to do this if the format allows us to know where the frames start and end and where the audio starts and ends. That way we can do some calculations to synch the two while rendering.

Just early ideas, have not thought much yet.


Last edited by codeslasher on Thu May 01, 2008 3:13 am, edited 1 time in total.

Offline
 Profile  
 
 Post subject:
PostPosted: Wed Apr 30, 2008 6:56 pm 

Joined: Thu Oct 25, 2007 9:49 pm
Posts: 33
DX has something about rendering video to texture i think...perhaps look there for inspiration? its not the video decoding/encoding that will be hard (im not very good at coding so its very opinionated) but getting the video to play properly and syncing it with audio.

--DX's implementation is something to do with getting each frame of video and updating it on a texture, perhaps add audio streaming in the same thread so they work together?


Offline
 Profile  
 
 Post subject:
PostPosted: Fri May 02, 2008 2:16 pm 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
So basically, you are getting stuck somewhere where openGL plays no role - thus one could actually just take a look at the source code of an open source video player and see how they do it - with the requirement of not being scared of the sheer amount of code...
VLC would be a good program to look at, I guess, as it actually uses openGL if available.


Offline
 Profile  
 
 Post subject:
PostPosted: Sun May 04, 2008 2:18 am 

Joined: Fri Jan 04, 2008 2:11 pm
Posts: 72
what if we store the movie and sound in diffrent files and sync them while playing...cuz using the method in nehe i can't open files with sound data

i'd also like a tutorial on how to pack all the data in large files that the the game exe unpacks to load the levels but the files aren't viewable to everyone..like the .pak files in quake engine uses zip to pack them.


Offline
 Profile  
 
 Post subject:
PostPosted: Sun May 04, 2008 11:01 am 

Joined: Thu Oct 25, 2007 9:49 pm
Posts: 33
im guessing you just need the code to open .pak files just like you need code to open other file formats

--if anything, a vritual file system like Crystal Space could be integrated so that you just name the file to load and it takes care of the rest


Offline
 Profile  
 
 Post subject:
PostPosted: Thu May 15, 2008 9:31 pm 

Joined: Thu Nov 29, 2007 9:44 pm
Posts: 22
One nice alternative to video cut scenes is a cut scene using the engine in "automatic mode".

If you could use the game to play out the cut scene for you then you would avoid the transition from a nicely detailed video to a less detailed game.

Cool video cut scenes in a way cheapen the rest of the gaming experience in my opinion.


Offline
 Profile  
 
 Post subject:
PostPosted: Fri May 16, 2008 6:42 pm 

Joined: Thu Oct 25, 2007 9:49 pm
Posts: 33
u mean using the game engine to play in-game graphic videos?


Offline
 Profile  
 
 Post subject:
PostPosted: Fri May 16, 2008 9:07 pm 

Joined: Thu Nov 29, 2007 9:44 pm
Posts: 22
Sure, lots of games do that. They have the characters move in a pre-determined way and do voice overs to move the story along. Then you aren't actually playing a movie you are just rendering a scene similar to the way you would normally be playing. With some added camera angles for effect.

Just an idea.


Offline
 Profile  
 
 Post subject:
PostPosted: Sat May 17, 2008 7:07 am 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
Of course, any decent game engine has support for both real videos and "automatic mode".


Offline
 Profile  
 
 Post subject:
PostPosted: Thu May 22, 2008 6:35 pm 

Joined: Fri Apr 25, 2008 6:12 pm
Posts: 32
Lots of games uses Bink video for that, and some In Game rendering or game engine do all stuff, just characters and all objects are scripted with some language or internal script to look like movie

This is only my opinion so don't take that seriously!!!


Offline
 Profile  
 
 Post subject: I think I did it Marek
PostPosted: Mon Mar 01, 2010 9:38 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 449
I didn't incorporate loding vidoes as a Texture into the GameEngine just yet. I am having a little trouble encapsulating it into a class. As of now I have all the functions in the class but all the varibles that contains info from the file stream are in the classe's .cpp file but are all global. I do have it working in a stand alone project using OpenGL and I am using the video stream as a Texture. :)

I arleady sent you the code to look at Marek. Any feedback or suggestions on how to improve it would help. Once I can get this completly workin with all data either in a class or structure. Then I will try to incorporate / import it into the game engine. No sound just yet. What I might do is create either another library for the GameEngine that works with the vids/sound from the AVI file format that I am using.

If anyone would like to use a copy of this project to see what I did just let me know by posting your email here as a reply and i will send you a copy or if you don't feel comfortable about displaying your email in the forums, you can ask Marek for it! Happy Video Texturing and Coding


Last edited by skilz80 on Tue Mar 16, 2010 4:47 am, edited 2 times in total.

Offline
 Profile  
 
 Post subject: Screen Shots!
PostPosted: Mon Mar 01, 2010 10:18 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 449
I will put these in order like a slide show. The way the program
works is you can toggle the background on and off and you can
rotate between a cube, sphere, cylinder and no 3D objects.
===============================================

For right now, I'll just post the link where I uploaded the screenshots to.
If this link doesn't work please let me know. I have a dynamic IP address,
it constantly changes. I have to keep checking to see if My server is up and
I am using wireless Internet so I also have to make sure that my ip
on this pc is in sync with my routers. Have to keep checking the portforwarding

You need to type it like it is, there is "NO" www. or .com in the address.

http://souls-of-light.game-server.cc/screenshots.html


Last edited by skilz80 on Tue Mar 02, 2010 8:14 am, edited 1 time in total.

Offline
 Profile  
 
 Post subject: Follow Up
PostPosted: Tue Mar 02, 2010 4:08 am 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 449
I tried using other AVI Files, but it had trouble loading in the file stream. I think this is due to the type of AVI File. The one I used in the code/program above did not have any sound. And some AVI files that have sound can follow server different formats. One is that the video and audio chunks/headers are in seperate sections of the file, two the file can be interleaved, three it depends on the codec, and four whether it is compressed or not. The last option shouldn't matter since we are just reading from the file stream whether it is compressed or not. But the first two makes a difference. This happens cause the pointer we are using to retrieve the file stream, won't know what to do if this file has audio and is interleaved. (Im only guessing this from what I have read about AVI file formats). But this is a good starting place to work at. I hope this helps you marek for loading in AVI Files. Maybe If I get some spare time I might try to load in FLV files (flash video) since they might be easier to parse.


Offline
 Profile  
 
 Post subject: I understand where you are coming form!
PostPosted: Tue Mar 02, 2010 8:30 am 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 449
Jasper wrote:
So basically, you are getting stuck somewhere where openGL plays no role - thus one could actually just take a look at the source code of an open source video player and see how they do it - with the requirement of not being scared of the sheer amount of code...
VLC would be a good program to look at, I guess, as it actually uses openGL if available.


If the AVI video has both video and audio streams, then it gets complicated, with this in mind we now how to worry about if the current file's streams are in seperate blocks/chunks or interleaved then after we establish that, we now have to deal with the audio codecs which is a completely serperate topic. There is one thing to keep us smiling though, not that it will make our tasks any easier, and that is OpenGL has a lovely library that works for sounds which is OpenAL. If you are familiar with the frame work of OpenGL, then OpenAL should not be too hard to pick up.


Offline
 Profile  
 
 Post subject: Playing CutScene In Game Videos Using DirectShow
PostPosted: Sat Dec 25, 2010 2:22 am 

Joined: Thu Dec 23, 2010 9:46 am
Posts: 6
Location: Pakistan
The purpose of the program is to play the In Game CutScene Videos using DirectShow. It Can be very simply
added to the OpenGL Game Engine created by Marek.

REQUIREMENTS:
=============
You Will Need To Have DirectShow which comes with the platform SDK. You will also need strmbasd.lib
which is also present in platform SDK. If you find it difficult to compile and execute the program
you can post comment and i will show you how to do it.

Platform SDK can be found on the following link.
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505&displaylang=en

REFERENCES:
===========
http://www.gamedev.net/reference/articles/article1345.asp
http://www.flipcode.com/archives/DirectShow_For_Media_Playback_In_Windows-Part_II_DirectShow_In_C.shtml

//Source Code For the Program.

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <streams.h>
#include <dshow.h>

#pragma warning (disable : 4996)

#define DEFAULT_SCREEN_WIDTH 800
#define DEFAULT_SCREEN_HEIGHT 600
#define DEFAULT_SCREEN_POSITION_X 250
#define DEFAULT_SCREEN_POSITION_Y 50
#define DEFAULT_CLASS_NAME "Default_Window_Class"
#define DEFAULT_WINDOW_TITLE "Default_Window_Title"
#define WINDOWED TRUE
#define FULLSCREEN FALSE

#define SAFE_RELEASE(X) if(X) { (X)->Release(); (X) = NULL; }
#define SAFE_DELETE(X) if(X) { delete (X); (X) = NULL; }
#define SAFE_DELETE_ARRAY(X) if(X) { delete [] (X); (X) = NULL; }
#define ERROR_MESSAGE(Message) MessageBox(NULL, Message, "ERROR!!!", MB_OK | MB_ICONERROR)
#define WARNING_MESSAGE(Message) MessageBox(NULL, Message, "WARNING!!!", MB_OK | MB_ICONWARNING)
#define INFO_MESSAGE(Title, Message) MessageBox(NULL, Message, Title, MB_OK)

typedef unsigned int uint;

LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

//================================
// WinMain
//================================

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{   
   //================================
   // Window Declarations
   //================================

   HWND hWnd;
   MSG Msg;
   
   RECT WindowRect;
   uint WindowWidth = DEFAULT_SCREEN_WIDTH;
   uint WindowHeight = DEFAULT_SCREEN_HEIGHT;
   uint WindowPosX = DEFAULT_SCREEN_POSITION_X;
   uint WindowPosY = DEFAULT_SCREEN_POSITION_Y;
   char *WindowTitle = DEFAULT_WINDOW_TITLE;
   bool WindowMode = WINDOWED;

   WindowRect.left = (long)0;
   WindowRect.right = (long)WindowWidth;
   WindowRect.top = (long)0;
   WindowRect.bottom = (long)WindowHeight;

   //================================
   // DirectShow Declarations
   //================================

   IGraphBuilder *GraphBuilder = NULL;
   IMediaControl *MediaControl = NULL;
   IVideoWindow *VideoWindow = NULL;

   //================================
   // Initialize COM
   //================================

   CoInitialize(NULL);

   //================================
   // Initialize Window Class
   //================================

   WNDCLASSEX WindowClass;

   ZeroMemory(&WindowClass, sizeof(WNDCLASSEX));

   WindowClass.cbSize = sizeof(WNDCLASSEX);
   WindowClass.style = CS_HREDRAW | CS_VREDRAW;
   WindowClass.lpfnWndProc = WindowProc;
   WindowClass.cbClsExtra = 0;
   WindowClass.cbWndExtra = 0;
   WindowClass.hInstance = hInstance;
   WindowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
   WindowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
   WindowClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
   WindowClass.lpszMenuName = NULL;
   WindowClass.lpszClassName = DEFAULT_CLASS_NAME;

   //================================
   // Register Window Class
   //================================

   if(!RegisterClassEx(&WindowClass))
   {
      ERROR_MESSAGE("Unable To Register Window");
      return FALSE;
   }

   //================================
   // Create Window
   //================================

   hWnd = CreateWindowEx(NULL, WindowClass.lpszClassName, WindowTitle,
                    WindowMode ? WS_OVERLAPPEDWINDOW : WS_EX_TOPMOST | WS_POPUP,
                    WindowPosX, WindowPosY, WindowRect.right - WindowRect.left,
                    WindowRect.bottom - WindowRect.top, NULL, NULL, hInstance,
                    NULL);   

   AdjustWindowRect(&WindowRect, GetWindowLong(hWnd, GWL_STYLE), FALSE);
   SetWindowPos(hWnd, 0, 0, 0, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, SWP_NOZORDER | SWP_NOMOVE);

   //================================
   // Show and Update Window
   //================================

   ShowWindow(hWnd, nShowCmd);
   UpdateWindow(hWnd);

   //================================
   // Initialize Direct Show
   //================================
   
   CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&GraphBuilder);

   GraphBuilder->QueryInterface(IID_IMediaControl, (void**)&MediaControl);
   GraphBuilder->QueryInterface(IID_IVideoWindow, (void**)&VideoWindow);

   //================================
   // Play Movie.
   //================================

   GraphBuilder->RenderFile(L"Video.avi", NULL);

   VideoWindow->put_Owner((OAHWND)hWnd);
   VideoWindow->put_WindowStyleEx(WS_CHILD | WS_CLIPSIBLINGS);

   VideoWindow->SetWindowPosition(-4, -30, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top);

   MediaControl->Run();

   //================================
   // Message Loop
   //================================

   while(TRUE)
    {
      if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
      {
         if(Msg.message == WM_QUIT)
         {
            return FALSE;
         }

         TranslateMessage(&Msg);
         DispatchMessage(&Msg);
      }

    }

   //================================
   // CleanUpDirectShow.
   //================================

   VideoWindow->put_Visible(OAFALSE);
   VideoWindow->put_Owner(NULL);
   SAFE_RELEASE(VideoWindow);
   SAFE_RELEASE(MediaControl);
   SAFE_RELEASE(GraphBuilder);

   //================================
   // DeInitialize COM
   //================================

    CoUninitialize();

   return 0;
}

//================================
// Window Procedure
//================================

LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    { 
      case WM_CHAR:
      {
         switch(toupper(wParam))
         {
            case VK_ESCAPE:
            {
               PostQuitMessage(0);
               return 0;
            }
            
            default:
            break;
         }

      }

        case WM_CLOSE:
        {
            PostQuitMessage(0);
              
         return 0;
        }
        break;

      case WM_DESTROY:
      {
         PostQuitMessage(0);
         break;
      }

      default:
      break;
   }
   
    return DefWindowProc (hWnd, message, wParam, lParam);
}


Note That the following program is written in a very simple manner.
And By Studying it a bit you will understand how to integrate it into the
game engine. The Reason i couldnt integrate it into the engine is because
i have just recently started to watch and implement the engine. So i am currently understanding the game engine.
The Program Creates a simple Window with an integrated child window displaying the movie inside the parent window. [/list][/list][/url][/code]


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 22 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron