Browse Source

fix scaling subtitles with nvidia accel (#1313)

pull/1314/head
Jason Dove 2 years ago committed by GitHub
parent
commit
0f91a43e3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 33
      ErsatzTV.FFmpeg/Filter/Cuda/SubtitleScaleNppFilter.cs
  3. 5
      ErsatzTV.FFmpeg/Pipeline/NvidiaPipelineBuilder.cs

2
CHANGELOG.md

@ -15,7 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -15,7 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
- Skip checking for subtitles to extract when subtitles are not enabled on a channel/schedule item
- Properly scale subtitles with QSV and some VAAPI configurations; now all configurations will scale subtitles
- Properly scale subtitles when using hardware acceleration
### Changed
- `HLS Direct` streaming mode

33
ErsatzTV.FFmpeg/Filter/Cuda/SubtitleScaleNppFilter.cs

@ -1,40 +1,13 @@ @@ -1,40 +1,13 @@
using ErsatzTV.FFmpeg.Format;
namespace ErsatzTV.FFmpeg.Filter.Cuda;
public class SubtitleScaleNppFilter : BaseFilter
{
private readonly FrameState _currentState;
private readonly FrameSize _paddedSize;
private readonly FrameSize _scaledSize;
public SubtitleScaleNppFilter(FrameState currentState, FrameSize scaledSize, FrameSize paddedSize)
{
_currentState = currentState;
_scaledSize = scaledSize;
_paddedSize = paddedSize;
}
public override string Filter
{
get
{
string scale = string.Empty;
if (_currentState.ScaledSize != _scaledSize)
{
var targetSize = $"{_paddedSize.Width}:{_paddedSize.Height}";
string format = string.Empty;
foreach (IPixelFormat pixelFormat in _currentState.PixelFormat)
{
format = $":format={pixelFormat.FFmpegName}";
}
scale = $"scale_npp={targetSize}{format}:force_original_aspect_ratio=1";
}
public SubtitleScaleNppFilter(FrameSize paddedSize) => _paddedSize = paddedSize;
return scale;
}
}
public override string Filter =>
$"scale_npp={_paddedSize.Width}:{_paddedSize.Height}:force_original_aspect_ratio=1";
public override FrameState NextState(FrameState currentState) => currentState;
}

5
ErsatzTV.FFmpeg/Pipeline/NvidiaPipelineBuilder.cs

@ -471,10 +471,7 @@ public class NvidiaPipelineBuilder : SoftwarePipelineBuilder @@ -471,10 +471,7 @@ public class NvidiaPipelineBuilder : SoftwarePipelineBuilder
// only scale if scaling or padding was used for main video stream
if (videoInputFile.FilterSteps.Any(s => s is ScaleFilter or ScaleCudaFilter or PadFilter))
{
var scaleFilter = new SubtitleScaleNppFilter(
currentState,
desiredState.ScaledSize,
desiredState.PaddedSize);
var scaleFilter = new SubtitleScaleNppFilter(desiredState.PaddedSize);
subtitle.FilterSteps.Add(scaleFilter);
}

Loading…
Cancel
Save