I’ve been searching for hours through the web, but the longer I am searching the more I get confused.
What audio bitrate shall I use for video encoding with libx264/libx265 and aac ?
Why do all the stock export profiles have the constant bitrate set and do not utilize the average or variable bit rate options?
I found a post from 2002 that no method exists for muxing a variable bitrate mp3 to an mpeg1 video file, but is it the same with modern codecs?
I found a contradictory post that if it comes to video encoding, AAC is always VBR, without any explanation, and a link to Making sure you're not a bot! which does not reply.
If so, why are rate control options offered in the Audio tab of the ShotCut export dialog, namely Constant Bitrate, Average bitrate and Quality-based VBR?
I found a post that the CBR value to enter represents the total of all channels which would mean that 256 kbit/s devided by 5 surround channels would result in 51 kbit per channel. If true, what is the recommended CBR setting for audiophile quality?
Quality-based VBR the default setting is 50% (aq=1,05). I found no documentation of the aq parameter, and I doubt that 50% is a good setting for demanding listeners. So what aq setting is recommended, if VBR is a choice after all? A aq value of 2.0 is equal to CBR I guess?
My suggestion is to start with the default setting. It was chosen as a good compromise for quality, bitrate, and compatibility. Listen to the export with your demanding ears. Does it sound good? If not, what do you hear that you do not like?
If you want to use the advanced section of the encode panel, you will want to build your understanding of FFMpeg. This page has some good information: https://ffmpeg.org/ffmpeg-codecs.html#aac
Wait for the progress bar to complete, and then the page will display. There is some good information in that page as well.
Regarding your first proposal, going with the default settings was also my first approach for a long time. But time comes when modern mankind wants to understand what it is doing, and why, therefore let me repeat my question:
Why do all the stock export profiles have the constant bitrate set and do not utilize the average or variable bit rate options?
I followed your link (thanks again), but all I got was q …Set quality for variable bit rate (VBR) mode. Because official documentation is withholding recommended settings, I am asking in a specialized forum, with reference to my first post.
The FFMPEG Wiki is available today (yesterday it did not answer although I tried with different IP addresses and segments) It tells that the Native FFmpeg AAC Encoder (and I assume this this is used by Shotcut) has an effective VBR q range from 0.1 … 2.0, and it does not do CBR audio encoding.
So, back to my questions: If Shotcut employs the native FFMPEG AAC encoder which is not capable of CBR, why on earth are the Shotcut stock export profiles configured for audio CBR?
Regarding your advise to judge, if the result of the CBR export sounds good enough to me: You are missing the point that in video encoding it is all about storage and bandwith reduction. The challenge is to find the least consuming audio VBR setting that is broadly accepted for demanding ears (not mine). I know audio is only I fraction of video bandwith, but I still hope to get opinions about good encoding practise.
Tonight, I have run some tests, with interesting results:
In Shotcut v25.01.25, I encoded a movie 4 times using the HEVC video codec and aac audio codec, with different aac settings and then checked the results with MediaArea MediaInfo. MediaInfo tells it’s the AAC LC codec (Low Complexity).
abbriviations used:
VBR … aac “Quality-based VBR”
% … Quality setting in %
250-256kb/s … Bit rate of 250 and Max. bit rate of 256
The bit rates include 2 channels (stereo)
Remarks on the surprising results:
CBR settings result in VBR, but VBR settings can result in CBR.
Medium quality VBR (50%) results a VBR of 250 (average?), which is much better than a higher quality VBR (70%, 80%) setting which turnes out as a CBR of 159kbit/s.
Both settings VBR 50% and CBR (256kbit/s) produce a VBR of 250 with a maximum bit rate of 256 kbit/s. While the result should be identical according to MediaInfo, the latter of them is 5% larger.
VBR 70% and 80% produce CBR of approximately the same quality, but the better quality setting of 80% results in a slightly lower bitrate of 158kb/s.
Findings:
Anyone aware of this, keeping it for himself? For me the audio encoder is an unpredictable black box, which causes headache to me.
Constant bit rate using -b:a
Variable bit rate using -q:a
Native FFmpeg AAC Encoder does not do CBR audio encoding.
I am not sure what to make of the last line. Maybe it means that “constant” is actually average and maybe mediainfo reports that as “variable” because average is a form of variable. Things are rarely truly constant in modern lossy codecs as that often requires padding data, which is wasteful. Rather, constant more often means not under- or over-flowing a decoder buffer size (i.e. a very strict average). I think better terminology is like quality-based (as I chose to use in Shotcut), loose bitrate (average), and tight bitrate (constant). And then there’s constrained VBR for video which is quality-oriented with a bitrate ceiling.
Shotcut uses MLT’s equivalent of those for the aac audio encoder, which are ab and aq respectively.
When I use a stock Shotcut video preset with AAC audio I get the same result as you with mediainfo–VBR. But when I use the audio/AAC preset, mediainfo reports CBR even though it uses the same ffmpeg library parameters. With ffmpeg command line mediainfo always reports CBR even when I use -q:a.
In Shotcut export, using defaults, I simply reduced the “constant” bitrate to 128k, and now mediainfo reports “constant.” So, I am not sure what is happening between FFmpeg and mediainfo, and it seems not trust worthy. Similar to what was reported here:
Googling the key phrase “Native FFmpeg AAC Encoder does not do CBR audio encoding” brings even more discussions to light: CBR Audio … does it work in shotcut forum. Also worth to read is what others say in the avidemux forum and in the audacity discussion.
Inspiringly the audacity team decided to change their settings dialogs in their user interface, to avoid misleading their users by well established terms like CBR and VBR which have a different meaning in FFmpeg. They offer bit rates to choose from, which they found out empirically.
Similar should be taken into account for the Shotcut UI: Why not reveal in the Audio tab of the advanced export dialog what Shotcut is doing in the background? In the dialog tab instead of just “aac” it should be indicated for transparency that the FFmpeg native AAC codec is used, and the -b:a and -q:a parameters will be called.
I wouldn’t let users believe they get CBR while all insiders are in agreement, that the outcome is different from that. Instead, I would avoid the established term “Constant Bitrate” at all (even if the author of the FFmpeg wiki uses it, because he or she revoces that in the next sentence). Better name this option “-b:a Average Bitrate (recommended)”.
Also, I would change the option “Quality based VBR” to “-q:a Variable Bitrate (experimental)” with reference to the FFmpeg wiki, because it is in fact nothing more than experimental, as it is known from several sources. It is definitely not quality based, nore is it content driven. In fact it is complex-conditional and not recommended.
Finally, the “Bitrate b/s” field should get adjusted dropdown choices within the range of 196k…233k for stereo and 98k…160k for mono (ref. audacity). They say the compilations for Win and MacOS behave slightly different (which is negligible), and in combination with video encoding the behavior could be different (I didn’t test that).
Thank you for authoring and maintaining the Shotcut project, and thank you for your support in the forum. Please recognize my constructive criticism as a contribution, I spent hours on research and writing.
The Advanced section of the Export panel is generic. It is not about one codec. So, things like “aac” are the literal name of the FFmpeg native encoder listed by its API for listing in the UI. And “experimental” is codec-specific. I am not going to add a lot of logic and rules to this part of the UI; however, I am considering to change the rule that determines what is considered Constant to instead be Average.
Thanks for the feedback on this thread. Shotcut is working exceptionally well for me - no issues to report. Thanks for your efforts in keeping this project going.
Dan, let me emphazise more than in my previous post that I thank you for sharing your wounderful software. Please read my questions coming from someone who is no multimedia specialist and no programmer, rather from a user with the ambition for a deeper understanding to develop own skills. Howsoever, questions from a clueless user can be inspiring for a developer.
You helped me by pointing out, that the advanced section of the export panel is universal. I did not know that before, because my installation of Shotcut just offers one choice of codec and that is “aac”. I don’t remember if the installer offered alternative codecs for installation, at least the user manual does not mention anything. I guess from your reply mentioning libopus, that, if I installed libopus myself, Shotcut would probably recognize the presence of another codec, and offer it for choice? Or is there more to do?
No, it doesn’t. Maybe you do not know that Export > Audio > Codec is an editable field. However, I discourage people from doing that as it is easy to create an invalid combination of codec and file format. Instead, choose a preset and then tweak in advanced. For example, the WebM presets use opus audio.
Yes, you are totally right, I remained to long with the presets and ‘main’ profiles, so I did not look beyond the presets of HEVC Main and H.264 Main.
I apollogize for occupying you with narrow minded questions.
Starting over, I will experiment with other audio codecs to leave aside the FFMpeg Native AAC with it’s ambiguous options. The choice of audio codecs offered by Shotcut is overwhelmingly large, and I hope not to stumble into the same issues with CBR/VBR/ABR with the other codecs. In any case I know now, that these designations can have a wide scope for interpretation, and the UI is universal.
The quick answer for transparent lossy audio encoding is Opus at 192kbps CBR or VBR and be done. Opus sounds better than AAC/AC3/MP3/etc. In particular, Opus retains detail in high-frequency shimmer instruments like cymbals much better than FFmpeg’s AAC encoder. Some people say 128kbps is good enough. But some musicians and audiophiles need 192kbps to claim transparency to the original.
I use 192kbps CBR because it also gives me a higher quality source should I transcode my high-quality video master to a lower resolution version for email or my phone (less generational loss from the transcode). Since I’m encoding at a transparent bitrate, nothing would be perceptibly gained if VBR used more bitrate, but something perceptible could be lost or an artefact potentially introduced if VBR used a lower bitrate.
EDIT: In the Shotcut Export > Advanced > Audio panel, Opus is called libopus. It only supports 48kHz sample rate, aside from a few much lower rates used for telecom devices.
EDIT: I removed my CBR vs VBR comment because it depends too much on the use case.