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

+18 -3
View File
@@ -182,6 +182,17 @@ public static class EncoderSelector
return new EncoderSelection { Status = EncoderSelectionStatus.Unavailable, Settings = settings, Notices = notices };
}
/// <summary>
/// The capability's size limit takes a <paramref name="width"/>×<paramref name="height"/> frame either way round: the
/// limit is a long edge × short edge (owner review 1, phase 4: Media Foundation's software H.264 encoder, announced as
/// 4096×2304, writes portrait UHD 2160×3840 too; checked on a real encode).
/// </summary>
public static bool Takes(EncoderCapability capability, int width, int height)
{
ArgumentNullException.ThrowIfNull(capability);
return (width <= capability.MaxWidth && height <= capability.MaxHeight) || (height <= capability.MaxWidth && width <= capability.MaxHeight);
}
private static List<(IVideoEncoderProvider Provider, EncoderCapability Capability)> Candidates(IReadOnlyList<IVideoEncoderProvider> providers, VideoCodec codec) =>
[.. providers.SelectMany(p => p.Capabilities.Where(c => c.Codec == codec).Select(c => (p, c)))];
@@ -203,12 +214,16 @@ public static class EncoderSelector
s = s with { Width = check.SuggestedWidth, Height = check.SuggestedHeight };
notices.Add(new EncoderNotice(EncoderNotices.ResolutionCappedByLevel, check.HighestLevel.Name, Size(s)));
}
if (s.Width > capability.MaxWidth || s.Height > capability.MaxHeight)
if (!Takes(capability, s.Width, s.Height))
{
var scale = double.Min((double)capability.MaxWidth / s.Width, (double)capability.MaxHeight / s.Height);
// The limit turned to the frame's orientation (long edge × short edge, Takes).
var (maxWidth, maxHeight) = (s.Width >= s.Height) == (capability.MaxWidth >= capability.MaxHeight)
? (capability.MaxWidth, capability.MaxHeight)
: (capability.MaxHeight, capability.MaxWidth);
var scale = double.Min((double)maxWidth / s.Width, (double)maxHeight / s.Height);
var width = int.Max(2, (int)(s.Width * scale) & ~1);
var height = int.Max(2, (int)double.Round(width * (double)s.Height / s.Width / 2) * 2);
if (height > capability.MaxHeight) height = capability.MaxHeight & ~1;
if (height > maxHeight) height = maxHeight & ~1;
s = s with { Width = width, Height = height };
notices.Add(new EncoderNotice(EncoderNotices.ResolutionCappedByEncoder, capability.Name, Size(s)));
}