Search code examples
audio-streamingpcmavi

Writing G.711 Stream to AVI File


I've inherited an application that opens a proprietary file which has a video stream and an audio stream (G.711 ULAW format). The application already writes the video to an AVI but without the audio. I want to add code that inserts the audio stream in the same format to the AVI file.

Are there any code samples/documentation that show how to write a G.711 stream into AVI?


Solution

  • This is an update on the solution:

    Basically I was doing the right thing and passing the correct codec code (WAVE_FORMAT_MULAW) as Richard suggested.

    However, each API call: AVIFileCreateStream and AVIStreamSetFormat accepts a different structure. But not all the fields are relevant for the call, so the rest of the structure has to be filled with zeros before setting each field.

    For example:

    AVISTREAMINFO aviHeader;
    ZeroMemory(&aviHeader, sizeof(aviHeader));
    aviHeader.fccType = streamtypeAUDIO;
    

    ...

    Thanks!