feat(server): route renders by settings format and adapted size; gate older servers

Owner review 1, phase 4 (P5). A render job now carries the output size its
settings give (RenderSize, proportions win) and the settings format it needs,
resolved on the server before the job is split, so only nodes that read that
format and whose encoder takes the frame claim it, and a job no online node
can read no longer waits for one. Nodes and the server announce the format
they read; settings of a newer Chronos fail saying so.

Encoder size limits are read as long edge x short edge: Media Foundation's
software H.264 encoder, announced as 4096x2304, accepts portrait 2160x3840
(probed on this PC), so EncoderSelector and the provider take either
orientation and cap a portrait frame against the turned limit.

On the desktop, Sync and Send-and-render are disabled with the
NeedsNewerServer tooltip while the server reads an older format than the
working settings need.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-04 19:48:23 +01:00
1 parent e4364c4f25
commit fca6c8dfea
27 files changed
+663 -47

No files matched your search

@@ -1,3 +1,4 @@
using Chronos.Core.Export;
using Chronos.Core.Imaging;
using Chronos.Core.Video;
using Chronos.Core.Windows.MediaFoundation;
@@ -143,6 +144,61 @@ public sealed class MediaFoundationEncoderTests(TestContext context)
Assert.Equal(60, report.FrameCount);
}
/// <summary>
/// Owner review 1, phase 4: 4K at 9:16 is 2160×3840. Each H.264 encoder of this machine is asked for portrait UHD and
/// its landscape twin: none takes one and refuses the other, so the announced limits are a long edge × short edge
/// (<see cref="EncoderSelector.Takes"/>), and portrait UHD is announced wherever landscape UHD is. Encoders that refuse
/// both (Microsoft's DX12 encoder on some GPUs) are left to the provider, which then opens the next one.
/// </summary>
[Test]
[WindowsOnly]
[Timeout(180_000)]
public void PortraitUhdH264EncodesWhereLandscapeDoes()
{
RequireMediaFoundation();
var provider = new MediaFoundationEncoderProvider();
var h264 = provider.Capabilities.Where(c => c.Codec == VideoCodec.H264).ToList();
if (h264.Count == 0) TestContext.Skip("No H.264 encoder on this machine");
foreach (var capability in h264)
{
var (portrait, landscape) = (Accepts(capability, 2160, 3840), Accepts(capability, 3840, 2160));
Assert.Equal(landscape, portrait, $"{capability.Name} takes portrait UHD as it takes landscape UHD");
Assert.Equal(EncoderSelector.Takes(capability, 3840, 2160), EncoderSelector.Takes(capability, 2160, 3840), "announced either way round");
}
var request = Settings(Path.Combine(context.CreateTempDirectory(), "portrait.mp4"), VideoCodec.H264, 8);
Assert.Equal(provider.CanEncode(request with { Width = 3840, Height = 2160 }), provider.CanEncode(request with { Width = 2160, Height = 3840 }));
bool Accepts(EncoderCapability capability, int width, int height)
{
var settings = Settings(Path.Combine(context.CreateTempDirectory(), $"{width}x{height}.mp4"), VideoCodec.H264, 8) with
{
Width = width,
Height = height,
EncoderName = capability.Name,
PreferHardware = capability.Hardware,
BitRate = 20_000_000,
};
try
{
using (var session = provider.Open(settings))
{
using var frame = new ImageBuffer(width, height);
for (var c = 0; c < 3; c++) frame.Plane(c).Fill(0.25f);
for (var f = 0; f < 3; f++) session.WriteFrame(frame, Frame30);
session.Complete();
}
var report = Mp4Inspector.Inspect(settings.OutputPath);
context.Log($"{capability.Name} {width}×{height}: {report}");
return report.IsValid && (report.Width, report.Height) == (width, height);
}
catch (NotSupportedException ex)
{
context.Log($"{capability.Name} {width}×{height}: refused ({ex.InnerException?.Message ?? ex.Message})");
return false;
}
}
}
[Test]
[WindowsOnly]
[Timeout(60_000)]