feat(transcoder): output audio volume gain on the re-encode path#31
Merged
Conversation
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.
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.
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:
"2","0.5"→ output = value × input"+9dB","-6dB"→ output level = input ± dB → factor =10^(dB/20)"1"/"0dB"→ unity (no change)domain.ParseAudioVolumeis 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
domain→proto(regenerated via protoc) →supervisor→ subprocesspipeline.Tests
TestParseAudioVolume(linear/dB/invalid/negative),TestApplyGain_ScalesAndClamps,TestApplyGain_UnityNoOp.make checkgreen (native built + raced with local libav; lint 0 issues).Notes
Already deployed to prod as
v4.4.7(dormant — no stream setsvolumeyet, so existing audio is unchanged). Volume only applies when audio is re-encoded (audio.copy=false).