mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
namespace ErsatzTV.FFmpeg.Filter; |
|
|
|
public class PadFilter : BaseFilter |
|
{ |
|
private readonly FrameState _currentState; |
|
private readonly FrameSize _paddedSize; |
|
|
|
public PadFilter(FrameState currentState, FrameSize paddedSize) |
|
{ |
|
_currentState = currentState; |
|
_paddedSize = paddedSize; |
|
} |
|
|
|
public override string Filter |
|
{ |
|
get |
|
{ |
|
string pad = $"pad={_paddedSize.Width}:{_paddedSize.Height}:-1:-1:color=black"; |
|
string pixelFormat = _currentState.PixelFormat.Match(pf => pf.FFmpegName, () => string.Empty); |
|
|
|
if (_currentState.FrameDataLocation == FrameDataLocation.Hardware) |
|
{ |
|
if (!string.IsNullOrWhiteSpace(pixelFormat)) |
|
{ |
|
return $"hwdownload,format={pixelFormat},{pad}"; |
|
} |
|
|
|
return $"hwdownload,{pad}"; |
|
} |
|
|
|
return pad; |
|
} |
|
} |
|
|
|
public override FrameState NextState(FrameState currentState) => currentState with |
|
{ |
|
PaddedSize = _paddedSize, |
|
FrameDataLocation = FrameDataLocation.Software |
|
}; |
|
}
|
|
|