Sign in to follow this  

AVI in OpenGL

This topic is 3592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I read NeHe's tutorial on the avi loading, and I tried to apply it to my project. He used this method to open the file void OpenAVI(LPCSTR szFile) // Opens An AVI File (szFile) { TCHAR title[100]; // Will Hold The Modified Window Title AVIFileInit(); // Opens The AVIFile Library // Opens The AVI Stream if (AVIStreamOpenFromFile(&pavi, szFile, streamtypeVIDEO, 0, OF_READ, NULL) !=0) { // An Error Occurred Opening The Stream MessageBox (HWND_DESKTOP, "Failed To Open The AVI Stream", "Error", MB_OK | MB_ICONEXCLAMATION); } AVIStreamInfo(pavi, &psi, sizeof(psi)); // Reads Information About The Stream Into psi width=psi.rcFrame.right-psi.rcFrame.left; // Width Is Right Side Of Frame Minus Left height=psi.rcFrame.bottom-psi.rcFrame.top; // Height Is Bottom Of Frame Minus Top lastframe=AVIStreamLength(pavi); // The Last Frame Of The Stream mpf=AVIStreamSampleToTime(pavi,lastframe)/lastframe; // Calculate Rough Milliseconds Per Frame bmih.biSize = sizeof (BITMAPINFOHEADER); // Size Of The BitmapInfoHeader bmih.biPlanes = 1; // Bitplanes bmih.biBitCount = 24; // Bits Format We Want (24 Bit, 3 Bytes) bmih.biWidth = 256; // Width We Want (256 Pixels) bmih.biHeight = 256; // Height We Want (256 Pixels) bmih.biCompression = BI_RGB; // Requested Mode = RGB hBitmap = CreateDIBSection (hdc, (BITMAPINFO*)(&bmih), DIB_RGB_COLORS, (void**)(&data), NULL, NULL); SelectObject (hdc, hBitmap); // Select hBitmap Into Our Device Context (hdc) pgf=AVIStreamGetFrameOpen(pavi, NULL); // Create The PGETFRAME Using Our Request Mode if (pgf==NULL) { // An Error Occurred Opening The Frame MessageBox (HWND_DESKTOP, "Failed To Open The AVI Frame", "Error", MB_OK | MB_ICONEXCLAMATION); } // Information For The Title Bar (Width / Height / Last Frame) wsprintf (title, "NeHe's AVI Player: Width: %d, Height: %d, Frames: %d", width, height, lastframe); SetWindowText(g_window->hWnd, title); // Modify The Title Bar } However, when I tried the same thing, these errors appeared. Can some one help?? Error 1 error LNK2019: unresolved external symbol _AVIStreamGetFrameOpen@8 referenced in function "void __cdecl OpenAVI(wchar_t const *)" (?OpenAVI@@YAXPB_W@Z) AppMain.obj Error 2 error LNK2019: unresolved external symbol _AVIStreamSampleToTime@8 referenced in function "void __cdecl OpenAVI(wchar_t const *)" (?OpenAVI@@YAXPB_W@Z) AppMain.obj Error 3 error LNK2019: unresolved external symbol _AVIStreamLength@4 referenced in function "void __cdecl OpenAVI(wchar_t const *)" (?OpenAVI@@YAXPB_W@Z) AppMain.obj Error 4 error LNK2019: unresolved external symbol _AVIStreamInfoW@12 referenced in function "void __cdecl OpenAVI(wchar_t const *)" (?OpenAVI@@YAXPB_W@Z) AppMain.obj Error 5 error LNK2019: unresolved external symbol _AVIStreamOpenFromFileW@24 referenced in function "void __cdecl OpenAVI(wchar_t const *)" (?OpenAVI@@YAXPB_W@Z) AppMain.obj Error 6 error LNK2019: unresolved external symbol _AVIFileInit@0 referenced in function "void __cdecl OpenAVI(wchar_t const *)" (?OpenAVI@@YAXPB_W@Z) AppMain.obj Error 7 error LNK2019: unresolved external symbol _DrawDibDraw@52 referenced in function "void __cdecl GrabAVIFrame(int)" (?GrabAVIFrame@@YAXH@Z) AppMain.obj Error 8 error LNK2019: unresolved external symbol _AVIStreamGetFrame@8 referenced in function "void __cdecl GrabAVIFrame(int)" (?GrabAVIFrame@@YAXH@Z) AppMain.obj

Share this post


Link to post
Share on other sites
Hey, I seem to have a problem =(
I cant open the avi file I want, even though I opened it in NeHe's Project folder.

void OpenAVI(char* szFile)
{
AVIFileInit(); // Opens The AVIFile Library

// Opens The AVI Stream
if (AVIStreamOpenFromFile(&pavi, (LPCWSTR)szFile, streamtypeVIDEO, 0, OF_READ, NULL) !=0)

it doesnt get pass this lines. The compiler keeps returning me errors, or returns the error message that says I cant open the file. The file has been placed in the correct folder, yet I dont know why?

Share this post


Link to post
Share on other sites
Because the cast from char* to LPCWSTR is very dangerous, and won't work. LPCWSTR resolves, by default, to wchar_t. Which is a 16-bit type on Windows. char* is an 8-bit type, and casting the pointers doesn't convert the string. In effect, you're passing garbage to the function.

The easiest way to solve this problem is to turn off unicode, since it is on by default. The settings should be under project settings somewhere. If unicode is on, it'll cause the LPCTSTR type to resolve to LPCWSTR (and then you'll have to convert the string using some obscure function that I can't remember right now). Otherwise, it'll resolve to LPCSTR, in which case the cast will be unnecessary.

Share this post


Link to post
Share on other sites


Re: Sorry, I forgot to define the textures parameteri. Now that I got the first frame, I have no idea how to advance.

NeHe defined DWORD milliseconds to move onwards. He gave no defination as to what is it, only that" //Perform Motion Updates Here"

To forward the frame, he used

next+=milliseconds; // Increase next Based On The Timer
frame=next/mpf; // Calculate The Current Frame

Where all the parameters are integers.


However, when I did it, my frame did not advance. I read about DWORD, and it is similar to LPCSTR( I think), but since I followed Sc4Freak's advice and switch off the Unicode, I am thinking that might be the problem.


[Edited by - LostinTime on February 16, 2008 1:50:30 PM]

Share this post


Link to post
Share on other sites

This topic is 3592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this