Skip to content

fix(audio_mixer): stop forcing 16 kHz mono PCM in extract - #577

Merged
calesthio merged 2 commits into
OpenMontageInc:mainfrom
PabloAraya6:fix/audio-mixer-extract-fidelity
Nov 8, 2026
Merged

calesthio merged 2 commits into
OpenMontageInc:mainfrom
PabloAraya6:fix/audio-mixer-extract-fidelity

Conversation

@PabloAraya6

Copy link
Copy Markdown
Contributor

Summary

audio_mixer's extract operation hardcoded a speech/STT preset onto every call. Any caller extracting a music or effects bed silently got 16 kHz mono, and any output container other than WAV failed outright. The schema documents the operation only as "extract audio from video file", so nothing warned the caller.

Related issue

Refs none. Found while mixing a montage's native audio.

Changes

  • tools/audio/audio_mixer.py: _extract drops -acodec pcm_s16le -ar 16000 -ac 1 and lets the muxer pick the codec for the requested container.
  • tests/tools/test_audio_mixer_extract_fidelity.py: asserts the command pins neither sample rate nor channel count, and does not push pcm_s16le into an m4a container.

Two failures from one preset

Fidelity: a 48 kHz stereo source came back 16 kHz mono. Half the spectrum and the stereo image, gone with no warning. Fine for Whisper, wrong for a mix bus.

Containers: pcm_s16le cannot be muxed into m4a. Extracting to anything but WAV died on Could not find tag for codec pcm_s16le in stream #0, codec not currently supported in container.

No caller in the repo depends on the old behavior. extract is reachable only through the operation dispatch, and transcriber does not route through it.

Tradeoffs

A caller that genuinely wants 16 kHz mono for speech now has to ask for it. No such caller exists in the repo, so I did not add parameters for a hypothetical one.

Blast Radius

One function, no in-repo callers. Anyone calling extract for STT gets a higher-fidelity file than before, which the downstream model resamples anyway.

Testing

  • pytest tests/tools/test_audio_mixer_extract_fidelity.py — 2 failed before, 2 passed after.
  • pytest tests/tools tests/contracts — 1750 passed, 7 skipped, 3 xfailed.
  • Ran the real extract against a generated 26 s clip. Before: 16000 Hz mono for WAV, hard failure for m4a. After: pcm_s16le,44100,2 for WAV and aac,44100,2 for m4a.

Checklist

  • The change is focused on a single logical concern.
  • I ran the relevant tests locally.
  • I updated docs/README if behavior or usage changed.
  • No unrelated files (build artifacts, local config) are included in the diff.

PabloAraya6 and others added 2 commits August 29, 2026 12:48
Two cases against `_extract`. The command must not pin a sample rate or
channel count, and must not push `pcm_s16le` into an m4a container. Both fail
today.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016K9spmyzHH5qkwvnxH573h
Drop `-acodec pcm_s16le -ar 16000 -ac 1` from `_extract` and let the muxer
pick the codec for the requested container. The flags were a speech preset on
an operation documented only as "extract audio from video file", so a music or
effects bed lost half its spectrum and its stereo image, and any container but
WAV failed on `Could not find tag for codec pcm_s16le`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016K9spmyzHH5qkwvnxH573h
@PabloAraya6
PabloAraya6 requested a review from calesthio as a code owner August 29, 2026 15:50
pavelhov pushed a commit to pavelhov/OpenMontage that referenced this pull request Sep 7, 2026
Adapt calesthio/OpenMontage PRs OpenMontageInc#598, OpenMontageInc#606, OpenMontageInc#573, OpenMontageInc#577, OpenMontageInc#625,
and OpenMontageInc#634 with regression coverage. Extract subtitle-disable behavior
from OpenMontageInc#629 and the local-first runtime idea from OpenMontageInc#614, preserving host
environment options and consistent CLI selection.

Keep source-frame directories distinct by full path, preserve SRT cue
boundaries, and prevent reference filenames from clipping on mobile.
Exclude duplicated and unrelated additions in OpenMontageInc#641 and OpenMontageInc#613.

Co-authored-by: Arnaud Chretien <achretien22@gmail.com>
Co-authored-by: Algoritim Bilişim <iletisim@algoritimbilisim.com>
Co-authored-by: xp <xue_yun@foxmail.com>
Co-authored-by: Pablo Araya <arayap812@gmail.com>
Co-authored-by: Bakary Gibba <162592884+BakaryGibba@users.noreply.github.com>
Co-authored-by: kraaft007 <63367797+kraaft007@users.noreply.github.com>
Co-authored-by: Oğuzhan Filiz <oguzhanfiliz3@gmail.com>
Co-authored-by: gaobenchang <gaobenchang@users.noreply.localhost>

@calesthio calesthio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for removing the speech-specific extraction preset from general audio extraction. Reviewed the complete diff against main 63d1087a. Validation: supplied focused tests 2 passed, plus actual FFmpeg extraction of a stereo 48 kHz fixture into WAV, M4A and MP3. ffprobe confirmed 48 kHz/stereo in all three, with the appropriate PCM/AAC/MP3 encoder chosen by each container. This fixes the accidental mono/16 kHz restriction; it does not promise bit-identical audio for lossy output formats.

@calesthio calesthio closed this Nov 7, 2026
@calesthio calesthio reopened this Nov 7, 2026
calesthio pushed a commit that referenced this pull request Nov 8, 2026
@calesthio
calesthio merged commit a1843b0 into OpenMontageInc:main Nov 8, 2026
1 check passed
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.

2 participants