mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* add scaling behavior - crop * fix ffmpeg version check on windows (snapshot) * update dependenciespull/1446/head
23 changed files with 172 additions and 21 deletions
@ -0,0 +1,49 @@ |
|||||||
|
using ErsatzTV.FFmpeg.Format; |
||||||
|
|
||||||
|
namespace ErsatzTV.FFmpeg.Filter; |
||||||
|
|
||||||
|
public class CropFilter : BaseFilter |
||||||
|
{ |
||||||
|
private readonly FrameState _currentState; |
||||||
|
private readonly FrameSize _croppedSize; |
||||||
|
|
||||||
|
public CropFilter(FrameState currentState, FrameSize croppedSize) |
||||||
|
{ |
||||||
|
_currentState = currentState; |
||||||
|
_croppedSize = croppedSize; |
||||||
|
} |
||||||
|
|
||||||
|
public override string Filter |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
var crop = $"crop=w={_croppedSize.Width}:h={_croppedSize.Height}"; |
||||||
|
|
||||||
|
if (_currentState.FrameDataLocation == FrameDataLocation.Hardware) |
||||||
|
{ |
||||||
|
foreach (IPixelFormat pixelFormat in _currentState.PixelFormat) |
||||||
|
{ |
||||||
|
if (pixelFormat is PixelFormatVaapi) |
||||||
|
{ |
||||||
|
foreach (IPixelFormat pf in AvailablePixelFormats.ForPixelFormat(pixelFormat.Name, null)) |
||||||
|
{ |
||||||
|
return $"hwdownload,format=vaapi|{pf.FFmpegName},{crop}"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return $"hwdownload,format={pixelFormat.FFmpegName},{crop}"; |
||||||
|
} |
||||||
|
|
||||||
|
return $"hwdownload,{crop}"; |
||||||
|
} |
||||||
|
|
||||||
|
return crop; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override FrameState NextState(FrameState currentState) => currentState with |
||||||
|
{ |
||||||
|
PaddedSize = _croppedSize, |
||||||
|
FrameDataLocation = FrameDataLocation.Software |
||||||
|
}; |
||||||
|
} |
||||||
Loading…
Reference in new issue