diff --git a/Code/Data/EncoderInfoVideo.cs b/Code/Data/EncoderInfoVideo.cs index 5660dce..e5c4114 100644 --- a/Code/Data/EncoderInfoVideo.cs +++ b/Code/Data/EncoderInfoVideo.cs @@ -15,7 +15,7 @@ namespace Flowframes.Data public int Modulo { get; set; } = 2; public int MaxFramerate { get; set; } = 1000; public List PixelFormats { get; set; } = new List(); - 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 QualityLevels { get; set; } = new List (); diff --git a/Code/Form1.cs b/Code/Form1.cs index 1e6340b..17763c1 100644 --- a/Code/Form1.cs +++ b/Code/Form1.cs @@ -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(comboxOutputFormat.Text, true, Strings.OutputFormat); } } Enums.Encoding.Encoder GetEncoder { get { return ParseUtils.GetEnum(comboxOutputEncoder.Text, true, Strings.Encoder); } } - Enums.Encoding.PixelFormat GetPixelFormat { get { return ParseUtils.GetEnum(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(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) { diff --git a/Code/Main/Export.cs b/Code/Main/Export.cs index aa02fff..54e194b 100644 --- a/Code/Main/Export.cs +++ b/Code/Main/Export.cs @@ -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 - " + diff --git a/Code/Main/InterpolateUtils.cs b/Code/Main/InterpolateUtils.cs index 06e66b5..aaf7fc6 100644 --- a/Code/Main/InterpolateUtils.cs +++ b/Code/Main/InterpolateUtils.cs @@ -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}."); diff --git a/Code/Media/FfmpegUtils.cs b/Code/Media/FfmpegUtils.cs index 818b022..2301fe9 100644 --- a/Code/Media/FfmpegUtils.cs +++ b/Code/Media/FfmpegUtils.cs @@ -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(); - 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) diff --git a/Code/MiscUtils/OutputUtils.cs b/Code/MiscUtils/OutputUtils.cs index 8cc9755..45c6933 100644 --- a/Code/MiscUtils/OutputUtils.cs +++ b/Code/MiscUtils/OutputUtils.cs @@ -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; diff --git a/Code/Os/AiProcess.cs b/Code/Os/AiProcess.cs index c988297..fb7fcb6 100644 --- a/Code/Os/AiProcess.cs +++ b/Code/Os/AiProcess.cs @@ -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); } - + } }