chakrik73 7d1dde7aa5 [ZoomIt] Port recording/editing features from Mac ZoomIt (trim editor, snip-to-clipboard, recording border) and fix video trim reliability (#49553)
## Summary of the Pull Request

Ports several recording and editing features from the Sysinternals **Mac
ZoomIt** into the Windows PowerToys ZoomIt module, and hardens the video
**trim/save** pipeline against a sporadic "Failed to trim the video"
failure.

Highlights:
- **Video trim editor — interior "Delete Region" editing.** In the
post-recording trim dialog you can now select and delete interior
segments (not just trim the head/tail). Includes red timeline overlays
with drag grips, right-drag to select, `Delete` to remove, `Ctrl+Z` to
undo, and `Esc` to cancel a pending selection.
- **Reliable trim/render.** Fixed a sporadic *"Failed to trim the
video"* error. The live capture pipeline produces **fragmented** MP4s
(moof/mdat) that play in preview but fail `MediaComposition` render/seek
with `0xC00DA7FC`. The render path now (a) sources resolution from the
clip's encoding properties first, (b) retries transient failures (0×0
dimensions from a fragmented-MP4 metadata race, `!CanTranscode()`,
post-remux render failure), and (c) remuxes fragmented MP4s to a
standard seekable MP4 via `MediaTranscoder` before rendering.
- **Snip → Copy to clipboard.** New ZoomIt setting to copy a snip
directly to the clipboard.
- **Recording border color.** The screen-recording selection border now
uses a distinct color, and turns orange while recording is active.
- **GIF recording robustness.** First-frame timeout so GIF capture
doesn't hang when no frames arrive.
- **Audio hardening.** Stereo downmix handling and defensive guards in
the audio sample generator.
- **Opt-in diagnostics.** Recording diagnostics (`[RecDiag]`) are gated
behind a registry DWORD
`HKCU\Software\Sysinternals\ZoomIt\EnableDebugTrace` (off by default),
and all module debug output is prefixed with `[ZoomIt]` for easy
filtering in DebugView.
- **Fix:** GDI bitmap leak in the snip-to-clipboard path when
`SetClipboardData` fails.

## PR Checklist

- [ ] **Tests:** ZoomIt is native Win32/WinRT with no unit-test harness;
validated manually (see Validation Steps)
- [ ] - [x] **Localization:** All end-user-facing strings can be
localized <!-- new strings added to Settings.UI en-us Resources.resw -->
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** N/A: no new binaries/projects 
  - [ ] JSON for signing — N/A
  - [ ] WXS for installer — N/A
  - [ ] YML for CI pipeline — N/A
  - [ ] YML for signed pipeline — N/A
- [ ] **Documentation updated:** N/A

## Detailed Description of the Pull Request / Additional comments

Files changed (17):

**ZoomIt module (native)**
- `VideoRecordingSession.cpp/.h` — interior delete-region trim editor;
render/trim reliability (resolution from clip encoding properties, retry
loop, fragmented-MP4 → seekable remux); registry-gated `[RecDiag]`
diagnostics.
- `GifRecordingSession.cpp` — first-frame timeout / no-frames handling.
- `AudioSampleGenerator.cpp` — stereo downmix + defensive guards.
- `SelectRectangle.cpp/.h`, `PanoramaCapture.cpp` — recording border
color parameter.
- `Zoomit.cpp` — snip → clipboard workflow; GDI bitmap leak fix on
`SetClipboardData` failure.
- `ZoomItSettings.h`, `ZoomIt.h`, `ZoomIt.rc`, `resource.h` — new
setting + "Delete Region" button + message id.
- `pch.h` — `[ZoomIt]` debug-output prefix wrapper.

**Settings UI**
- `ZoomItProperties.cs`, `ZoomItViewModel.cs`, `ZoomItPage.xaml`,
`Resources.resw` — "Copy snip to clipboard" setting and localized
strings.

Note: ZoomIt is a Sysinternals port kept in its upstream code style, so
it is intentionally exempt from the repo `.clang-format` (changed lines
follow the surrounding Sysinternals convention).

## Validation Steps Performed

Manual validation (no automated ZoomIt harness):
- **Trim reliability:** Recorded multiple clips and used Trim → Save
repeatedly (including 3-clip compositions produced by Delete Region);
render now succeeds consistently (previously failed sporadically with
"Failed to trim the video").
- **Delete Region editor:** Right-drag to select an interior segment,
`Delete` to remove, `Ctrl+Z` to undo, `Esc` to cancel; saved output
reflects the removed segments.
- **Snip → clipboard:** Enabled the new setting; snip is placed on the
clipboard and pastes correctly. Verified no GDI handle leak when
clipboard set fails.
- **Recording border:** Verified border color and the orange
active-recording state (full-monitor and region).
- **GIF:** Confirmed capture no longer hangs when no frames arrive.
- **Diagnostics:** With `EnableDebugTrace` unset, no
`%TEMP%\ZoomIt_RecDiag.log` and no `[RecDiag]` output; with it set to
`1`, `[ZoomIt] [RecDiag ...]` traces appear.
- **Style checks:** XamlStyler (clean), StyleCop via building
`Settings.UI.Library` and `PowerToys.Settings` (no `SA####` warnings),
ZoomIt x64 Release builds with exit code 0.
2026-07-30 09:17:52 -07:00

Microsoft PowerToys

Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks.

Installation · Documentation · Blog · Release notes

🔨 Utilities

PowerToys includes over 30 utilities to help you customize and optimize your Windows experience:

Advanced Paste icon Advanced Paste Always on Top icon Always on Top Awake icon Awake
Color Picker icon Color Picker Command Not Found icon Command Not Found Command Palette icon Command Palette
Crop and Lock icon Crop And Lock Environment Variables icon Environment Variables FancyZones icon FancyZones
File Explorer Add-ons icon File Explorer Add-ons File Locksmith icon File Locksmith Grab And Move icon Grab And Move
Hosts File Editor icon Hosts File Editor Image Resizer icon Image Resizer Keyboard Manager icon Keyboard Manager
Light Switch icon Light Switch Mouse Utilities icon Mouse Utilities Mouse Without Borders icon Mouse Without Borders
New+ icon New+ Peek icon Peek PowerDisplay icon PowerDisplay
PowerRename icon PowerRename PowerToys Run icon PowerToys Run Quick Accent icon Quick Accent
Registry Preview icon Registry Preview Screen Ruler icon Screen Ruler Shortcut Guide icon Shortcut Guide
Text Extractor icon Text Extractor Workspaces icon Workspaces ZoomIt icon ZoomIt

📦 Installation

For detailed installation instructions and system requirements, visit the installation docs.

But to get started quickly, choose one of the installation methods below:

Download the .exe file from GitHub

Go to the PowerToys GitHub releases, scroll down and select Assets to reveal the installation files, and choose the one that matches your architecture and install scope. For most devices, that would be x64 per-user.

Microsoft Store
You can easily install PowerToys from the Microsoft Store:

WinGet
Download PowerToys from [WinGet](https://github.com/microsoft/winget-cli#installing-the-client). Updating PowerToys via winget will respect the current PowerToys installation scope. To install PowerToys, run the following command from the command line / PowerShell:
  • User scope installer (default)
winget install Microsoft.PowerToys -s winget
  • Machine-wide scope installer
winget install --scope machine Microsoft.PowerToys -s winget
Other methods
There are [community driven install methods](https://learn.microsoft.com/windows/powertoys/install#community-driven-install-tools) such as Chocolatey and Scoop. If these are your preferred install solutions, you can find the install instructions there.

What's new?

What's new image

To see what's new, check out the release notes.

🛣️ Roadmap

We are planning some nice new features and improvements for the next releases a brand-new Shortcut Guide experience, ensuring it's easier to find and install Command Palette extensions and so much more! Stay tuned for v0.100!

❤️ PowerToys Community

The PowerToys team is extremely grateful to have the support of an amazing active community. The work you do is incredibly important. PowerToys wouldn't be nearly what it is today without your help filing bugs, updating documentation, guiding the design, or writing features. We want to say thank you and take time to recognize your work. Your contributions and feedback improve PowerToys month after month!

Contributing

This project welcomes contributions of all types. Besides coding features / bug fixes, other ways to assist include spec writing, design, documentation, and finding bugs. We are excited to work with the power user community to build a set of tools for helping you get the most out of Windows. We ask that before you start work on a feature that you would like to contribute, please read our Contributor's Guide. We would be happy to work with you to figure out the best approach, provide guidance and mentorship throughout feature development, and help avoid any wasted or duplicate effort. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you grant us the rights to use your contribution and that you have permission to do so. For guidance on developing for PowerToys, please read the developer docs for a detailed breakdown. This includes how to setup your computer to compile.

Code of conduct

This project has adopted the Microsoft Open Source Code of Conduct.

Privacy statement

The application logs basic diagnostic data (telemetry). For more privacy information and what we collect, see our PowerToys Data and Privacy documentation.

Description
Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks
Readme MIT 742 MiB
Languages
C 44.9%
C# 26.4%
JavaScript 14%
C++ 13.8%
PowerShell 0.6%
Other 0.2%