Skip to content

feat(transcoder): output audio volume gain on the re-encode path#31

Merged
ntt0601zcoder merged 1 commit into
mainfrom
feat/audio-volume
Jun 16, 2026
Merged

feat(transcoder): output audio volume gain on the re-encode path#31
ntt0601zcoder merged 1 commit into
mainfrom
feat/audio-volume

Conversation

@ntt0601zcoder

Copy link
Copy Markdown
Owner

What

Adds a per-stream audio output volume gain on the transcoder re-encode path (AudioTranscodeConfig.Volume).

The value follows the standard playout volume convention — two interchangeable forms that both reduce to a single linear factor:

  • linear multiplier: "2", "0.5" → output = value × input
  • decibels: "+9dB", "-6dB" → output level = input ± dB → factor = 10^(dB/20)
  • empty / "1" / "0dB" → unity (no change)

domain.ParseAudioVolume is the single parser (also usable for save-time validation).

How

The gain is applied per sample on the FLTP encoder-input frame just before encode, clamped to full scale [-1, 1] so a boost can't wrap/distort past the float range. Unity is a no-op (early return) → streams without a volume set are byte-identical. Only the re-encode path is affected; audio copy/passthrough has no decoded samples to scale.

Plumbed domainproto (regenerated via protoc) → supervisor → subprocess pipeline.

Tests

TestParseAudioVolume (linear/dB/invalid/negative), TestApplyGain_ScalesAndClamps, TestApplyGain_UnityNoOp. make check green (native built + raced with local libav; lint 0 issues).

Notes

Already deployed to prod as v4.4.7 (dormant — no stream sets volume yet, so existing audio is unchanged). Volume only applies when audio is re-encoded (audio.copy=false).

Adds a per-stream audio output volume control (AudioTranscodeConfig.Volume),
applied on the re-encode path. The value follows the standard playout volume
convention: a plain linear multiplier ("2", "0.5" -> output = value x input)
or a decibel string ("+9dB", "-6dB" -> output level = input +/- dB). Both
reduce to a single linear factor via ParseAudioVolume (factor = 10^(dB/20) for
dB). Empty / "1" / "0dB" = unity gain (no change).

The gain is applied per sample on the FLTP encoder-input frame just before
encode, clamped to full scale [-1, 1] so a boost cannot wrap/distort past the
float range. Unity is a no-op (early return) so streams without a volume set
are byte-identical. Only the re-encode path is affected; audio copy /
passthrough has no decoded samples to scale.

Plumbed domain -> proto (regenerated) -> supervisor -> subprocess pipeline.

Tests: TestParseAudioVolume (linear/dB/invalid), TestApplyGain_ScalesAndClamps
and _UnityNoOp.
@ntt0601zcoder ntt0601zcoder merged commit b1abd79 into main Jun 16, 2026
4 checks passed
@ntt0601zcoder ntt0601zcoder deleted the feat/audio-volume branch June 17, 2026 02:43
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.

1 participant