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.
36 lines
1.0 KiB
36 lines
1.0 KiB
namespace ErsatzTV.FFmpeg.Filter; |
|
|
|
public class FrameRateFilter : BaseFilter |
|
{ |
|
private readonly FrameState _currentState; |
|
private readonly int _frameRate; |
|
|
|
public FrameRateFilter(FrameState currentState, int frameRate) |
|
{ |
|
_currentState = currentState; |
|
_frameRate = frameRate; |
|
} |
|
|
|
public override string Filter |
|
{ |
|
get |
|
{ |
|
var frameRate = $"framerate=fps={_frameRate}:flags=-scd"; |
|
string pixelFormat = _currentState.PixelFormat.Match(pf => pf.FFmpegName, () => string.Empty); |
|
|
|
if (_currentState.FrameDataLocation == FrameDataLocation.Hardware) |
|
{ |
|
if (!string.IsNullOrWhiteSpace(pixelFormat)) |
|
{ |
|
return $"hwdownload,format={pixelFormat},{frameRate}"; |
|
} |
|
|
|
return $"hwdownload,{frameRate}"; |
|
} |
|
|
|
return frameRate; |
|
} |
|
} |
|
|
|
public override FrameState NextState(FrameState currentState) => currentState with { FrameRate = _frameRate }; |
|
}
|
|
|