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

Remove FFmpeg normalization causing "quiet" songs. #1276

Merged
merged 4 commits into from
May 10, 2021

Conversation

phcreery
Copy link
Contributor

Title

Audio downloaded with spotdl is relatively quiet.

Description

Audio normalization flags in the FFmpeg command reduces actual song loudness by almost 50%

Motivation and Context

dr.boaf on discord originally voiced the issue and I too took notice of it. Removing the normalization flags causes the converted audio to match closer to the actual song. The normalization causes the song to be very dull and can be very apparent in certain conditions. I believe @MikhailZex originally introduced the flags. Could you expand on the usage and purpose?

Testing / Screenshots (if appropriate)

Subject: Tristam - Over the Edge
image
The absence of apad_dir also makes the song the exact same length

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the CONTRIBUTING document
  • I have read the CORE VALUES document
  • I have added tests to cover my changes
  • All new and existing tests passed

@phcreery
Copy link
Contributor Author

Just fixed a flag that increased bitrate. See https://trac.ffmpeg.org/wiki/Encode/MP3

before/after
image

@ghost
Copy link

ghost commented Apr 26, 2021

The dullness is due to the dynaudnorm flag that causes local amplitude modulation instead of global amplitude modulation. This ensures consistent loudness with almost no variation - variation that's supposed to be an integral part of a song.

It has been removed multiple times in the past and then been reintroduced again and again. Kind of gave up on getting it out.

Try conversion of the song with only loudnorm, if you still feel the audio is dull, go ahead with this PR as is, else remove all flags except loudnorm.

You can checkout my personal modified spotdl copy with alternate flags here.

@xnetcat xnetcat changed the base branch from master to dev April 26, 2021 06:38
@xnetcat
Copy link
Member

xnetcat commented Apr 26, 2021

Please pull changes from upstream/dev

@phcreery
Copy link
Contributor Author

My question is why is the audio modification in there at all. I feel like most people would want the unmodified audio.

@ghost
Copy link

ghost commented Apr 26, 2021

Instrumental music on YouTube has wayyy to much loudness variation. Without normalisation, your have to change the volume on a song to song basis. This effect is far less pronounced for mainstream music.

P.S. It's mostly for that reason that Spotify itself implemented loudness normalisation in songs by default.

@phcreery
Copy link
Contributor Author

That makes sense. I will mess with the normalization to see if I could improve it. For now, though, I feel it would be better to have inconsistently varying songs rather than a quieted song (in place over an already compressed mp3 file). Most older songs were naturally quieter.

@phcreery
Copy link
Contributor Author

phcreery commented Apr 26, 2021

I feel like the dynaudnorm should be left out altogether since it applies normalization dynamically over windowed portions of the file and changed characteristics of the song. This is not desired since some songs intend areas to be quiet while others to be loud.

@ghost
Copy link

ghost commented Apr 26, 2021

I feel like the dynaudnorm should be left out altogether since it applies normalization dynamically over windowed portions of the file and changed characteristics of the song. This is not desired since some songs intend areas to be quiet while others to be loud.

The dullness is due to the dynaudnorm flag that causes local amplitude modulation instead of global amplitude modulation. This ensures consistent loudness with almost no variation - variation that's supposed to be an integral part of a song.

It has been removed multiple times in the past and then been reintroduced again and again. Kind of gave up on getting it out.

Try conversion of the song with only loudnorm, if you still feel the audio is dull, go ahead with this PR as is, else remove all flags except loudnorm.

You can checkout my personal modified spotdl copy with alternate flags here.

@ghost
Copy link

ghost commented Apr 26, 2021

From my set of experimentation, one other thing of note is setting a relatively high level for loudnorm (eg. loudnorm=-3) will cause "pumping" - rhythmic loudness-softness loops.

@xnetcat xnetcat added the Enhancement Enhancing spotDL label May 1, 2021
@Silverarmor Silverarmor requested review from xnetcat and a user May 6, 2021 20:03
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the most part.

spotdl/download/ffmpeg.py Outdated Show resolved Hide resolved
Copy link
Member

@xnetcat xnetcat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@ghost
Copy link

ghost commented May 9, 2021

@Silverarmor, I think this PR is a Go.

@Silverarmor Silverarmor merged commit 1b355c8 into spotDL:dev May 10, 2021
Silverarmor added a commit that referenced this pull request May 25, 2021
Publish v3.6.0

* ignore .cache and other hidden files (#1274)

* Bump minimal required python version to 3.6.1 (#1278)

* Remove FFmpeg normalization causing "quiet" songs. (#1276)

* Saved Songs Download and User Authentication (#1240)

* regenerate cassettes (#1290)

* Use ffmpeg_path to check for version (#1289)

* Skip already downloaded songs before doing youtube search (#1287)

* Fix security risk (#1285)

* Song matching improvements (#1279)

* Artist songs fixes (#1284)

* More output formats (#1244)

* Bump version number to 3.6.0

* Update .gitignore to remove duplicate cache

* docs update (#1293)


Co-authored-by: Silverarmor <23619946+Silverarmor@users.noreply.github.com>
Co-authored-by: Jakub Kot <42355410+xnetcat@users.noreply.github.com>
Co-authored-by: Peyton Creery <44987569+phcreery@users.noreply.github.com>
Co-authored-by: AZMCode <adrianozambrana@protonmail.com>
Co-authored-by: Aiden Gardner <19619206+aiden2480@users.noreply.github.com>
Co-authored-by: Oliver Blanthorn <freedom4cows@gmail.com>
Co-authored-by: Andrzej Klajnert <github@aklajnert.pl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Enhancing spotDL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants