Allow fractional manual fps input, better err handling if encoding fails

This commit is contained in:
N00MKRAD
2021-04-05 11:58:07 +02:00
parent f51c10bef0
commit 9287ec6b77
4 changed files with 30 additions and 9 deletions

View File

@@ -219,6 +219,9 @@ namespace Flowframes.Data
public float GetFloat() public float GetFloat()
{ {
if (Denominator < 1) // Avoid div by zero
return 0f;
return (float)Numerator / (float)Denominator; return (float)Numerator / (float)Denominator;
} }

View File

@@ -280,22 +280,34 @@ namespace Flowframes
private void fpsInTbox_TextChanged(object sender, EventArgs e) private void fpsInTbox_TextChanged(object sender, EventArgs e)
{ {
fpsInTbox.Text = fpsInTbox.Text.TrimNumbers(true); UpdateUiFps();
UpdateOutputFPS();
} }
public void UpdateOutputFPS() public void UpdateUiFps()
{ {
float fpsOut = fpsInTbox.GetFloat() * interpFactorCombox.GetFloat(); if (fpsInTbox.Text.Contains("/")) // Parse fraction
fpsOutTbox.Text = fpsOut.ToString(); {
string[] split = fpsInTbox.Text.Split('/');
Fraction frac = new Fraction(split[0].GetInt(), split[1].GetInt());
fpsInTbox.Text = frac.ToString();
fpsOutTbox.Text = (frac * interpFactorCombox.GetFloat()).ToString();
if (!fpsInTbox.ReadOnly) if (!fpsInTbox.ReadOnly)
currInFps = new Fraction(fpsInTbox.GetFloat()); currInFps = frac;
}
else // Parse float
{
fpsInTbox.Text = fpsInTbox.Text.TrimNumbers(true);
fpsOutTbox.Text = (fpsInTbox.GetFloat() * interpFactorCombox.GetFloat()).ToString();
if (!fpsInTbox.ReadOnly)
currInFps = new Fraction(fpsInTbox.GetFloat());
}
} }
private void interpFactorCombox_SelectedIndexChanged(object sender, EventArgs e) private void interpFactorCombox_SelectedIndexChanged(object sender, EventArgs e)
{ {
UpdateOutputFPS(); UpdateUiFps();
int guiInterpFactor = interpFactorCombox.GetInt(); int guiInterpFactor = interpFactorCombox.GetInt();
if (!initialized) if (!initialized)
return; return;

View File

@@ -218,6 +218,12 @@ namespace Flowframes.Main
public static async Task MuxOutputVideo(string inputPath, string outVideo) public static async Task MuxOutputVideo(string inputPath, string outVideo)
{ {
if (!File.Exists(outVideo))
{
I.Cancel($"No video was encoded!\n\nFFmpeg Output:\n{AvProcess.lastOutputFfmpeg}");
return;
}
if (!Config.GetBool("keepAudio") && !Config.GetBool("keepAudio")) if (!Config.GetBool("keepAudio") && !Config.GetBool("keepAudio"))
return; return;

View File

@@ -323,7 +323,7 @@ namespace Flowframes.Main
} }
if (passes && fpsOut.GetFloat() < 1f || fpsOut.GetFloat() > 1000f) if (passes && fpsOut.GetFloat() < 1f || fpsOut.GetFloat() > 1000f)
{ {
ShowMessage("Invalid output frame rate - Must be 1-1000."); ShowMessage($"Invalid output frame rate ({fpsOut.GetFloat()}).\nMust be 1-1000.");
passes = false; passes = false;
} }
if (!passes) if (!passes)