SHA256
Improve Support for Floating-point FPS
This commit is contained in:
1 parent
b10f72b529
commit
5ee4a7fc51
3 files changed
+18
-14
No files matched your search
@@ -246,14 +246,16 @@ namespace ADOFAIRenderer.Component
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var workingFps = (float)(targetFps % videoFps == 0.0 ? videoFps : targetFps);
|
var quotient = targetFps / videoFps;
|
||||||
var videoFFmpeg = new VideoFFmpeg(Configuration.RenderWidth, Configuration.RenderHeight, (int)workingFps, (int)videoFps, selectedCodec);
|
var isMultiple = Math.Abs(quotient - Math.Round(quotient)) < 1e-9;
|
||||||
|
var workingFps = isMultiple ? videoFps : targetFps;
|
||||||
|
var videoFFmpeg = new VideoFFmpeg(Configuration.RenderWidth, Configuration.RenderHeight, workingFps, videoFps, selectedCodec);
|
||||||
|
|
||||||
SetupCaptureDirectory();
|
SetupCaptureDirectory();
|
||||||
|
|
||||||
videoFFmpeg.Start(_currentOutPath, bitrate);
|
videoFFmpeg.Start(_currentOutPath, bitrate);
|
||||||
|
|
||||||
int num = targetFps % videoFps != 0.0 ? 1 : (int)(targetFps / videoFps);
|
var num = isMultiple ? (int)Math.Round(quotient) : 1;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-8
@@ -95,14 +95,15 @@ namespace ADOFAIRenderer
|
|||||||
// 60회 초과 시 최후의 블랙 프레임 삽입하여 전체 파이프라인 마비 방지
|
// 60회 초과 시 최후의 블랙 프레임 삽입하여 전체 파이프라인 마비 방지
|
||||||
Melon<RenderMod>.Logger.Error($"[Render Skipped] Frame {RenderManager.FrameCount} rendering failed after 60 retries. Supplying black frame.");
|
Melon<RenderMod>.Logger.Error($"[Render Skipped] Frame {RenderManager.FrameCount} rendering failed after 60 retries. Supplying black frame.");
|
||||||
|
|
||||||
var targetFps = (int)RenderManager.Configuration.TargetFPS;
|
var targetFps = RenderManager.Configuration.TargetFPS;
|
||||||
var videoFps = (int)RenderManager.Configuration.VideoFPS;
|
var videoFps = RenderManager.Configuration.VideoFPS;
|
||||||
var num = targetFps % videoFps != 0 ? 1 : targetFps / videoFps;
|
var quotient = targetFps / videoFps;
|
||||||
|
var num = Math.Abs(quotient - Math.Round(quotient)) < 1e-9 ? (int)Math.Round(quotient) : 1;
|
||||||
|
|
||||||
if (FrameCountForVideo % num == 0)
|
if (FrameCountForVideo % num == 0)
|
||||||
{
|
{
|
||||||
int byteSize = RenderManager.Configuration.RenderWidth * RenderManager.Configuration.RenderHeight * 4;
|
var byteSize = RenderManager.Configuration.RenderWidth * RenderManager.Configuration.RenderHeight * 4;
|
||||||
byte[] blackFrame = System.Buffers.ArrayPool<byte>.Shared.Rent(byteSize);
|
var blackFrame = System.Buffers.ArrayPool<byte>.Shared.Rent(byteSize);
|
||||||
Array.Clear(blackFrame, 0, byteSize);
|
Array.Clear(blackFrame, 0, byteSize);
|
||||||
|
|
||||||
lock (RenderManager.ImageQueue)
|
lock (RenderManager.ImageQueue)
|
||||||
@@ -119,10 +120,10 @@ namespace ADOFAIRenderer
|
|||||||
RenderCheck = true; // 다음 프레임 검사용으로 초기화
|
RenderCheck = true; // 다음 프레임 검사용으로 초기화
|
||||||
RenderManager.FrameCount++;
|
RenderManager.FrameCount++;
|
||||||
|
|
||||||
if (realDeltaTime > 0)
|
/*if (realDeltaTime > 0)
|
||||||
{
|
{
|
||||||
Time.timeScale = (float)(Time.deltaTime / realDeltaTime);
|
Time.timeScale = (float)(Time.deltaTime / realDeltaTime);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int FrameCountForVideo;
|
public static int FrameCountForVideo;
|
||||||
@@ -163,7 +164,8 @@ namespace ADOFAIRenderer
|
|||||||
|
|
||||||
var targetFps = RenderManager.Configuration.TargetFPS;
|
var targetFps = RenderManager.Configuration.TargetFPS;
|
||||||
var videoFps = RenderManager.Configuration.VideoFPS;
|
var videoFps = RenderManager.Configuration.VideoFPS;
|
||||||
var num = targetFps % videoFps != 0.0 ? 1 : (int)(targetFps / videoFps);
|
var quotient = targetFps / videoFps;
|
||||||
|
var num = Math.Abs(quotient - Math.Round(quotient)) < 1e-9 ? (int)Math.Round(quotient) : 1;
|
||||||
|
|
||||||
if (currentFrame % num != 0)
|
if (currentFrame % num != 0)
|
||||||
{
|
{
|
||||||
|
|||||||
+3
-3
@@ -25,8 +25,8 @@ namespace ADOFAIRenderer.Util
|
|||||||
|
|
||||||
public int Width;
|
public int Width;
|
||||||
public int Height;
|
public int Height;
|
||||||
public int FrameRate;
|
public double FrameRate;
|
||||||
public int VideoFPS;
|
public double VideoFPS;
|
||||||
public Codec VideoCodec;
|
public Codec VideoCodec;
|
||||||
|
|
||||||
private static string Codec2String(Codec c)
|
private static string Codec2String(Codec c)
|
||||||
@@ -48,7 +48,7 @@ namespace ADOFAIRenderer.Util
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public VideoFFmpeg(int w, int h, int frame, int videoFrame, Codec codec)
|
public VideoFFmpeg(int w, int h, double frame, double videoFrame, Codec codec)
|
||||||
{
|
{
|
||||||
Width = w;
|
Width = w;
|
||||||
Height = h;
|
Height = h;
|
||||||
|
|||||||
Reference in new issue
Block a user