Add Vulkan filtering support for AMD VAAPI (Vega/gfx9+)

This requires:
- VK_EXT_image_drm_format_modifier extension
- Linux kernel version >= 5.15
- jellyfin-ffmpeg5 >= 5.0.1-2

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
This commit is contained in:
nyanmisaka
2022-10-16 23:08:59 +08:00
parent 976dd012e7
commit 560d0838c7
5 changed files with 340 additions and 15 deletions

View File

@@ -102,7 +102,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
"tonemap_vaapi",
"procamp_vaapi",
"overlay_vaapi",
"hwupload_vaapi"
"hwupload_vaapi",
// vulkan
"libplacebo",
"scale_vulkan",
"overlay_vulkan"
};
private static readonly IReadOnlyDictionary<int, string[]> _filterOptionsDict = new Dictionary<int, string[]>
@@ -111,7 +115,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
{ 1, new string[] { "tonemap_cuda", "GPU accelerated HDR to SDR tonemapping" } },
{ 2, new string[] { "tonemap_opencl", "bt2390" } },
{ 3, new string[] { "overlay_opencl", "Action to take when encountering EOF from secondary input" } },
{ 4, new string[] { "overlay_vaapi", "Action to take when encountering EOF from secondary input" } }
{ 4, new string[] { "overlay_vaapi", "Action to take when encountering EOF from secondary input" } },
{ 5, new string[] { "overlay_vulkan", "Action to take when encountering EOF from secondary input" } }
};
// These are the library versions that corresponds to our minimum ffmpeg version 4.x according to the version table below
@@ -351,6 +356,39 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
}
public bool CheckVulkanDrmDeviceByExtensionName(string renderNodePath, string[] vulkanExtensions)
{
if (!OperatingSystem.IsLinux())
{
return false;
}
if (string.IsNullOrEmpty(renderNodePath))
{
return false;
}
try
{
var command = "-v verbose -hide_banner -init_hw_device drm=dr:" + renderNodePath + " -init_hw_device vulkan=vk@dr";
var output = GetProcessOutput(_encoderPath, command, true, null);
foreach (string ext in vulkanExtensions)
{
if (!output.Contains(ext, StringComparison.Ordinal))
{
return false;
}
}
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Error detecting the given drm render node path");
return false;
}
}
private IEnumerable<string> GetHwaccelTypes()
{
string? output = null;