diff --git a/vmaf-gui/Form1.Designer.cs b/vmaf-gui/Form1.Designer.cs index 0ea1898..25aee74 100644 --- a/vmaf-gui/Form1.Designer.cs +++ b/vmaf-gui/Form1.Designer.cs @@ -40,6 +40,8 @@ private void InitializeComponent() this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); this.prgProgress = new System.Windows.Forms.ProgressBar(); this.lblProgress = new System.Windows.Forms.Label(); + this.cmbModel = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.vmafLogo)).BeginInit(); this.grpFiles.SuspendLayout(); this.SuspendLayout(); @@ -117,7 +119,7 @@ private void InitializeComponent() // // button1 // - this.button1.Location = new System.Drawing.Point(12, 267); + this.button1.Location = new System.Drawing.Point(12, 301); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(272, 23); this.button1.TabIndex = 6; @@ -127,7 +129,7 @@ private void InitializeComponent() // // prgProgress // - this.prgProgress.Location = new System.Drawing.Point(12, 297); + this.prgProgress.Location = new System.Drawing.Point(12, 331); this.prgProgress.Maximum = 4; this.prgProgress.Name = "prgProgress"; this.prgProgress.Size = new System.Drawing.Size(272, 23); @@ -142,12 +144,31 @@ private void InitializeComponent() this.lblProgress.Size = new System.Drawing.Size(0, 13); this.lblProgress.TabIndex = 12; // + // cmbModel + // + this.cmbModel.FormattingEnabled = true; + this.cmbModel.Location = new System.Drawing.Point(95, 267); + this.cmbModel.Name = "cmbModel"; + this.cmbModel.Size = new System.Drawing.Size(189, 21); + this.cmbModel.TabIndex = 13; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(9, 270); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(71, 13); + this.label1.TabIndex = 14; + this.label1.Text = "VMAF Model:"; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; this.ClientSize = new System.Drawing.Size(305, 420); + this.Controls.Add(this.label1); + this.Controls.Add(this.cmbModel); this.Controls.Add(this.lblProgress); this.Controls.Add(this.prgProgress); this.Controls.Add(this.button1); @@ -180,6 +201,8 @@ private void InitializeComponent() private System.ComponentModel.BackgroundWorker backgroundWorker1; private System.Windows.Forms.ProgressBar prgProgress; private System.Windows.Forms.Label lblProgress; + private System.Windows.Forms.ComboBox cmbModel; + private System.Windows.Forms.Label label1; } } diff --git a/vmaf-gui/Form1.cs b/vmaf-gui/Form1.cs index 67469db..8ca4412 100644 --- a/vmaf-gui/Form1.cs +++ b/vmaf-gui/Form1.cs @@ -27,6 +27,8 @@ string ChildProcess(string program_name, string args, bool show) p.StartInfo.FileName = program_name; p.StartInfo.Arguments = args; + p.StartInfo.RedirectStandardError = true; + p.Start(); @@ -39,6 +41,16 @@ string ChildProcess(string program_name, string args, bool show) Console.WriteLine(args); p.WaitForExit(); + + int exitCode = p.ExitCode; + + if(exitCode != 0) + { + throw new Exception(p.StandardError.ReadToEnd()); + } + + + return output; } @@ -76,12 +88,13 @@ private void Form1_Load(object sender, EventArgs e) string safeName = model.Substring(8, model.Length - 8); if (!safeName.Contains(".model") && safeName.Contains(".json")) { - // cmbModel.Items.Add(safeName); + Console.WriteLine(safeName); + cmbModel.Items.Add(safeName); } } try { - //cmbModel.SelectedIndex = 0; + cmbModel.SelectedIndex = 0; } catch { @@ -124,43 +137,58 @@ private void button1_Click(object sender, EventArgs e) bool psnr = chkPSNR.Checked; bool ssim = chkSSIM.Checked;*/ string resolution = ""; - string model = ""; + string model = cmbModel.Text; bool psnr = false; bool ssim = false; + + // Define what functions the thread does ThreadStart tStart = new ThreadStart( () => { + try + { + // Decompress source video file + lblProgress.Invoke(new Action(delegate () { lblProgress.Text = "Decompressing Source..."; })); + decompressVideo(sourcePath, "./temp/source.y4m"); + prgProgress.Invoke(new Action(delegate () { prgProgress.PerformStep(); })); + + // Decompress compressed video file + lblProgress.Invoke(new Action(delegate () { lblProgress.Text = "Decompressing Compressed..."; })); + decompressVideo(compressedPath, "./temp/compressed.y4m"); + prgProgress.Invoke(new Action(delegate () { prgProgress.PerformStep(); })); + + + // Start vmaf + vmaf(resolution, model, psnr, ssim); + prgProgress.Invoke(new Action(delegate () { prgProgress.PerformStep(); })); - // Decompress source video file - lblProgress.Invoke(new Action(delegate () { lblProgress.Text = "Decompressing Source..."; })); - decompressVideo(sourcePath, "./temp/source.y4m"); - prgProgress.Invoke(new Action(delegate () { prgProgress.PerformStep(); })); - - // Decompress compressed video file - lblProgress.Invoke(new Action(delegate () { lblProgress.Text = "Decompressing Compressed..."; })); - decompressVideo(compressedPath, "./temp/compressed.y4m"); - prgProgress.Invoke(new Action(delegate () { prgProgress.PerformStep(); })); - - // Start vmaf - vmaf(resolution, model, psnr, ssim); - prgProgress.Invoke(new Action(delegate () { prgProgress.PerformStep(); })); - - // Done - prgProgress.Invoke(new Action(delegate () { prgProgress.PerformStep(); })); - lblProgress.Invoke(new Action(delegate () { lblProgress.Text = "Done."; })); - - // Clean up form controls and delete .yuv files to save disk space - lblProgress.Invoke(new Action(delegate () { lblProgress.Text = ""; })); - File.Delete("./temp/compressed.yuv"); - File.Delete("./temp/source.yuv"); - button1.Invoke(new Action(delegate () { button1.Enabled = true; })); - - // Show Results - results resultsForm = new results(); - resultsForm.showResults("./log.xml"); - resultsForm.ShowDialog(); + + // Done + prgProgress.Invoke(new Action(delegate () { prgProgress.PerformStep(); })); + lblProgress.Invoke(new Action(delegate () { lblProgress.Text = "Done."; })); + + // Clean up form controls and delete .yuv files to save disk space + lblProgress.Invoke(new Action(delegate () { lblProgress.Text = ""; })); + File.Delete("./temp/compressed.yuv"); + File.Delete("./temp/source.yuv"); + button1.Invoke(new Action(delegate () { button1.Enabled = true; })); + + // Show Results + results resultsForm = new results(); + resultsForm.showResults("./log.xml"); + resultsForm.ShowDialog(); + }catch + { + prgProgress.Invoke(new Action(delegate () { + prgProgress.Value = 0; + })); + lblProgress.Invoke(new Action(delegate () { lblProgress.Text = "There was a problem running VMAF"; })); + button1.Invoke(new Action(delegate () { button1.Enabled = true; })); + + + } } @@ -172,6 +200,7 @@ private void button1_Click(object sender, EventArgs e) } catch (Exception err) { + MessageBox.Show(err.Message); } } @@ -200,7 +229,9 @@ void vmaf(string resolution, string model, bool psnr, bool ssim) //string args = "yuv420p "+ resolution +" ./temp/source.yuv ./temp/compressed.yuv .\\model\\"+ model +" --log log.xml"; Array res = resolution.Split(' '); - string args = $"--threads 4 --reference ./temp/source.y4m --distorted ./temp/compressed.y4m -o log.xml"; + string args = $"--threads 4 --reference ./temp/source.y4m --distorted ./temp/compressed.y4m -o log.xml "; + + args += "--model path=./model/" + model; /* if (chkPSNR.Checked) { @@ -212,9 +243,13 @@ void vmaf(string resolution, string model, bool psnr, bool ssim) }*/ lblProgress.Invoke(new Action(delegate () { lblProgress.Text = "Performing VMAF..."; })); - - ChildProcess("vmaf.exe", args, false); - + try{ + ChildProcess("vmaf.exe", args, false); + }catch(Exception err) + { + MessageBox.Show(err.Message,"There was a problem with VMAF"); + throw new Exception(); + }