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

[Bug] Post processing audio quality option scale is wrong #25912

Open
msemple1111 opened this issue Jul 6, 2020 · 6 comments
Open

[Bug] Post processing audio quality option scale is wrong #25912

msemple1111 opened this issue Jul 6, 2020 · 6 comments

Comments

@msemple1111
Copy link

@msemple1111 msemple1111 commented Jul 6, 2020

Checklist

  • I'm reporting a broken site support issue
  • I've verified that I'm running youtube-dl version 2020.06.16.1
  • I've checked that all provided URLs are alive and playable in a browser
  • I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • I've searched the bugtracker for similar bug reports including closed ones
  • I've read bugs section in FAQ

Log

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '--extract-audio', '--audio-format', 'm4a', '--audio-quality', '9', 'https://www.youtube.com/watch?v=yF2mSU15yyg']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2020.06.16.1
[debug] Python version 3.6.1 (CPython) - Darwin-18.0.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 3.0.2, ffprobe 3.0.2
[debug] Proxy map: {}
[youtube] yF2mSU15yyg: Downloading webpage
[youtube] yF2mSU15yyg: Downloading MPD manifest
[debug] Invoking downloader on 'https://manifest.googlevideo.com/api/manifest/dash/expire/1594052457/ei/CfsCX-KeNtOvmLAPnvGv2AQ/ip/91.85.43.140/id/c85da6494d79cb28/source/youtube/requiressl/yes/playback_host/r1---sn-3jvh-ajte.googlevideo.com/mh/He/mm/31%2C29/mn/sn-3jvh-ajte%2Csn-aigzrne7/ms/au%2Crdu/mv/m/mvi/0/pl/24/hfr/all/as/fmp4_audio_clear%2Cwebm_audio_clear%2Cwebm2_audio_clear%2Cfmp4_sd_hd_clear%2Cwebm2_sd_hd_clear/initcwndbps/581250/vprv/1/mt/1594030777/fvip/1/keepalive/yes/itag/0/sparams/expire%2Cei%2Cip%2Cid%2Csource%2Crequiressl%2Chfr%2Cas%2Cvprv%2Citag/sig/AOq0QJ8wRQIgNdFO1v6jqEQFjpUvl6SQysOsnXuOREiGqQN3Rkwl56cCIQC_1LXzCjig_DlSWVnWj6T9e1hG2JlSq9675hJ5hWKZvg%3D%3D/lsparams/playback_host%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps/lsig/AG3C_xAwRAIgWj8KYXPTfMMgrha4wqDLmT7quNLX71nA1Kk1neQMAsgCIEoAaNketNHleb29_KtbHb2U-i9dSymTqc9LgtROeqbx'
[dashsegments] Total fragments: 24
[download] Destination: Tom Misch - The Journey (G-TOWN Soft Boys Edit)-yF2mSU15yyg.webm
[download] 100% of 3.59MiB in 00:22
[debug] ffmpeg command line: ffprobe -show_streams 'file:Tom Misch - The Journey (G-TOWN Soft Boys Edit)-yF2mSU15yyg.webm'
[ffmpeg] Destination: Tom Misch - The Journey (G-TOWN Soft Boys Edit)-yF2mSU15yyg.m4a
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:Tom Misch - The Journey (G-TOWN Soft Boys Edit)-yF2mSU15yyg.webm' -vn -acodec aac -q:a 9 -bsf:a aac_adtstoasc 'file:Tom Misch - The Journey (G-TOWN Soft Boys Edit)-yF2mSU15yyg.m4a'
Deleting original file Tom Misch - The Journey (G-TOWN Soft Boys Edit)-yF2mSU15yyg.webm (pass -k to keep)

Description

Post processing audio quality scale is inversed

In the post processing options, the --audio-quality option is the wrong way round. In all the docs it says --audio-quality 9 is worst and --audio-quality 0 is best. After listening, and then looking at the bitrates, I have confirmed the opposite is true.

--audio-quality 0 is in fact the worst, and
--audio-quality 9 is in fact the best

Proposed fix

The easiest fix is to update the docs.
Or an alternate fix is to provide a --audio-quality best option, which is mapped to -q:a 9 in ffmpeg

@michealespinola
Copy link

@michealespinola michealespinola commented Sep 5, 2020

Was it opposite day when you posted this? Because this is completely untrue. '--audio-quality 0' is the best VBR you can do, achieving upward of ~256 kbps. '--audio-quality 9' is the worst VBR you can do, hitting well below ~100 kbps.

What did you listen with, and what did you use to compare the bitrates? And are you certain that you didn't mix up your files names during your tests? Because I have tested this repeatedly in the past - as well as right now, using MediaInfo, and you are 100% incorrect with your findings.

If this setting were truly backward, it would have been discovered a long long time ago.

@mara004
Copy link

@mara004 mara004 commented Sep 9, 2020

I had the same problem as @msemple1111. I wanted to get the best quality converting from opus to ogg vorbis using --audio-quality 0, and the result was a very small file with bad quality and low bitrates. Then I tried --audio-quality 9, which resulted in a bigger file with better quality / higher bitrates. So I wondered what was going on, and finally figured it out: the -q:a option of ffmpeg is format/encoder-specific: While -q:a / --audio-quality 0 leads to best quality for mp3, it leads to worst quality for vorbis, for instance.
A good overview of which number results in which quality (best/worst) can be found here (section 'audio'): https://slhck.info/video/2017/02/24/vbr-settings.html
Actually, -q:a 9 is not the best quality for ogg vorbis, that would be -q:a 10, but youtube-dl by mistake interprets 10 already as a specific bitrate (like 128K), and not as a VBR value.
The documentation should be changed according to the information provided in the aforementioned link, and youtube-dl should be improved to interpret --audio-quality as VBR if the given number is inside the VBR range possible for the chosen --audio-format, instead of 0-9 for all formats.

@mara004
Copy link

@mara004 mara004 commented Sep 9, 2020

@michealespinola I too wonder why this hasn't been discovered earlier. The problem is existing ever since I use youtube-dl.

@mara004
Copy link

@mara004 mara004 commented Sep 9, 2020

@msemple1111 I think in your case it is best to use -f and the corresponding format number (which can be determined using -F, on youtube m4a should be 140) instead of --audio-format, since youtube/googlevideo also directly provide an m4a/aac option, so you can avoid the quality loss, conversion time and increased file size caused by re-encoding opus to aac.
So your command line should look like this: youtube-dl -x -f 140 "https://www.youtube.com/watch?v=yF2mSU15yyg"
If you use the -x option, you will get a .aac file, otherwise, you'll get a .m4a file.

@mara004
Copy link

@mara004 mara004 commented Sep 15, 2020

Perhaps the link which I quoted in my first post doesn't cover enough formats, might be too outdated and is unofficial, so probably it's better to look at ffmpeg's main documentation, sections "Audio Encoders" and, maybe, "External Libraries":
https://ffmpeg.org/ffmpeg-all.html#Audio-Encoders
https://ffmpeg.org/ffmpeg-all.html#External-libraries

Here is the proof for my libvorbis example (from https://ffmpeg.org/ffmpeg-all.html#Options-16):
q (-q) Set constant quality setting for VBR. The value should be a float number in the range of -1.0 to 10.0. The higher the value, the better the quality. The default value is ‘3.0’

@mara004
Copy link

@mara004 mara004 commented Sep 16, 2020

for mp3 (libmp3lame):
compression_level (-q) Set algorithm quality. Valid arguments are integers in the 0-9 range, with 0 meaning highest quality but slowest, and 9 meaning fastest while producing the worst quality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.