Higher aac/opus bitrates - can be changed in config

This commit is contained in:
N00MKRAD
2020-12-24 12:31:16 +01:00
parent e8d338dbc9
commit 3bf8ca9cea
4 changed files with 24 additions and 10 deletions

View File

@@ -207,7 +207,7 @@ namespace Flowframes
Logger.Log($"[FFCmds] Extracting audio from {inputFile} to {outFile}", true);
//string ext = GetAudioExt(inputFile);
outFile = Path.ChangeExtension(outFile, ".ogg");
string args = $" -loglevel panic -i {inputFile.Wrap()} -vn -acodec libopus -b:a 320k {outFile.Wrap()}";
string args = $" -loglevel panic -i {inputFile.Wrap()} -vn -acodec libopus -b:a 256k {outFile.Wrap()}";
await AvProcess.RunFfmpeg(args, AvProcess.LogMode.Hidden);
if (AvProcess.lastOutputFfmpeg.ToLower().Contains("error") && File.Exists(outFile)) // If broken file was written
File.Delete(outFile);
@@ -235,7 +235,7 @@ namespace Flowframes
// tempPath = Path.ChangeExtension(tempPath, "mkv");
// }
string aCodec = Utils.GetAudioEnc(Utils.GetCodec(Interpolate.current.outMode));
int aKbits = Utils.GetAudioBitrate(aCodec);
int aKbits = Utils.GetAudioKbits(aCodec);
string args = $" -i {inputFile.Wrap()} -stream_loop {looptimes} -i {audioPath.Wrap()} -shortest -c:v copy -c:a {aCodec} -b:a {aKbits}k {tempPath.Wrap()}";
await AvProcess.RunFfmpeg(args, AvProcess.LogMode.Hidden);
if (AvProcess.lastOutputFfmpeg.Contains("Invalid data"))

View File

@@ -83,14 +83,14 @@ namespace Flowframes.AudioVideo
return "aac";
}
public static int GetAudioBitrate (string codec)
public static int GetAudioKbits (string codec)
{
if (codec.Trim().ToLower() == "aac")
return 128;
return Config.GetInt("aacBitrate", 160);
if (codec.Trim().ToLower().Contains("opus"))
return 112;
return Config.GetInt("opusBitrate", 128);
return 160;
return 192;
}
public static string GetExt(Interpolate.OutMode outMode, bool dot = true)

View File

@@ -1046,9 +1046,9 @@
this.label58.Location = new System.Drawing.Point(420, 301);
this.label58.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
this.label58.Name = "label58";
this.label58.Size = new System.Drawing.Size(82, 13);
this.label58.Size = new System.Drawing.Size(255, 13);
this.label58.TabIndex = 65;
this.label58.Text = "Lower is better. ";
this.label58.Text = "Lower is better. Use slightly higher values than h265!";
//
// vp9Crf
//
@@ -1272,9 +1272,9 @@
this.label16.Location = new System.Drawing.Point(420, 271);
this.label16.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(82, 13);
this.label16.Size = new System.Drawing.Size(224, 13);
this.label16.TabIndex = 39;
this.label16.Text = "Lower is better. ";
this.label16.Text = "Lower is better. Use higher values than h264! ";
//
// label14
//

View File

@@ -74,6 +74,12 @@ namespace Flowframes.IO
return Get(key, Type.Int).GetInt();
}
public static int GetInt(string key, int defaultVal)
{
WriteIfDoesntExist(key, defaultVal.ToString());
return GetInt(key);
}
public static float GetFloat(string key)
{
return float.Parse(Get(key, Type.Float), CultureInfo.InvariantCulture);
@@ -84,6 +90,14 @@ namespace Flowframes.IO
return Get(key, Type.Float).Replace(",", ".");
}
static void WriteIfDoesntExist (string key, string val)
{
foreach (string line in cachedLines)
if (line.Contains(key + "|"))
return;
Set(key, val);
}
public enum Type { String, Int, Float, Bool }
private static string WriteDefaultValIfExists(string key, Type type)
{