diff --git a/VideoNodes/LogicalNodes/CanUseHardwareEncoding.cs b/VideoNodes/LogicalNodes/CanUseHardwareEncoding.cs index c377e0cd..f8e3bf1c 100644 --- a/VideoNodes/LogicalNodes/CanUseHardwareEncoding.cs +++ b/VideoNodes/LogicalNodes/CanUseHardwareEncoding.cs @@ -256,65 +256,65 @@ public class CanUseHardwareEncoding:Node /// true if can be processed 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 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 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; } } diff --git a/VideoNodes/Tests/Resources/subtitles.mkv b/VideoNodes/Tests/Resources/subtitles.mkv new file mode 100644 index 00000000..91877b1e Binary files /dev/null and b/VideoNodes/Tests/Resources/subtitles.mkv differ diff --git a/VideoNodes/Tests/_VideoTestBase.cs b/VideoNodes/Tests/_VideoTestBase.cs index 162861db..bbf922d7 100644 --- a/VideoNodes/Tests/_VideoTestBase.cs +++ b/VideoNodes/Tests/_VideoTestBase.cs @@ -32,9 +32,14 @@ public abstract class VideoTestBase : TestBase protected static readonly string VideoMkvHevc = ResourcesTestFilesDir + "/hevc.mkv"; /// - /// Video Corrutp file + /// Video Corrupt file /// protected static readonly string VideoCorrupt = ResourcesTestFilesDir + "/corrupt.mkv"; + + /// + /// Video with many subtitles file + /// + protected static readonly string VideoSubtitles = ResourcesTestFilesDir + "/subtitles.mkv"; /// /// Audio MP3 file