Slashdot Mirror


Writing Video Codecs for Win32?

Gldm asks: "I've been working on a video codec as part of a college computer science project, but I've been stuck at an impasse for several months now: I can't figure out how to get video data from the OS to compress or test anything with. All the software applications I have (Premiere, Virtualdub, and AVIcap) want to use Microsoft's Video For Windows API, but I can't find any books on how to get a codec to interface with it. I've tried Microsoft's own docs, but they're not very helpful. The only example source I've found is huffyuv but it's written and commented so poorly, I can't understand it. I've tried emailing the author but he never replied. I thought it would be simple to do this but apparently VFW is some kind of ancient byzantine labyrinth of messages and function calls and data types I don't understand. If anyone knows a book on the VFW API that still exists and maybe something that very clearly explains exactly how you go about building a DLL please let me know. Or if you have experience programming for this API please please email me."

"I've tried asking my CS department for help, but they barely acknowledge the existence of GUIs and usually have us do everything in SunOS on their ancient 50mhz machines using gcc, which is not practical for this project. Nobody in the department knows any Windows programming and I've been unable to teach myself how to do it. I'm really frustrated because all I need is some kind of pointer to the pixels in a frame, its size and color format, and a pointer of where to put the compressed output."

2 of 31 comments (clear)

  1. Try DirectShow by Cecil · · Score: 3, Informative

    It's (kindof) a part of Microsoft's DirectX, and is definitely the next generation of Video Codecs. Please, don't proliferate the horrible VFW API any further. Do yourself and everyone else a favour and move to DirectShow.

    Microsoft's page is here, and you might also find some useful stuff at this website.

  2. Do a static file transform first. by crapulent · · Score: 3, Informative
    It appears that you have little experience working with Windows. If this is the case, then I suggest you start out with a simple file transform application. Read an encoded AVI, write the decoded AVI out in a RAW format. This will give you the ability to view the output of your codec in a media player without having to delve too much into COM objects and all the other Windows programming stuff.

    If you really want to write a codec, you don't necessarily have to use the VFW calls. The audio and video codec management under VFW is old stuff, from the 16 bit Win 3.1 days. It's supported through wrappers in DirectX/DirectShow. What you might want to do instead is create a DirectShow filter, specifically a Transform Filter. If you are not familiar with the DirectShow architecture, you will want to read up on this first. Once you are familiar with the terminology (graphs, filters, pins, etc.) then write a transform filter. You can derive it from a base class supplied in the SDK and this will take care of making a DLL that knows how to register itself, etc. The section Writing Transform Filters has all the details in a step-by-step list, including build directions. This page is found through the path MSDN Home > MSDN Library > DirectX > DirectShow > Using DirectShow > Writing DirectShow Filters. From the linked page:

    This section describes how to write a transform filter, defined as a filter that has exactly one input pin and one output pin. To illustrate the steps, this section describes a hypothetical transform filter that outputs run-length encoded (RLE) video. It does not describe the RLE-encoding algorithm itself, only the tasks that are specific to DirectShow.