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()
{
if (Denominator < 1) // Avoid div by zero
return 0f;
return (float)Numerator / (float)Denominator;
}

View File

@@ -280,22 +280,34 @@ namespace Flowframes
private void fpsInTbox_TextChanged(object sender, EventArgs e)
{
fpsInTbox.Text = fpsInTbox.Text.TrimNumbers(true);
UpdateOutputFPS();
UpdateUiFps();
}
public void UpdateOutputFPS()
public void UpdateUiFps()
{
float fpsOut = fpsInTbox.GetFloat() * interpFactorCombox.GetFloat();
fpsOutTbox.Text = fpsOut.ToString();
if (fpsInTbox.Text.Contains("/")) // Parse fraction
{
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)
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)
{
UpdateOutputFPS();
UpdateUiFps();
int guiInterpFactor = interpFactorCombox.GetInt();
if (!initialized)
return;

View File

@@ -218,6 +218,12 @@ namespace Flowframes.Main
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"))
return;

View File

@@ -323,7 +323,7 @@ namespace Flowframes.Main
}
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;
}
if (!passes)