public static void MakeFileFromStream(String fileName, AviStream stream) { IntPtr newFile = IntPtr.Zero; IntPtr streamPointer = stream.StreamPointer; Avi.AVICOMPRESSOPTIONS_CLASS opts = new Avi.AVICOMPRESSOPTIONS_CLASS(); opts.fccType = (uint)Avi.streamtypeVIDEO; opts.lpParms = IntPtr.Zero; opts.lpFormat = IntPtr.Zero; Avi.AVISaveOptions(IntPtr.Zero, Avi.ICMF_CHOOSE_KEYFRAME | Avi.ICMF_CHOOSE_DATARATE, 1, ref streamPointer, ref opts); Avi.AVISaveOptionsFree(1, ref opts); Avi.AVISaveV(fileName, 0, 0, 1, ref streamPointer, ref opts); }