try to fix vaapi by always using nv12 or vaapi pixel format (#42)
This commit is contained in:
@@ -209,7 +209,7 @@ namespace ErsatzTV.Core.Tests.FFmpeg
|
|||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
"[0:v]scale_npp=1920:1000:format=yuv420p,hwdownload,setsar=1,hwupload[v]",
|
"[0:v]scale_npp=1920:1000,hwdownload,format=nv12,setsar=1,hwupload[v]",
|
||||||
"[v]")]
|
"[v]")]
|
||||||
[TestCase(
|
[TestCase(
|
||||||
true,
|
true,
|
||||||
@@ -221,13 +221,13 @@ namespace ErsatzTV.Core.Tests.FFmpeg
|
|||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
"[0:v]scale_npp=1920:1000:format=yuv420p,hwdownload,setsar=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,hwupload[v]",
|
"[0:v]scale_npp=1920:1000,hwdownload,format=nv12,setsar=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,hwupload[v]",
|
||||||
"[v]")]
|
"[v]")]
|
||||||
[TestCase(
|
[TestCase(
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
"[0:v]scale_npp=1920:1000:format=yuv420p,hwdownload,setsar=1,hwupload[v]",
|
"[0:v]scale_npp=1920:1000,hwdownload,format=nv12,setsar=1,hwupload[v]",
|
||||||
"[v]")]
|
"[v]")]
|
||||||
[TestCase(
|
[TestCase(
|
||||||
false,
|
false,
|
||||||
@@ -239,7 +239,7 @@ namespace ErsatzTV.Core.Tests.FFmpeg
|
|||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
"[0:v]scale_npp=1920:1000:format=yuv420p,hwdownload,setsar=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,hwupload[v]",
|
"[0:v]scale_npp=1920:1000,hwdownload,format=nv12,setsar=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,hwupload[v]",
|
||||||
"[v]")]
|
"[v]")]
|
||||||
public void Should_Return_NVENC_Video_Filter(
|
public void Should_Return_NVENC_Video_Filter(
|
||||||
bool deinterlace,
|
bool deinterlace,
|
||||||
@@ -280,32 +280,37 @@ namespace ErsatzTV.Core.Tests.FFmpeg
|
|||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
"[0:v]deinterlace_vaapi,scale_vaapi=w=1920:h=1000,hwdownload,setsar=1,hwupload[v]",
|
"[0:v]deinterlace_vaapi,scale_vaapi=w=1920:h=1000,hwdownload,format=nv12|vaapi,setsar=1,hwupload[v]",
|
||||||
"[v]")]
|
"[v]")]
|
||||||
[TestCase(
|
[TestCase(
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
"[0:v]deinterlace_vaapi,hwdownload,setsar=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,hwupload[v]",
|
"[0:v]deinterlace_vaapi,hwdownload,format=nv12|vaapi,setsar=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,hwupload[v]",
|
||||||
"[v]")]
|
"[v]")]
|
||||||
[TestCase(
|
[TestCase(
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
"[0:v]deinterlace_vaapi,scale_vaapi=w=1920:h=1000,hwdownload,setsar=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,hwupload[v]",
|
"[0:v]deinterlace_vaapi,scale_vaapi=w=1920:h=1000,hwdownload,format=nv12|vaapi,setsar=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,hwupload[v]",
|
||||||
|
"[v]")]
|
||||||
|
[TestCase(
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
"[0:v]scale_vaapi=w=1920:h=1000,hwdownload,format=nv12|vaapi,setsar=1,hwupload[v]",
|
||||||
"[v]")]
|
"[v]")]
|
||||||
[TestCase(false, true, false, "[0:v]scale_vaapi=w=1920:h=1000,hwdownload,setsar=1,hwupload[v]", "[v]")]
|
|
||||||
[TestCase(
|
[TestCase(
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
"[0:v]hwdownload,setsar=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,hwupload[v]",
|
"[0:v]hwdownload,format=nv12|vaapi,setsar=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,hwupload[v]",
|
||||||
"[v]")]
|
"[v]")]
|
||||||
[TestCase(
|
[TestCase(
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
"[0:v]scale_vaapi=w=1920:h=1000,hwdownload,setsar=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,hwupload[v]",
|
"[0:v]scale_vaapi=w=1920:h=1000,hwdownload,format=nv12|vaapi,setsar=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,hwupload[v]",
|
||||||
"[v]")]
|
"[v]")]
|
||||||
public void Should_Return_VAAPI_Video_Filter(
|
public void Should_Return_VAAPI_Video_Filter(
|
||||||
bool deinterlace,
|
bool deinterlace,
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace ErsatzTV.Core.FFmpeg
|
|||||||
string filter = acceleration switch
|
string filter = acceleration switch
|
||||||
{
|
{
|
||||||
HardwareAccelerationKind.Qsv => $"scale_qsv=w={size.Width}:h={size.Height}",
|
HardwareAccelerationKind.Qsv => $"scale_qsv=w={size.Width}:h={size.Height}",
|
||||||
HardwareAccelerationKind.Nvenc => $"scale_npp={size.Width}:{size.Height}:format=yuv420p",
|
HardwareAccelerationKind.Nvenc => $"scale_npp={size.Width}:{size.Height}",
|
||||||
HardwareAccelerationKind.Vaapi => $"scale_vaapi=w={size.Width}:h={size.Height}",
|
HardwareAccelerationKind.Vaapi => $"scale_vaapi=w={size.Width}:h={size.Height}",
|
||||||
_ => $"scale={size.Width}:{size.Height}:flags=fast_bilinear"
|
_ => $"scale={size.Width}:{size.Height}:flags=fast_bilinear"
|
||||||
};
|
};
|
||||||
@@ -105,11 +105,12 @@ namespace ErsatzTV.Core.FFmpeg
|
|||||||
if (acceleration != HardwareAccelerationKind.None)
|
if (acceleration != HardwareAccelerationKind.None)
|
||||||
{
|
{
|
||||||
filterQueue.Add("hwdownload");
|
filterQueue.Add("hwdownload");
|
||||||
if (_scaleToSize.IsNone && acceleration == HardwareAccelerationKind.Nvenc ||
|
string format = acceleration switch
|
||||||
acceleration == HardwareAccelerationKind.Qsv)
|
|
||||||
{
|
{
|
||||||
filterQueue.Add("format=nv12");
|
HardwareAccelerationKind.Vaapi => "format=nv12|vaapi",
|
||||||
}
|
_ => "format=nv12"
|
||||||
|
};
|
||||||
|
filterQueue.Add(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterQueue.Add("setsar=1");
|
filterQueue.Add("setsar=1");
|
||||||
@@ -119,8 +120,12 @@ namespace ErsatzTV.Core.FFmpeg
|
|||||||
|
|
||||||
if ((_scaleToSize.IsSome || _padToSize.IsSome) && acceleration != HardwareAccelerationKind.None)
|
if ((_scaleToSize.IsSome || _padToSize.IsSome) && acceleration != HardwareAccelerationKind.None)
|
||||||
{
|
{
|
||||||
filterQueue.Add(
|
string upload = acceleration switch
|
||||||
acceleration == HardwareAccelerationKind.Qsv ? "hwupload=extra_hw_frames=64" : "hwupload");
|
{
|
||||||
|
HardwareAccelerationKind.Qsv => "hwupload=extra_hw_frames=64",
|
||||||
|
_ => "hwupload"
|
||||||
|
};
|
||||||
|
filterQueue.Add(upload);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterQueue.Any())
|
if (filterQueue.Any())
|
||||||
@@ -128,7 +133,7 @@ namespace ErsatzTV.Core.FFmpeg
|
|||||||
// TODO: any audio filter
|
// TODO: any audio filter
|
||||||
if (_audioDuration.IsSome)
|
if (_audioDuration.IsSome)
|
||||||
{
|
{
|
||||||
complexFilter.Append(";");
|
complexFilter.Append(';');
|
||||||
}
|
}
|
||||||
|
|
||||||
complexFilter.Append($"[{videoLabel}]");
|
complexFilter.Append($"[{videoLabel}]");
|
||||||
|
|||||||
Reference in New Issue
Block a user