Creating a File from Existing Streams

One way to create a file that contains data streams is to combine existing streams into a new file. The streams that provide data for the new file can reside in memory or in one or more files.

You can build a file from several streams by using the AVISave function. This function creates a file and writes the data streams specified in its calling sequence to the file. The calling sequence for AVISave uses a variable number of arguments that include interfaces for the streams combined in the new file.

You can also combine data streams in a new file by using the AVISaveV function. This function provides the same functionality as AVISave, but when you use AVISaveV, your application specifies the data streams as an array, not as a variable number of arguments.

You can create a dialog box in which the user can select compression settings for the new file by using the AVISaveOptions function. The dialog box displays the current compression settings and lets the user edit them. Compression setting changes are stored in an AVICOMPRESSOPTIONS structure.

You can also include a callback function with AVISave and AVISaveV that your application can use to display the progress of writing the file and, if needed, let the user cancel the save operation. You can include the address of the callback function in the calling sequence of AVISave or AVISaveV.

You can let the user select a filename for the new file by using the GetSaveFileNamePreview function. This function displays the Save As dialog box in which the user can preview the first stream (normally the video stream) of an AVI file.

You can create a file interface pointer (and a virtual file) for a group of streams by using the AVIMakeFileFromStreams function. Other AVIFile functions can use the file interface pointer returned by this function to access the streams in the virtual file. After you finish using the virtual file, delete the file interface pointer by using the AVIFileRelease function.

Note  To minimize image and audio degradation, avoid compressing an AVI file more than once. Combine uncompressed pieces of video in your editing system and then compress the final product. For information about compression options, see Video Compression Manager.