[PR #8703] Calculate output audio bitrate from output channel count #11830

Closed
opened 2026-02-07 06:45:20 +03:00 by OVERLORD · 0 comments
Owner

Original Pull Request: https://github.com/jellyfin/jellyfin/pull/8703

State: closed
Merged: No


384kbps is unnecessarily high for stereo output with our encoders and sending data over network is expensive. This commit introduces logic for calculating output bitrate based on output channel count, like this:

(inputChannels, outputChannels) switch
{
    ( >= 6, >= 6 or 0) => Math.Min(640000, audioBitRate.Value),
    ( > 0, > 0) => Math.Min(outputChannels * 128000, audioBitRate.Value),
    ( > 0, _) => Math.Min(inputChannels * 128000, audioBitRate.Value),
    (_, _) => Math.Min(384000, audioBitRate.Value)
}

That means transcoded stereo output in hls is going to be at most 256kbps, mono 128kbps, surround 640kbps, etc.

The second commit adds VBR mode calculation from the output bitrate based on expected upper-bound average bitrate for high-quality audio. This is user-configurable and disabled by default.

Continued from https://github.com/jellyfin/jellyfin/pull/8113

**Original Pull Request:** https://github.com/jellyfin/jellyfin/pull/8703 **State:** closed **Merged:** No --- 384kbps is unnecessarily high for stereo output with our encoders and sending data over network is expensive. This commit introduces logic for calculating output bitrate based on output channel count, like this: ```csharp (inputChannels, outputChannels) switch { ( >= 6, >= 6 or 0) => Math.Min(640000, audioBitRate.Value), ( > 0, > 0) => Math.Min(outputChannels * 128000, audioBitRate.Value), ( > 0, _) => Math.Min(inputChannels * 128000, audioBitRate.Value), (_, _) => Math.Min(384000, audioBitRate.Value) } ``` That means transcoded stereo output in hls is going to be **at most** 256kbps, mono 128kbps, surround 640kbps, etc. The second commit adds VBR mode calculation from the output bitrate based on expected upper-bound average bitrate for high-quality audio. This is user-configurable and disabled by default. Continued from https://github.com/jellyfin/jellyfin/pull/8113
OVERLORD added the pull-request label 2026-02-07 06:45:20 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#11830