private static int ProcessStatisticsFromFile(string inputName, string videoFilename, string audioFilename, int frameOffset) { string logFile = Path.GetDirectoryName(inputName) + "\\" + Path.GetFileNameWithoutExtension(inputName) + "_scoring.log"; using (var output = new StreamWriter(logFile, false)) { } var filenames = FileDetect.FillFilenames(inputName, videoFilename, audioFilename); Statistics.IStatisticsProcessor processor; processor = new Statistics.StatisticsProcessor(filenames, frameOffset); processor.Log += (message) => { Console.WriteLine(message); using (var output = new StreamWriter(logFile, true)) { output.WriteLine(message); } }; int ret; ret = processor.Process(); if (ret < 0) { return(ret); } ret = processor.WriteCuttermaranFile(); return(ret); }
private void Open(string filename, bool loadFiles = true) { _filenames = FileDetect.FillFilenames(filename); if (loadFiles) { RunOnBackgroundThread("Loading files", LoadFiles); } }
public MainForm(string inputName, string videoFilename, string audioFilename, int frameOffset) { _filenames = FileDetect.FillFilenames(inputName, videoFilename, audioFilename); _frameOffset = frameOffset; this.MouseWheel += new MouseEventHandler(MainForm_MouseWheel); InitializeComponent(); tabControl.Dock = DockStyle.Fill; panelGraphs.Dock = DockStyle.Fill; objectListViewBlocks.RowFormatter = delegate(BrightIdeasSoftware.OLVListItem item) { var block = item.RowObject as Block; if (block == null) { return; } item.UseItemStyleForSubItems = true; var isCommercial = (block.IsCommercialOverride.HasValue ? block.IsCommercialOverride.Value : block.IsCommercial); if (block.IsCommercialOverride.HasValue) { item.BackColor = Color.FromArgb(0xFF, 0xFE, 0xD6); } if (block.IsCommercial) { item.ForeColor = Color.Maroon; } else { item.ForeColor = Color.Navy; } //if (merged) // item.ForeColor = Color.LightGray; //else if (checkBoxShowExcluded.Checked && !entry.Export) // item.ForeColor = Color.LightGray; //else if (entry.SqlScriptEntry.ObjectType == SqlScriptEntry.ObjectTypes.Unknown) // item.ForeColor = Color.White; //else if (entry.SqlScriptEntry.CommandType == SqlScriptEntry.CommandTypes.Drop) // item.ForeColor = Color.Maroon; //else if (entry.SqlScriptEntry.CommandType == SqlScriptEntry.CommandTypes.Delete) // item.ForeColor = Color.Maroon; //else if (entry.SqlScriptEntry.CommandType == SqlScriptEntry.CommandTypes.Create) // item.ForeColor = Color.Navy; //else if (entry.SqlScriptEntry.CommandType == SqlScriptEntry.CommandTypes.Alter) // item.ForeColor = Color.Indigo; //else if (entry.SqlScriptEntry.CommandType == SqlScriptEntry.CommandTypes.Recreate) // item.ForeColor = Color.MidnightBlue; //else if (entry.SqlScriptEntry.CommandType == SqlScriptEntry.CommandTypes.Insert) // item.ForeColor = Color.Purple; //else if (entry.SqlScriptEntry.CommandType == SqlScriptEntry.CommandTypes.Update) // item.ForeColor = Color.SeaGreen; }; //button3.Visible = true; }
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); }
private static int ProcessTxtFile(string inputName, string videoFilename, string audioFilename, int frameOffset) { var filenames = FileDetect.FillFilenames(inputName, videoFilename, audioFilename); videoFilename = filenames.videoFilename; audioFilename = filenames.audioFilename; string filename = Path.GetFileNameWithoutExtension(inputName); string outputName = Path.GetDirectoryName(inputName) + "\\" + filename + ".cpf"; using (var input = new StreamReader(inputName)) { string line; line = input.ReadLine(); if (line == null) { Console.WriteLine("Unexpected EOF: missing line 1"); return(-2); } string[] parts = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); int totalFrames; if (!int.TryParse(parts[3], out totalFrames)) { Console.WriteLine("The 4th word of the line is not the total number of frames"); Console.WriteLine("line: " + line); return(-3); } line = input.ReadLine(); if (line == null) { Console.WriteLine("Unexpected EOF: missing line 2"); return(-4); } using (var output = new CuttermaranFileWriter(outputName, videoFilename, audioFilename, totalFrames)) { int lastAdEnd = -1; while ((line = input.ReadLine()) != null) { parts = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length != 2) { Console.WriteLine("Unexpected line format: " + line); return(-5); } int adStart; if (!int.TryParse(parts[0], out adStart)) { Console.WriteLine("Failed to parse integer: " + parts[0]); Console.WriteLine("line: " + line); return(-6); } adStart += frameOffset; int showStart = lastAdEnd + 1; int showEnd = adStart - 1; output.WriteCut(showStart, showEnd); if (!int.TryParse(parts[1], out lastAdEnd)) { Console.WriteLine("Failed to parse integer: " + parts[0]); Console.WriteLine("line: " + line); return(-7); } if (lastAdEnd < totalFrames) { lastAdEnd += frameOffset; } } if (lastAdEnd == -1) { Console.WriteLine("Unexpected EOF: missing commercial blocks"); return(-10); } output.WriteCut(lastAdEnd + 1, totalFrames); } } return(0); }