private void SaveAviHelper(AviType aviType, ref List <ManagedImage> imageList, string aviFileName, float frameRate) { // Set maximum AVI file size to 2GB. A new AVI file is generated when 2GB // limit is reached. Setting maximum file size to 0 indicates no limit. const uint AviMaxSize = 2048; using (ManagedAVIRecorder aviRecorder = new ManagedAVIRecorder()) { aviRecorder.SetMaximumAVISize(AviMaxSize); switch (aviType) { case AviType.Uncompressed: { AviOption option = new AviOption(); option.frameRate = frameRate; aviRecorder.AVIOpen(aviFileName, option); } break; case AviType.Mjpg: { MJPGOption option = new MJPGOption(); option.frameRate = frameRate; option.quality = 75; aviRecorder.AVIOpen(aviFileName, option); } break; case AviType.H264: { H264Option option = new H264Option(); option.frameRate = frameRate; option.bitrate = 1000000; option.height = Convert.ToInt32(imageList[0].rows); option.width = Convert.ToInt32(imageList[0].cols); aviRecorder.AVIOpen(aviFileName, option); } break; } Console.WriteLine("Appending {0} images to AVI file {1}...", imageList.Count, aviFileName); for (int imageCnt = 0; imageCnt < imageList.Count; imageCnt++) { // Append the image to AVI file aviRecorder.AVIAppend(imageList[imageCnt]); Console.WriteLine("Appended image {0}", imageCnt); } aviRecorder.AVIClose(); } }
private void SaveAviHelper(AviType aviType, ref List <ManagedImage> imageList, string aviFileName, float frameRate) { using (ManagedAVIRecorder aviRecorder = new ManagedAVIRecorder()) { switch (aviType) { case AviType.Uncompressed: { AviOption option = new AviOption(); option.frameRate = frameRate; aviRecorder.AVIOpen(aviFileName, option); } break; case AviType.Mjpg: { MJPGOption option = new MJPGOption(); option.frameRate = frameRate; option.quality = 75; aviRecorder.AVIOpen(aviFileName, option); } break; case AviType.H264: { H264Option option = new H264Option(); option.frameRate = frameRate; option.bitrate = 1000000; option.height = Convert.ToInt32(imageList[0].rows); option.width = Convert.ToInt32(imageList[0].cols); aviRecorder.AVIOpen(aviFileName, option); } break; } Console.WriteLine("Appending {0} images to AVI file {1}...", imageList.Count, aviFileName); for (int imageCnt = 0; imageCnt < imageList.Count; imageCnt++) { // Append the image to AVI file aviRecorder.AVIAppend(imageList[imageCnt]); Console.WriteLine("Appended image {0}", imageCnt); } aviRecorder.AVIClose(); } }