mirror of https://github.com/ErsatzTV/ErsatzTV.git
9 changed files with 131 additions and 12 deletions
@ -0,0 +1,37 @@ |
|||||||
|
using ErsatzTV.FFmpeg.Format; |
||||||
|
|
||||||
|
namespace ErsatzTV.FFmpeg.Filter; |
||||||
|
|
||||||
|
public class HardwareDownloadFilter : BaseFilter |
||||||
|
{ |
||||||
|
private readonly FrameState _currentState; |
||||||
|
|
||||||
|
public HardwareDownloadFilter(FrameState currentState) |
||||||
|
{ |
||||||
|
_currentState = currentState; |
||||||
|
} |
||||||
|
|
||||||
|
public override FrameState NextState(FrameState currentState) => |
||||||
|
currentState with { FrameDataLocation = FrameDataLocation.Software }; |
||||||
|
|
||||||
|
public override string Filter |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
string hwdownload = string.Empty; |
||||||
|
if (_currentState.FrameDataLocation == FrameDataLocation.Hardware) |
||||||
|
{ |
||||||
|
hwdownload = "hwdownload"; |
||||||
|
foreach (IPixelFormat pixelFormat in _currentState.PixelFormat) |
||||||
|
{ |
||||||
|
if (!string.IsNullOrWhiteSpace(pixelFormat.FFmpegName)) |
||||||
|
{ |
||||||
|
hwdownload = $"hwdownload,format={pixelFormat.FFmpegName}"; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return hwdownload; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
namespace ErsatzTV.FFmpeg.Filter; |
||||||
|
|
||||||
|
public class WatermarkHardwareUploadFilter : BaseFilter |
||||||
|
{ |
||||||
|
private readonly FrameState _currentState; |
||||||
|
private readonly FFmpegState _ffmpegState; |
||||||
|
|
||||||
|
public WatermarkHardwareUploadFilter(FrameState currentState, FFmpegState ffmpegState) |
||||||
|
{ |
||||||
|
_currentState = currentState; |
||||||
|
_ffmpegState = ffmpegState; |
||||||
|
} |
||||||
|
|
||||||
|
public override FrameState NextState(FrameState currentState) => currentState; |
||||||
|
|
||||||
|
public override string Filter => _ffmpegState.HardwareAccelerationMode switch |
||||||
|
{ |
||||||
|
HardwareAccelerationMode.None => string.Empty, |
||||||
|
HardwareAccelerationMode.Nvenc => "hwupload_cuda", |
||||||
|
HardwareAccelerationMode.Qsv => "hwupload=extra_hw_frames=64", |
||||||
|
|
||||||
|
// leave vaapi in software since we don't (yet) use overlay_vaapi
|
||||||
|
HardwareAccelerationMode.Vaapi when _currentState.FrameDataLocation == FrameDataLocation.Software => |
||||||
|
string.Empty, |
||||||
|
|
||||||
|
_ => "hwupload" |
||||||
|
}; |
||||||
|
} |
Loading…
Reference in new issue