fix scaling image subs with vaapi (#2526)
This commit is contained in:
@@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Fix intermittent watermark opacity
|
||||
- Improve reliability of live remote streams; they should transcode closer to realtime in most cases
|
||||
- Dramatically improve stream startup time
|
||||
- VAAPI: fix scaling image-based subtitles (e.g. dvdsub)
|
||||
|
||||
### Changed
|
||||
- Do not use graphics engine for single, permanent watermark
|
||||
|
||||
+2
-2
@@ -283,10 +283,10 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
|
||||
|
||||
bool isComplete = true;
|
||||
|
||||
// if we are working ahead, limit to 45s
|
||||
// if we are working ahead, limit to 44s (multiple of segment size)
|
||||
if (!request.HlsRealtime)
|
||||
{
|
||||
TimeSpan limit = TimeSpan.FromSeconds(45);
|
||||
TimeSpan limit = TimeSpan.FromSeconds(44);
|
||||
|
||||
if (duration > limit)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace ErsatzTV.FFmpeg.Filter;
|
||||
|
||||
public class ScaleSubtitleImageFilter(FrameSize scaledSize) : BaseFilter
|
||||
{
|
||||
public override string Filter =>
|
||||
$"scale={scaledSize.Width}:{scaledSize.Height}:force_original_aspect_ratio=decrease,pad=w={scaledSize.Width}:h={scaledSize.Height}:x=-1:y=-1:color=black@0";
|
||||
|
||||
public override FrameState NextState(FrameState currentState) => currentState with
|
||||
{
|
||||
ScaledSize = scaledSize,
|
||||
PaddedSize = scaledSize,
|
||||
FrameDataLocation = FrameDataLocation.Software
|
||||
};
|
||||
}
|
||||
@@ -516,16 +516,16 @@ public class VaapiPipelineBuilder : SoftwarePipelineBuilder
|
||||
}
|
||||
else
|
||||
{
|
||||
var subtitleHardwareUpload = new HardwareUploadVaapiFilter(false);
|
||||
subtitle.FilterSteps.Add(subtitleHardwareUpload);
|
||||
|
||||
// only scale if scaling or padding was used for main video stream
|
||||
if (videoInputFile.FilterSteps.Any(s => s is ScaleFilter or ScaleVaapiFilter or PadFilter))
|
||||
{
|
||||
var scaleFilter = new SubtitleScaleVaapiFilter(desiredState.PaddedSize);
|
||||
var scaleFilter = new ScaleSubtitleImageFilter(desiredState.PaddedSize);
|
||||
subtitle.FilterSteps.Add(scaleFilter);
|
||||
}
|
||||
|
||||
var subtitleHardwareUpload = new HardwareUploadVaapiFilter(false);
|
||||
subtitle.FilterSteps.Add(subtitleHardwareUpload);
|
||||
|
||||
var subtitlesFilter = new OverlaySubtitleVaapiFilter();
|
||||
subtitleOverlayFilterSteps.Add(subtitlesFilter);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user