Skip to content

Named an audio-bearing source _audiovideo and described its sound - #47

Merged
CodyCBakerPhD merged 2 commits into
mainfrom
claude/bep047-audio-video-suffix-65ci6s
Aug 25, 2026
Merged

Named an audio-bearing source _audiovideo and described its sound#47
CodyCBakerPhD merged 2 commits into
mainfrom
claude/bep047-audio-video-suffix-65ci6s

Conversation

@CodyCBakerPhD

@CodyCBakerPhD CodyCBakerPhD commented Aug 25, 2026

Copy link
Copy Markdown
Member

BEP047 gives a recording that carries sound its own _audiovideo suffix, where a silent one is _video. The copy of the source video carried into sourcedata/ is the only file a delivery writes that can be either, so it now takes that suffix whenever the file has an audio track, and its sidecar carries BEP047's audio keys beside the picture ones:

AudioCodec, AudioSampleRate, AudioChannelCount, AudioBitDepth, AudioCodecRFC6381

The derivative keeps the plain _video name: the frame-exact cut and the stream copy both drop audio already (-an, mediabunny's audio: { discard: true }), so nothing extracted here ever has sound to describe.

How the track is read

New lib/audioFormat.ts, the counterpart to lib/videoFormat.ts: mediabunny opens the file and reports its primary audio track. Nothing is inferred from the filename or MIME type, and each key is left out rather than guessed when the track does not answer for it — a file that cannot be opened at all reads as silent, since naming a file _audiovideo on a guess is worse than under-describing one.

Two translations, mirroring the pixel-format one already in videoFormat.ts: mediabunny names codecs after the WebCodecs registry, BEP047 asks for FFmpeg's naming, so the PCM family maps across (pcm-s16pcm_s16le, ulawpcm_mulaw, …). That mapping is also where AudioBitDepth comes from — for uncompressed audio the codec name is the sample width — and it is omitted for compressed codecs, which state none.

Testing

?test&mock_audio synthesizes the mock recording with a real Opus track, so tests/integration/audio.spec.ts drives the whole path end to end: a save with sound writes sub-unknown_audiovideo.mp4 plus a sidecar naming the codec, rate and channel count, and the clip cut out of it is still _video with no audio keys at all. It is written through mediabunny rather than recorded through MediaRecorder because a page that boots straight into a synthesized recording has no user gesture to start an AudioContext with, and a recorder waiting on a suspended one writes nothing.

Unit tests cover the codec translation, the probe's best-effort behavior, both filename suffixes and the sidecar keys. Full suite green: 586 unit, 72 integration.

Original prompt

For the BEP047 (bids-standard/bids-specification#2231) output, if input source video has an audio track, the suffix should become _audiovideoand should include

AudioCodec	RECOMMENDED	string	The audio codec used to encode the audio stream, expressed as an FFmpeg codec name (for example, "aac", "mp3", "opus", "flac", "pcm_s16le"). This value can be auto-extracted using ffprobe -v quiet -print_format json -show_streams.
AudioSampleRate	RECOMMENDED	number	Sampling frequency of the audio stream, in Hz (for example, 44100, 48000, 96000).

Must be a number greater than 0.
AudioChannelCount	RECOMMENDED	integer	Number of audio channels in the audio or audio-video file (for example, 1 for mono, 2 for stereo).

Must be a number greater than or equal to 1.
AudioBitDepth	OPTIONAL	integer	Number of bits per sample in the audio stream (for example, 16, 24, or 32). Typically reported for uncompressed or losslessly compressed audio.

Must be a number greater than or equal to 1.
AudioCodecRFC6381	OPTIONAL	string	The audio codec expressed as an RFC 6381 codec string (for example, "mp4a.40.2" for AAC-LC). This representation is useful for web and broadcast interoperability.

the derivative extraction should strip the audio and so just be _video as it currently is

🤖 Generated with Claude Code

https://claude.ai/code/session_01VkP8ocV3fTrT1FzVnRR5Eg

claude added 2 commits August 25, 2026 16:26
BEP047 gives a recording that carries sound its own `_audiovideo` suffix
where a silent one is `_video`. The copy of the source video carried into
`sourcedata/` is the only file a delivery writes that can be either, since
everything extracted from it drops audio on the way out, so it now takes
that suffix whenever the file has an audio track, and its sidecar carries
BEP047's audio keys (`AudioCodec`, `AudioSampleRate`, `AudioChannelCount`,
`AudioBitDepth`, `AudioCodecRFC6381`) beside the picture ones. The
derivative keeps the plain `_video` name.

The track is read off the container with mediabunny rather than inferred
from the file's name or type; a file that cannot be opened reads as silent
rather than being named on a guess, and each key is omitted rather than
guessed when the track does not answer for it. `?test&mock_audio`
synthesizes a mock recording with a real Opus track, so the whole path is
driven end to end.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VkP8ocV3fTrT1FzVnRR5Eg
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VkP8ocV3fTrT1FzVnRR5Eg
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-25 16:41 UTC

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.88235% with 30 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lib/testInjection.ts 11.76% 30 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #47      +/-   ##
==========================================
- Coverage   84.98%   83.92%   -1.06%     
==========================================
  Files          41       42       +1     
  Lines        1845     1910      +65     
  Branches      472      487      +15     
==========================================
+ Hits         1568     1603      +35     
- Misses        277      307      +30     
Files with missing lines Coverage Δ
src/lib/audioFormat.ts 100.00% <100.00%> (ø)
src/lib/bidsPath.ts 100.00% <100.00%> (ø)
src/lib/provenance.ts 100.00% <100.00%> (ø)
src/lib/testInjection.ts 43.38% <11.76%> (-10.54%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@CodyCBakerPhD CodyCBakerPhD self-assigned this Aug 25, 2026
@CodyCBakerPhD
CodyCBakerPhD marked this pull request as ready for review August 25, 2026 16:33
@CodyCBakerPhD
CodyCBakerPhD merged commit 74283d6 into main Aug 25, 2026
15 checks passed
@CodyCBakerPhD
CodyCBakerPhD deleted the claude/bep047-audio-video-suffix-65ci6s branch August 25, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants