Issues with extracting the FOURCC codes...

TheFaimousOne
TheFaimousOne used Ask the Experts™
on
I am trying to build a small program that will allow me to get the FOURCC codes from an AVI (media) file. What I would need is the complete code and all of the functions I would need to accomplish this. I know it will require an API call, and I have looked everywhere for documentation, but I can't seem to find any!

Here is what I want to build: A small program for a group of inexperienced users, so they can find out what Video codec is required and what Audio codec is required to watch a movie. I know there are already programs out there, but I want one that does just that, and nothing more.

This is probably so simple and I have just overlooked the detail somewhere, but I know it can be done, and it can be done in VB6.

So, I need the code to find the FOURCC in a video file. Who can help?!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Here's a site to detect how many FOURCC Codes you have:
http://www.cse.unsw.edu.au/~atan164/ddraw_print.html

Here's MS sites about the FourCC code in use and how to get it.  You will need to convert the call to VB, and if you need help with that, let me know:

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/ddraw7/directdraw7/ddref_4ilz.asp

The interface call
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/ddraw7/directdraw7/ddref_4307.asp

The PixelFormat Type:

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/ddraw7/directdraw7/ddref_5n3r.asp

Author

Commented:
OK... I see that, but I need it laid out in layman's terms with code snippets. If you, or someone, would like to spend the time writing out the code for me with examples to UI (how it could be with a standard form, button and text or labels for the output) and the code for the background (API calls, regular code, etc.) I would be willing to sweeten the pot of points for ya!

All the help I can get would be awesome! I know VB to an extent, but have a little bit of a hard time with this sort of stuff!

Thanks a million!
Here's what I found on fourCC:

From: http://www.chipcenter.com/eexpert/gdorman/gdorman006.html
Type MMCKINFO
     ckid As FOURCC
     cksize As Long
     fccType As FOURCC
     dwDataOffset As Long
     dwFlags As Long
End Type

The type FOURCC, a four-character fixed-length string is defined as:
Type FOURCC
     chars as string * 4
end type


MCI commands begin with the letters, "mci." Some MCI functions are: mciGetDeviceID(), mciSendString() and mciGetErrorString(). If you go to the windows/system directory, you will find the file winmm.dll that contains all the multimedia commands, including the few listed above. Find the file, winmm.dll and right-click on it. Select Quick View from the menu and scroll down the files contents.

Here's what I found I could do with VB and the Windows Media Control.  It doesn't always seem to get the codecs ( I managed to get them sometimes), but I thought I'd show you what I have.  These codecs are related to fourcc codes, I just don't know how to get them.  I wish I could be of more use


Private Sub Command1_Click()
    Dim lCount As Long
    Dim lCodecCount As Long
    With MediaPlayer1
        .FileName = "c:\indeo5.avi"
        lCodecCount = .CodecCount
        For lCount = 1 To lCodecCount
           
            Debug.Print .GetCodecDescription(lCount)
           
        Next
    End With
End Sub


I got some sample AVI files from here to test with:

http://dshow.narod.ru/codec.htm

Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
twalgrave: Well, I tried that, but unfortunately it has issues working with the new WMP9. It doesn't want to give back a code and tells me it won't work... I'm beginning to believe that it is a WMP issue, so I'll want to stay away from that... I found something similar to that and tried it earlier, but to no avail...

Thanks for your help tho!

All I want to really do is to find the info contained in the FOURCC in any AVI file. All I need to do is to be able to extract that info out of the movie. Just to be able to tell me what codecs I need for audio and video. Hopefully someone has the answer...

Author

Commented:
Moderators... I have solved this problem myself and wish to close this posting. Could you please give twalgrave 20 points for assisting me and pushing me in the right direction...? Thanks for your help twalgrave.

I would like to have 180 points put back into my account please (was giving away 200 for the question.) Thanks a lot!
Points reduced,

Now you can accept the comment as an answer

Computer101
E_E Admin

Author

Commented:
Thanks for the help!
TheFaimousOne,

Thanks for the points.  Can you post the solution or at least a synopsis?

Author

Commented:
Sure...

Well, I knew I would have to figure out the header from the first few hundred lines of the text. Knowing that, and knowing that I didn't want to open the file the whole way (which was one the the problems I was running into...), I had to try to figure something out to get the file open part way. That is when I realized I could use a simple Open|Get|Seek function. Using that, I was able to open the file, seek to certain spots, get the information from there and place them into strings. And when all was said and done, I didn't have to open the whole file... Although that was still an issue at first, until I realized I needed to use the Close function before reading it all! (Doh!)

Anyhow, I knew the locations of each setting (Bitrate, Width, Height, FOURCC, etc.) and how to decode it once I had it. I just thought it would require an API call, and I was wrong about that! All the info is stored in the actual 'header' of the file! Which is to say, it is all stored near the beginning of the file!

Once all the info was stored into a array of strings, all I had to do was semi-parse it, match it to its actual name (Snippet: Case "DIV5"
               lblCodecFound.Caption = "DivX 5"
               iscodec = "divxc32"
               ifcodec = "divxc32.dll") and then display it for the people that needed to see it. It really wasn't that hard after all! I just wish I would have KNOWN that!

Hope the info helps somebody... Since I scoured the net looking for something on this and FOUND NOTHING!!!

And thanks again for your help!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial