FFmpeg MP3 Size Issue: Why Bitrate Changes Don't Affect File Size

Understanding Audio File Conversion Issues
For individuals unfamiliar with audio file conversion, the intricacies of the process can often lead to confusion, particularly when outcomes differ from expectations.
When encountering problems during conversion, knowing how to troubleshoot is essential. This article addresses a reader’s query regarding unexpected results in audio file conversions.
SuperUser Q&A Session
The following question and answer are sourced from SuperUser, a segment of Stack Exchange—a network of communities dedicated to question and answer forums.
Stack Exchange provides a collaborative platform where users can seek and share knowledge across a wide range of topics.
The accompanying image is credited to Warein, as featured on Flickr.
Understanding Consistent File Sizes During Audio Conversion
A SuperUser user, Arlen Beiler, recently inquired about an unexpected outcome during audio stream conversion. Despite employing varying bitrate settings, the resulting files exhibited identical sizes.
The User's Scenario
Arlen converted a single audio stream into three separate files, each utilizing a distinct bitrate. The conversion process leveraged the ffmpeg tool, maintaining the original video stream while re-encoding the audio portion.
The specific ffmpeg commands used were as follows:
ffmpeg -i "Likoonl-Q1-All.mp4" -c:v copy -c:a libmp3lame -q:a 1 -b:a 192k "Q1-All-192k.mp4"ffmpeg -i "Likoonl-Q1-All.mp4" -c:v copy -c:a libmp3lame -q:a 1 -b:a 160k "Q1-All-160k.mp4"ffmpeg -i "Likoonl-Q1-All.mp4" -c:v copy -c:a libmp3lame -q:a 1 -b:a 128k "Q1-All-128k.mp4"
The Core Issue: Variable Bitrate (VBR) Encoding
The reason for this seemingly paradoxical result lies in the use of Variable Bitrate (VBR) encoding with the libmp3lame codec. VBR doesn't allocate a fixed amount of data for each unit of audio.
Instead, it dynamically adjusts the bitrate based on the complexity of the audio signal. More complex sections receive a higher bitrate, while simpler sections receive a lower bitrate.
How VBR Affects File Size
When using VBR, the target average bitrate is specified, but the actual bitrate fluctuates. The -q:a 1 parameter in the commands instructs ffmpeg to use a specific VBR quality setting.
This quality setting, rather than a fixed bitrate, dictates the overall encoding process. If the source audio doesn't require the full bitrate potential allowed by each quality setting, the resulting files can end up being the same size.
The Role of the Video Stream
Crucially, the -c:v copy option ensures that the video stream remains unchanged. This means the video data contributes equally to the file size across all conversions.
Since the video portion is identical, any differences in audio encoding must be offset by changes in the audio data size. However, with VBR and a source audio that doesn't fully utilize the higher bitrates, this offset doesn't occur.
In Conclusion
The consistent file sizes were a consequence of utilizing VBR encoding with libmp3lame. The audio complexity, combined with the -q:a 1 setting, resulted in similar data requirements for each bitrate target.
Understanding MP3 File Size Consistency with Variable Bitrate Encoding
A SuperUser user, slhck, provides insight into why MP3 files might maintain the same size despite bitrate adjustments. The core issue stems from utilizing the -q:a flag within FFmpeg, which activates LAME's Variable Bitrate (VBR) encoding.
The Conflict Between -q:a and -b:a
When the -q:a parameter is specified, it overrides any Constant Bitrate (CBR) settings defined by the -b:a flag. Consequently, alterations made to the bitrate using -b:a will not influence the final file size.
The FFmpeg Wiki's MP3 encoding guide details the available values for -q:a and their corresponding average bitrates. This documentation clarifies the relationship between quality settings and resulting file sizes.
Inside libmp3lame.c
For a deeper understanding, the relevant section of the libmp3lame.c source code reveals how the qscale (the full name of q) parameter functions. This internal view illustrates the encoding process.
Further discussion and contributions are welcome in the comments section. For a more comprehensive view, the original discussion thread on Stack Exchange can be accessed for additional perspectives from other knowledgeable users.