feat(P6): grouped Export panel with preset table, encoding and playback rows

The Export step's cards and long form gave no room for the advanced
encoding settings and the new playback contract. The Output panel is now
four collapsible groups (Output, Encoding, Playback, File) with a muted
summary while closed and a fixed footer (result line, Render now, Add to
queue, Batch (n), Videos (n), Reveal, Send again). Presets become a 28 px
table grouped by preset group.

- Encoding: rate control, bit rate or quality, keyframes in seconds kept
  across a frame rate change, B-frames and profile, each gated per codec
  and depth with the reason in the tooltip.
- Resolution: Preset, Source, the standard boxes fitted to the chosen
  proportions (4K at 9:16 renders 2160 x 3840) and Custom.
- Playback: direction (Boomerang gated with star trails), loops, fades
  and hold; a non-default playback writes settings format 3.
- Group open state is kept by the app through EditorSettings.Groups
  (bound to the app settings later), not in the project.
- ExportPlan carries the output program for duration and frame count.
- The tab resolves the export at once instead of from a stale plan.

Refs #21

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-05 02:26:04 +01:00
1 parent d472dfdec1
commit 503b5f766a
12 files changed
+1663 -336

No files matched your search

+485 -163
View File
@@ -19,77 +19,6 @@ using Chronos.Ui.Mvvm;
namespace Chronos.App.Editor;
/// <summary>A preset card of the Export tab (Export.html): what it renders and what it will cost on this machine.</summary>
public sealed class PresetCard(ExportTab owner, ExportChoice choice) : ObservableObject
{
private string? _format;
private string? _encoding;
private string? _estimate;
private bool _isSelected;
public ExportChoice Choice { get; } = choice;
public string Name => Choice.Name;
public bool IsRecommended => Choice.IsRecommended;
/// <summary>Sequence presets apply full settings; export presets only choose the output.</summary>
public bool IsSequencePreset => Choice.Sequence is not null;
/// <summary>What choosing the card does, or why it cannot be chosen now (a job runs, the project cannot change).</summary>
public string ToolTip => owner.Editor.LockedToolTip ?? (Choice.Reason is { } reason
? Loc.L(IsSequencePreset ? "Tooltips.Editor.Export.ApplyPreset" : "Tooltips.Editor.Export.Recommended", reason)
: Loc.L("Tooltips.Editor.Export.Preset", Name));
public string BatchToolTip => owner.Editor.LockedToolTip ?? Loc.L("Tooltips.Editor.Export.InBatch");
/// <summary>"MP4 · HEVC Main10 · 3840×2160 · 24 fps".</summary>
public string? Format { get => _format; private set => Set(ref _format, value); }
/// <summary>"120 Mb/s · 0.07 bpp · NVENC".</summary>
public string? Encoding { get => _encoding; private set => Set(ref _encoding, value); }
/// <summary>"2.2 GB · about 5 min".</summary>
public string? Estimate { get => _estimate; private set => Set(ref _estimate, value); }
public bool IsSelected { get => _isSelected; set => Set(ref _isSelected, value); }
/// <summary>Ticked for "Batch…" (export presets only).</summary>
public bool IsInBatch
{
get => owner.IsInBatch(Choice.ExportPresetId);
set => owner.SetInBatch(Choice.ExportPresetId, value);
}
public bool CanBatch => !IsSequencePreset;
public ICommand SelectCommand => owner.SelectCommand;
/// <remarks>A server sequence renders on the server: this PC's encoders neither name nor rule out the encoding.</remarks>
public void Update(ExportPlan? plan)
{
if (plan is null)
{
Format = Encoding = Estimate = null;
return;
}
var settings = plan.Setup.Encoder.Settings;
var remote = owner.Editor.IsRemote;
Format = EditorText.Format(plan.Export, settings.Width, settings.Height);
Encoding = EditorText.Encoding(plan.Export, settings.BitRate, remote ? null : plan.Setup.Encoder.Capability?.Name);
Estimate = remote || plan.Setup.Encoder.IsReady ? EditorText.Estimate(plan.Estimate) : Loc.L("Editor.Export.Unavailable");
}
public void RefreshBatch() => OnPropertyChanged(nameof(IsInBatch));
/// <summary>A job of the sequence started or ended, or the project became read-only: the tooltips say why the card waits.</summary>
public void RefreshLocked()
{
OnPropertyChanged(nameof(ToolTip));
OnPropertyChanged(nameof(BatchToolTip));
}
}
/// <summary>A codec choice of the Output panel with the profile and depth it implies.</summary>
public sealed record CodecChoice(VideoCodec Codec, CodecProfile Profile, int BitDepth)
{
@@ -104,10 +33,15 @@ public sealed record SaveChoice(string? Folder, bool Browse = false)
public string Label => Browse ? Loc.L("Editor.Export.Browse") : Folder is null ? Loc.L("Editor.Export.SequenceFolder") : Path.GetFileName(Folder.TrimEnd('\\', '/'));
}
/// <summary>A choice that may not apply now (Boomerang with star trails): disabled in the list, its reason in the tooltip.</summary>
public sealed record GatedChoice(object Value, string Label, bool IsAvailable, string ToolTip);
/// <summary>
/// Export (Export.html, BRIEF §11.4–11.5): preset cards with size and time estimates, the Output panel (container,
/// codec, size, frame rate, quality, encoder, colour depth, name template, folder) with the estimate and the encoder's
/// notices, and the render actions (now, queue, batch). Editing a value makes the preset "Custom" (§11.4).
/// Export (Export.html, BRIEF §11.4–11.5, owner review 1 R3/R8): the preset table with size and time estimates, the Output
/// panel in four collapsible groups (Output: container, codec, resolution, frame rate, colour depth; Encoding: encoder,
/// rate control, bit rate or quality, keyframes, B-frames, profile; Playback: direction, loops, fades, hold; File: name
/// template, folder, sync, restore), the encoder's notices, and a fixed footer with the result line and the render
/// actions (now, queue, batch). Editing a value makes the preset "Custom" (§11.4).
/// </summary>
public sealed class ExportTab : EditorTab
{
@@ -119,79 +53,138 @@ public sealed class ExportTab : EditorTab
new(VideoCodec.Tiff16Sequence, CodecProfile.Auto, 16), new(VideoCodec.LinearDngSequence, CodecProfile.Auto, 16),
];
/// <summary>The Resolution choice's value for the preset's own box (no override).</summary>
public const string PresetResolution = "preset";
/// <summary>The Resolution choice's value for the source size (a box of 0 × 0).</summary>
public const string SourceResolution = "source";
/// <summary>The Resolution choice's value that shows the Width × Height fields.</summary>
public const string CustomResolution = "custom";
/// <summary>The longest fade or hold the sliders reach (seconds); the fields take up to the playback's own limits.</summary>
public const double SliderSeconds = 10;
private readonly LatestRunner _estimates = new(TimeSpan.FromMilliseconds(250));
private readonly AsyncRelayCommand _renderNow;
private readonly AsyncRelayCommand _addToQueue;
private readonly AsyncRelayCommand _batch;
private readonly AsyncRelayCommand _restore;
private SavedCopy? _selectedCopy;
private IReadOnlyList<PresetCard> _cards = [];
private IReadOnlyList<PresetRow> _presets = [];
private IReadOnlyList<PresetGroup> _presetGroups = [];
private IReadOnlyList<CodecChoice> _codecChoices = [];
private IReadOnlyList<Choice> _encoders = [];
private IReadOnlyList<SaveChoice> _saveChoices = [];
private IReadOnlyList<Choice> _depths = [];
private IReadOnlyList<Choice> _keyframeChoices = [];
private IReadOnlyList<Choice> _bFrameChoices = [];
private IReadOnlyList<Choice> _profileChoices = [];
private IReadOnlyList<GatedChoice> _directions = [];
private IReadOnlyList<string> _notices = [];
private bool _refreshing;
private bool _customResolution;
public ExportTab(EditorViewModel editor)
: base(editor, "Export", AdvisorSection.Export)
{
SelectCommand = new RelayCommand(p => Select(p as PresetCard), _ => !Editor.IsLocked);
SelectCommand = new RelayCommand(p => Select(p as PresetRow), _ => !Editor.IsLocked);
_renderNow = new AsyncRelayCommand(() => Editor.RenderAsync(JobPriority.User, batch: false), () => Editor.CanRender);
_addToQueue = new AsyncRelayCommand(() => Editor.RenderAsync(JobPriority.Normal, batch: false), () => Editor.CanRender);
_batch = new AsyncRelayCommand(() => Editor.RenderAsync(JobPriority.User, batch: true), () => Editor.CanRender && Batch.Count > 0);
HistoryCommand = new RelayCommand(OpenHistory);
RevealLastCommand = new RelayCommand(() => ShellActions.Reveal(Editor.Session.Content.Renders[0].OutputPath), () => CanReveal);
VideosCommand = new RelayCommand(OpenVideos, () => CanOpenVideos);
_restore = new AsyncRelayCommand(RestoreAsync, () => !Editor.IsLocked && SelectedCopy is not null);
SaveProjectCommand = new AsyncRelayCommand(() => new ProjectFiles(Editor.Shell).SaveAsync(Editor.Session), () => !Editor.IsRemote);
ResetFrameRateCommand = new RelayCommand(() => EditOverrides(o => o with { FrameRate = null }));
ResetFrameRateCommand = new RelayCommand(() => SetFrameRate(null));
ResetRateControlCommand = new RelayCommand(() => EditOverrides(o => o with { RateControl = null }));
ResetQualityCommand = new RelayCommand(() => EditOverrides(o => o with { BitRate = null, Quality = null }));
ResetProfileCommand = new RelayCommand(() => EditOverrides(o => o with { Profile = null, BFrames = IsBaseline(o.Profile) ? null : o.BFrames }));
ResetPlaybackCommand = new RelayCommand(() => EditExport(e => e with { Playback = null }), () => !IsPlaybackDefault);
Width = new EditableField(string.Empty, ValidateSize, v => EditOverrides(o => o with { Width = ParseSize(v) }), () => Loc.L("Tooltips.Editor.Export.Width"));
Height = new EditableField(string.Empty, ValidateSize, v => EditOverrides(o => o with { Height = ParseSize(v) }), () => Loc.L("Tooltips.Editor.Export.Height"));
NameTemplate = new EditableField(string.Empty, ValidateTemplate, v => EditExport(e => e with { NameTemplate = v }), () => Loc.L("Tooltips.Editor.Export.Name"));
FadeInField = SecondsField(PlaybackSettings.MaxFadeSeconds, (p, v) => p with { FadeIn = v }, "Tooltips.Export.FadeIn");
FadeOutField = SecondsField(PlaybackSettings.MaxFadeSeconds, (p, v) => p with { FadeOut = v }, "Tooltips.Export.FadeOut");
HoldEndField = SecondsField(PlaybackSettings.MaxHoldSeconds, (p, v) => p with { HoldEnd = v }, "Tooltips.Export.HoldEnd");
OutputGroup = new SettingGroup("export.output", "Export.Group.Output", "Tooltips.Export.Group.Output", expandedByDefault: true);
EncodingGroup = new SettingGroup("export.encoding", "Export.Group.Encoding", "Tooltips.Export.Group.Encoding", expandedByDefault: false);
PlaybackGroup = new SettingGroup("export.playback", "Export.Group.Playback", "Tooltips.Export.Group.Playback", expandedByDefault: false);
FileGroup = new SettingGroup("export.file", "Export.Group.File", "Tooltips.Export.Group.File", expandedByDefault: true);
_selectedCopy = SavedCopies.FirstOrDefault();
LoadCards();
LoadTable();
Refresh();
}
public IReadOnlyList<PresetCard> Cards { get => _cards; private set => Set(ref _cards, value); }
// ---- Preset table (measure area) ----
/// <summary>Every preset, in table order.</summary>
public IReadOnlyList<PresetRow> Presets { get => _presets; private set => Set(ref _presets, value); }
/// <summary>The presets by group (Video, Social, Intermediate, Image sequence, Web), each one opened or closed.</summary>
public IReadOnlyList<PresetGroup> PresetGroups { get => _presetGroups; private set => Set(ref _presetGroups, value); }
public ICommand SelectCommand { get; }
// ---- The groups of the Output panel ----
public SettingGroup OutputGroup { get; }
public SettingGroup EncodingGroup { get; }
public SettingGroup PlaybackGroup { get; }
public SettingGroup FileGroup { get; }
// ---- Footer ----
public ICommand RenderNowCommand => _renderNow;
public ICommand AddToQueueCommand => _addToQueue;
public ICommand BatchCommand => _batch;
/// <summary>Jobs, filtered on this sequence (its renders and analyses).</summary>
public ICommand HistoryCommand { get; }
/// <summary>"Reveal in Explorer" for the newest render (BRIEF §11.5 follow-up).</summary>
public ICommand RevealLastCommand { get; }
public string AddToQueueToolTip => Editor.RenderBlockedReason ?? Loc.L("Tooltips.Editor.Export.AddToQueue");
/// <summary>"Batch (2)": the ticked presets.</summary>
public string BatchText => Loc.L("Export.Footer.Batch", Batch.Count.ToString("N0", Loc.Culture));
public string BatchToolTip => Editor.RenderBlockedReason ?? (Batch.Count == 0 ? Loc.L("Tooltips.Editor.Export.BatchEmpty")
: Editor.IsRemote ? Loc.L("Tooltips.Editor.Export.BatchServer", Editor.ServerName)
: Loc.L("Tooltips.Editor.Export.Batch"));
public bool HasHistory => Editor.Session.Content.Renders.Count > 0;
/// <summary>The "history" link opens this PC's Jobs screen, which does not list a server's jobs.</summary>
public bool CanOpenHistory => !Editor.IsRemote;
: Loc.L("Tooltips.Export.Footer.Batch"));
/// <summary>The newest render is a file on this PC (a server's renders stay on the server).</summary>
public bool CanReveal => Editor.Session.Content.Renders is [{ OutputPath.Length: > 0 }, ..];
/// <summary>"Videos (3)": the renders of this sequence.</summary>
public string VideosText => Loc.L("Export.Footer.Videos", Editor.Session.Content.Renders.Count.ToString("N0", Loc.Culture));
/// <summary>Opens the Videos section filtered on this sequence (owner review 1, R9).</summary>
public ICommand VideosCommand { get; }
/// <summary>The app has a Videos section to open.</summary>
public bool CanOpenVideos => VideosLink.Find(Editor.Shell.AllSections) is not null;
/// <summary>
/// "2026-09-28 Harbour sunset - 4K archive.mp4 · 1.2 GB · about 4 min · 42 s · 1,260 frames": the result, its estimates,
/// and the video's duration and frames as the playback plays them; null before the plan.
/// </summary>
public string? FooterSummary => Editor.Plan is { } plan
? ExportSummaries.Footer(plan.FileName, Estimated?.Estimate, plan.DurationSeconds, plan.FrameCount)
: null;
/// <summary>
/// Saves a <c>.chronos</c> project file of this sequence and its settings (BRIEF §18); a server sequence has no
/// archive on this PC for the file to name.
/// archive on this PC for the file to name. Offered in the project ▾ menu.
/// </summary>
public ICommand SaveProjectCommand { get; }
public string SaveProjectToolTip => Editor.IsRemote ? Loc.L("Tooltips.Editor.ProjectFile.Remote") : Loc.L("Tooltips.Editor.ProjectFile.Save");
// ---- Export "Sync" (Export.html, next to Save to) ----
// ---- File: Sync ----
/// <summary>Send each render made on this PC to the server the sequence is linked to; remembered in the project.</summary>
public bool SyncToServer
@@ -218,7 +211,7 @@ public sealed class ExportTab : EditorTab
/// <summary>A server sequence renders into its exports folder on the server.</summary>
public bool CanChooseFolder => !Editor.IsRemote;
// ---- "Save both" copies of this PC's settings ----
// ---- File: "Save both" copies of this PC's settings ----
public IReadOnlyList<SavedCopy> SavedCopies => Editor.Session.Content.SavedCopies;
@@ -244,7 +237,7 @@ public sealed class ExportTab : EditorTab
public ICommand RestoreCommand => _restore;
public ICommand ResetFrameRateCommand { get; }
// ---- Output ----
/// <summary>"Output · 4K archive".</summary>
public string Title => Loc.L("Editor.Export.Output", Editor.Plan?.PresetName ?? ProcessingJobs.PresetName(ExportResolver.Resolve(Export)));
@@ -276,6 +269,46 @@ public sealed class ExportTab : EditorTab
}
}
/// <summary>Preset, Source, the standard sizes (720p … 8K) and Custom (decision 7).</summary>
public IReadOnlyList<Choice> Resolutions { get; } =
[
new(PresetResolution, "Export.Resolution.Preset"), new(SourceResolution, "Export.Resolution.Source"),
.. ExportRules.StandardResolutions.Select(r => new Choice(r.Key, r.LabelKey)),
new(CustomResolution, "Export.Resolution.Custom"),
];
/// <summary>
/// The size the export asks for: the preset's box, the source, a standard box (written into the overrides as landscape,
/// so the chosen proportions are fitted in it: 4K at 9:16 renders 2160 × 3840), or Custom with Width × Height.
/// </summary>
public Choice? SelectedResolution
{
get => Resolutions.FirstOrDefault(c => Equals(c.Value, ResolutionKey(Export.Overrides, _customResolution)));
set
{
if (_refreshing || value?.Value is not string key) return;
_customResolution = key == CustomResolution;
if (_customResolution)
{
OnPropertyChanged();
OnPropertyChanged(nameof(IsCustomResolution));
return;
}
var (width, height) = key switch
{
PresetResolution => ((int?)null, (int?)null),
SourceResolution => (0, 0),
_ => ExportRules.StandardResolutions.Where(r => r.Key == key).Select(r => ((int?)r.Width, (int?)r.Height)).First(),
};
Width.Revert();
Height.Revert();
EditOverrides(o => o with { Width = width, Height = height });
}
}
/// <summary>Custom is chosen: the Width × Height fields show.</summary>
public bool IsCustomResolution => Equals(SelectedResolution?.Value, CustomResolution);
public EditableField Width { get; }
public EditableField Height { get; }
@@ -311,7 +344,7 @@ public sealed class ExportTab : EditorTab
get => FrameRates.FirstOrDefault(c => FrameRateText.TryParse((string)c.Value, out var r) && FrameRateText.AreEqual(r, Resolved.FrameRate));
set
{
if (!_refreshing && value?.Value is string rate) EditOverrides(o => o with { FrameRate = rate });
if (!_refreshing && value?.Value is string rate) SetFrameRate(rate);
}
}
@@ -320,29 +353,27 @@ public sealed class ExportTab : EditorTab
public string FrameRateAutoToolTip => Loc.L("Tooltips.Editor.Export.FrameRateAuto", EditorText.FrameRate(ExportResolver.Resolve(Export with { Overrides = new ExportOverrides() }).FrameRate));
/// <summary>Bit rate in Mb/s (video) or quality 1–100 (JPEG, MJPEG, GIF).</summary>
public double Quality
public ICommand ResetFrameRateCommand { get; }
public IReadOnlyList<Choice> Depths { get => _depths; private set => Set(ref _depths, value); }
public Choice? SelectedDepth
{
get => IsBitRate ? (Editor.Plan?.Setup.Encoder.Settings.BitRate ?? Resolved.BitRate) / 1e6 : Resolved.Quality;
get => Depths.FirstOrDefault(d => (int)d.Value == Resolved.BitDepth) ?? Depths[0];
set
{
if (_refreshing) return;
if (IsBitRate) EditOverrides(o => o with { BitRate = (long)(double.Round(value) * 1e6) }, "Export.Quality");
else EditOverrides(o => o with { Quality = (int)double.Round(value) }, "Export.Quality");
if (_refreshing || value?.Value is not int depth || depth == Resolved.BitDepth) return;
EditOverrides(o => o with
{
BitDepth = depth,
Profile = Resolved.Codec == VideoCodec.Hevc ? (depth > 8 ? CodecProfile.HevcMain10 : CodecProfile.HevcMain).ToString() : o.Profile,
});
}
}
public bool IsBitRate => !VideoCodecInfo.IsManaged(Resolved.Codec);
public bool CanChooseDepth => Depths.Count > 1;
public double QualityMaximum => IsBitRate ? 400 : 100;
public bool IsQualityApplicable => IsBitRate || Resolved.Codec is VideoCodec.Mjpeg or VideoCodec.JpegSequence or VideoCodec.Gif;
public string? QualityNotApplicable => IsQualityApplicable ? null : Loc.L("Tooltips.Editor.NotApplicable.Lossless");
public string QualityText => IsBitRate ? EditorText.BitRate((long)(Quality * 1e6)) : Quality.ToString("0", Loc.Culture);
public string QualityToolTip => Loc.L(IsBitRate ? "Tooltips.Editor.Export.BitRate" : "Tooltips.Editor.Export.Quality");
// ---- Encoding ----
public IReadOnlyList<Choice> Encoders { get => _encoders; private set => Set(ref _encoders, value); }
@@ -367,23 +398,193 @@ public sealed class ExportTab : EditorTab
public bool IsHardware => !Editor.IsRemote && Editor.Plan?.Setup.Encoder.Capability?.Hardware == true;
public IReadOnlyList<Choice> Depths { get => _depths; private set => Set(ref _depths, value); }
/// <summary>Variable, constant, quality (H.264, HEVC and AV1 only).</summary>
public IReadOnlyList<Choice> RateControls { get; } =
[.. Enum.GetValues<RateControl>().Select(r => new Choice(r, "Export.RateControl." + r))];
public Choice? SelectedDepth
public Choice? SelectedRateControl
{
get => Depths.FirstOrDefault(d => (int)d.Value == Resolved.BitDepth) ?? Depths[0];
get => RateControls.FirstOrDefault(c => Equals(c.Value, Resolved.RateControl));
set
{
if (_refreshing || value?.Value is not int depth || depth == Resolved.BitDepth) return;
if (_refreshing || value?.Value is not RateControl rateControl || rateControl == Resolved.RateControl) return;
// The preset's own rate control (every preset is variable) is no override.
EditOverrides(o => o with { RateControl = rateControl == PresetValues.RateControl ? null : rateControl.ToString().ToLowerInvariant() });
}
}
/// <summary>The codec has a rate control (and a keyframe interval) to choose.</summary>
public bool HasRateControl => ExportRules.HasRateControl(Resolved.Codec);
public string RateControlToolTip => ExportRules.RateControlBlocked(Resolved.Codec) ?? Loc.L("Tooltips.Export.RateControl");
public bool IsRateControlSet => HasRateControl && Export.Overrides.RateControl is not null;
public ICommand ResetRateControlCommand { get; }
/// <summary>Bit rate in Mb/s (variable and constant rate) or quality 1–100 (quality rate control, JPEG, MJPEG, GIF).</summary>
public double Quality
{
get => IsBitRate ? (Editor.Plan?.Setup.Encoder.Settings.BitRate ?? Resolved.BitRate) / 1e6 : Resolved.Quality;
set
{
if (_refreshing) return;
if (IsBitRate) EditOverrides(o => o with { BitRate = (long)(double.Round(value) * 1e6) }, "Export.Quality");
else EditOverrides(o => o with { Quality = (int)double.Round(value) }, "Export.Quality");
}
}
/// <summary>The slider sets the bit rate: a video codec at variable or constant rate.</summary>
public bool IsBitRate => HasRateControl && Resolved.RateControl != RateControl.Quality;
public double QualityMaximum => IsBitRate ? 400 : 100;
public bool IsQualityApplicable => HasRateControl || Resolved.Codec is VideoCodec.Mjpeg or VideoCodec.JpegSequence or VideoCodec.Gif;
public string? QualityNotApplicable => IsQualityApplicable ? null : Loc.L("Tooltips.Editor.NotApplicable.Lossless");
/// <summary>"Bit rate" or "Quality": the row's label follows what the slider sets.</summary>
public string QualityHeader => Loc.L(IsBitRate ? "Export.BitRate" : "Editor.Export.Quality");
public string QualityText => IsBitRate ? EditorText.BitRate((long)(Quality * 1e6)) : Quality.ToString("0", Loc.Culture);
public string QualityToolTip => Loc.L(IsBitRate ? "Tooltips.Export.BitRate" : "Tooltips.Export.Quality");
public bool IsQualitySet => IsQualityApplicable && (IsBitRate ? Export.Overrides.BitRate : Export.Overrides.Quality) is not null;
public ICommand ResetQualityCommand { get; }
/// <summary>Auto (the preset's), then 0.5 to 10 s.</summary>
public IReadOnlyList<Choice> KeyframeChoices { get => _keyframeChoices; private set => Set(ref _keyframeChoices, value); }
/// <summary>
/// The keyframe interval in seconds (decision 6), stored as whole frames at the export's rate
/// (<see cref="ExportOverrides.GopFrames"/>); 0 is Auto (the preset's).
/// </summary>
public Choice? SelectedKeyframes
{
get
{
var seconds = Export.Overrides.GopFrames is { } gop ? ExportRules.NearestKeyframeSeconds(gop, Resolved.FrameRate) : 0.0;
return KeyframeChoices.FirstOrDefault(c => (double)c.Value == seconds);
}
set
{
if (_refreshing || value?.Value is not double seconds) return;
var rate = Resolved.FrameRate;
EditOverrides(o => o with { GopFrames = seconds <= 0 ? null : ExportRules.GopFrames(seconds, rate) });
}
}
public string KeyframesToolTip => ExportRules.RateControlBlocked(Resolved.Codec) ?? Loc.L("Tooltips.Export.Keyframes");
/// <summary>Auto (the preset's), then 0 to 4.</summary>
public IReadOnlyList<Choice> BFrameChoices { get => _bFrameChoices; private set => Set(ref _bFrameChoices, value); }
/// <summary>B-frames, −1 for Auto (the preset's).</summary>
public Choice? SelectedBFrames
{
get => BFrameChoices.FirstOrDefault(c => (int)c.Value == (Export.Overrides.BFrames ?? -1));
set
{
if (_refreshing || value?.Value is not int count) return;
EditOverrides(o => o with { BFrames = count < 0 ? null : count });
}
}
/// <summary>Baseline, MJPEG, GIF, APNG and the image sequences take no B-frames.</summary>
public bool CanChooseBFrames => ExportRules.BFramesBlocked(Resolved.Codec, Resolved.Profile) is null;
public string BFramesToolTip => ExportRules.BFramesBlocked(Resolved.Codec, Resolved.Profile) ?? Loc.L("Tooltips.Export.BFrames");
/// <summary>The profiles of the codec at the chosen depth.</summary>
public IReadOnlyList<Choice> ProfileChoices { get => _profileChoices; private set => Set(ref _profileChoices, value); }
public Choice? SelectedProfile
{
get => ProfileChoices.FirstOrDefault(c => Equals(c.Value, Resolved.Profile)) ?? ProfileChoices.FirstOrDefault();
set
{
if (_refreshing || value?.Value is not CodecProfile profile || profile == Resolved.Profile) return;
// Baseline takes no B-frames: none are asked for while it is chosen, the preset's again once it is not.
EditOverrides(o => o with
{
BitDepth = depth,
Profile = Resolved.Codec == VideoCodec.Hevc ? (depth > 8 ? CodecProfile.HevcMain10 : CodecProfile.HevcMain).ToString() : o.Profile,
Profile = profile.ToString(),
BFrames = profile == CodecProfile.H264Baseline ? 0 : IsBaseline(o.Profile) ? null : o.BFrames,
});
}
}
public bool CanChooseDepth => Depths.Count > 1;
public bool CanChooseProfile => ProfileChoices.Count > 1;
public string ProfileToolTip => ExportRules.ProfileBlocked(Resolved.Codec, Resolved.BitDepth) ?? Loc.L("Tooltips.Export.Profile");
public bool IsProfileSet => CanChooseProfile && Export.Overrides.Profile is not null;
public ICommand ResetProfileCommand { get; }
// ---- Playback (settings format 3) ----
/// <summary>Forward, Reverse, Boomerang; Boomerang is not offered with star trails (decision 11).</summary>
public IReadOnlyList<GatedChoice> Directions { get => _directions; private set => Set(ref _directions, value); }
public GatedChoice? SelectedDirection
{
get => Directions.FirstOrDefault(d => Equals(d.Value, Playback.EffectiveDirection));
set
{
if (_refreshing || value is not { IsAvailable: true, Value: string direction } || direction == Playback.EffectiveDirection) return;
EditPlayback(p => p with { Direction = direction });
}
}
/// <summary>Passes of the whole video, 1 to 10.</summary>
public double Loops
{
get => Playback.EffectiveLoops;
set
{
var loops = int.Clamp((int)double.Round(value), 1, PlaybackSettings.MaxLoops);
if (_refreshing || loops == Playback.EffectiveLoops) return;
EditPlayback(p => p with { Loops = loops }, "Export.Loops");
}
}
/// <summary>"×2".</summary>
public string LoopsText => Loc.L("Export.Summary.Loops", Playback.EffectiveLoops);
/// <summary>Seconds of fade from black (slider 0–10, step 0.5; the field takes up to 30).</summary>
public double FadeIn
{
get => double.Min(Playback.EffectiveFadeIn, SliderSeconds);
set => SetSeconds(value, Playback.EffectiveFadeIn, (p, v) => p with { FadeIn = v }, "Export.FadeIn");
}
public double FadeOut
{
get => double.Min(Playback.EffectiveFadeOut, SliderSeconds);
set => SetSeconds(value, Playback.EffectiveFadeOut, (p, v) => p with { FadeOut = v }, "Export.FadeOut");
}
/// <summary>Seconds the last frame stays (slider 0–10, step 0.5; the field takes up to 60).</summary>
public double HoldEnd
{
get => double.Min(Playback.EffectiveHoldEnd, SliderSeconds);
set => SetSeconds(value, Playback.EffectiveHoldEnd, (p, v) => p with { HoldEnd = v }, "Export.HoldEnd");
}
public EditableField FadeInField { get; }
public EditableField FadeOutField { get; }
public EditableField HoldEndField { get; }
/// <summary>Forward, once, without fades or hold: the project writes no playback (and keeps its settings format).</summary>
public bool IsPlaybackDefault => Export.Playback is null or { IsDefault: true };
public ICommand ResetPlaybackCommand { get; }
// ---- File ----
public EditableField NameTemplate { get; }
@@ -411,6 +612,8 @@ public sealed class ExportTab : EditorTab
? Loc.L("Tooltips.Editor.Export.FolderServer")
: Loc.L("Tooltips.Editor.Export.Folder", Export.Folder ?? Editor.Session.Content.ExportsFolder ?? string.Empty);
// ---- Estimate and notices ----
public string? EstimatedSize => Estimated is { } plan ? Formatting.Bytes(plan.Estimate.Bytes) : null;
/// <summary>"about 5 min · NVENC"; without this PC's encoder for a server sequence.</summary>
@@ -420,14 +623,9 @@ public sealed class ExportTab : EditorTab
public string? ResultName => Editor.Plan?.FileName;
/// <summary>What the encoder changed or cannot do (localised notices and render remarks).</summary>
/// <summary>What the encoder changed or cannot do, and what the playback could not do (localised notices and render remarks).</summary>
public IReadOnlyList<string> Notices { get => _notices; private set => Set(ref _notices, value); }
/// <summary>"Previous renders of this sequence: 2 · last 2026-09-21".</summary>
public string HistoryText => Editor.Session.Content.Renders is { Count: > 0 } renders
? Loc.Plural("Editor.Export.History", renders.Count, Formatting.Date(renders[0].Created))
: Loc.L("Editor.Export.NoHistory");
/// <summary>A workspace project's renders made on this PC that are not at its home yet (phase 5c): "Not sent".</summary>
public bool HasUnsent => Editor.Session.Source is WorkspaceSequenceSource { UnsentRenders: > 0 };
@@ -466,12 +664,18 @@ public sealed class ExportTab : EditorTab
public IReadOnlyList<string> Batch => Export.Batch;
/// <summary>Completes when the card estimates in flight are done.</summary>
/// <summary>Completes when the preset estimates in flight are done.</summary>
public Task EstimatesIdle => _estimates.Idle;
private ExportSettings Export => Editor.Session.Project.Export;
private ResolvedExport Resolved => Editor.Plan?.Export ?? ExportResolver.Resolve(Export);
private PlaybackSettings Playback => Export.Playback ?? new PlaybackSettings();
/// <summary>The project's export as the plan resolves it, read at once (the plan follows an edit later).</summary>
private ResolvedExport Resolved => ExportResolver.Resolve(Export);
/// <summary>The export's preset without overrides: what Auto and Reset go back to.</summary>
private ResolvedExport PresetValues => ExportResolver.Resolve(Export with { Overrides = new ExportOverrides() });
/// <summary>The plan when its estimates mean something: this PC can encode it, or the server renders it.</summary>
private ExportPlan? Estimated => Editor.Plan is { } plan && (Editor.IsRemote || plan.Setup.Encoder.IsReady) ? plan : null;
@@ -484,9 +688,26 @@ public sealed class ExportTab : EditorTab
EditExport(e => e with { Batch = value ? [.. e.Batch, presetId] : [.. e.Batch.Where(b => !b.Equals(presetId, StringComparison.OrdinalIgnoreCase))] });
}
/// <summary>The preset cards take more of the height than the preview (Export.html).</summary>
/// <summary>The preset table takes more of the height than the preview (Export.html).</summary>
public override bool PrefersTallMeasure => true;
/// <summary>
/// The Resolution choice of <paramref name="overrides"/>: Preset without a box of its own, Source for 0 × 0, a standard
/// size for its box, else Custom (also while <paramref name="custom"/>, chosen to type a size).
/// </summary>
public static string ResolutionKey(ExportOverrides overrides, bool custom = false)
{
ArgumentNullException.ThrowIfNull(overrides);
if (custom) return CustomResolution;
return (overrides.Width, overrides.Height) switch
{
(null, null) => PresetResolution,
(0, 0) => SourceResolution,
({ } w, { } h) when ExportRules.StandardResolutions.FirstOrDefault(r => r.Width == w && r.Height == h) is { Key: { } key } => key,
_ => CustomResolution,
};
}
public override void Refresh()
{
base.Refresh();
@@ -494,20 +715,21 @@ public sealed class ExportTab : EditorTab
try
{
UpdateLists();
LoadBox();
LoadFields();
SaveChoices = !CanChooseFolder ? [new SaveChoice(null)]
: Export.Folder is { } folder ? [new SaveChoice(null), new SaveChoice(folder), new SaveChoice(null, Browse: true)]
: [new SaveChoice(null), new SaveChoice(null, Browse: true)];
if (!NameTemplate.IsDirty) NameTemplate.Load(Export.NameTemplate);
UpdateSummaries();
OnAllPropertiesChanged();
}
finally
{
_refreshing = false;
}
SelectCards();
foreach (var card in Cards) card.RefreshBatch();
_ = EstimateCardsAsync();
SelectRows();
foreach (var row in Presets) row.RefreshBatch();
_ = EstimateRowsAsync();
}
public override void OnPlanChanged()
@@ -515,9 +737,10 @@ public sealed class ExportTab : EditorTab
_refreshing = true;
try
{
LoadBox();
LoadFields();
UpdateLists();
Notices = Editor.Plan is { } plan ? PlanNotices(plan) : [];
UpdateSummaries();
OnAllPropertiesChanged();
}
finally
@@ -525,13 +748,13 @@ public sealed class ExportTab : EditorTab
_refreshing = false;
}
// The plan follows the preset a read-only session chose to render.
SelectCards();
SelectRows();
}
public override void OnBusyChanged()
{
base.OnBusyChanged();
foreach (var card in Cards) card.RefreshLocked();
foreach (var row in Presets) row.RefreshLocked();
}
public override void OnContentChanged()
@@ -539,8 +762,12 @@ public sealed class ExportTab : EditorTab
// The ledger was read again: Send again goes by what it holds now.
_sendQueued = false;
_sendAgain?.RaiseCanExecuteChanged();
LoadCards();
LoadTable();
if (SelectedCopy is null || !SavedCopies.Contains(SelectedCopy)) SelectedCopy = SavedCopies.FirstOrDefault();
// The rows and groups keep texts in objects (a language switch comes this way too).
_keyframeChoices = _bFrameChoices = _profileChoices = [];
_directions = [];
foreach (var group in new[] { OutputGroup, EncodingGroup, PlaybackGroup, FileGroup }) group.Refresh();
base.OnContentChanged();
}
@@ -559,6 +786,7 @@ public sealed class ExportTab : EditorTab
{
OnPropertyChanged(nameof(CanSync));
OnPropertyChanged(nameof(SyncToolTip));
FileGroup.Summary = FileSummary();
}
public override void Dispose()
@@ -569,15 +797,33 @@ public sealed class ExportTab : EditorTab
/// <summary>
/// Width and Height edit the preset's box, which the chosen proportions are fitted in (owner review 1, R5): they show the
/// resolved box (empty for a side the preset leaves to the source), not the size rendered (Output size).
/// resolved box (empty for a side the preset leaves to the source), not the size rendered (Output size). The playback
/// fields show the seconds in force.
/// </summary>
private void LoadBox()
private void LoadFields()
{
var resolved = Resolved;
if (!Width.IsDirty) Width.Load(resolved.Width > 0 ? resolved.Width.ToString(CultureInfo.InvariantCulture) : string.Empty);
if (!Height.IsDirty) Height.Load(resolved.Height > 0 ? resolved.Height.ToString(CultureInfo.InvariantCulture) : string.Empty);
var playback = Playback;
if (!FadeInField.IsDirty) FadeInField.Load(SecondsText(playback.EffectiveFadeIn));
if (!FadeOutField.IsDirty) FadeOutField.Load(SecondsText(playback.EffectiveFadeOut));
if (!HoldEndField.IsDirty) HoldEndField.Load(SecondsText(playback.EffectiveHoldEnd));
}
/// <summary>The one-line summaries the groups show while collapsed.</summary>
private void UpdateSummaries()
{
var resolved = Resolved;
var settings = Editor.Plan?.Setup.Encoder.Settings;
OutputGroup.Summary = EditorText.Format(resolved, settings?.Width ?? resolved.Width, settings?.Height ?? resolved.Height);
EncodingGroup.Summary = ExportSummaries.Encoding(resolved, settings?.BitRate ?? resolved.BitRate);
PlaybackGroup.Summary = ExportSummaries.Playback(Export.Playback);
FileGroup.Summary = FileSummary();
}
private string FileSummary() => ExportSummaries.File(ResultName, SelectedSave?.Label ?? Loc.L("Editor.Export.SequenceFolder"), SyncToServer && CanSync);
/// <summary>"2160 × 3840".</summary>
private static string SizeText((int Width, int Height) size) =>
size.Width.ToString(Loc.Culture) + " × " + size.Height.ToString(Loc.Culture);
@@ -596,7 +842,7 @@ public sealed class ExportTab : EditorTab
return width > maxWidth || height > maxHeight ? (maxWidth, maxHeight) : plan.EncodedSize;
}
/// <summary>The choices that depend on the resolved codec (new lists only when they change, so selections stay bound).</summary>
/// <summary>The choices that depend on the resolved codec and the project (new lists only when they change, so selections stay bound).</summary>
private void UpdateLists()
{
var resolved = Resolved;
@@ -610,43 +856,77 @@ public sealed class ExportTab : EditorTab
_ => [resolved.BitDepth],
};
if (!depths.SequenceEqual(Depths.Select(d => (int)d.Value))) Depths = [.. depths.Select(d => new Choice(d, "Editor.Export.Depth", d))];
// Auto names the preset's own value (its keyframe interval is in seconds, whatever the frame rate).
var preset = PresetValues;
var autoKeyframes = Auto(ExportRules.Seconds(ExportRules.GopSeconds(preset.GopFrames, preset.FrameRate)));
if (KeyframeChoices.FirstOrDefault()?.Label != autoKeyframes)
KeyframeChoices = [new Choice(0.0, "Editor.Value.Text", autoKeyframes), .. ExportRules.KeyframeSeconds.Select(s => new Choice(s, "Editor.Value.Text", ExportRules.Seconds(s)))];
var autoBFrames = Auto(preset.BFrames.ToString(Loc.Culture));
if (BFrameChoices.FirstOrDefault()?.Label != autoBFrames)
BFrameChoices = [new Choice(-1, "Editor.Value.Text", autoBFrames), .. ExportRules.BFrameCounts.Select(n => new Choice(n, "Editor.Value.Number", n))];
var profiles = ExportRules.Profiles(resolved.Codec, resolved.BitDepth);
if (!profiles.Cast<object>().SequenceEqual(ProfileChoices.Select(c => c.Value)))
ProfileChoices = [.. profiles.Select(p => new Choice(p, "Editor.Value.Text", ExportRules.ProfileLabel(p)))];
var starTrails = Editor.Session.Project.Stack.Mode == StackSetting.StarTrails;
if (Directions.Count == 0 || Directions.Any(d => (string)d.Value == PlaybackDirection.Boomerang && d.IsAvailable == starTrails))
{
Directions =
[
.. PlaybackDirection.All.Select(d =>
{
var blocked = starTrails && d == PlaybackDirection.Boomerang;
return new GatedChoice(d, ExportSummaries.DirectionLabel(d), !blocked, Loc.L(blocked ? "Tooltips.Export.BoomerangStack" : "Tooltips.Export.Direction"));
}),
];
}
}
private void LoadCards() => Cards = [.. ExportPlanner.Choices(Editor.Session.Presets, Editor.Session.Advice).Select(c => new PresetCard(this, c))];
/// <summary>"Auto · 1 s".</summary>
private static string Auto(string value) => Loc.L("Export.Auto") + Loc.Separator + value;
/// <summary>The card of the export preset the plan renders.</summary>
private void SelectCards()
private void LoadTable()
{
foreach (var card in Cards)
card.IsSelected = card.Choice.Sequence is null && string.Equals(card.Choice.ExportPresetId, Resolved.PresetId, StringComparison.OrdinalIgnoreCase);
Presets = [.. ExportPlanner.Choices(Editor.Session.Presets, Editor.Session.Advice).Select(c => new PresetRow(this, c))];
PresetGroups = PresetTable.Build(Presets, Resolved.PresetId);
}
/// <summary>The row of the export preset the plan renders.</summary>
private void SelectRows()
{
foreach (var row in Presets)
row.IsSelected = row.Choice.Sequence is null && string.Equals(row.Choice.ExportPresetId, Resolved.PresetId, StringComparison.OrdinalIgnoreCase);
}
/// <summary>
/// What the plan changed or cannot do, localised; for a server sequence without this PC's encoder notices (the server
/// or its render node picks the encoder).
/// or its render node picks the encoder). The output program's remarks (fades shortened, a direction not known) follow.
/// </summary>
private IReadOnlyList<string> PlanNotices(ExportPlan plan)
{
var encoder = Editor.IsRemote ? plan.Setup.Encoder.Notices.Select(n => n.Key).ToHashSet(StringComparer.Ordinal) : [];
return [.. plan.Setup.Warnings.Where(w => !encoder.Contains(w.Key)).Select(w => Loc.L(w.Key, [.. w.Args]))
.Concat(plan.Export.Warnings.Select(k => Loc.L(k))).Distinct()];
.Concat(plan.Export.Warnings.Select(k => Loc.L(k)))
.Concat(plan.Program?.Warnings.Select(w => Loc.L(w.Key, [.. w.Args])) ?? []).Distinct()];
}
/// <summary>Estimates every card off the UI thread for the project as it is now (latest request wins).</summary>
private async Task EstimateCardsAsync()
/// <summary>Estimates every preset off the UI thread for the project as it is now (latest request wins).</summary>
private async Task EstimateRowsAsync()
{
var project = Editor.Session.Project;
var cards = Cards;
var plans = new ExportPlan?[cards.Count];
var rows = Presets;
var plans = new ExportPlan?[rows.Count];
var done = false;
try
{
await _estimates.Schedule(token =>
{
for (var i = 0; i < cards.Count; i++)
for (var i = 0; i < rows.Count; i++)
{
token.ThrowIfCancellationRequested();
var export = project.Export with { Preset = project.Export.Preset.WithManual(cards[i].Choice.ExportPresetId), Overrides = new ExportOverrides(), Batch = [] };
// The playback stays: a preset renders with the loops and holds of the export (batch presets inherit it).
var export = project.Export with { Preset = project.Export.Preset.WithManual(rows[i].Choice.ExportPresetId), Overrides = new ExportOverrides(), Batch = [] };
plans[i] = Editor.Planner.Plan(project, export);
}
done = true;
@@ -655,12 +935,12 @@ public sealed class ExportTab : EditorTab
}
catch (Exception ex) when (ex is ArgumentException or InvalidOperationException)
{
Core.Diagnostics.Log.Warning("editor", "Preset estimates failed", ex);
Log.Warning("editor", "Preset estimates failed", ex);
return;
}
// A superseded request stops part way (or never starts); undo can bring back the same project instance.
if (!done || !ReferenceEquals(cards, Cards) || !ReferenceEquals(project, Editor.Session.Project)) return;
for (var i = 0; i < cards.Count; i++) cards[i].Update(plans[i]);
if (!done || !ReferenceEquals(rows, Presets) || !ReferenceEquals(project, Editor.Session.Project)) return;
for (var i = 0; i < rows.Count; i++) rows[i].Update(plans[i]);
}
/// <summary>
@@ -697,18 +977,14 @@ public sealed class ExportTab : EditorTab
});
}
private void OpenHistory()
{
Editor.Shell.Jobs.Filter = Jobs.JobFilter.All;
Editor.Shell.Jobs.SearchText = Editor.Title;
Editor.Shell.Navigate(Shell.SectionKey.Jobs);
}
private void OpenVideos() => VideosLink.Open(Editor.Shell.AllSections, Editor.Shell.Navigate, Editor.Session.Content.Sequence.Id);
private void Select(PresetCard? card)
private void Select(PresetRow? row)
{
if (card is null) return;
if (card.Choice.Sequence is { } preset) Editor.Session.ApplyPreset(preset);
else EditExport(e => e with { Preset = e.Preset.WithManual(card.Choice.ExportPresetId), Overrides = new ExportOverrides() });
if (row is null) return;
_customResolution = false;
if (row.Choice.Sequence is { } preset) Editor.Session.ApplyPreset(preset);
else EditExport(e => e with { Preset = e.Preset.WithManual(row.Choice.ExportPresetId), Overrides = new ExportOverrides() });
}
private void SelectCodec(CodecChoice choice) => EditOverrides(o => o with
@@ -720,6 +996,17 @@ public sealed class ExportTab : EditorTab
Encoder = null,
});
/// <summary>
/// Sets the frame rate (null: the preset's). A keyframe interval chosen by hand is kept in seconds (decision 6), so
/// its frames follow the new rate.
/// </summary>
private void SetFrameRate(string? rate)
{
var from = Resolved.FrameRate;
var to = rate is not null && FrameRateText.TryParse(rate, out var parsed) ? parsed : PresetValues.FrameRate;
EditOverrides(o => o with { FrameRate = rate, GopFrames = o.GopFrames is { } gop ? ExportRules.RescaleGop(gop, from, to) : null });
}
private IReadOnlyList<Choice> EncoderChoices(VideoCodec codec)
{
var names = Editor.Planner.Encoders.SelectMany(p => p.Capabilities).Where(c => c.Codec == codec).Select(c => c.Name).Distinct();
@@ -732,6 +1019,41 @@ public sealed class ExportTab : EditorTab
private void EditOverrides(Func<ExportOverrides, ExportOverrides> change, string? mergeKey = null) =>
EditExport(e => e with { Overrides = change(e.Overrides) }, mergeKey);
/// <summary>
/// Changes the playback; at its default (forward, once, no fades or hold) the export holds none, so an ordinary project
/// keeps its settings format (decision 8).
/// </summary>
private void EditPlayback(Func<PlaybackSettings, PlaybackSettings> change, string? mergeKey = null) =>
EditExport(e => e with { Playback = change(e.Playback ?? new PlaybackSettings()) is var p && p.IsDefault ? null : p.Normalized() }, mergeKey);
/// <summary>A slider of seconds: snapped to 0.5 s; a value the field set above the slider's end stays until the slider moves.</summary>
private void SetSeconds(double value, double current, Func<PlaybackSettings, double?, PlaybackSettings> set, string mergeKey)
{
var seconds = double.Round(double.Clamp(value, 0, SliderSeconds) * 2) / 2;
if (_refreshing || seconds == double.Min(current, SliderSeconds)) return;
EditPlayback(p => set(p, seconds), mergeKey);
}
private EditableField SecondsField(double maximum, Func<PlaybackSettings, double?, PlaybackSettings> set, string toolTipKey) =>
new(SecondsText(0), text => ParseSeconds(text, maximum) is null ? Loc.L("Errors.Number.DecimalRange", 0.ToString("0.##", Loc.Culture), maximum.ToString("0.##", Loc.Culture)) : null,
text => EditPlayback(p => set(p, ParseSeconds(text, maximum))), () => Loc.L(toolTipKey));
/// <summary>"1.5" in the UI language.</summary>
private static string SecondsText(double seconds) => seconds.ToString("0.##", Loc.Culture);
/// <summary>Seconds 0..<paramref name="maximum"/> in the UI language (or with a point); null when the text is not one.</summary>
private static double? ParseSeconds(string text, double maximum)
{
var trimmed = text.Trim();
if (trimmed.Length == 0) return 0;
return (double.TryParse(trimmed, NumberStyles.Float, Loc.Culture, out var v) || double.TryParse(trimmed, NumberStyles.Float, CultureInfo.InvariantCulture, out v))
&& double.IsFinite(v) && v >= 0 && v <= maximum
? v
: null;
}
private static bool IsBaseline(string? profile) => string.Equals(profile, nameof(CodecProfile.H264Baseline), StringComparison.OrdinalIgnoreCase);
private static string? ValidateSize(string text) =>
text.Length == 0 || (int.TryParse(text, NumberStyles.None, CultureInfo.InvariantCulture, out var v) && v is >= 16 and <= 16384)
? null