feat(chroma): offer to remove a green or blue screen, and key it in the decode

TASK 64 slices D and E: the feature is usable end to end.

- Add a video file → one frame is probed (new `IChromaProbe`/`FfmpegChromaProbe`, one ffmpeg
  pass at 160x90, off the UI thread) and the layer gets an offer: "Looks like a green screen —
  Remove it", with the measured colour as a swatch.
- Accepting it turns the offer into settings (Amount / Softness / Fringe) that reach ffmpeg as
  `colorkey` + `despill` + `format=bgra`, so the key is computed in the pipe and both consumers
  (the shared preview bitmap and the compositor's frame) carry the same alpha.
- Media sessions are now keyed by **path + look** (`MainViewModel.MediaSessionKey`), so two
  layers with the same settings still share one decoder, and changing the look releases the old
  session and starts the new one. Removal, load reconciliation, loop and audio settings all move
  to the same key.
- Settings persist on the `Source` row (six ALTER TABLE guards + SELECT/INSERT), so a keyed layer
  comes back keyed.
- Panel section is plain creator words: Green/Blue Screen, Amount, Softness, Fringe.

Test: `ChromaKeyApplyTests` — the pipe asks ffmpeg to key (and does not when off); a green-screen
clip is offered, accepting it starts a keyed session, the layer's resolver then reads that session
rather than the old one; the setting survives a save.

Docs: TASK 64 D/E ticked with slice F (auto-apply setting + alert clips) left open; frame-pipeline
records the decode-option design; HANDOFF rewritten. verify.sh: 544 passed, 0 failed, 0 warnings.
This commit is contained in:
2026-11-05 08:15:32 -08:00
parent 21db8a17b8
commit ea24405ba2
19 changed files with 732 additions and 106 deletions
+41
View File
@@ -761,6 +761,47 @@
</DockPanel>
<TextBlock Text="Sound plays through the desktop audio controls, like game audio."
Style="{StaticResource PropertyHint}"/>
<!-- Green/Blue Screen (TASK 64): the app offers, the creator
accepts. No engineering words — Amount/Softness/Fringe. -->
<Border Style="{StaticResource PropertyDivider}"/>
<TextBlock Text="Green/Blue Screen" Style="{StaticResource PropertyHeader}"/>
<Border Margin="10,0,0,4" Padding="6,5" CornerRadius="4"
Background="{StaticResource Brush.Outline}"
Visibility="{Binding SelectedElement.HasChromaSuggestion, Converter={StaticResource BoolToVis}}">
<DockPanel>
<Border DockPanel.Dock="Left" Width="12" Height="12" CornerRadius="2"
Margin="0,0,6,0" VerticalAlignment="Center"
Background="{Binding SelectedElement.ChromaSuggestionColor}"
ToolTip="The screen colour this clip was shot against"/>
<Button DockPanel.Dock="Right" Content="Remove it"
Style="{StaticResource PropertyButton}" Padding="8,2" FontSize="11"
Command="{Binding AcceptChromaSuggestionCommand}"
CommandParameter="{Binding SelectedElement}"/>
<TextBlock Text="{Binding SelectedElement.ChromaSuggestionText}"
Style="{StaticResource PropertyFieldLabel}" VerticalAlignment="Center"/>
</DockPanel>
</Border>
<CheckBox Style="{StaticResource PropertyPillCheck}" Margin="10,0,0,4"
Content="Remove the background" IsChecked="{Binding SelectedElement.ChromaKeyEnabled, Mode=TwoWay}"
ToolTip="Key out the green/blue backdrop so the layers beneath show through"/>
<DockPanel Margin="10,0,0,4">
<TextBlock DockPanel.Dock="Left" Text="Amount" Style="{StaticResource PropertyFieldLabel}" Width="52"/>
<Slider Minimum="0" Maximum="0.5" Width="110"
Value="{Binding SelectedElement.ChromaKeySimilarity, Mode=TwoWay}"
VerticalAlignment="Center"/>
</DockPanel>
<DockPanel Margin="10,0,0,4">
<TextBlock DockPanel.Dock="Left" Text="Softness" Style="{StaticResource PropertyFieldLabel}" Width="52"/>
<Slider Minimum="0" Maximum="0.5" Width="110"
Value="{Binding SelectedElement.ChromaKeySoftness, Mode=TwoWay}"
VerticalAlignment="Center"/>
</DockPanel>
<CheckBox Style="{StaticResource PropertyPillCheck}" Margin="10,0,0,4"
Content="Fringe" IsChecked="{Binding SelectedElement.ChromaKeySpill, Mode=TwoWay}"
ToolTip="Clean the coloured rim the screen leaves on hair and edges"/>
</StackPanel>
<!-- Chat box config -->