SHA256
forked from ADOFAIEditorForum/ADOFAIRenderer
Move Codec From Normal Config to Encoding Config
This commit is contained in:
7 files changed
+50
-13
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -388,7 +388,7 @@ namespace ADOFAIRenderer.Core
|
|||||||
|
|
||||||
private IEnumerator SetupPlay()
|
private IEnumerator SetupPlay()
|
||||||
{
|
{
|
||||||
if (Configuration.RenderAudio && GetOutputExtension(Configuration.Codec) != ".mp4")
|
if (Configuration.RenderAudio && GetOutputExtension(Configuration.EncodingConfig!.Codec) != ".mp4")
|
||||||
{
|
{
|
||||||
Configuration.AudioSampleRate = 48000;
|
Configuration.AudioSampleRate = 48000;
|
||||||
}
|
}
|
||||||
@@ -476,7 +476,7 @@ namespace ADOFAIRenderer.Core
|
|||||||
var renderFPS = Configuration.RenderFPS;
|
var renderFPS = Configuration.RenderFPS;
|
||||||
var videoFPS = Configuration.VideoFPS;
|
var videoFPS = Configuration.VideoFPS;
|
||||||
|
|
||||||
var selectedCodec = Configuration.Codec;
|
var selectedCodec = Configuration.EncodingConfig?.Codec ?? Codec.H264;
|
||||||
var ext = GetOutputExtension(selectedCodec);
|
var ext = GetOutputExtension(selectedCodec);
|
||||||
|
|
||||||
var startTime = DateTime.Now;
|
var startTime = DateTime.Now;
|
||||||
|
|||||||
+26
-2
@@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using MelonLoader.Utils;
|
using MelonLoader.Utils;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace ADOFAIRenderer.Data
|
namespace ADOFAIRenderer.Data
|
||||||
{
|
{
|
||||||
@@ -68,12 +69,35 @@ namespace ADOFAIRenderer.Data
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string json = File.ReadAllText(file);
|
string json = File.ReadAllText(file);
|
||||||
var preset = JsonConvert.DeserializeObject<RenderPreset>(json);
|
var jObject = JsonConvert.DeserializeObject<JObject>(json);
|
||||||
if (preset != null && !string.IsNullOrEmpty(preset.Name) && preset.Config != null)
|
if (jObject != null)
|
||||||
|
{
|
||||||
|
var configToken = jObject["Config"];
|
||||||
|
if (configToken is JObject configObj)
|
||||||
|
{
|
||||||
|
var legacyCodecToken = configObj["Codec"];
|
||||||
|
if (legacyCodecToken != null)
|
||||||
|
{
|
||||||
|
var encodingConfigToken = configObj["EncodingConfig"];
|
||||||
|
if (encodingConfigToken == null)
|
||||||
|
{
|
||||||
|
configObj["EncodingConfig"] = new JObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
var encodingConfigObj = (JObject)configObj["EncodingConfig"]!;
|
||||||
|
encodingConfigObj["Codec"] ??= legacyCodecToken;
|
||||||
|
|
||||||
|
configObj.Remove("Codec");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var preset = jObject.ToObject<RenderPreset>();
|
||||||
|
if (preset != null && !string.IsNullOrEmpty(preset.Name))
|
||||||
{
|
{
|
||||||
presets.Add(preset);
|
presets.Add(preset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MelonLogger.Warning($"프리셋 파일 '{Path.GetFileName(file)}' 로드 중 오류 발생: {ex.Message}");
|
MelonLogger.Warning($"프리셋 파일 '{Path.GetFileName(file)}' 로드 중 오류 발생: {ex.Message}");
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ namespace ADOFAIRenderer.Data
|
|||||||
public int RenderWidth { get; set; }
|
public int RenderWidth { get; set; }
|
||||||
public int RenderHeight { get; set; }
|
public int RenderHeight { get; set; }
|
||||||
|
|
||||||
public Codec Codec { get; set; }
|
|
||||||
public EncodingConfig? EncodingConfig { get; set; }
|
public EncodingConfig? EncodingConfig { get; set; }
|
||||||
|
|
||||||
public double DelayAfterLevelEnd { get; set; }
|
public double DelayAfterLevelEnd { get; set; }
|
||||||
@@ -26,6 +25,7 @@ namespace ADOFAIRenderer.Data
|
|||||||
|
|
||||||
public class EncodingConfig
|
public class EncodingConfig
|
||||||
{
|
{
|
||||||
|
public Codec Codec { get; set; } = Codec.H264;
|
||||||
public RateControlMode RateControlMode { get; set; }
|
public RateControlMode RateControlMode { get; set; }
|
||||||
|
|
||||||
public int Bitrate { get; set; }
|
public int Bitrate { get; set; }
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ namespace ADOFAIRenderer.UI
|
|||||||
private VisualElement _root = null!;
|
private VisualElement _root = null!;
|
||||||
private IntegerInputValidator _intValidator = null!;
|
private IntegerInputValidator _intValidator = null!;
|
||||||
private DoubleInputValidator _doubleValidator = null!;
|
private DoubleInputValidator _doubleValidator = null!;
|
||||||
private EnumDropdownBinder<Codec> _codecBinder = null!;
|
|
||||||
|
|
||||||
private Button _goRenderButton = null!;
|
private Button _goRenderButton = null!;
|
||||||
private Button _encodingConfigButton = null!;
|
private Button _encodingConfigButton = null!;
|
||||||
@@ -45,10 +44,6 @@ namespace ADOFAIRenderer.UI
|
|||||||
_intValidator.SetupValidation();
|
_intValidator.SetupValidation();
|
||||||
_doubleValidator.SetupValidation();
|
_doubleValidator.SetupValidation();
|
||||||
|
|
||||||
// Init Enum Binders & Event Listeners
|
|
||||||
_codecBinder = new EnumDropdownBinder<Codec>(_root, "CodecDropdown", Codec.H264);
|
|
||||||
_codecBinder.OnValueChanged(value => RenderManager.Instance.Configuration.Codec = value);
|
|
||||||
|
|
||||||
// Attach Button Event Listener
|
// Attach Button Event Listener
|
||||||
_goRenderButton = _root.Q<Button>("GoRenderButton");
|
_goRenderButton = _root.Q<Button>("GoRenderButton");
|
||||||
_goRenderButton?.RegisterCallback<ClickEvent>(_ => TryGoRender());
|
_goRenderButton?.RegisterCallback<ClickEvent>(_ => TryGoRender());
|
||||||
@@ -91,6 +86,7 @@ namespace ADOFAIRenderer.UI
|
|||||||
|
|
||||||
var tempConfig = new EncodingConfig
|
var tempConfig = new EncodingConfig
|
||||||
{
|
{
|
||||||
|
Codec = config.EncodingConfig.Codec,
|
||||||
RateControlMode = config.EncodingConfig.RateControlMode,
|
RateControlMode = config.EncodingConfig.RateControlMode,
|
||||||
Bitrate = config.EncodingConfig.Bitrate,
|
Bitrate = config.EncodingConfig.Bitrate,
|
||||||
MaxBitrate = config.EncodingConfig.MaxBitrate,
|
MaxBitrate = config.EncodingConfig.MaxBitrate,
|
||||||
@@ -138,6 +134,20 @@ namespace ADOFAIRenderer.UI
|
|||||||
titleRow.Add(title);
|
titleRow.Add(title);
|
||||||
_encodingConfigContainer.Add(titleRow);
|
_encodingConfigContainer.Add(titleRow);
|
||||||
|
|
||||||
|
// 2.5. 코덱 로우 (라벨 + 드롭다운)
|
||||||
|
var codecRow = CreateRow();
|
||||||
|
var codecLabel = CreateFormLabel("비디오 코덱");
|
||||||
|
var codecDropdown = new DropdownField { label = "" };
|
||||||
|
foreach (Codec codecVal in System.Enum.GetValues(typeof(Codec)))
|
||||||
|
{
|
||||||
|
codecDropdown.choices.Add(codecVal.ToString());
|
||||||
|
}
|
||||||
|
codecDropdown.value = tempConfig.Codec.ToString();
|
||||||
|
|
||||||
|
codecRow.Add(codecLabel);
|
||||||
|
codecRow.Add(codecDropdown);
|
||||||
|
_encodingConfigContainer.Add(codecRow);
|
||||||
|
|
||||||
// 3. 전송률 모드 로우 (라벨 + 드롭다운)
|
// 3. 전송률 모드 로우 (라벨 + 드롭다운)
|
||||||
var modeRow = CreateRow();
|
var modeRow = CreateRow();
|
||||||
var modeLabel = CreateFormLabel("전송률 제어 모드");
|
var modeLabel = CreateFormLabel("전송률 제어 모드");
|
||||||
@@ -259,6 +269,10 @@ namespace ADOFAIRenderer.UI
|
|||||||
{
|
{
|
||||||
tempConfig.RateControlMode = mode;
|
tempConfig.RateControlMode = mode;
|
||||||
}
|
}
|
||||||
|
if (System.Enum.TryParse<Codec>(codecDropdown.value, out var codec))
|
||||||
|
{
|
||||||
|
tempConfig.Codec = codec;
|
||||||
|
}
|
||||||
tempConfig.Bitrate = bitrateField.value;
|
tempConfig.Bitrate = bitrateField.value;
|
||||||
tempConfig.MaxBitrate = maxBitrateField.value;
|
tempConfig.MaxBitrate = maxBitrateField.value;
|
||||||
tempConfig.QP = qpField.value;
|
tempConfig.QP = qpField.value;
|
||||||
@@ -411,7 +425,6 @@ namespace ADOFAIRenderer.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_codecBinder.SetValue(config.Codec);
|
|
||||||
RenderManager.Instance.Configuration = config;
|
RenderManager.Instance.Configuration = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,8 +764,7 @@ namespace ADOFAIRenderer.UI
|
|||||||
VideoFPS = videoFpsField.value,
|
VideoFPS = videoFpsField.value,
|
||||||
DelayAfterLevelEnd = delayField.value,
|
DelayAfterLevelEnd = delayField.value,
|
||||||
ShowJudgementText = showJudgementText.value,
|
ShowJudgementText = showJudgementText.value,
|
||||||
ProcessAudio = processAudio.value,
|
ProcessAudio = processAudio.value
|
||||||
Codec = _codecBinder.Value
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(randomSeedField.text))
|
if (!string.IsNullOrEmpty(randomSeedField.text))
|
||||||
@@ -848,6 +860,7 @@ namespace ADOFAIRenderer.UI
|
|||||||
{
|
{
|
||||||
return new EncodingConfig
|
return new EncodingConfig
|
||||||
{
|
{
|
||||||
|
Codec = Codec.H264,
|
||||||
RateControlMode = RateControlMode.CBR,
|
RateControlMode = RateControlMode.CBR,
|
||||||
Bitrate = 30000, MaxBitrate = 50000,
|
Bitrate = 30000, MaxBitrate = 50000,
|
||||||
QP = 18, KeyframeInterval = 2.0,
|
QP = 18, KeyframeInterval = 2.0,
|
||||||
|
|||||||
Reference in new issue
Block a user