Fix Color Space Issue

This commit is contained in:
copecone committed 2026-06-23 19:01:08 +09:00
1 parent 189612dbeb
commit 18fe547603
4 files changed
+73 -55

No files matched your search

+63 -32
View File
@@ -8,6 +8,7 @@ using ADOFAIRenderer.Data;
using ADOFAIRenderer.UI;
using ADOFAIRenderer.Util;
using ADOFAIRenderer.Util.FFmpeg;
using FFmpeg.AutoGen;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Utils;
@@ -396,8 +397,25 @@ namespace ADOFAIRenderer.Core
frameCountBase = Time.frameCount;
_frameReader?.Dispose();
_frameReader = new FrameReader();
StartFFmpegThread();
_frameReader = null;
try
{
StartFFmpegThread();
_frameReader = _activeVideoFFmpeg != null ? new FrameReader(_activeVideoFFmpeg.SelectedPixelFormat) : new FrameReader(AVPixelFormat.AV_PIX_FMT_YUV420P);
}
catch (Exception ex)
{
Melon<RenderMod>.Logger.Error($"인코더 초기화 에러: {ex}");
CommonWarningDialogUI.ShowDialog(
"인코더 오류",
$"비디오 인코더를 초기화할 수 없습니다.\n오류: {ex.Message}",
new DialogButton("확인", () =>
{
ADOBase.loader.LoadSceneWithTransition(WipeDirection.StartsFromRight, "scnEditor");
})
);
yield break;
}
StartCapturing();
scrController.instance.paused = scrController.instance.audioPaused = false;
@@ -453,37 +471,53 @@ namespace ADOFAIRenderer.Core
var fileName = startTime.ToString("yyyy-MM-dd HH-mm-ss") + ext;
_currentOutPath = Path.Combine(MelonEnvironment.GameRootDirectory, "Render", fileName);
RenderThread = new Thread(() =>
FFmpegNativeEncoder? videoFFmpeg = null;
try
{
FFmpegNativeEncoder? videoFFmpeg = null;
try
var effectiveVideoFps = Math.Min(videoFPS, renderFPS);
var settings = new FFmpegNativeEncoder.EncoderSettings
{
var effectiveVideoFps = Math.Min(videoFPS, renderFPS);
var settings = new FFmpegNativeEncoder.EncoderSettings
{
Width = Configuration.RenderWidth,
Height = Configuration.RenderHeight,
FPS = effectiveVideoFps,
Codec = selectedCodec,
Mode = Configuration.EncodingConfig!.RateControlMode,
QualityValue = Configuration.EncodingConfig.QP,
TargetBitrate = Configuration.EncodingConfig.Bitrate,
MaxBitrate = Configuration.EncodingConfig.MaxBitrate,
GopSize = Configuration.EncodingConfig.KeyframeInterval,
ForceSoftware = Configuration.EncodingConfig.ForceSoftwareEncoder
};
Width = Configuration.RenderWidth,
Height = Configuration.RenderHeight,
FPS = effectiveVideoFps,
Codec = selectedCodec,
Mode = Configuration.EncodingConfig!.RateControlMode,
QualityValue = Configuration.EncodingConfig.QP,
TargetBitrate = Configuration.EncodingConfig.Bitrate,
MaxBitrate = Configuration.EncodingConfig.MaxBitrate,
GopSize = Configuration.EncodingConfig.KeyframeInterval,
ForceSoftware = Configuration.EncodingConfig.ForceSoftwareEncoder
};
videoFFmpeg = new FFmpegNativeEncoder(settings);
SetupCaptureDirectory();
_activeVideoFFmpeg = videoFFmpeg;
videoFFmpeg = new FFmpegNativeEncoder(settings);
SetupCaptureDirectory();
_activeVideoFFmpeg = videoFFmpeg;
lock (_allVideoFFmpegInstances)
{
_allVideoFFmpegInstances.Add(videoFFmpeg);
}
videoFFmpeg.Start(_currentOutPath);
}
catch (Exception)
{
if (videoFFmpeg != null)
{
lock (_allVideoFFmpegInstances)
{
_allVideoFFmpegInstances.Add(videoFFmpeg);
_allVideoFFmpegInstances.Remove(videoFFmpeg);
}
videoFFmpeg.Start(_currentOutPath);
videoFFmpeg.Dispose();
}
_activeVideoFFmpeg = null;
throw;
}
RenderThread = new Thread(() =>
{
try
{
while (true)
{
CapturedFrame frame = default;
@@ -565,13 +599,10 @@ namespace ADOFAIRenderer.Core
catch (Exception ex)
{
Melon<RenderMod>.Logger.Error($"FFmpeg 렌더링 스레드 오류: {ex}");
videoFFmpeg?.Dispose();
if (videoFFmpeg != null)
videoFFmpeg.Dispose();
lock (_allVideoFFmpegInstances)
{
lock (_allVideoFFmpegInstances)
{
_allVideoFFmpegInstances.Remove(videoFFmpeg);
}
_allVideoFFmpegInstances.Remove(videoFFmpeg);
}
_activeVideoFFmpeg = null;
}