use proper nvidia accel output format for 10-bit content (#865)
This commit is contained in:
@@ -17,8 +17,16 @@ public class DecoderH264Cuvid : DecoderBase
|
||||
{
|
||||
IList<string> result = base.InputOptions(inputFile);
|
||||
|
||||
result.Add("-hwaccel_output_format");
|
||||
result.Add(_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None ? "cuda" : "nv12");
|
||||
if (_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None)
|
||||
{
|
||||
result.Add("-hwaccel_output_format");
|
||||
result.Add("cuda");
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Add("-hwaccel_output_format");
|
||||
result.Add(InputBitDepth(inputFile) == 10 ? "p010le" : "nv12");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,16 @@ public class DecoderHevcCuvid : DecoderBase
|
||||
{
|
||||
IList<string> result = base.InputOptions(inputFile);
|
||||
|
||||
result.Add("-hwaccel_output_format");
|
||||
result.Add(_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None ? "cuda" : "nv12");
|
||||
if (_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None)
|
||||
{
|
||||
result.Add("-hwaccel_output_format");
|
||||
result.Add("cuda");
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Add("-hwaccel_output_format");
|
||||
result.Add(InputBitDepth(inputFile) == 10 ? "p010le" : "nv12");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,16 @@ public class DecoderMpeg2Cuvid : DecoderBase
|
||||
{
|
||||
IList<string> result = base.InputOptions(inputFile);
|
||||
|
||||
result.Add("-hwaccel_output_format");
|
||||
result.Add(_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None ? "cuda" : "nv12");
|
||||
if (_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None)
|
||||
{
|
||||
result.Add("-hwaccel_output_format");
|
||||
result.Add("cuda");
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Add("-hwaccel_output_format");
|
||||
result.Add(InputBitDepth(inputFile) == 10 ? "p010le" : "nv12");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,16 @@ public class DecoderMpeg4Cuvid : DecoderBase
|
||||
{
|
||||
IList<string> result = base.InputOptions(inputFile);
|
||||
|
||||
result.Add("-hwaccel_output_format");
|
||||
result.Add(_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None ? "cuda" : "nv12");
|
||||
if (_ffmpegState.EncoderHardwareAccelerationMode != HardwareAccelerationMode.None)
|
||||
{
|
||||
result.Add("-hwaccel_output_format");
|
||||
result.Add("cuda");
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Add("-hwaccel_output_format");
|
||||
result.Add(InputBitDepth(inputFile) == 10 ? "p010le" : "nv12");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using ErsatzTV.FFmpeg.Environment;
|
||||
using ErsatzTV.FFmpeg.Format;
|
||||
|
||||
namespace ErsatzTV.FFmpeg.Decoder;
|
||||
|
||||
@@ -20,4 +21,22 @@ public abstract class DecoderBase : IDecoder
|
||||
public bool AppliesTo(VideoInputFile videoInputFile) => true;
|
||||
|
||||
public bool AppliesTo(ConcatInputFile concatInputFile) => false;
|
||||
|
||||
protected int InputBitDepth(InputFile inputFile)
|
||||
{
|
||||
var bitDepth = 8;
|
||||
|
||||
if (inputFile is VideoInputFile videoInputFile)
|
||||
{
|
||||
foreach (VideoStream videoStream in videoInputFile.VideoStreams.HeadOrNone())
|
||||
{
|
||||
foreach (IPixelFormat pixelFormat in videoStream.PixelFormat)
|
||||
{
|
||||
bitDepth = pixelFormat.BitDepth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bitDepth;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user