Move NTSC Handling

This commit is contained in:
copecone committed 2026-10-11 16:45:18 +09:00
1 parent 7aa8ae4b54
commit bd24152a2e
3 files changed
+19 -11

No files matched your search

+18
View File
@@ -840,6 +840,10 @@ internal static class RenderConfigWindow
{
if (_renderFpsSlider != null) target.RenderFPS = _renderFpsSlider.Value;
if (_videoFPSSlider != null) target.VideoFPS = _videoFPSSlider.Value;
target.RenderFPS = AlignNTSCFramerate(target.RenderFPS);
target.VideoFPS = AlignNTSCFramerate(target.VideoFPS);
if (_renderWidthSlider != null) target.RenderWidth = (int)Math.Round(_renderWidthSlider.Value);
if (_renderHeightSlider != null) target.RenderHeight = (int)Math.Round(_renderHeightSlider.Value);
if (_delayAfterEndSlider != null) target.DelayAfterEnd = _delayAfterEndSlider.Value;
@@ -895,6 +899,20 @@ internal static class RenderConfigWindow
target.AdvancedConfig.windPlanetColor = (_windPlanetToggle?.Value == true && _windPlanetPicker != null)
? _windPlanetPicker.Value
: null;
return;
// ReSharper disable once InconsistentNaming
double AlignNTSCFramerate(double framerate)
{
const double tolerance = 0.001;
if (Math.Abs(framerate - 29.97) < tolerance) framerate = 30000.0 / 1001;
else if (Math.Abs(framerate - 59.94) < tolerance) framerate = 60000.0 / 1001;
else if (Math.Abs(framerate - 23.976) < tolerance || Math.Abs(framerate - 23.98) < tolerance) framerate = 24000.0 / 1001;
return framerate;
}
}
private static string CustomPresetLabel => LocalizationManager.Get("ui.render_config.preset_custom");
-5
View File
@@ -15,11 +15,6 @@ internal class AudioSyncCalculator
{
_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);
}
public void Reset()
+1 -6
View File
@@ -437,16 +437,11 @@ namespace ADOFAIRenderer.Util.FFmpeg
// framerate: Framerate value giving hints to the encoder (reciprocal of time_base).
//
// RationalUtil: Converts FPS (double) into fractional form (numerator/denominator).
// e.g., 29.97 → 30000/1001 (NTSC standard)
// e.g., 60.00 -> 60/1
//
// Reference: 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