Skip to content

Commit

Permalink
Merge pull request #10 from ThatNerdUKnow/selectable-model
Browse files Browse the repository at this point in the history
Selectable model
  • Loading branch information
ThatNerdUKnow authored May 1, 2022
2 parents 2748034 + 07983ab commit 0373c85
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 37 deletions.
27 changes: 25 additions & 2 deletions vmaf-gui/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

105 changes: 70 additions & 35 deletions vmaf-gui/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
}

Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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; }));


}

}

Expand All @@ -172,6 +200,7 @@ private void button1_Click(object sender, EventArgs e)
}
catch (Exception err)
{

MessageBox.Show(err.Message);
}
}
Expand Down Expand Up @@ -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)
{
Expand All @@ -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();
}



Expand Down

0 comments on commit 0373c85

Please sign in to comment.