mirror of
https://github.com/n00mkrad/flowframes.git
synced 2026-07-10 04:21:49 +02:00
Check NVENC compatibility before even starting interpolation
This commit is contained in:
@@ -34,15 +34,16 @@ namespace Flowframes
|
||||
{
|
||||
if (!BatchProcessing.busy && Program.busy) return;
|
||||
canceled = false;
|
||||
Program.mainForm.SetWorking(true);
|
||||
if (!Utils.InputIsValid(current.inPath, current.outPath, current.outFps, current.interpFactor, current.outMode)) return; // General input checks
|
||||
if (!Utils.CheckAiAvailable(current.ai)) return; // Check if selected AI pkg is installed
|
||||
if (!ResumeUtils.resumeNextRun && !Utils.CheckDeleteOldTempFolder()) return; // Try to delete temp folder if an old one exists
|
||||
if (!Utils.CheckPathValid(current.inPath)) return; // Check if input path/file is valid
|
||||
if (!(await Utils.CheckEncoderValid())) return; // Check NVENC compat
|
||||
Utils.PathAsciiCheck(current.outPath, "output path");
|
||||
currentInputFrameCount = await Utils.GetInputFrameCountAsync(current.inPath);
|
||||
current.stepByStep = false;
|
||||
Program.mainForm.SetStatus("Starting...");
|
||||
Program.mainForm.SetWorking(true);
|
||||
|
||||
if (!ResumeUtils.resumeNextRun)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Flowframes.Main
|
||||
|
||||
class InterpolateSteps
|
||||
{
|
||||
public enum Step { ExtractScnChanges, ExtractFrames, Interpolate, CreateVid, Reset }
|
||||
|
||||
public static async Task Run(string step)
|
||||
{
|
||||
@@ -27,14 +26,7 @@ namespace Flowframes.Main
|
||||
current.stepByStep = true;
|
||||
|
||||
if (!InterpolateUtils.InputIsValid(current.inPath, current.outPath, current.outFps, current.interpFactor, current.outMode)) return; // General input checks
|
||||
|
||||
// if (step.Contains("Extract Scene Changes"))
|
||||
// {
|
||||
// if (!current.inputIsFrames) // Input is video - extract frames first
|
||||
// await ExtractSceneChanges();
|
||||
// else
|
||||
// InterpolateUtils.ShowMessage("Scene changes can only be extracted from videos, not frames!", "Error");
|
||||
// }
|
||||
if (!InterpolateUtils.CheckPathValid(current.inPath)) return; // Check if input path/file is valid
|
||||
|
||||
if (step.Contains("Extract Frames"))
|
||||
await ExtractFramesStep();
|
||||
@@ -86,6 +78,8 @@ namespace Flowframes.Main
|
||||
|
||||
public static async Task DoInterpolate()
|
||||
{
|
||||
if (!InterpolateUtils.CheckAiAvailable(current.ai)) return;
|
||||
|
||||
current.framesFolder = Path.Combine(current.tempFolder, Paths.framesDir);
|
||||
|
||||
if (!Directory.Exists(current.framesFolder) || IOUtils.GetAmountOfFiles(current.framesFolder, false, "*.png") < 2)
|
||||
@@ -105,6 +99,8 @@ namespace Flowframes.Main
|
||||
//if (Config.GetBool("sbsAllowAutoEnc"))
|
||||
// nextOutPath = Path.Combine(currentOutPath, Path.GetFileNameWithoutExtension(current.inPath) + IOUtils.GetAiSuffix(current.ai, current.interpFactor) + InterpolateUtils.GetExt(current.outMode));
|
||||
|
||||
if (Config.GetBool("sbsAllowAutoEnc") && !(await InterpolateUtils.CheckEncoderValid())) return;
|
||||
|
||||
if (canceled) return;
|
||||
Program.mainForm.SetStatus("Running AI...");
|
||||
await RunAi(current.interpFolder, current.ai, true);
|
||||
@@ -121,6 +117,8 @@ namespace Flowframes.Main
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(await InterpolateUtils.CheckEncoderValid())) return;
|
||||
|
||||
string[] outFrames = IOUtils.GetFilesSorted(current.interpFolder, $"*.{InterpolateUtils.GetOutExt()}");
|
||||
|
||||
if (outFrames.Length > 0 && !IOUtils.CheckImageValid(outFrames[0]))
|
||||
|
||||
@@ -361,6 +361,23 @@ namespace Flowframes.Main
|
||||
return true;
|
||||
}
|
||||
|
||||
public static async Task<bool> CheckEncoderValid ()
|
||||
{
|
||||
string enc = FFmpegUtils.GetEnc(FFmpegUtils.GetCodec(I.current.outMode));
|
||||
|
||||
if (!enc.ToLower().Contains("nvenc"))
|
||||
return true;
|
||||
|
||||
if (!(await FfmpegCommands.IsEncoderCompatible(enc)))
|
||||
{
|
||||
ShowMessage("NVENC encoding is not available on your hardware!\nPlease use a different encoder.", "Error");
|
||||
I.Cancel();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool IsVideoValid(string videoPath)
|
||||
{
|
||||
if (videoPath == null || !IOUtils.IsFileValid(videoPath))
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Flowframes
|
||||
if (line.Contains("Could not open file"))
|
||||
Interpolate.Cancel($"FFmpeg Error: {line}");
|
||||
|
||||
if (line.Contains("No NVENC capable devices found"))
|
||||
if (line.Contains("No NVENC capable devices found") || line.Contains("Cannot load nvcuda.dll"))
|
||||
Interpolate.Cancel($"FFmpeg Error: {line}\nMake sure you have an NVENC-capable Nvidia GPU.");
|
||||
|
||||
if (!hidden && showProgressBar && line.Contains("time="))
|
||||
|
||||
@@ -169,6 +169,14 @@ namespace Flowframes
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<bool> IsEncoderCompatible(string enc)
|
||||
{
|
||||
Logger.Log($"IsEncoderCompatible('{enc}')", true, false, "ffmpeg");
|
||||
string args = $"-loglevel error -f lavfi -i color=black:s=540x540 -vframes 1 -an -c:v {enc} -f null -";
|
||||
string output = await GetFfmpegOutputAsync(args);
|
||||
return !output.ToLower().Contains("error");
|
||||
}
|
||||
|
||||
public static string GetAudioCodec(string path)
|
||||
{
|
||||
string args = $" -v panic -show_streams -select_streams a -show_entries stream=codec_name {path.Wrap()}";
|
||||
|
||||
Reference in New Issue
Block a user