mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-22 19:29:24 +01:00
Completely revamped output settings (quality settings WIP)
This commit is contained in:
20
Code/Data/EncoderInfo.cs
Normal file
20
Code/Data/EncoderInfo.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Flowframes.Data
|
||||
{
|
||||
public class EncoderInfo
|
||||
{
|
||||
public string Name { get; set; } = "unknown";
|
||||
|
||||
public EncoderInfo() { }
|
||||
|
||||
public EncoderInfo(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Code/Data/EncoderInfoVideo.cs
Normal file
22
Code/Data/EncoderInfoVideo.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static Flowframes.Data.Enums.Encoding;
|
||||
|
||||
namespace Flowframes.Data
|
||||
{
|
||||
public class EncoderInfoVideo : EncoderInfo
|
||||
{
|
||||
public Codec Codec { get; set; } = (Codec)(-1);
|
||||
public bool Lossless { get; set; } = false;
|
||||
public bool HwAccelerated { get; set; } = false;
|
||||
public int Modulo { get; set; } = 2;
|
||||
public int MaxFramerate { get; set; } = 1000;
|
||||
public List<PixelFormat> PixelFormats { get; set; } = new List<PixelFormat>();
|
||||
public PixelFormat PixelFormatDefault { get; set; }
|
||||
public bool IsImageSequence { get; set; } = false;
|
||||
public string OverideExtension { get; set; } = "";
|
||||
}
|
||||
}
|
||||
20
Code/Data/Enums.cs
Normal file
20
Code/Data/Enums.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace Flowframes.Data
|
||||
{
|
||||
public class Enums
|
||||
{
|
||||
public class Output
|
||||
{
|
||||
public enum Format { Mp4, Mkv, Webm, Mov, Avi, Gif, Images, Realtime };
|
||||
public enum ImageFormat { Png, Jpeg, Webp };
|
||||
public enum Dithering { None, Bayer, FloydSteinberg };
|
||||
}
|
||||
|
||||
public class Encoding
|
||||
{
|
||||
public enum Codec { H264, H265, AV1, VP9, ProRes, Gif, Png, Jpeg, Webp, Ffv1, Huffyuv, Magicyuv, Rawvideo }
|
||||
public enum Encoder { X264, X265, SvtAv1, VpxVp9, Nvenc264, Nvenc265, NvencAv1, ProResKs, Gif, Png, Jpeg, Webp, Ffv1, Huffyuv, Magicyuv, Rawvideo }
|
||||
public enum PixelFormat { Yuv420P, Yuva420P, Yuv420P10Le, Yuv422P, Yuv422P10Le, Yuv444P, Yuv444P10Le, Yuva444P10Le, Rgb24, Rgba, Rgb8 };
|
||||
public enum ProResProfiles { Proxy, Lt, Standard, Hq, Quad4, Quad4Xq }
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Code/Data/ExportSettings.cs
Normal file
15
Code/Data/ExportSettings.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Flowframes.Data
|
||||
{
|
||||
public class ExportSettings
|
||||
{
|
||||
public Enums.Output.Format Format { get; set; }
|
||||
public Enums.Encoding.Encoder Encoder { get; set; }
|
||||
public Enums.Encoding.PixelFormat PixelFormat { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ namespace Flowframes
|
||||
public Fraction outFps;
|
||||
public float outItsScale;
|
||||
public float interpFactor;
|
||||
public Interpolate.OutMode outMode;
|
||||
public ExportSettings outSettings;
|
||||
public ModelCollection.ModelInfo model;
|
||||
|
||||
public string tempFolder;
|
||||
@@ -46,7 +46,7 @@ namespace Flowframes
|
||||
|
||||
public InterpSettings() { }
|
||||
|
||||
public InterpSettings(string inPathArg, string outPathArg, AI aiArg, Fraction inFpsDetectedArg, Fraction inFpsArg, float interpFactorArg, float itsScale, Interpolate.OutMode outModeArg, ModelCollection.ModelInfo modelArg)
|
||||
public InterpSettings(string inPathArg, string outPathArg, AI aiArg, Fraction inFpsDetectedArg, Fraction inFpsArg, float interpFactorArg, float itsScale, ExportSettings outSettingsArg, ModelCollection.ModelInfo modelArg)
|
||||
{
|
||||
inPath = inPathArg;
|
||||
outPath = outPathArg;
|
||||
@@ -56,7 +56,7 @@ namespace Flowframes
|
||||
interpFactor = interpFactorArg;
|
||||
outFps = inFpsArg * (double)interpFactorArg;
|
||||
outItsScale = itsScale;
|
||||
outMode = outModeArg;
|
||||
outSettings = outSettingsArg;
|
||||
model = modelArg;
|
||||
|
||||
alpha = false;
|
||||
@@ -95,7 +95,7 @@ namespace Flowframes
|
||||
inFps = new Fraction();
|
||||
interpFactor = 0;
|
||||
outFps = new Fraction();
|
||||
outMode = Interpolate.OutMode.VidMp4;
|
||||
outSettings = new ExportSettings();
|
||||
model = null;
|
||||
alpha = false;
|
||||
stepByStep = false;
|
||||
@@ -112,6 +112,7 @@ namespace Flowframes
|
||||
entries.Add(keyValuePair[0], keyValuePair[1]);
|
||||
}
|
||||
|
||||
// TODO: Rework this ugly stuff, JSON?
|
||||
foreach (KeyValuePair<string, string> entry in entries)
|
||||
{
|
||||
switch (entry.Key)
|
||||
@@ -123,7 +124,7 @@ namespace Flowframes
|
||||
case "INFPS": inFps = new Fraction(entry.Value); break;
|
||||
case "OUTFPS": outFps = new Fraction(entry.Value); break;
|
||||
case "INTERPFACTOR": interpFactor = float.Parse(entry.Value); break;
|
||||
case "OUTMODE": outMode = (Interpolate.OutMode)Enum.Parse(typeof(Interpolate.OutMode), entry.Value); break;
|
||||
case "OUTMODE": outSettings.Format = (Enums.Output.Format)Enum.Parse(typeof(Enums.Output.Format), entry.Value); break;
|
||||
case "MODEL": model = AiModels.GetModelByName(ai, entry.Value); break;
|
||||
case "INPUTRES": _inputResolution = FormatUtils.ParseSize(entry.Value); break;
|
||||
case "ALPHA": alpha = bool.Parse(entry.Value); break;
|
||||
@@ -173,14 +174,13 @@ namespace Flowframes
|
||||
try
|
||||
{
|
||||
bool alphaModel = model.SupportsAlpha;
|
||||
bool png = outMode == Interpolate.OutMode.ImgPng;
|
||||
bool gif = outMode == Interpolate.OutMode.VidGif;
|
||||
bool proResAlpha = outMode == Interpolate.OutMode.VidProRes && Config.GetInt(Config.Key.proResProfile) > 3;
|
||||
bool outputSupportsAlpha = png || gif || proResAlpha;
|
||||
bool pngOutput = outSettings.Encoder == Enums.Encoding.Encoder.Png;
|
||||
bool gifOutput = outSettings.Encoder == Enums.Encoding.Encoder.Gif;
|
||||
bool proResAlpha = outSettings.Encoder == Enums.Encoding.Encoder.ProResKs && Config.GetInt(Config.Key.proResProfile) > 3; // TODO: CHECK IF WORKS WITH NEW ENCODING SETTINGS CODE
|
||||
bool outputSupportsAlpha = pngOutput || gifOutput || proResAlpha;
|
||||
string ext = inputIsFrames ? Path.GetExtension(IoUtils.GetFilesSorted(inPath).First()).ToLowerInvariant() : Path.GetExtension(inPath).ToLowerInvariant();
|
||||
alpha = (alphaModel && outputSupportsAlpha && (ext == ".gif" || ext == ".png" || ext == ".apng" || ext == ".mov"));
|
||||
Logger.Log($"RefreshAlpha: model.supportsAlpha = {alphaModel} - outputSupportsAlpha = {outputSupportsAlpha} - " +
|
||||
$"input ext: {ext} => alpha = {alpha}", true);
|
||||
Logger.Log($"RefreshAlpha: model.supportsAlpha = {alphaModel} - outputSupportsAlpha = {outputSupportsAlpha} - input ext: {ext} => alpha = {alpha}", true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -193,9 +193,9 @@ namespace Flowframes
|
||||
|
||||
public void RefreshExtensions(FrameType type = FrameType.Both)
|
||||
{
|
||||
bool pngOutput = outMode == Interpolate.OutMode.ImgPng;
|
||||
bool aviHqChroma = outMode == Interpolate.OutMode.VidAvi && Config.Get(Config.Key.aviColors) != "yuv420p";
|
||||
bool proresHqChroma = outMode == Interpolate.OutMode.VidProRes && Config.GetInt(Config.Key.proResProfile) > 3;
|
||||
bool pngOutput = outSettings.Encoder == Enums.Encoding.Encoder.Png;
|
||||
bool aviHqChroma = outSettings.Format == Enums.Output.Format.Avi && outSettings.PixelFormat != Enums.Encoding.PixelFormat.Yuv420P; // TODO: CHECK IF WORKS WITH NEW ENCODING SETTINGS CODE
|
||||
bool proresHqChroma = outSettings.Encoder == Enums.Encoding.Encoder.ProResKs && Config.GetInt(Config.Key.proResProfile) > 3; // TODO: CHECK IF WORKS WITH NEW ENCODING SETTINGS CODE
|
||||
|
||||
bool forceHqChroma = pngOutput || aviHqChroma || proresHqChroma;
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace Flowframes
|
||||
s += $"INFPS|{inFps}\n";
|
||||
s += $"OUTFPS|{outFps}\n";
|
||||
s += $"INTERPFACTOR|{interpFactor}\n";
|
||||
s += $"OUTMODE|{outMode}\n";
|
||||
s += $"OUTMODE|{outSettings.Format}\n";
|
||||
s += $"MODEL|{model.Name}\n";
|
||||
s += $"INPUTRES|{InputResolution.Width}x{InputResolution.Height}\n";
|
||||
s += $"OUTPUTRES|{ScaledResolution.Width}x{ScaledResolution.Height}\n";
|
||||
|
||||
54
Code/Data/Strings.cs
Normal file
54
Code/Data/Strings.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Flowframes.Data
|
||||
{
|
||||
public class Strings
|
||||
{
|
||||
public static Dictionary<string, string> OutputFormat = new Dictionary<string, string>
|
||||
{
|
||||
{ Enums.Output.Format.Mp4.ToString(), "MP4" },
|
||||
{ Enums.Output.Format.Mkv.ToString(), "MKV" },
|
||||
{ Enums.Output.Format.Webm.ToString(), "WEBM" },
|
||||
{ Enums.Output.Format.Mov.ToString(), "MOV" },
|
||||
{ Enums.Output.Format.Avi.ToString(), "AVI" },
|
||||
{ Enums.Output.Format.Gif.ToString(), "GIF" },
|
||||
{ Enums.Output.Format.Images.ToString(), "Images" },
|
||||
{ Enums.Output.Format.Realtime.ToString(), "Real-time" },
|
||||
};
|
||||
|
||||
public static Dictionary<string, string> Encoder = new Dictionary<string, string>
|
||||
{
|
||||
{ Enums.Encoding.Encoder.X264.ToString(), "h264" },
|
||||
{ Enums.Encoding.Encoder.X265.ToString(), "h265" },
|
||||
{ Enums.Encoding.Encoder.SvtAv1.ToString(), "AV1" },
|
||||
{ Enums.Encoding.Encoder.VpxVp9.ToString(), "VP9" },
|
||||
{ Enums.Encoding.Encoder.ProResKs.ToString(), "ProRes" },
|
||||
{ Enums.Encoding.Encoder.Nvenc264.ToString(), "h264 (NVENC)" },
|
||||
{ Enums.Encoding.Encoder.Nvenc265.ToString(), "h265 (NVENC)" },
|
||||
{ Enums.Encoding.Encoder.NvencAv1.ToString(), "AV1 (NVENC)" },
|
||||
{ Enums.Encoding.Encoder.Gif.ToString(), "Animated GIF" },
|
||||
{ Enums.Encoding.Encoder.Png.ToString(), "PNG" },
|
||||
{ Enums.Encoding.Encoder.Jpeg.ToString(), "JPEG" },
|
||||
{ Enums.Encoding.Encoder.Webp.ToString(), "WEBP" },
|
||||
{ Enums.Encoding.Encoder.Ffv1.ToString(), "FFV1" },
|
||||
{ Enums.Encoding.Encoder.Huffyuv.ToString(), "HuffYUV" },
|
||||
{ Enums.Encoding.Encoder.Magicyuv.ToString(), "MagicYUV" },
|
||||
{ Enums.Encoding.Encoder.Rawvideo.ToString(), "Raw Video" },
|
||||
};
|
||||
|
||||
public static Dictionary<string, string> PixelFormat = new Dictionary<string, string>
|
||||
{
|
||||
{ Enums.Encoding.PixelFormat.Yuv420P.ToString(), "YUV 4:2:0 8-bit" },
|
||||
{ Enums.Encoding.PixelFormat.Yuva420P.ToString(), "YUVA 4:2:0 8-bit" },
|
||||
{ Enums.Encoding.PixelFormat.Yuv420P10Le.ToString(), "YUV 4:2:0 10-bit" },
|
||||
{ Enums.Encoding.PixelFormat.Yuv422P.ToString(), "YUV 4:2:2 8-bit" },
|
||||
{ Enums.Encoding.PixelFormat.Yuv422P10Le.ToString(), "YUV 4:2:2 10-bit" },
|
||||
{ Enums.Encoding.PixelFormat.Yuv444P.ToString(), "YUV 4:4:4 8-bit" },
|
||||
{ Enums.Encoding.PixelFormat.Yuv444P10Le.ToString(), "YUV 4:4:4 10-bit" },
|
||||
{ Enums.Encoding.PixelFormat.Yuva444P10Le.ToString(), "YUVA 4:4:4 10-bit" },
|
||||
{ Enums.Encoding.PixelFormat.Rgb24.ToString(), "RGB 8-bit" },
|
||||
{ Enums.Encoding.PixelFormat.Rgb8.ToString(), "RGB 256-color" },
|
||||
{ Enums.Encoding.PixelFormat.Rgba.ToString(), "RGBA 8-bit" },
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user