mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-14 02:04:14 +01:00
parent
e264c93f67
commit
679b1b4c47
1 changed files with 17 additions and 17 deletions
|
@ -104,31 +104,31 @@ private static FFMpegArguments BuildSnapshotArguments(MediaAnalysis source, Size
|
||||||
.Resize(size);
|
.Resize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Size? PrepareSnapshotSize(MediaAnalysis source, Size? size)
|
private static Size? PrepareSnapshotSize(MediaAnalysis source, Size? wantedSize)
|
||||||
{
|
{
|
||||||
if (size == null || (size.Value.Height == 0 && size.Value.Width == 0))
|
if (wantedSize == null || (wantedSize.Value.Height <= 0 && wantedSize.Value.Width <= 0))
|
||||||
size = new Size(source.PrimaryVideoStream.Width, source.PrimaryVideoStream.Height);
|
return null;
|
||||||
|
|
||||||
if (size.Value.Width != size.Value.Height)
|
var currentSize = new Size(source.PrimaryVideoStream.Width, source.PrimaryVideoStream.Height);
|
||||||
{
|
if (source.PrimaryVideoStream.Rotation == 90 || source.PrimaryVideoStream.Rotation == 180)
|
||||||
if (size.Value.Width == 0)
|
currentSize = new Size(source.PrimaryVideoStream.Height, source.PrimaryVideoStream.Width);
|
||||||
{
|
|
||||||
var ratio = (double)size.Value.Height / source.PrimaryVideoStream.Height;
|
|
||||||
|
|
||||||
size = new Size((int)(source.PrimaryVideoStream.Width * ratio),
|
if (wantedSize.Value.Width != currentSize.Width || wantedSize.Value.Height != currentSize.Height)
|
||||||
(int)(source.PrimaryVideoStream.Height * ratio));
|
{
|
||||||
|
if (wantedSize.Value.Width <= 0 && wantedSize.Value.Height > 0)
|
||||||
|
{
|
||||||
|
var ratio = (double)wantedSize.Value.Height / currentSize.Height;
|
||||||
|
return new Size((int)(currentSize.Width * ratio), (int)(currentSize.Height * ratio));
|
||||||
|
}
|
||||||
|
if (wantedSize.Value.Height <= 0 && wantedSize.Value.Width > 0)
|
||||||
|
{
|
||||||
|
var ratio = (double)wantedSize.Value.Width / currentSize.Width;
|
||||||
|
return new Size((int)(currentSize.Width * ratio), (int)(currentSize.Height * ratio));
|
||||||
|
}
|
||||||
|
return wantedSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size.Value.Height == 0)
|
return null;
|
||||||
{
|
|
||||||
var ratio = (double)size.Value.Width / source.PrimaryVideoStream.Width;
|
|
||||||
|
|
||||||
size = new Size((int)(source.PrimaryVideoStream.Width * ratio),
|
|
||||||
(int)(source.PrimaryVideoStream.Height * ratio));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue