SHA256
Compare commits
3
Commits
48a56cd3f2
...
888663aa86
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
888663aa86
|
||
|
|
1a8fcaec7d
|
||
|
|
394fe00b25
|
No files matched your search
+4
-12
@@ -364,9 +364,10 @@ internal class RenderManager : MonoBehaviour
|
||||
|
||||
private IEnumerator SetupPlay()
|
||||
{
|
||||
if (Configuration.AudioConfig.RenderAudio && Configuration.VideoConfig.Codec is Codec.VP9 or Codec.AV1 or Codec.VVC)
|
||||
if (Configuration.AudioConfig.RenderAudio)
|
||||
{
|
||||
if (Configuration.AudioConfig.AudioSampleRate == 44100) Configuration.AudioConfig.AudioSampleRate = 48000;
|
||||
if (!CodecUtil.AvailableSampleRate[CodecUtil.AudioCodecMatch[Configuration.VideoConfig.Codec]].Contains(Configuration.AudioConfig.AudioSampleRate))
|
||||
Configuration.AudioConfig.AudioSampleRate = 48000; // most compatible value
|
||||
}
|
||||
|
||||
for (; countdown > 0; countdown--)
|
||||
@@ -463,7 +464,7 @@ internal class RenderManager : MonoBehaviour
|
||||
try
|
||||
{
|
||||
var effectiveVideoFps = Math.Min(videoFPS, renderFPS);
|
||||
var codecId = AudioCodecMatch[Configuration.VideoConfig.Codec];
|
||||
var codecId = CodecUtil.AudioCodecMatch[Configuration.VideoConfig.Codec];
|
||||
var settings = new FFmpegNativeEncoder.EncoderSettings
|
||||
{
|
||||
Width = Configuration.RenderWidth,
|
||||
@@ -816,13 +817,4 @@ internal class RenderManager : MonoBehaviour
|
||||
Melon<RenderMod>.Logger.Error($"OnLastUpdate callback caused error: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Dictionary<Codec, AVCodecID> AudioCodecMatch = new()
|
||||
{
|
||||
[Codec.H264] = AVCodecID.AV_CODEC_ID_AAC,
|
||||
[Codec.H265] = AVCodecID.AV_CODEC_ID_AAC,
|
||||
[Codec.VP9] = AVCodecID.AV_CODEC_ID_OPUS,
|
||||
[Codec.AV1] = AVCodecID.AV_CODEC_ID_OPUS,
|
||||
[Codec.VVC] = AVCodecID.AV_CODEC_ID_OPUS
|
||||
};
|
||||
}
|
||||
@@ -57,8 +57,8 @@ public class AudioEncodingConfig
|
||||
|
||||
public int AudioSampleRate
|
||||
{
|
||||
get => _audioSampleRate <= 0 ? 44100 : _audioSampleRate;
|
||||
set => _audioSampleRate = value <= 0 ? 44100 : value;
|
||||
get => _audioSampleRate <= 0 ? 48000 : _audioSampleRate;
|
||||
set => _audioSampleRate = value <= 0 ? 48000 : value;
|
||||
}
|
||||
|
||||
public int AudioChannels
|
||||
|
||||
@@ -102,6 +102,20 @@ internal static class RenderConfigWindow
|
||||
|
||||
double[] audioBitrateSnap = { 64, 96, 128, 192, 256, 320, 384 };
|
||||
|
||||
double[] renderWidthSnap = {
|
||||
256, 426, 640, 854, 960, 1280, 1366, 1600, 1920, 2048, 2560, 3200, 3840, 4096, 5120, 5760, 6016, 7680, 10240, 15360, // 16:9
|
||||
230, 384, 576, 768, 1152, 1440, 1680, 2880, 3072, // 16:10
|
||||
192, 320, 480, 800, 1024, 1400, 2732, 6400, 11520 // 4:3
|
||||
};
|
||||
|
||||
double[] renderHeightSnap = {
|
||||
144, 240, 360, 480, 540, 720, 768, 900, 1080, 1152, 1440, 1800, 2160, 2304, 2880, 3240, 3384, 4320, 5760, 8640, // 16:9
|
||||
400, 600, 800, 1050, 1200, 1600, 1920, 2400, 3200, 4800, 9600, // 16:10
|
||||
864, 960, 1536, 2048, 3072 // 4:3
|
||||
};
|
||||
|
||||
// TODO: Presets
|
||||
|
||||
// 1-3. Top section: 좌/우 컨테이너 1개씩으로 3행을 쌓는다 (중앙선 1개)
|
||||
var (topLeft, topRight) = CreateTwoColumnPanel(scrollContent, spacing: 8f, columnSpacing: 10f);
|
||||
|
||||
@@ -132,7 +146,7 @@ internal static class RenderConfigWindow
|
||||
defaultValue: 2560, min: 0, max: 15360, value: 2560,
|
||||
format: "F0", clampMode: ClampMode.All,
|
||||
|
||||
sliderFilter: value => Math.Max(value, 2), inputFilter: value => Math.Max(value, 2),
|
||||
sliderFilter: value => renderWidthSnap.OrderBy(n => Math.Abs(n - value)).First(), inputFilter: value => Math.Max(value, 2),
|
||||
onComplete: null, onChanged: val => { config.RenderWidth = (int)Math.Round(val); },
|
||||
text: LocalizationManager.Get("ui.render_config.render_width"),
|
||||
id: "slider_render_width", showFill: true
|
||||
@@ -143,7 +157,7 @@ internal static class RenderConfigWindow
|
||||
defaultValue: 1440, min: 0, max: 8640, value: 1440,
|
||||
format: "F0", clampMode: ClampMode.All,
|
||||
|
||||
sliderFilter: value => Math.Max(value, 2), inputFilter: value => Math.Max(value, 2),
|
||||
sliderFilter: value => renderHeightSnap.OrderBy(n => Math.Abs(n - value)).First(), inputFilter: value => Math.Max(value, 2),
|
||||
onComplete: null, onChanged: val => { config.RenderWidth = (int)Math.Round(val); },
|
||||
text: LocalizationManager.Get("ui.render_config.render_height"),
|
||||
id: "slider_render_height", showFill: true
|
||||
@@ -188,8 +202,12 @@ internal static class RenderConfigWindow
|
||||
Codec.H264, config.VideoConfig.Codec,
|
||||
codecs, c => c.ToString(),
|
||||
"dd_video_codec",
|
||||
c => config.VideoConfig.Codec = c
|
||||
);
|
||||
c =>
|
||||
{
|
||||
config.VideoConfig.Codec = c;
|
||||
UpdateVideoCodec(c);
|
||||
});
|
||||
|
||||
_bitrateInput = CreateInputField(
|
||||
ctx, CreateFieldSlot(videoLeft),
|
||||
LocalizationManager.Get("ui.render_config.bitrate"),
|
||||
@@ -198,6 +216,7 @@ internal static class RenderConfigWindow
|
||||
TMPro.TMP_InputField.CharacterValidation.Integer,
|
||||
val => { if (int.TryParse(val, out var b) && b > 0) config.VideoConfig.Bitrate = b; }
|
||||
);
|
||||
|
||||
_qpInput = CreateInputField(
|
||||
ctx, CreateFieldSlot(videoLeft),
|
||||
LocalizationManager.Get("ui.render_config.qp"),
|
||||
@@ -216,6 +235,7 @@ internal static class RenderConfigWindow
|
||||
"dd_rate_control",
|
||||
m => config.VideoConfig.RateControlMode = m
|
||||
);
|
||||
|
||||
_maxBitrateInput = CreateInputField(
|
||||
ctx, CreateFieldSlot(videoRight),
|
||||
LocalizationManager.Get("ui.render_config.max_bitrate"),
|
||||
@@ -227,7 +247,7 @@ internal static class RenderConfigWindow
|
||||
|
||||
_forceSoftwareToggle = CreateToggleField(
|
||||
ctx, CreateFieldSlot(videoRight), "",
|
||||
true, config.VideoConfig.ForceSoftwareEncoder,
|
||||
false, config.VideoConfig.ForceSoftwareEncoder,
|
||||
LocalizationManager.Get("ui.render_config.force_software"),
|
||||
"toggle_force_software",
|
||||
val => config.AudioConfig.RenderAudio = val,
|
||||
@@ -384,6 +404,7 @@ internal static class RenderConfigWindow
|
||||
"dd_adv_file_extension",
|
||||
e => { if (!string.IsNullOrEmpty(e)) config.AdvancedConfig.FileExtension = e; }
|
||||
);
|
||||
|
||||
_processAudioToggle = CreateToggleField(
|
||||
ctx, CreateFieldSlot(advLeft), "",
|
||||
true, config.AdvancedConfig.ProcessAudio,
|
||||
@@ -405,6 +426,7 @@ internal static class RenderConfigWindow
|
||||
else if (string.IsNullOrWhiteSpace(val)) config.AdvancedConfig.RandomSeed = null;
|
||||
}
|
||||
);
|
||||
|
||||
_nonTileToggle = CreateToggleField(
|
||||
ctx, CreateFieldSlot(advRight), "",
|
||||
false, config.AdvancedConfig.NonTile,
|
||||
@@ -422,6 +444,13 @@ internal static class RenderConfigWindow
|
||||
"btn_go_render",
|
||||
height: 48f
|
||||
);
|
||||
|
||||
return;
|
||||
|
||||
void UpdateVideoCodec(Codec codec)
|
||||
{
|
||||
_sampleRateDropdown?.SetValues(CodecUtil.AvailableSampleRate[CodecUtil.AudioCodecMatch[codec]]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnsureDefaultConfig(RenderConfig config)
|
||||
|
||||
+21
-1
@@ -1,4 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using FFmpeg.AutoGen;
|
||||
|
||||
namespace ADOFAIRenderer.Util.FFmpeg
|
||||
{
|
||||
@@ -7,4 +9,22 @@ namespace ADOFAIRenderer.Util.FFmpeg
|
||||
{
|
||||
H264, H265, VP9, AV1, VVC
|
||||
}
|
||||
|
||||
internal static class CodecUtil
|
||||
{
|
||||
public static readonly Dictionary<Codec, AVCodecID> AudioCodecMatch = new()
|
||||
{
|
||||
[Codec.H264] = AVCodecID.AV_CODEC_ID_AAC,
|
||||
[Codec.H265] = AVCodecID.AV_CODEC_ID_AAC,
|
||||
[Codec.VP9] = AVCodecID.AV_CODEC_ID_OPUS,
|
||||
[Codec.AV1] = AVCodecID.AV_CODEC_ID_OPUS,
|
||||
[Codec.VVC] = AVCodecID.AV_CODEC_ID_OPUS
|
||||
};
|
||||
|
||||
public static readonly Dictionary<AVCodecID, List<int>> AvailableSampleRate = new()
|
||||
{
|
||||
[AVCodecID.AV_CODEC_ID_AAC] = new List<int> { 44100, 48000, 96000 },
|
||||
[AVCodecID.AV_CODEC_ID_OPUS] = new List<int> { 48000, 96000 }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1536,9 +1536,9 @@ namespace ADOFAIRenderer.Util.FFmpeg
|
||||
if (_pAudioCodecContext == null)
|
||||
throw new Exception("Failed to allocate audio codec context.");
|
||||
|
||||
var sampleRate = audioSettings.SampleRate > 0 ? audioSettings.SampleRate : 44100;
|
||||
var sampleRate = audioSettings.SampleRate > 0 ? audioSettings.SampleRate : 48000;
|
||||
var channels = audioSettings.Channels > 0 ? audioSettings.Channels : 2;
|
||||
var bitrate = audioSettings.Bitrate > 0 ? audioSettings.Bitrate : 128000;
|
||||
var bitrate = audioSettings.Bitrate > 0 ? audioSettings.Bitrate : 256000;
|
||||
|
||||
// Select the first sample format supported by the encoder.
|
||||
// Most encoders prefer AV_SAMPLE_FMT_FLTP (float planar).
|
||||
|
||||
Reference in new issue
Block a user