Browse Source

nvidia 10 bit fixes (#413)

pull/414/head
Jason Dove 5 years ago committed by GitHub
parent
commit
fd3de2d82a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ErsatzTV.Core/FFmpeg/FFmpegComplexFilter.cs
  2. 17
      ErsatzTV.Core/FFmpeg/FFmpegComplexFilterBuilder.cs
  3. 20
      ErsatzTV.Core/FFmpeg/FFmpegProcessBuilder.cs
  4. 2
      ErsatzTV.Core/FFmpeg/FFmpegProcessService.cs

2
ErsatzTV.Core/FFmpeg/FFmpegComplexFilter.cs

@ -1,4 +1,4 @@
namespace ErsatzTV.Core.FFmpeg namespace ErsatzTV.Core.FFmpeg
{ {
public record FFmpegComplexFilter(string ComplexFilter, string VideoLabel, string AudioLabel); public record FFmpegComplexFilter(string ComplexFilter, string VideoLabel, string AudioLabel, string PixelFormat);
} }

17
ErsatzTV.Core/FFmpeg/FFmpegComplexFilterBuilder.cs

@ -234,6 +234,8 @@ namespace ErsatzTV.Core.FFmpeg
_padToSize.IfSome(size => videoFilterQueue.Add($"pad={size.Width}:{size.Height}:(ow-iw)/2:(oh-ih)/2")); _padToSize.IfSome(size => videoFilterQueue.Add($"pad={size.Width}:{size.Height}:(ow-iw)/2:(oh-ih)/2"));
string outputPixelFormat = null;
if (usesSoftwareFilters && acceleration != HardwareAccelerationKind.None && if (usesSoftwareFilters && acceleration != HardwareAccelerationKind.None &&
string.IsNullOrWhiteSpace(watermarkOverlay)) string.IsNullOrWhiteSpace(watermarkOverlay))
{ {
@ -245,6 +247,19 @@ namespace ErsatzTV.Core.FFmpeg
videoFilterQueue.Add(upload); videoFilterQueue.Add(upload);
} }
if (!usesSoftwareFilters && string.IsNullOrWhiteSpace(watermarkOverlay))
{
switch (acceleration, _videoEncoder, _pixelFormat)
{
case (HardwareAccelerationKind.Nvenc, "h264_nvenc", "yuv420p10le"):
outputPixelFormat = "yuv420p";
break;
case (HardwareAccelerationKind.Nvenc, "h264_nvenc", "yuv444p10le"):
outputPixelFormat = "yuv444p";
break;
}
}
bool hasAudioFilters = audioFilterQueue.Any(); bool hasAudioFilters = audioFilterQueue.Any();
if (hasAudioFilters) if (hasAudioFilters)
{ {
@ -307,7 +322,7 @@ namespace ErsatzTV.Core.FFmpeg
var filterResult = complexFilter.ToString(); var filterResult = complexFilter.ToString();
return string.IsNullOrWhiteSpace(filterResult) return string.IsNullOrWhiteSpace(filterResult)
? Option<FFmpegComplexFilter>.None ? Option<FFmpegComplexFilter>.None
: new FFmpegComplexFilter(filterResult, videoLabel, audioLabel); : new FFmpegComplexFilter(filterResult, videoLabel, audioLabel, outputPixelFormat);
} }
} }
} }

20
ErsatzTV.Core/FFmpeg/FFmpegProcessBuilder.cs

@ -47,6 +47,7 @@ namespace ErsatzTV.Core.FFmpeg
private bool _isConcat; private bool _isConcat;
private VaapiDriver _vaapiDriver; private VaapiDriver _vaapiDriver;
private HardwareAccelerationKind _hwAccel; private HardwareAccelerationKind _hwAccel;
private string _outputPixelFormat;
public FFmpegProcessBuilder(string ffmpegPath, bool saveReports, ILogger logger) public FFmpegProcessBuilder(string ffmpegPath, bool saveReports, ILogger logger)
{ {
@ -72,7 +73,7 @@ namespace ErsatzTV.Core.FFmpeg
return this; return this;
} }
public FFmpegProcessBuilder WithHardwareAcceleration(HardwareAccelerationKind hwAccel, string pixelFormat) public FFmpegProcessBuilder WithHardwareAcceleration(HardwareAccelerationKind hwAccel, string pixelFormat, string encoder)
{ {
_hwAccel = hwAccel; _hwAccel = hwAccel;
@ -85,10 +86,11 @@ namespace ErsatzTV.Core.FFmpeg
_arguments.Add("qsv=qsv:MFX_IMPL_hw_any"); _arguments.Add("qsv=qsv:MFX_IMPL_hw_any");
break; break;
case HardwareAccelerationKind.Nvenc: case HardwareAccelerationKind.Nvenc:
string outputFormat = pixelFormat switch string outputFormat = (encoder, pixelFormat) switch
{ {
"yuv420p10le" => "p010le", ("hevc_nvenc", "yuv420p10le") => "p010le",
// "yuv444p10le" => "p016le", ("h264_nvenc", "yuv420p10le") => "p010le",
// ("hevc_nvenc", "yuv444p10le") => "p016le",
_ => "cuda" _ => "cuda"
}; };
@ -371,6 +373,11 @@ namespace ErsatzTV.Core.FFmpeg
"-sc_threshold", "0" // disable scene change detection "-sc_threshold", "0" // disable scene change detection
}; };
if (!string.IsNullOrWhiteSpace(_outputPixelFormat))
{
arguments.AddRange(new[] { "-pix_fmt", _outputPixelFormat });
}
string[] videoBitrateArgs = playbackSettings.VideoBitrate.Match( string[] videoBitrateArgs = playbackSettings.VideoBitrate.Match(
bitrate => bitrate =>
new[] new[]
@ -478,6 +485,11 @@ namespace ErsatzTV.Core.FFmpeg
_arguments.Add(filter.ComplexFilter); _arguments.Add(filter.ComplexFilter);
videoLabel = filter.VideoLabel; videoLabel = filter.VideoLabel;
audioLabel = filter.AudioLabel; audioLabel = filter.AudioLabel;
if (!string.IsNullOrWhiteSpace(filter.PixelFormat))
{
_outputPixelFormat = filter.PixelFormat;
}
}); });
_arguments.Add("-map"); _arguments.Add("-map");

2
ErsatzTV.Core/FFmpeg/FFmpegProcessService.cs

@ -64,7 +64,7 @@ namespace ErsatzTV.Core.FFmpeg
FFmpegProcessBuilder builder = new FFmpegProcessBuilder(ffmpegPath, saveReports, _logger) FFmpegProcessBuilder builder = new FFmpegProcessBuilder(ffmpegPath, saveReports, _logger)
.WithThreads(playbackSettings.ThreadCount) .WithThreads(playbackSettings.ThreadCount)
.WithHardwareAcceleration(playbackSettings.HardwareAcceleration, videoStream.PixelFormat) .WithHardwareAcceleration(playbackSettings.HardwareAcceleration, videoStream.PixelFormat, playbackSettings.VideoCodec)
.WithVaapiDriver(maybeVaapiDriver) .WithVaapiDriver(maybeVaapiDriver)
.WithQuiet() .WithQuiet()
.WithFormatFlags(playbackSettings.FormatFlags) .WithFormatFlags(playbackSettings.FormatFlags)

Loading…
Cancel
Save