slhck / ffmpeg-normalize

Audio Normalization for Python/ffmpeg
MIT License
1.25k stars 117 forks source link

Help normalizing MP3 files #247

Closed alltiagocom closed 11 months ago

alltiagocom commented 11 months ago

I'm not a developer or anywhere near familiar with scripting, etc, so please bear with me...

I have ffmpeg installed as well as ffmpeg-normalize. All I would like to do is normalize MP3 files without changing their sample rate or anything else. The only thing I want specifically is the files to be normalized to -1dB.

I saw the option "-normalization-type", but I can't seem to understand how to use it properly.

This is what I got from copying something from your Github page: ffmpeg-normalize original.mp3 -f -c:a libmp3lame -b:a 320k --output normalized.mp3

I don't know if I need any of the other options such as "-f -c:a libmp3lame -b:a 320k", but again, I'm really not familiar with this.

Can you please clarify if I need those options and how to use "-normalization-type" set to "peak" and specify -1dB?

Thanks!

slhck commented 11 months ago

Use:

ffmpeg-normalize original.mp3 -f -c:a libmp3lame -b:a 320k -nt peak -t -1 --output normalized.mp3

Note that when performing this kind of modification, the audio stream has to be re-encoded. In the above case, it will be re-encoded to MP3 using the libmp3lamer encoder at 320 kBit/s. The bitrate is chosen in order to preserve the quality of the content as much as possible, because re-encoding causes generation loss.

I don't know your exact use case, but you may want to look at MP3Gain. It does not re-encode the files and instead targets a particular volume using metadata only.

alltiagocom commented 11 months ago

Use:

ffmpeg-normalize original.mp3 -f -c:a libmp3lame -b:a 320k -nt peak -t -1 --output normalized.mp3

Note that when performing this kind of modification, the audio stream has to be re-encoded. In the above case, it will be re-encoded to MP3 using the libmp3lamer encoder at 320 kBit/s. The bitrate is chosen in order to preserve the quality of the content as much as possible, because re-encoding causes generation loss.

I don't know your exact use case, but you may want to look at MP3Gain. It does not re-encode the files and instead targets a particular volume using metadata only.

Thank you so much for the script! I checked the normalized version and whatever quality was lost, it's not noticeable at all. This is also more for personal use and I have all the WAV versions anyway if I need to have the full quality audio.

I looked at MP3Gain, but it seems to be Windows only and I have a Mac.

I saw that there's some app version (http://projects.sappharad.com/mp3gain/), but 1) it doesn't have the peak normalize feature. It seems to be just an app to add or remove gain. And 2) I need something that works inside Keyboard Maestro, because I will be creating macros and I'm using its Shell Script actions.

Again, I appreciate your time and help! :)

slhck commented 11 months ago

Understood, in that case the above command is probably all you need! Glad to have been able to help.