From 6c806aa08cf5f792d932e0050b767aea9fef13d3 Mon Sep 17 00:00:00 2001 From: Alex Mihaiuc <69110671+foxmsft@users.noreply.github.com> Date: Thu, 26 Feb 2026 19:27:19 +0100 Subject: [PATCH] Make the ZoomIt AAC audio track depend on system audio or audio input (#45700) When neither option is selected, then the resulting .mp4 container won't have an audio track added to it. This is due to the recent audio input addition. As a result, all .mp4 recordings now have an audio track, even if empty. Restoring the prior functionality, where just the h264 video is present on no audio. ## Summary of the Pull Request ## PR Checklist - [ ] Closes: #xxx - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --- .../ZoomIt/ZoomIt/VideoRecordingSession.cpp | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/modules/ZoomIt/ZoomIt/VideoRecordingSession.cpp b/src/modules/ZoomIt/ZoomIt/VideoRecordingSession.cpp index 367c732dc6..0ee20fdad4 100644 --- a/src/modules/ZoomIt/ZoomIt/VideoRecordingSession.cpp +++ b/src/modules/ZoomIt/ZoomIt/VideoRecordingSession.cpp @@ -940,10 +940,12 @@ VideoRecordingSession::VideoRecordingSession( video.PixelAspectRatio().Denominator(1); m_encodingProfile.Video(video); - // Always set up audio profile for loopback capture (stereo AAC) - auto audio = m_encodingProfile.Audio(); - audio = winrt::AudioEncodingProperties::CreateAac(48000, 2, 192000); - m_encodingProfile.Audio(audio); + if (captureAudio || captureSystemAudio) + { + auto audio = m_encodingProfile.Audio(); + audio = winrt::AudioEncodingProperties::CreateAac(48000, 2, 192000); + m_encodingProfile.Audio(audio); + } // Describe our input: uncompressed BGRA8 buffers auto properties = winrt::VideoEncodingProperties::CreateUncompressed( @@ -964,8 +966,14 @@ VideoRecordingSession::VideoRecordingSession( winrt::check_hresult(m_previewSwapChain->GetBuffer(0, winrt::guid_of(), backBuffer.put_void())); winrt::check_hresult(m_d3dDevice->CreateRenderTargetView(backBuffer.get(), nullptr, m_renderTargetView.put())); - // Always create audio generator for loopback capture; captureAudio controls microphone - m_audioGenerator = std::make_unique(captureAudio, captureSystemAudio, micMonoMix); + if (captureAudio || captureSystemAudio) + { + m_audioGenerator = std::make_unique(captureAudio, captureSystemAudio, micMonoMix); + } + else + { + m_audioGenerator = nullptr; + } } @@ -1207,14 +1215,8 @@ void VideoRecordingSession::OnMediaStreamSourceSampleRequested( { try { - if (auto sample = m_audioGenerator->TryGetNextSample()) - { - request.Sample(sample.value()); - } - else - { - request.Sample(nullptr); - } + auto sample = m_audioGenerator ? m_audioGenerator->TryGetNextSample() : std::optional{}; + request.Sample(sample.has_value() ? sample.value() : nullptr); } catch (winrt::hresult_error const& error) {