From 6ff08f723da17e7522ec5b7e3f799de97e4a03c286dcd8702dd351dff0255904 Mon Sep 17 00:00:00 2001 From: copecone Date: Fri, 10 Jul 2026 00:09:28 +0900 Subject: [PATCH] Add NTSC Support for FFmpegNativeEncoder --- RenderMod.cs | 3 +-- Util/Audio/AudioSyncCalculator.cs | 1 + Util/FFmpeg/FFmpegNativeEncoder.cs | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/RenderMod.cs b/RenderMod.cs index 272921f..8418bb7 100644 --- a/RenderMod.cs +++ b/RenderMod.cs @@ -1,6 +1,5 @@ using ADOFAIRenderer; using ADOFAIRenderer.Core; -using ADOFAIRenderer.Patch.Engine; using ADOFAIRenderer.Util; using FFmpeg.AutoGen; using MelonLoader; @@ -8,7 +7,7 @@ using MelonLoader.Utils; using UnityEngine; using UnityEngine.EventSystems; -[assembly: MelonInfo(typeof(RenderMod), "ADOFAI Renderer", "0.0.6-INDEV-AUDIO", "ADOFAI Editor Forum")] +[assembly: MelonInfo(typeof(RenderMod), "ADOFAI Renderer", "0.0.7-INDEV", "ADOFAI Editor Forum")] [assembly: MelonGame("7th Beat Games", "A Dance of Fire and Ice")] namespace ADOFAIRenderer diff --git a/Util/Audio/AudioSyncCalculator.cs b/Util/Audio/AudioSyncCalculator.cs index 8ff7609..e5e6ff8 100644 --- a/Util/Audio/AudioSyncCalculator.cs +++ b/Util/Audio/AudioSyncCalculator.cs @@ -16,6 +16,7 @@ namespace ADOFAIRenderer.Util.Audio _sampleRate = sampleRate; _fpsRational = RationalUtil.Double2MaxPrecisionInt(fps); + // NTSC if (Math.Abs(fps - 29.97) < 0.001) _fpsRational = (30000, 1001); if (Math.Abs(fps - 59.94) < 0.001) _fpsRational = (60000, 1001); if (Math.Abs(fps - 23.976) < 0.001 || Math.Abs(fps - 23.98) < 0.001) _fpsRational = (24000, 1001); diff --git a/Util/FFmpeg/FFmpegNativeEncoder.cs b/Util/FFmpeg/FFmpegNativeEncoder.cs index 27162f4..8c9cf3a 100644 --- a/Util/FFmpeg/FFmpegNativeEncoder.cs +++ b/Util/FFmpeg/FFmpegNativeEncoder.cs @@ -436,6 +436,12 @@ namespace ADOFAIRenderer.Util.FFmpeg // // 참고: https://ffmpeg.org/doxygen/trunk/structAVCodecContext.html var fpsRational = RationalUtil.Double2MaxPrecisionInt(_settings.FPS); + + // NTSC + if (Math.Abs(_settings.FPS - 29.97) < 0.001) fpsRational = (30000, 1001); + if (Math.Abs(_settings.FPS - 59.94) < 0.001) fpsRational = (60000, 1001); + if (Math.Abs(_settings.FPS - 23.976) < 0.001 || Math.Abs(_settings.FPS - 23.98) < 0.001) fpsRational = (24000, 1001); + _pCodecContext->time_base = new AVRational { num = fpsRational.Denominator, den = fpsRational.Numerator }; _pCodecContext->framerate = new AVRational @@ -519,7 +525,7 @@ namespace ADOFAIRenderer.Util.FFmpeg var qsvReady = false; int err; - bool isWindows = RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows); + var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); string childDeviceName = isWindows ? "d3d11va" : "vaapi"; AVHWDeviceType childDeviceType = isWindows ? AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA : AVHWDeviceType.AV_HWDEVICE_TYPE_VAAPI;