【IT168技术文档】
Windows AVI 库是avifil32.dll中函数的集合. 使用之前先得用 AVIFileInit初始化. AVIFileOpen 打开文件, AVIFileGetStream 取得视频流. 这些函数申请的内存最后都必须释放. AVI文件可以包含四种不同类型的多个流,通常每种类型只有一个流,我们这里只关心视频流.
//Initialize the AVI library [DllImport("avifil32.dll")] public static extern void AVIFileInit(); //Open an AVI file [DllImport("avifil32.dll", PreserveSig=true)] public static extern int AVIFileOpen( ref int ppfile, String szFile, int uMode, int pclsidHandler); //Get a stream from an open AVI file [DllImport("avifil32.dll")] public static extern int AVIFileGetStream( int pfile, out IntPtr ppavi, int fccType, int lParam); //Release an open AVI stream [DllImport("avifil32.dll")] public static extern int AVIStreamRelease(IntPtr aviStream); //Release an ope AVI file [DllImport("avifil32.dll")] public static extern int AVIFileRelease(int pfile); //Close the AVI library [DllImport("avifil32.dll")] public static extern void AVIFileExit(); private int aviFile = 0; private IntPtr aviStream; public void Open(string fileName) { AVIFileInit(); //Intitialize AVI library //Open the file int result = AVIFileOpen( ref aviFile, fileName, OF_SHARE_DENY_WRITE, 0); //Get the video stream result = AVIFileGetStream( aviFile, out aviStream, streamtypeVIDEO, 0); }