I was trying to do AVI from openGL on my computer and decided to try out lesson 35 of the NeHe tutorial: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=35

Well I tried using my own video, and I tried using the video (Face2.avi) he supplied, but both of them crap out on this line:

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);
}

Always throws the error on me:
"Failed To Open The AVI Frame"

But the problem is...I have no idea what to do now. It won't run, and there is no explanation of why it won't get the frame. Is it a codec thing? Is it a format problem? I'm confused. If anyone could help on this I would appreciate it greatly.

I tried to post this on the Gamedev.net forums, but I can see that those forums are for readers...not posters. No one responded to me. I have always gotten some good response from this community so I am asking you all now if you've done this tutorial and have suggestions. Also if anyone has done video as a texture on an object in openGL that is what I'm really looking for as an end goal. If there are good tutorials out there regarding this topic I have not found them. Thank you for your time.

Recommended Answers

All 14 Replies

Download the executable plus the packed source code of the tutorial from here and see if the executable runs. If yes then the problem is not with codecs but with your code.

Try compiling and running the code which comes in the zip file and see if it works. If it does compare the source code with the code you have written -- there has got to be a minor discrepancy in both the codes....

Repost if what I suggested doesn't work...

First of all Thank you a million times over for responding to me. I began to think no one cared at all about my trouble

I downloaded and ran the zip that Jeff Molofee(NeHe) gives on that lesson35.zip. I both ran the exe and I ran it from within VC++ It still gave me the same error each time, so I know its not discrepency in code at least...Did it work for you? There must be some other problem there

Thank you again for helping me

I began to think no one cared at all about my trouble

Don't think that way; after all, this is DaniWeb! :D

Well, you've obviously narrowed it down to the codecs (definitely not your code), thanks to ~s.o.s~. My guess is that you're missing some sort of DLL file. Could you possibly be missing msvfw32.dll? If you are, you may want to download it, as this file is crucial for playing videos in your application.

oh and btw ~s.o.s~, maybe you want to move this thread to the game development forum? That would be an excellent place for this thread.

You are right. Daniweb is one of the best online communities of which I've been a part.

So I do have msvfw32.dll it is in my windows/system32 folder. Did a search for it to make sure. It cannot be that then. Any other suggestions perhaps? I have to try to test this code again on another computer so that I know whether or not it is my computer that's the problem, but barring my ability to do that any time soon (Due to the fact that I am sick right now) any other ideas that might help would be greatly appreciated. I feel like it's my computer. Did you all get it to work fine on yours?

Does the executable run well on your computer.. ?

From an extract on NeHe's site:

All you need to know is that you MUST include the vfw.h header file and you must link to the vfw32.lib library file

Do you have the header as well as the library file on your computer... ?

Does the executable run well on your computer.. ?

Yes, I believe he said that the executable downloaded from NeHe's site failed also:

I both ran the exe and I ran it from within VC++ It still gave me the same error each time, so I know its not discrepency in code at least...Did it work for you?

From an extract on NeHe's site:

Do you have the header as well as the library file on your computer... ?

Yes, I read that too. However, several things:

  • Without the header file, you'd have syntax errors in the code. Without the library file, you'd have linker errors.
  • Since .lib is statically linked, it shouldn't be a problem in the executable downloaded.
  • Which is why I suspected a missing dll file that contains function code that vfw.lib depends on. I looked it up, and the modern dll file msvfw.dll has replaced the old vfw.dll.

I doubt that you would need the old vfw.dll file to run it though, because as far as I know, vfw.lib is still current.

Well the reason I asked was that I can't seem to find the lib file on my computer so I thought that it might be the problem. But yes you are right, without the library file the code might not have got compiled and I guess he did mention that his code compiled...

I didn't know that his executable is not working -- if that is the case then it surely is something related to the DLL's since the executable seems to be working in my case and I have neither the header not the library file.

Kharri, the only problem I can think of, as Joey has already mentioned is that of the missing DLL. Check your Windows folder to see if the file msvfw32.dll is present or not, since its present in my case....

Kharri, the only problem I can think of, as Joey has already mentioned is that of the missing DLL. Check your Windows folder to see if the file msvfw32.dll is present or not, since its present in my case....

Well as I did say before I do have the msvfw32.dll in my Windows/system32 folder. I havea geforce ti4200....I'm wondering if my antiquated vid card could be a reason for it. I am updating the drivers to see if that fixes the trouble. I tested his exe on a computer at school today. It worked....sigh. It's definitely mine. The thing is. I have vfw.lib, I have msvfw32.dll....I must be missing something yet.

It really is strange since you are able to play AVI files on your computer. ( are you ? )

If not then I can't think of putting the blame on anyone other than the missing codecs...

Yes, I am thinking it has to be the codec. Vid card update had no effect. The face2.avi does not play on my comptuer if I just play it in windows media player. It uses Cinepak Codec(which I found out at school where it does play) which is a codec that works with Video for Windows specifically. I did not know this until yesterday at closer inspection of John McGowan's website (one of NeHe's links on Lesson 35 tutorial)

Now here is wierd thing number two. Cinepak codec is shipped with Windows (has been since Window's 95) so I should have had it. However, I have over the past few years installed various codec packs (Nimo, K-Lite) of which K-Lite is my current codec pack. This may have f'd up the previous settings beyond repair. Taking that knowledge I figured, okay, download cinepak codec. So went to download the codec and install it, but when I went to drop the file into my windows/system32 folder, the file was there. ICCVID.dll is the one in question. So I replaced the old one with this new one. Still cannot play the video.

I get caught up a lot with codecs. Do I have to assign the video the cinepak codec? Does it not know to use it?

So the end result here is that it seems this code using video for windows can only play a certain type of AVI stream, in particular one using Cinepak Codec as it was made for Video for Windows (vfw.lib) It will not play any other video if it doesn't use Cinepak codec.

That being said, how can I assign a video a codec (They usually just look for the best match and use it) and if that doesn't seem to be the trouble what is...I think I'm edging on the right path, but cannot be sure

I definitely narrowed it to the codec being the trouble! For future posters and readers of this, if you have trouble with the video not grabbing the frame and everything else compiles and runs. It is definitely the codec that is your trouble.

I got one to work by doing a playblast from Maya using the Intel Indeo 5.1 codec as the compression for it. It seems I have a LOT to learn about AVIs. Video For Windows only works with the following codecs it seems: MRLE, Cinepak, Intel Indeo, and Microsoft Video 1(whatever that is). Thank you a million times over for your help. I would have never known how to narrow this down w/o your help. I wonder if perhaps however there is a way I can change this code to accept different codec types. I am afraid I know so little that I would not know where to begin changing the code. For instance DIB i beileve relies on the video for windows libarary to work. There would be a lot of deconstructing the nitty gritty in this code to see if it could work with a codec that when put full screen would not look pixelated as hell. Any suggestions of places to start based on your expert opinions?

Thanks again.

I don't know a lot about codecs, maybe Joey would have something enlightning to say on this, but just a recommendation -- try VLC player. Most of the people on the internet recommend since it comes packaged with all the codecs required to play most of the type of video files.

Uninstall all the third party codecs you have installed on your computer and try playing the face.avi with VLC and see if it works. Its worth an effort since we have tried out most of the things and come up against a brick wall....

I don't know a lot about codecs, maybe Joey would have something enlightning to say on this, but just a recommendation -- try VLC player. Most of the people on the internet recommend since it comes packaged with all the codecs required to play most of the type of video files.

Hmm, VLC player definitely has tons of codecs - in fact, there's not that many video formats that don't play on VLC. However, I'm not entirely sure how many of these codecs the Video for Windows can use, as many of these codecs are from Linux or are installed in weird locations that Windows won't find.

Take a look at the list of codecs in Windows (look in Windows Media Player settings) before you install VLC, and check back after installation to see if it did anything. If not, then VLC only installs codecs for itself. Unfortunately I do not know much about codecs on Windows, but what I can suggest is researching which codecs you need, and what the standard files and locations are for them. If they don't exist, google to find a download location so you can install the file.

Uninstall all the third party codecs you have installed on your computer and try playing the face.avi with VLC and see if it works. Its worth an effort since we have tried out most of the things and come up against a brick wall....

Definitely. Many third-party codecs clog up the system, but my suspicoun is that although VLC will almost certainly play the face.avi video, it's quite likely that VLC doesn't use Video for Windows, and as I explained previously, might keep codecs to itself.

But like Sanjay said, it's definitely worth a try...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.