private static int ShowWindow(string inputName, string videoFilename, string audioFilename, int frameOffset) { if (true) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var form = new MainForm(inputName, videoFilename, audioFilename, frameOffset); Application.Run(form); } else { var _filenames = FileDetect.FillFilenames(inputName, videoFilename, audioFilename); var _videoFile = new MediaFile(); _videoFile.Resolution = MediaFile.ResolutionOption.Full; _videoFile.OutputRGBImage = false; _videoFile.OutputYData = true; _videoFile.OutputYImage = false; _videoFile.Open(_filenames.videoFilename); int lastPrintSeconds = 0; int frameCount = 0; var stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); for (int fieldNumber = 0; fieldNumber < _videoFile.TotalFields; fieldNumber++) //for (int fieldNumber = 0; fieldNumber < 1000; fieldNumber++) { var frameField = _videoFile.GetVideoFrameField(fieldNumber, MediaFile.SeekModes.Accurate); //frameField.YData.GetBitmap().Save(@"D:\temp\image-" + frameField.FieldNumber.ToString("00000") + ".png", System.Drawing.Imaging.ImageFormat.Png); frameField.Dispose(); long elapsedMilliseconds = stopwatch.ElapsedMilliseconds; int elapsedSeconds = (int)(elapsedMilliseconds / 1000); if (elapsedSeconds != lastPrintSeconds) { lastPrintSeconds = elapsedSeconds; var fps = frameCount * 1000.0f / (float)stopwatch.ElapsedMilliseconds; Console.WriteLine("Frame: " + frameCount.ToString() + " FPS: " + fps.ToString("0.00")); } frameCount++; } //for (int fieldNumber = 500; fieldNumber < 504; fieldNumber++) //{ // var frameField = _videoFile.GetVideoFrameField(fieldNumber, MediaFile.SeekModes.Accurate); // //frameField.Image.Save(@"D:\temp\image-" + frameField.FieldNumber.ToString("00000") + ".png", System.Drawing.Imaging.ImageFormat.Png); // //frameField.YData.GetBitmap().Save(@"D:\temp\image-" + frameField.FieldNumber.ToString("00000") + ".png", System.Drawing.Imaging.ImageFormat.Png); // frameField.YData.GetFloatData().GetBitmap().Save(@"D:\temp\image-" + frameField.FieldNumber.ToString("00000") + ".png", System.Drawing.Imaging.ImageFormat.Png); // var yData = frameField.YData; // var floatData = frameField.YData.GetFloatData(); // stopwatch.Restart(); // for (int test = 0; test < 1000; test++) // { // //var image = floatData.GetBitmap(); // var image = yData.GetBitmap(); // image = null; // //GC.Collect(); // } // Console.WriteLine("Elapsed: " + stopwatch.Elapsed.ToString()); // frameField.Dispose(); //} } return(0); }