Upcoming Events
Southwest Gaming Expo
11/20 - 11/22 @ Dallas, TX

Workshop on Network and Systems Support for Games (NetGames 2009)
11/23 - 11/25 @ Paris, France

ICIDS 2009 Interactive Storytelling
12/9 - 12/11 @ Guimarăes, Portugal

Global Game Jam
1/29 - 1/31  

More events...


Quick Stats
6404 people currently visiting GDNet.
2341 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!



Link to us

Link to us

  Intel sponsors gamedev.net search:   

Contents
 Introduction
 Files
 Streams
 Processing
 Cleaning Up

 Printable version
 Discuss this article
 in the forums


Comment on this Document

Abstract

You have several options when working with AVI files.

* Parse the file yourself.
* Parse the file with MMIO routines.
* Piece together a DirectShow filter.
* Use the Win32 AVIFile API.
* Use MCI to draw it to a window.

There are benefits and drawbacks to each of them, but only Microsoft’s AVIFile api makes it easy enough for the novice, but advanced enough for most purposes. This document deals with the loading and interpreting of AVI files using the AVIFile interface. If you are already comfortable with DirectShow, then I recommend that method instead. As an alternative, AVIFile will allow you to process the many different kinds of AVI files, handle decompression, and read the video frames easily. The API is also for reading any Resource Interchange File Format (RIFF), so learning the API will enable you to process other types of RIFF files like WAV, and even help you to create your own custom format that extends AVI’s capabilities while remaining compatible with other software.

This document will show you how to extract video and sound information from an AVI file. You’ll see how to synchronize game elements over the top of the AVI video, and the sample code shows how the AVI can be blitted with transparency so it’s superimposed over a game’s action. You will receive royalty-free wrapper classes for avi files, bitmap files, and direct draw to get you started.

Introduction

When learning to process a file, I usually learn its file format and create a wrapper class to make it easier for the rest of my code. One thing noticed as files get more advanced, are that they’re utilizing a chunk based format. WAV is probably the easiest of the chunk based, and PCM waves can be parsed with little difficulty. The reason why I recommend using an API for AVI files, though, is because they come in so many forms that you must either learn them all or limit your capability in some way. They’re also usually compressed with one of several different formats.

This document is designed to lead you through the entire process from beginning to end. I only talk about the stuff that’s pertinent to opening and getting frames and audio from the file. I don’t go into how the sound can be played back or the images rendered, because there are many different ways depending on what you want to do. The sample code, written using MSVC++ 6.0, displays the frame sequence using DirectX 7.0 in full screen exclusive mode. If there’s popular demand I will submit other articles to describe in more detail how the video is rendered and sound played back.





Next : Files