mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-05-09 11:59:15 -05:00
plugin
This commit is contained in:
@@ -256,65 +256,65 @@ public class CanUseHardwareEncoding:Node
|
||||
/// <returns>true if can be processed</returns>
|
||||
internal static bool CanProcess(NodeParameters args, string ffmpeg, string[] encodingParams)
|
||||
{
|
||||
bool can = CanExecute();
|
||||
bool can = CanExecute(args, ffmpeg, encodingParams);
|
||||
if (can == false && encodingParams?.Contains("amf") == true)
|
||||
{
|
||||
// AMD/AMF has a issue where it reports false at first but then passes
|
||||
// https://github.com/revenz/FileFlows/issues/106
|
||||
Thread.Sleep(2000);
|
||||
can = CanExecute();
|
||||
can = CanExecute(args, ffmpeg, encodingParams);
|
||||
}
|
||||
return can;
|
||||
|
||||
bool CanExecute()
|
||||
}
|
||||
|
||||
private static bool CanExecute(NodeParameters args, string ffmpeg, string[] encodingParams)
|
||||
{
|
||||
bool vaapi = encodingParams.Any(x => x.Contains("vaapi")) && VaapiHelper.VaapiLinux;
|
||||
List<string> arguments = encodingParams.ToList();
|
||||
if (vaapi)
|
||||
arguments.AddRange(new [] { "-vf", "format=nv12,hwupload", "-strict", "-2"});
|
||||
arguments.InsertRange(0, new []
|
||||
{
|
||||
bool vaapi = encodingParams.Any(x => x.Contains("vaapi")) && VaapiHelper.VaapiLinux;
|
||||
List<string> arguments = encodingParams.ToList();
|
||||
if (vaapi)
|
||||
arguments.AddRange(new [] { "-vf", "format=nv12,hwupload", "-strict", "-2"});
|
||||
arguments.InsertRange(0, new []
|
||||
{
|
||||
"-loglevel",
|
||||
"error",
|
||||
"-f",
|
||||
"lavfi",
|
||||
"-i",
|
||||
"color=black:s=1080x1080",
|
||||
"-vframes",
|
||||
"1",
|
||||
"-an",
|
||||
"-c:v"
|
||||
});
|
||||
if (vaapi)
|
||||
{
|
||||
arguments.InsertRange(0,
|
||||
new[] { "-fflags", "+genpts", "-vaapi_device", VaapiHelper.VaapiRenderDevice });
|
||||
arguments.Add(FileHelper.Combine(args.TempPath, Guid.NewGuid() + ".mkv"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
arguments.AddRange(new []
|
||||
{
|
||||
"-f",
|
||||
"null",
|
||||
"-"
|
||||
});
|
||||
}
|
||||
var cmd = args.Process.ExecuteShellCommand(new ExecuteArgs
|
||||
{
|
||||
Command = ffmpeg,
|
||||
ArgumentList = arguments.ToArray(),
|
||||
Silent = true
|
||||
}).Result;
|
||||
string? output = cmd.Output?.Contains("va_openDriver() returns 0") == true ? null : cmd.Output;
|
||||
if (cmd.ExitCode != 0 || string.IsNullOrWhiteSpace(output) == false)
|
||||
{
|
||||
string asStr = string.Join(" ", arguments.Select(x => x.Contains(" ") ? "\"" + x + "\"" : x));
|
||||
args.Logger?.WLog($"Cant process '{ffmpeg} {asStr}': {cmd.Output ?? ""}");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
"-loglevel",
|
||||
"error",
|
||||
"-f",
|
||||
"lavfi",
|
||||
"-i",
|
||||
"color=black:s=1080x1080",
|
||||
"-vframes",
|
||||
"1",
|
||||
"-an",
|
||||
"-c:v"
|
||||
});
|
||||
if (vaapi)
|
||||
{
|
||||
arguments.InsertRange(0,
|
||||
new[] { "-fflags", "+genpts", "-vaapi_device", VaapiHelper.VaapiRenderDevice });
|
||||
arguments.Add(FileHelper.Combine(args.TempPath, Guid.NewGuid() + ".mkv"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
arguments.AddRange(new []
|
||||
{
|
||||
"-f",
|
||||
"null",
|
||||
"-"
|
||||
});
|
||||
}
|
||||
var cmd = args.Process.ExecuteShellCommand(new ExecuteArgs
|
||||
{
|
||||
Command = ffmpeg,
|
||||
ArgumentList = arguments.ToArray(),
|
||||
Silent = true
|
||||
}).Result;
|
||||
string? output = cmd.Output?.Contains("va_openDriver() returns 0") == true ? null : cmd.Output;
|
||||
if (cmd.ExitCode != 0 || string.IsNullOrWhiteSpace(output) == false)
|
||||
{
|
||||
string asStr = string.Join(" ", arguments.Select(x => x.Contains(" ") ? "\"" + x + "\"" : x));
|
||||
args.Logger?.WLog($"Cant process '{ffmpeg} {asStr}': {cmd.Output ?? ""}");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -32,9 +32,14 @@ public abstract class VideoTestBase : TestBase
|
||||
protected static readonly string VideoMkvHevc = ResourcesTestFilesDir + "/hevc.mkv";
|
||||
|
||||
/// <summary>
|
||||
/// Video Corrutp file
|
||||
/// Video Corrupt file
|
||||
/// </summary>
|
||||
protected static readonly string VideoCorrupt = ResourcesTestFilesDir + "/corrupt.mkv";
|
||||
|
||||
/// <summary>
|
||||
/// Video with many subtitles file
|
||||
/// </summary>
|
||||
protected static readonly string VideoSubtitles = ResourcesTestFilesDir + "/subtitles.mkv";
|
||||
|
||||
/// <summary>
|
||||
/// Audio MP3 file
|
||||
|
||||
Reference in New Issue
Block a user