fix scaling behavior crop (#1928)

This commit is contained in:
Jason Dove
2024-10-26 08:38:44 -05:00
committed by GitHub
parent c0a14ba81c
commit 6c4f63ad91
4 changed files with 104 additions and 7 deletions
@@ -335,8 +335,24 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
if (channel.FFmpegProfile.ScalingBehavior is ScalingBehavior.Crop)
{
paddedSize = ffmpegVideoStream.SquarePixelFrameSizeForCrop(
new FrameSize(channel.FFmpegProfile.Resolution.Width, channel.FFmpegProfile.Resolution.Height));
bool isTooSmallToCrop = videoVersion.Height < channel.FFmpegProfile.Resolution.Height ||
videoVersion.Width < channel.FFmpegProfile.Resolution.Width;
// if any dimension is smaller than the crop, scale beyond the crop (beyond the target resolution)
if (isTooSmallToCrop)
{
foreach (IDisplaySize size in playbackSettings.ScaledSize)
{
scaledSize = new FrameSize(size.Width, size.Height);
}
paddedSize = scaledSize;
}
else
{
paddedSize = ffmpegVideoStream.SquarePixelFrameSizeForCrop(
new FrameSize(channel.FFmpegProfile.Resolution.Width, channel.FFmpegProfile.Resolution.Height));
}
cropSize = new FrameSize(
channel.FFmpegProfile.Resolution.Width,