mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-25 12:49:26 +01:00
Fix VS scaling and realtime pix_fmt
This commit is contained in:
@@ -15,7 +15,7 @@ namespace Flowframes.Data
|
||||
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 PixelFormat PixelFormatDefault { get; set; } = (PixelFormat)(-1);
|
||||
public bool IsImageSequence { get; set; } = false;
|
||||
public string OverideExtension { get; set; } = "";
|
||||
public List<string> QualityLevels { get; set; } = new List<string> ();
|
||||
|
||||
@@ -126,7 +126,8 @@ namespace Flowframes
|
||||
|
||||
var pixelFormats = info.PixelFormats;
|
||||
comboxOutputColors.Visible = pixelFormats.Count > 0;
|
||||
comboxOutputColors.FillFromEnum(pixelFormats, Strings.PixelFormat, info.PixelFormatDefault);
|
||||
int defaultPixFmt = (int)info.PixelFormatDefault != -1 ? info.PixelFormats.IndexOf(info.PixelFormatDefault) : 0;
|
||||
comboxOutputColors.FillFromEnum(pixelFormats, Strings.PixelFormat, defaultPixFmt);
|
||||
comboxOutputColors.Width = adjustableQuality ? 117 : 223;
|
||||
|
||||
if(pixelFormats.Count > 0)
|
||||
@@ -216,7 +217,12 @@ namespace Flowframes
|
||||
public InterpSettings GetCurrentSettings()
|
||||
{
|
||||
SetTab("interpolate");
|
||||
return new InterpSettings(inputTbox.Text.Trim(), outputTbox.Text.Trim(), GetAi(), currInFpsDetected, currInFps, interpFactorCombox.GetFloat(), outSpeedCombox.GetInt().Clamp(1, 64), GetExportSettings, GetModel(GetAi()));
|
||||
string inPath = inputTbox.Text.Trim();
|
||||
string outPath = outputTbox.Text.Trim();
|
||||
AI ai = GetAi();
|
||||
float interpFactor = interpFactorCombox.GetFloat();
|
||||
float itsScale = outSpeedCombox.GetInt().Clamp(1, 64);
|
||||
return new InterpSettings(inPath, outPath, ai, currInFpsDetected, currInFps, interpFactor, itsScale, GetOutputSettings(), GetModel(ai));
|
||||
}
|
||||
|
||||
public InterpSettings UpdateCurrentSettings(InterpSettings settings)
|
||||
@@ -236,7 +242,7 @@ namespace Flowframes
|
||||
settings.inFps = currInFps;
|
||||
settings.interpFactor = interpFactorCombox.GetFloat();
|
||||
settings.outFps = settings.inFps * settings.interpFactor;
|
||||
settings.outSettings = GetExportSettings;
|
||||
settings.outSettings = GetOutputSettings();
|
||||
settings.model = GetModel(GetAi());
|
||||
|
||||
return settings;
|
||||
@@ -408,8 +414,19 @@ namespace Flowframes
|
||||
|
||||
Enums.Output.Format GetOutputFormat { get { return ParseUtils.GetEnum<Enums.Output.Format>(comboxOutputFormat.Text, true, Strings.OutputFormat); } }
|
||||
Enums.Encoding.Encoder GetEncoder { get { return ParseUtils.GetEnum<Enums.Encoding.Encoder>(comboxOutputEncoder.Text, true, Strings.Encoder); } }
|
||||
Enums.Encoding.PixelFormat GetPixelFormat { get { return ParseUtils.GetEnum<Enums.Encoding.PixelFormat>(comboxOutputColors.Text, true, Strings.PixelFormat); } }
|
||||
OutputSettings GetExportSettings { get { return new OutputSettings() { Encoder = GetEncoder, Format = GetOutputFormat, PixelFormat = GetPixelFormat, Quality = comboxOutputQuality.Text }; } }
|
||||
|
||||
private Enums.Encoding.PixelFormat GetPixelFormat ()
|
||||
{
|
||||
if (!comboxOutputColors.Visible)
|
||||
return (Enums.Encoding.PixelFormat)(-1);
|
||||
|
||||
return ParseUtils.GetEnum<Enums.Encoding.PixelFormat>(comboxOutputColors.Text, true, Strings.PixelFormat);
|
||||
}
|
||||
|
||||
public OutputSettings GetOutputSettings ()
|
||||
{
|
||||
return new OutputSettings() { Encoder = GetEncoder, Format = GetOutputFormat, PixelFormat = GetPixelFormat(), Quality = comboxOutputQuality.Text };
|
||||
}
|
||||
|
||||
public void SetFormat(Enums.Output.Format format)
|
||||
{
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Flowframes.Main
|
||||
|
||||
if (ffplay)
|
||||
{
|
||||
encArgs = $"-pix_fmt {encArgs.Split("-pix_fmt ").Last()}";
|
||||
encArgs = $"-pix_fmt yuv444p";
|
||||
|
||||
return
|
||||
$"{extraArgsIn} -i pipe: {encArgs} {extraArgsOut} -f yuv4mpegpipe - | ffplay - " +
|
||||
|
||||
@@ -256,6 +256,7 @@ namespace Flowframes.Main
|
||||
Logger.Log($"Un-rounded downscaled size: {(res.Width * factor).ToString("0.###")}x{(res.Height * factor).ToString("0.###")}", true);
|
||||
int width = RoundDivisibleBy((res.Width * factor).RoundToInt(), mod);
|
||||
int height = RoundDivisibleBy((res.Height * factor).RoundToInt(), mod);
|
||||
res = new Size(width, height);
|
||||
|
||||
if (print && factor < 1f)
|
||||
Logger.Log($"Video is bigger than the maximum - Downscaling to {width}x{height}.");
|
||||
|
||||
@@ -171,15 +171,20 @@ namespace Flowframes.Media
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string[] GetEncArgs(OutputSettings settings, Size res, float fps, bool realtime = false) // Array contains as many entries as there are encoding passes. If "realtime" is true, force single pass.
|
||||
public static string[] GetEncArgs(OutputSettings settings, Size res, float fps, bool realtime = false) // Array contains as many entries as there are encoding passes. If "realtime" is true, force single pass.
|
||||
{
|
||||
Encoder enc = settings.Encoder;
|
||||
PixelFormat pixFmt = settings.PixelFormat;
|
||||
int keyint = 10;
|
||||
|
||||
var args = new List<string>();
|
||||
|
||||
EncoderInfoVideo info = OutputUtils.GetEncoderInfoVideo(enc);
|
||||
PixelFormat pixFmt = settings.PixelFormat;
|
||||
|
||||
if (settings.Format == Enums.Output.Format.Realtime)
|
||||
pixFmt = PixelFormat.Yuv444P;
|
||||
|
||||
if (pixFmt == (PixelFormat)(-1)) // No pixel format set in GUI
|
||||
pixFmt = info.PixelFormatDefault != (PixelFormat)(-1) ? info.PixelFormatDefault : info.PixelFormats.First(); // Set default or fallback to first in list
|
||||
|
||||
args.Add($"-c:v {info.Name}");
|
||||
|
||||
if (enc == Encoder.X264 || enc == Encoder.X265 || enc == Encoder.SvtAv1 || enc == Encoder.VpxVp9 || enc == Encoder.Nvenc264 || enc == Encoder.Nvenc265 || enc == Encoder.NvencAv1)
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
using Flowframes.Data;
|
||||
using Flowframes.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
using static Flowframes.Data.Enums.Encoding;
|
||||
using Encoder = Flowframes.Data.Enums.Encoding.Encoder;
|
||||
using PixFmt = Flowframes.Data.Enums.Encoding.PixelFormat;
|
||||
|
||||
@@ -112,7 +112,9 @@ namespace Flowframes.Os
|
||||
Program.mainForm.SetStatus("Creating output video from frames...");
|
||||
}
|
||||
|
||||
Logger.Log(logStr);
|
||||
if (Interpolate.currentSettings.outSettings.Format != Enums.Output.Format.Realtime)
|
||||
Logger.Log(logStr);
|
||||
|
||||
processTime.Stop();
|
||||
|
||||
if (!Interpolate.currentSettings.ai.Piped && interpFramesCount < 3)
|
||||
@@ -339,7 +341,7 @@ namespace Flowframes.Os
|
||||
|
||||
public static async Task RunRifeNcnnVs(string framesPath, string outPath, float factor, string mdl, bool rt = false)
|
||||
{
|
||||
if(Interpolate.canceled) return;
|
||||
if (Interpolate.canceled) return;
|
||||
|
||||
AI ai = Implementations.rifeNcnnVs;
|
||||
processTimeMulti.Restart();
|
||||
@@ -368,7 +370,7 @@ namespace Flowframes.Os
|
||||
Logger.Log($"Note: RIFE-NCNN-VS is experimental and may not work as expected with certain Flowframes features, such as image sequence exporting.");
|
||||
|
||||
string avDir = Path.Combine(Paths.GetPkgPath(), Paths.audioVideoDir);
|
||||
|
||||
|
||||
string pipedTargetArgs = $"{Path.Combine(avDir, "ffmpeg").Wrap()} -y {await Export.GetPipedFfmpegCmd(rt)}";
|
||||
|
||||
string pkgDir = Path.Combine(Paths.GetPkgPath(), Implementations.rifeNcnnVs.PkgDir);
|
||||
@@ -715,6 +717,6 @@ namespace Flowframes.Os
|
||||
InterpolationProgress.UpdateLastFrameFromInterpOutput(line);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user