feat(chroma): opt-in auto key, and alert clips key like any other clip
TASK 64 slice F — the two things left after the feature worked by hand. - App Settings → **Video clips → Auto Green/Blue Screen** (off by default). When on, a high-confidence detected screen is keyed as soon as the clip is added; the panel says "Removed automatically" so an automatic change is never silent. Medium confidence still asks, low says nothing — a wrong automatic key eats the picture. - **A clip is a clip:** the alert box's own replacement clip keys through the same settings block (one alert box per layout, so its settings are the ones the next alert uses), and choosing an alert clip runs the same detector. The Green/Blue Screen panel now appears for a video layer *or* an alert box with a custom clip (`Source.ShowsChromaKey`). - Spill ships as the creator-facing **Fringe** switch; nothing further to tune behind it. Test: `ChromaKeyApplyTests` gains the auto-apply case (no click, still explicit in the panel) and an alert-clip case (its pipe asks ffmpeg for colorkey+despill with the blue screen type). Docs: TASK 64 complete in TASKS.md, known limits recorded in the task file, HANDOFF rewritten. verify.sh: 546 passed, 0 failed, 0 warnings.
This commit is contained in:
@@ -134,6 +134,71 @@ public sealed class ChromaKeyApplyTests
|
||||
});
|
||||
}
|
||||
|
||||
// ─── the opt-in setting ───
|
||||
|
||||
[Fact]
|
||||
public void AutoGreenBlueScreen_KeysAHighConfidenceClipWithoutAsking()
|
||||
{
|
||||
_app.Run(() =>
|
||||
{
|
||||
var tempDb = Path.Combine(Path.GetTempPath(), $"ytLlive-test-{Guid.NewGuid():N}.db");
|
||||
var videoPath = Path.Combine(Path.GetTempPath(), "auto-keyed.mp4");
|
||||
var decoders = new List<FakeMediaSource>();
|
||||
MainViewModel.LayoutPathOverride = tempDb;
|
||||
MainViewModel.MediaFrameSourceFactoryOverride = key =>
|
||||
{
|
||||
var decoder = new FakeMediaSource(key);
|
||||
decoders.Add(decoder);
|
||||
return decoder;
|
||||
};
|
||||
MainViewModel.ChromaProbeOverride = new FakeProbe(GreenScreenFrame());
|
||||
|
||||
var window = new MainWindow();
|
||||
var vm = (MainViewModel)window.DataContext;
|
||||
try
|
||||
{
|
||||
window.Show();
|
||||
vm.AutoChromaScreen = true;
|
||||
|
||||
vm.AddMediaSource(videoPath);
|
||||
|
||||
var layer = vm.StagedScene!.Elements.OfType<Source>().Single(s => s.IsMediaSource);
|
||||
Assert.True(layer.ChromaKeyEnabled, "the auto setting did not key a high-confidence screen");
|
||||
Assert.True(layer.ChromaKeyAutoApplied, "an automatic key must say that it was automatic");
|
||||
Assert.True(layer.HasAutoChromaKey);
|
||||
Assert.Equal(2, decoders.Count); // plain session released, keyed one started
|
||||
}
|
||||
finally
|
||||
{
|
||||
window.Close();
|
||||
MainViewModel.ChromaProbeOverride = null;
|
||||
MainViewModel.MediaFrameSourceFactoryOverride = null;
|
||||
MainViewModel.LayoutPathOverride = null;
|
||||
SqliteConnection.ClearAllPools();
|
||||
try { File.Delete(tempDb); } catch { /* best-effort cleanup */ }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ─── an alert clip is a clip ───
|
||||
|
||||
[Fact]
|
||||
public async Task AlertClip_KeyedThroughTheSameSettingsBlock()
|
||||
{
|
||||
var seen = new List<string>();
|
||||
using var decoder = new AlertClipDecoder(
|
||||
"alert-clip.mp4", 320, 180, new FakeLocator(),
|
||||
() => new CapturingProcess(seen),
|
||||
delay: (_, _) => Task.CompletedTask,
|
||||
chromaKey: new ChromaKeyOptions(true, "#0047BB", 0.1, 0.05, true, ChromaScreen.Blue));
|
||||
|
||||
decoder.Start();
|
||||
await Task.Delay(150);
|
||||
decoder.Stop();
|
||||
|
||||
Assert.Contains(seen, args => args.Contains("colorkey=0x0047BB") && args.Contains("despill=type=blue"));
|
||||
}
|
||||
|
||||
private static bool ReadChromaEnabled(string dbPath)
|
||||
{
|
||||
using var connection = new SqliteConnection($"Data Source={dbPath}");
|
||||
|
||||
Reference in New Issue
Block a user