Skip to main content
GameDev.net gamedev.net
🔒 Locked

AVI in OpenGL

Started by LostinTime Feb 16, 2008 at 12:05 AM 5 replies 4.6k views
Original Post
LostinTime
LostinTime
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, ψ, 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
hahaha
hahaha
Did you link to Vfw32.lib? if you didnt then do this
#pragma comment(lib, "Vfw32.Lib")
LostinTime
LostinTime
ah..I see. Done it, now it works. Thanks!
hahaha
hahaha
Glad to help:)
LostinTime
LostinTime
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?
Sc4Freak
Sc4Freak
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.
LostinTime
LostinTime


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]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.