Repository navigation
mediaPreview: warn when a media file's audio codec can't be played - #346571
Merged
Logan Ramos (lramos15) merged 2 commits intoNov 6, 2026
Merged
Conversation
Chromium silently drops audio tracks it can't decode, so a video whose audio uses an unsupported codec (such as AAC in builds whose FFmpeg doesn't include it) plays without sound and looks like a broken file. The audio and video previews now read the codecs of the file's audio tracks from its container (MP4, WebM, Ogg or WAV) and, if the webview can't play any of them, show a warning that suggests opening the file in an external application. The WebM fallback that plays files through Media Source Extensions now gets the codecs of all tracks from the same parser instead of searching the first bytes of the file for codec IDs. Fixes #343048 Co-authored-by: Copilot <[email protected]>
Ross Wollman (rwoll)
previously approved these changes
Nov 6, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The codec mapping incorrectly labels MPEG-4 ALS streams as AAC, causing unsupported-playback warnings to report the wrong codec.
1 open issue
What changed in this PR
Adds unsupported-audio-codec warnings to VS Code’s media previews, helping explain silent video playback and audio load failures reported in #343048.
Changes:
- Adds bounded container parsing for MP4, WebM, Ogg, and WAV.
- Displays localized codec warnings and reuses parsed track information for the WebM playback fallback.
- Adds parser fixtures and tests for codec detection, read limits, and webview messaging.
| File | Description |
|---|---|
src/vs/workbench/contrib/mediaPreview/test/common/mediaTestFiles.ts |
Adds minimal media-file fixture builders. |
src/vs/workbench/contrib/mediaPreview/test/common/mediaCodecs.test.ts |
Tests codec parsing and file-read behavior. |
src/vs/workbench/contrib/mediaPreview/test/browser/mediaPreviewEditorInputs.test.ts |
Tests codec-warning and WebM-type messaging. |
src/vs/workbench/contrib/mediaPreview/common/mediaCodecs.ts |
Implements bounded container and track-codec parsing. |
src/vs/workbench/contrib/mediaPreview/browser/mediaPlayerEditorInput.ts |
Integrates warnings and parser-backed WebM fallback detection. |
Review effort: Balanced
MPEG-4 Audio also covers codecs that aren't AAC, such as lossless ALS. Any audio object type other than MPEG-1/2 Layer 1 to 3 was named AAC, so the warning for an unsupported ALS track blamed AAC, even in builds that play AAC. AAC object types are now named explicitly, and other object types are left unnamed so that the warning doesn't name a codec. Co-authored-by: Copilot <[email protected]>
roblourens
approved these changes
Nov 6, 2026
Logan Ramos (lramos15)
deleted the
agents/audio-video-preview-warning-support
branch
November 6, 2026 18:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #343048
The video and audio previews now warn when a file's audio uses a codec that can't be played, and suggest opening the file in an external application, so users don't think the file is broken. For example:
For an audio file that fails to load, the warning replaces the generic "An error occurred while loading the audio file." message.
Why the container is parsed
Chromium silently drops audio tracks it can't decode: a video whose AAC audio can't be decoded plays with no error, no tracks and no decoded audio, just like a video without audio. Since #343490,
canPlayTypeandMediaSource.isTypeSupportedreport codec support correctly, but they need the codec as input, and nothing in the browser or Electron exposes the codecs of a file. So the newreadMediaInfo(mediaPreview/common/mediaCodecs.ts) reads the container and the codecs of the tracks of MP4, WebM, Ogg and WAV files, and the webview checks them against the runtime.Notes for reviewers
readFileStream, up to 2 MiB.readFilereads whole files whenever the provider can, even withpositionandlength. Providers that can only read whole files, such as the Agent Host file system used for remote agent sessions, are read once and only up to 64 MiB. Reads never extend past the end of the file, which avoids a truncation bug inreadFileIntoStreamthat's fixed separately in files: fix truncated ranged reads that reach the end of a file #346572; this PR doesn't depend on it.canPlayTypeonly recognizes PCM (IEEE float, A-law, mu-law, MP3) are never reported.How to test
ffmpeg -f lavfi -i testsrc=duration=3 -f lavfi -i sine=duration=3 -c:v libx264 -c:a aac narrated.mp4). The video plays and the warning above it names AAC.-c:a ac3) to see the warning, and an IMA ADPCM WAV file (-c:a adpcm_ima_wav) to see the warning replace the audio preview's load error.Validation:
./scripts/test.sh --run src/vs/workbench/contrib/mediaPreview/test/common/mediaCodecs.test.ts --run src/vs/workbench/contrib/mediaPreview/test/browser/mediaPreviewEditorInputs.test.ts --run src/vs/workbench/contrib/mediaPreview/test/common/mediaPreview.test.ts: passed (11 tests).pnpm run typecheck-client: passed.pnpm run eslinton the changed files: passed.canPlayTypeandMediaSource.isTypeSupported.