Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The slider setting value for AAC/MP4 export is not honored by Audacity - and the slider cannot make precise settings #1818

Closed
petersampsonaudacity opened this issue Oct 4, 2021 · 34 comments · Fixed by #3634
Assignees
Labels
bug An error, undesired behaviour, or missed functionality P2 High priority
Milestone

Comments

@petersampsonaudacity
Copy link

petersampsonaudacity commented Oct 4, 2021

Describe the bug
a) The slider setting value for AAC/MP4 export is not honored by Audacity.

b) Plus it is very hard (perhaps impossble) to set precise values - I found it impossible to set it to the "standard" rates of 192kbps and 256kbps

To Reproduce
Steps to reproduce the behavior:

  1. Get some stereo audio
  2. File > Export > Export Audio
  3. choose M4A(AAC) Files FFmpeg
  4. Set the Quality slider to 320kbps
  5. Click "Save" to make the export
  6. Examine the file (on W10 I used Windows Explorer)
  7. Observe the file is not 320kbps (mine was 465kbps YMMV)

Expected behavior
a) Audacity should export at the rate the user selects
b) The slider should allow for more precise setting (making it wider may help_
c) the user should be able to set a precise kbps value by typing it in (cf. MP3 export and mic/speaker sliders)

Screenshots
None

Additional information (please complete the following information):

  • OS: tested on Windows 10 - but assume all
  • Version: Audacity 3.0.5 and 3.1.0

Additional context

  1. Note that I am using the "recommended" FFmpeg the 64-bit Win downloaded from Buanzo's site
    This of course may change with an updated FFmpeg version ...

  2. This does not happen with MP3 export in Audacity - the precise value is used for the exported file

  3. Note that MP3 export uses a picking list and not a slider for the kbps setting - so we have an inconsistency issue here

  4. The AACs that I have were made in iTunes,
    4.1) I export fro m Audacity as 16-bit WAV files
    4.2) I import those WAV files into iTunes
    4.3) I use iTunes to convert these WAVS to AAC files choosing 256kbps
    4.4) I observe that iTunes converts these to 256kbps AAC files:
    image

@petersampsonaudacity petersampsonaudacity added bug An error, undesired behaviour, or missed functionality P2 High priority labels Oct 4, 2021
@petersampsonaudacity
Copy link
Author

This was reported today on the Forum:
https://forum.audacityteam.org/viewtopic.php?f=46&t=120701&p=436404

It looks to be the same issue as this one logged in Bugzilla, which I shall close in favor of this GitHub issue
https://bugzilla.audacityteam.org/show_bug.cgi?id=2161
Bug 2161 - Enh: Same quality setting and range used for mono and stereo M4A (AAC).

@petersampsonaudacity petersampsonaudacity changed the title The slider setting valufor AAC/MP4 export is not honored by Audacity The slider setting value for AAC/MP4 export is not honored by Audacity - and the slider cannot make precise settings Oct 4, 2021
@petersampsonaudacity
Copy link
Author

This of course may change with an updated FFmpeg version ...

@Penikov
Copy link
Contributor

Penikov commented Oct 4, 2021

Related to b)
There is a way around it. You can choose the desired bitrate with the left-right keys.
изображение

@petersampsonaudacity
Copy link
Author

Well whoever knew that?

Is is documented or just an easter-egg ?

@petersampsonaudacity
Copy link
Author

Looks like an easter-egg to me:
https://alphamanual.audacityteam.org/man/AAC_Export_Options

@Penikov
Copy link
Contributor

Penikov commented Oct 5, 2021

I don't think this is a documented feature.

@petersampsonaudacity
Copy link
Author

I don't think this is a documented feature.

It's not a documented feature - I looked earlier this morning, that's why I said it's an easter-egg ;-)

Apart from that one has to ask the question: just why us the slider so small in width anyway? There is plenty of additional screen real-estate in the M4A(AAC) export dialog to widen it and make it easier to use.

@petersampsonaudacity
Copy link
Author

OK so now for the upcoming 3.1.0 I have revealed this Easter-Egg in a tip div:
{{tip|You can use the keyboard left and right arrows to move or fine-tune your slider position.}}

See: https://alphamanual.audacityteam.org/man/AAC_Export_Options#Format_Options

@crsib crsib self-assigned this Oct 6, 2021
@AnitaBats AnitaBats added this to To do in Sprint 8 - 3.1 Stabilisation via automation Oct 28, 2021
@werewolfgold
Copy link

Are there any updates on this? I'm still getting the same problem in version 3.1.3 of Windows 10 64-bit.

@petersampsonaudacity
Copy link
Author

@crsib Dmitry does this need updated FFmpeg in order to fix this ?

@SteveDaulton
Copy link
Member

Related to b)
There is a way around it. You can choose the desired bitrate with the left-right keys.

Perhaps "b)" should be split off into a separate issue, as the more serious issue is (a) that the exported file does not have the bit-rate specified by the user, and there is no good workaround for this issue.

@petersampsonaudacity
Copy link
Author

petersampsonaudacity commented May 15, 2022

the more serious issue is (a) that the exported file does not have the bit-rate specified by the user, and there is no good workaround for this issue.

And of course the user usually has no idea at all that the bit-rate is not the one they specified and that is why this is important to get fixed ...


BTW there is a good workaround:

  1. Export the audio as a WAV file
  2. Import it into iTunes
  3. use iTunes to make the conversion to AAC

This is the method I always used when converting my vinyl and tapes for use on my iPods.

This tutorial in the Manual has long recommended this approach:
https://manual.audacityteam.org/man/tutorial_exporting_to_itunes.html#conversion

And this Workflow in the Manual (linked to from the above tutorial) explicitly uses this method:
https://manual.audacityteam.org/man/sample_workflow_for_exporting_to_itunes.html

@SteveDaulton
Copy link
Member

BTW there is a good workaround:

I don't think it's particularly "good" for a software development company if they have to say "use a different app" to do something that their app is supposed to be able to do. Perhaps a better workaround is to use Audacity's command line encoder, for example:
ffmpeg -i - -b:a 96k "%f.m4a"
but that's not very user friendly.

@petersampsonaudacity
Copy link
Author

petersampsonaudacity commented May 15, 2022

As it looks likely that this bug may not get fixed any time soon I have updated this page in the manual with Advice divs about this bug to warn the user:
https://alphamanual.audacityteam.org/man/Tutorial_-_Exporting_to_iTunes

And also on other related pages:
https://alphamanual.audacityteam.org/man/Export_Formats_supported_by_Audacity
https://alphamanual.audacityteam.org/man/File_Export_Dialog
https://alphamanual.audacityteam.org/man/AAC_Export_Options#Format_Options

@petersampsonaudacity
Copy link
Author

petersampsonaudacity commented Jul 29, 2022

BUMP - and yesterday/today is yet another Forum user complaining about this issue:
https://forum.audacityteam.org/viewtopic.php?f=46&t=126452

@LWinterberg @dozzzzer @Tantacrul @crsib
this really should be getting fixed, not just because it is a P2 - but mainly because it's just plain sloppy - and leads to poor UX

@petersampsonaudacity
Copy link
Author

petersampsonaudacity commented Jul 29, 2022

The other thing I note about Audacity's M4A?AAC export dialog is that there is no option to choose between CBR and VBR.

This is not the case with MP3 export where the user can choose.

And note that the poor old user is left in the dark with M4A/AAC export as to which is being used. I tend to infer from the dialog GUI that it may be CBR - but who knows ...

image

Update

Careful reading of the Manual shows that actually "a form of VBR" is used" - but we know how few readers bother to RTFM (and its hidden at the bottom of the page)
https://alphamanual.audacityteam.org/man/AAC_Export_Options

If an option for CBR is not to be provided, then it would make makes sense to change the wording in the dialog to say:
Quality (kbps VBR):

and that, surely, cannot be difficult to do at all.

@crsib
Copy link
Contributor

crsib commented Jul 29, 2022

We should fix the docs about how to get FFmpeg as well or send Buanzo the new builds as well @LWinterberg

@Tantacrul
Copy link

BUMP - and yesterday/today is yet another Forum user complaining about this issue: https://forum.audacityteam.org/viewtopic.php?f=46&t=126452

@LWinterberg @dozzzzer @Tantacrul @crsib this really should be getting fixed, not just because it is a P2 - but mainly because it's just plain sloppy - and leads to poor UX

Unless I'm mistaken, this really seems like a separate issue. I agree, it should be an exposed parameter for sure.

@petersampsonaudacity
Copy link
Author

petersampsonaudacity commented Jul 29, 2022

@Tantacrul the recent Forum post is complaining about the issue as stated "The slider setting value for AAC/MP4 export is not honored by Audacity - and the slider cannot make precise settings"

I added a related thing for VBR/CBR in this thread - is that what you are saying is a separate issue? If so do you want me to raise a new issue for it?

@crsib
Copy link
Contributor

crsib commented Jul 29, 2022

Probably let's just update this issue title and description. We need to investigate first the possible inputs for ABR/VBR/CBR anyway

@crsib
Copy link
Contributor

crsib commented Jul 29, 2022

I can say for sure, that VBR expects the quality from 1 to 5, not the bitrate

=====

And turns out that depends on the encoder. "Native" encoder expects a float between [0.1,2]. Fraunhofer integer from 1 to 5

@ksoze95 ksoze95 assigned ksoze95 and unassigned crsib Aug 11, 2022
@AnitaBats AnitaBats added this to the Audacity 3.2 milestone Aug 30, 2022
@petersampsonaudacity
Copy link
Author

Bump @LWinterberg @dozzzzer @crsib

This is a long-standing bug that really should be fixed (we get lots of user complaints about this).

Any chance it can get fixed for 3.2.0 please?

@LWinterberg
Copy link
Member

As you can see it got added to the 3.2 milestone yesterday

@petersampsonaudacity
Copy link
Author

Still the case on 3.2.0 Beta on W10

See this recent Forum post with yet another user complaining about this:
https://forum.audacityteam.org/viewtopic.php?f=46&t=126899

@ksoze95 ksoze95 mentioned this issue Sep 16, 2022
6 tasks
@petersampsonaudacity
Copy link
Author

@LWinterberg

Testing @ksoze95 's Kit's latest branch build on W10: https://github.com/audacity/audacity/actions/runs/3068870464

Testing the STR - i.e requesting a 320 kbps AAC file I get much closer now with 317 kbps.

I have not had time today to test other settings (I may be able to do that over the weekend)

@petersampsonaudacity
Copy link
Author

petersampsonaudacity commented Sep 17, 2022

@LWinterberg

Further testing with @ksoze95 latest branch on W10 and macOS 12.5/1 - https://github.com/audacity/audacity/actions/runs/3068870464

I get vastly different results on both platforms - test file id track 1 fro Sergeant Pepper's Lonely Hearts Club Band.

W10

requestedrate actual rate SizeMB
32 195 2.88
64 195 2.88
128 195 2.88
160 195 2.88 (default rate)
192 195 2.88
256 254 3.75
320 317 4.67

So close but not accurate for rates of 192 kbps and above - and plain wrong for rates below 192 kbps

Also note that for any selected rate below 98kbps the "remembered rate" on the next visit to File Export as AAC is always 98kbps

macOS 12.5.1

No matter what I select for the requested rate the rate of the output file I get is always 196kbps and the file size is always 3.1MB

Also on Mac the last-used rate is never "remembered" and re-offered on the next visit to File Export as AAC - instead Audacity always offers the default rate of 160kbps

@LWinterberg
Copy link
Member

The W10 behavior looks roughly intended:

 q = wxClip( q, 98 * mChannels, 160 * mChannels );
      // Set bit rate to between 98 kbps and 320 kbps (if two channels)

which is the restriction the old slider had; it goes no lower than 98 kbit/s for mono and 196 kbit/s for stereo, and no higher than 160 for mono and 320 for stereo.

What I don't know is how necessary this exact range is. The Wikipedia article on AAC has the unhelpful line

The MPEG-4 audio coding algorithm family spans the range from low bit rate speech encoding (down to 2 kbit/s) to high-quality audio coding (at 64 kbit/s per channel and higher).

Hydrogenaudio and the Fraunhofer AAC encoder apparently recommend a range of 8kbit/s-288 kbit/s per channel for AAC-LC, with the built-in VBR modes supporting 20-112 kbit/s per channel:
https://wiki.hydrogenaud.io/index.php?title=Fraunhofer_FDK_AAC

no idea what the problem is for mac.

@petersampsonaudacity
Copy link
Author

petersampsonaudacity commented Sep 18, 2022

Flagging @Tantacrul as this is a GUI design/UX issue

which is the restriction the old slider had; it goes no lower than 98 kbit/s for mono and 196 kbit/s for stereo, and no higher than 160 for mono and 320 for stereo.

1) iTunes created AAC files

In contrast iTunes allows one to go down as low as 64kbps Stereo (or 32kbps mono):
image
And BTW also offers the choice of VBR (default) or CBR

And when one examines the file in iTunes it says that it's 64 kbps, 256 kbps - bot some number that's close as Audacity is doing,

2) Audacity 3.1.3

In Audacity 3.1.3 the restriction is made clear as we had the slider to indicate (and indeed restrict ) the allowable range:
image

3) @ksoze95 Kit's branch

In this branch build the limit(s) are not made clear to the user via the GUI
image
If one clicks in any of the other data entry fields then (in the case shown here) the rate is changed to 98kbps, which the user may or may not notice (I certainly didn't when I was testing yesterday, only to be surprised by the kpbs rates when I examined the exported files).

Really if the user types an out of range number in that field a warning should be issued and the correction made immediately.

Or perhaps we should be restoring the slider that we had previously

4) Continuous range of values or discrete values

In contrast with iTunes AAC conversion and also Audacity's MP3 conversion where a pick-list range of discrete values is offered - Audacity's AAC conversion offers a continuous range 98-320 (this has always been the case with Audacity's Audacity conversion). Maybe it would be better (and more consistent) if we followed that Audacity MP3 model:
image
Note too that Audacity's MP3 export offers kbps rates much lower than can be obtained with AAC export in Audacity - though iTunes only goes down to 64kbps stereo 32kbps mono.

@crsib
Copy link
Contributor

crsib commented Sep 19, 2022

AAC is very complex codec with different implementations doing compression differently. We can only rely on the "native" FFmpeg encoder, there is no way to guarantee the Fraunhofer encoder is present. Default encoder from Apple is definitely not usable now.

What makes everything even more complex - Fraunhofer and FFmpeg "native" encoders are configured quite differently.

and indeed restrict

I'm not sure what you mean. Setup for M4A file format was never done right. There is a possibility, that FFmpeg changed the meaning of q:a significantly, but for the few latest version it definitely does not expect the values Audacity passed to it.

Maybe it would be better (and more consistent) if we followed that Audacity MP3 model:

AAC and MP3 handle bitrate differently. We can extend the input range, though. It is quite hard to tell, when native ffmpeg encoder will fail.

@petersampsonaudacity
Copy link
Author

petersampsonaudacity commented Sep 19, 2022

@crsib Dmitry, boy oh boy - this makes me real glad that I always exported as WAV and then used iTunes to make the AAC (and MP3) conversions that I needed for my iPods

@ksoze95
Copy link
Contributor

ksoze95 commented Sep 19, 2022

@petersampsonaudacity

Really if the user types an out of range number in that field a warning should be issued and the correction made immediately.

I was working on the text entry validation, but unfortunately did not manage to get it working before I took my annual leave. A later PR will address this issue.

@petersampsonaudacity
Copy link
Author

@ksoze95

I was working on the text entry validation, but unfortunately did not manage to get it working before I took my annual leave. A later PR will address this issue.

So I'm guessing this will not make 3.2.0 release then ?

@dozzzzer dozzzzer self-assigned this Sep 20, 2022
@dozzzzer
Copy link
Contributor

dozzzzer commented Sep 22, 2022

@ksoze95 @petersampsonaudacity
When exporting, if I set 160 kbps and 320 kbps, I'm getting 198 kbps and 333 kbps respectively.

@crsib
Copy link
Contributor

crsib commented Sep 22, 2022

Generally FFmpeg does not really allow to set the precise value. You can play with ffmpeg -c:a aac -b:a 320k -i input.file -o out.m4a to see how the command line handles it. The results will be slightly different anyway, but this shows how "native" FFmpeg AAC encoder handles the bitrate.

Optionally you can change the codec to libfdk_aac and play with that as well :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error, undesired behaviour, or missed functionality P2 High priority
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

10 participants