INDEX  F.A.Q.  SEARCH  LATEST POSTS     Rules  Register  Profile  Private messages  Login


Search all forums or this forum: Advanced search
Mini Guide: Normalizing Audio for Multiple AVI files

Forum Index -> Video -> Audio Printer-friendly version
Goto page Previous  1, 2, 3, 4  Next
Reply to topic
Author Message
Digiface
Member


Joined: 02 Jul 2005
Location: Finland

Post Posted: Jul 30, 2007 19:41 Posts Comp View users profile Send private message Reply with quote

Btw, i get an error when i try to open that 4CCchanger.

Soopafresh
Dismember


Joined: 01 Jan 2004
Location: United States

Post Posted: Jul 30, 2007 20:37 Posts Comp View users profile Send private message Reply with quote

If you don't want to do install .NET 2.0, copy Mencoder.exe, Pthreadgc2.dll, and sdl.dll into the COMPLETED folder, along with this

change4cc.zip







GUI version (needs .Net 2.0)

4cc_changer.rar


foxidrive
Member


Joined: 11 Sep 2007
Location: Australia

Post Posted: Sep 11, 2007 05:24 Posts Comp View users profile Send private message Reply with quote

Soopafresh wrote:
Sorry about that... Mirror

http://www.savefile.com/files/847228


Thanks so much for your work Soopafresh, I was pleased to find a command line solution and it worked well for me.

I modified your code a bit - couldn't see what mencoder was doing in the lossless batch file so removed it (and it worked fine for my files) as well as removing the need for LMOD and a separate pass of ffmpeg to create the temp video file (it now streams video from the original file to the new copy in the "converted" folder).

The sequence "o-0" in divxmux isn't listed in the short help - what does it do?

Thanks again!

Code:
@echo off

rem Lossless_Gain.bat v.5.1

md completed 2>nul
for %%a in (*.avi) do (
if exist a-temp-*.* del a-temp-*.*
ffmpeg -i "%%a" -vn -y -acodec copy a-temp-audio.mp3
mp3gain /f /c /r a-temp-audio.mp3
divxmux -o "completed\%%a" -v "%%a" -a "a-temp-audio.mp3"
rem is -a o-0 "filename.mp3" necessary?
)
if exist a-temp-*.* del a-temp-*.*


Soopafresh
Dismember


Joined: 01 Jan 2004
Location: United States

Post Posted: Sep 11, 2007 09:56 Posts Comp View users profile Send private message Reply with quote

Thanks for that, foxidrive. I was looking for a way to get rid of Lmod, as it isn't XP64 compatible.

access kid
Member


Joined: 27 Sep 2007
Location: United Kingdom

Post Posted: Sep 27, 2007 08:35 Posts Comp View users profile Send private message Reply with quote

Top program, just fixed a DVD Rip as the sound was very low.
Many thanks.


Soopafresh
Dismember


Joined: 01 Jan 2004
Location: United States

Post Posted: Sep 27, 2007 17:22 Posts Comp View users profile Send private message Reply with quote

Thanks for your kind words smile.gif

Snelg
Member


Joined: 13 Nov 2007
Location: United States

Post Posted: Nov 13, 2007 12:00 Posts Comp View users profile Send private message Reply with quote

Hey, thanks for making these handy batch files! Now I finally have an answer for the e-mails I still get that say, "Can you add .avi support to MP3Gain?"

Suggested extra parameter for the Lossless one:

Adding "/s s" to the mp3gain command line, e.g.

mp3gain /f /s s /c /r *.mp3

will completely skip the tag reading/writing part of mp3gain. No extra garbage added to the file. I don't know if divxmux ignores that extra bit of tag data in the first place, so maybe that's not necessary.

Added bonus: there's a kludgy way to make mp3gain do peak normalization (i.e. maximizing) from the command-line:

mp3gain /f /s s /d 100 /k /r *.mp3

The "/d 100" switch means "bump up the regular 'normal' volume target by 100 decibels". That would normally completely destroy the volume into an unholy mess of clipping, but then the "/k" switch says, "Oh, and if the suggested volume change for this file will cause clipping, then bump the volume back down to the loudest point where this particular file won't clip at all".

...yeah, it would have been simpler if I'd just added a "maximize" switch in the first place wink.gif

And to clear up a misunderstanding from much earlier in the thread, the changes made by mp3gain work in anything that plays mp3s. Mp3gain directly modifies the raw mp3 data. The tag stuff was added in a later version just as a convenience for people who went back to modify their mp3s more than once-- mp3gain stores the analysis results so it doesn't have to re-analyze the file.


HBx2000
Member


Joined: 14 Nov 2007
Location: Netherlands

Post Posted: Nov 14, 2007 11:51 Posts Comp View users profile Send private message Reply with quote

hey, i just registered to say thx for this nifty little trick..

i just found one little bug: i've you don't have a dir called 'completed' it deletes the new file after creating it, the dir 'completed' isn't created for you..


Soopafresh
Dismember


Joined: 01 Jan 2004
Location: United States

Post Posted: Nov 14, 2007 16:30 Posts Comp View users profile Send private message Reply with quote

Hi, and welcome smile.gif. I'll look into it.

Soopafresh
Dismember


Joined: 01 Jan 2004
Location: United States

Post Posted: Nov 16, 2007 00:26 Posts Comp View users profile Send private message Reply with quote

Snelg, thanks for those suggestions! I never looked into the Mp3gain parameters that carefully. Looks like a new release will be in the works. smile.gif

gg2004
Member


Joined: 13 Sep 2007
Location: United States

Post Posted: Nov 24, 2007 02:43 Posts Comp View users profile Send private message Reply with quote

Thanks so much, Soopafresh and foxidrive – this thread is really a life saver!

I was going to take advantage of Snelg’s “presence” and ask him whether there is a command line option to get mp3Gain to normalize files to a specific level (other than 89dB, that is), but then I realized that it makes little sense to do so regardless of clipping.

On the other hand, the “maximization” achieved by bumping up each mp3’s volume by 100dB and then bumping it back down to avoid clipping is not completely satisfactory to me, because I don’t get an overall feel for where the individual levels end up…

With that in mind, I have settled on a workflow that (while not completely automated) makes eminent sense to me (I mostly deal with TV series captured by friends in Europe). In short, I:

1) Extract the mp3s from the AVIs and put them aside in a separate directory, lest mp3Gain overwrite them [see “GG_AVI--Extract to mp3s.BAT” below]

2) Place a copy of the extracted mp3s into the AVIs’ directory, and normalize them to the highest common value not causing clipping, using mp3GainGUI – I play a bit with the value in the “Target” box after analyzing the files, and sometimes make a judgement call as to whether I can live with clipping in one or two of them. I also take a snapshot of the mp3GainGUI window with Snagit and save it, just to know what changes have been made.

3) Mux the normalized mp3s back into the AVIs, or more precisely, replace the original audio (mp3/AC3/etc) with the normalized mp3s. I put these new AVIs in their own directory as well, modifying their name to reflect the normalization level – this can easily be removed or modified by editing “ GG_AVI--Replace normalized mp3s into AVIs.BAT” below, currently set up for 94dB.

A couple of comments:
*) I agree that 224 kbps would be a desirable sampling rate, but in fact I usually match what’s in the original AVI (easily determined using gSpot or an equivalent application). The “Extract to mp3s.BAT” (currently set for 192 kbps) can be edited before using it.
**) I try to stay away from mencoder, because TMPGEnc does not recognize the audio portion of AVIs muxed with it.

Thanks again, and of course corrections and feedback are always welcome.

@echo off
rem GG_AVI--Extract to mp3s.BAT (based on Avi_Gain.bat v0.5)
md "AAA_Original mp3s" >nul
if exist x-gain.wav del x-gain.wav
if exist a-norm.mp3 del a-norm.mp3
for %%a in ("*.avi") do (
ffmpeg -i "%%a" -vn -y x-gain.wav
lame x-gain.wav -b 192 --cbr -F -m s -h --noreplaygain a-norm.mp3
copy a-norm.mp3 "AAA_Original mp3s\%%a.mp3"
del x-gain.wav
del a-norm.mp3
)


@echo off
rem GG_AVI--Replace normalized mp3s into AVIs.BAT (based on Avi_Gain.bat v0.5)
md "AAA_Normalized AVIs" >nul
if exist a-temp-*.* del a-temp-*.*
for %%a in (*.avi) do (
copy "(Norm94dB)-%%a.mp3" a-temp-audio.mp3
divxmux -o "AAA_Normalized AVIs\(Norm94dB)-%%a" -v "%%a" -a "a-temp-audio.mp3"
del a-temp-*.*
)


Soopafresh
Dismember


Joined: 01 Jan 2004
Location: United States

Post Posted: Nov 24, 2007 02:56 Posts Comp View users profile Send private message Reply with quote

Great ideas, gg2004. I'm gonna try out your batch files.

Wow, I just realized why Snelg knows so much about MP3gain laugh.gif


Soopafresh
Dismember


Joined: 01 Jan 2004
Location: United States

Post Posted: Nov 24, 2007 21:10 Posts Comp View users profile Send private message Reply with quote

Okey dokey, new version 06 contains a few changes:

1) Updated the Lame Mp3 encoder

2) Used Peak Normalizing on the Lossless gain batch file (thanks, Snelg)

3) Optimized the batch files to hopefully work with 64 bit Windows

4) Reduced the file size to host on Videohelp.com


Soopafresh
Dismember


Joined: 01 Jan 2004
Location: United States

Post Posted: Feb 27, 2008 14:14 Posts Comp View users profile Send private message Reply with quote

Version 07 has a minor update of the Lame encoder. No need to update if you're already running v06.



avi_gain_batch.zip


Last edited by Soopafresh on Mar 13, 2008 19:36, edited 1 time in total


W_Eagle
Member


Joined: 04 Jul 2002
Location: Israel

Post Posted: Mar 07, 2008 18:00 Posts Comp View users profile Send private message Reply with quote

I capture avi files with PCM wave audio, which I convert to AC3 for DVD authoring. Now, the correct AC3 level is –27 dB. Is any of the normalizing methods mentioned here normalizes the audio level to -27 dB?

Soopafresh
Dismember


Joined: 01 Jan 2004
Location: United States

Post Posted: Mar 07, 2008 21:12 Posts Comp View users profile Send private message Reply with quote

Are you sure you don't mean "Dialog Normalization" ? That would be something you apply at the Dolby Digital encoding stage. 27 means adding 4dB of gain reduction to the Dolby playback

"Dialnorm is the meta-data parameter that controls decoder gain within the proprietary Dolby Laboratories Dolby Digital (AC-3) audio compression system. It ranges in integer values from 31, where decoder gain remains at unity, to a value of 1, where decoder gain is reduced by 30 dB."

http://en.wikipedia.org/wiki/Dialnorm


The only thing these AVI_GAIN scripts do is ensure the PEAK loudness of the audio never goes over 0dB


halsboss
Member


Joined: 13 Jan 2004
Location: Australia

Post Posted: Mar 08, 2008 00:02 Posts Comp View users profile Send private message Reply with quote

Soopa, you're a wonder.
Thanks.
Cheerio


Soopafresh
Dismember


Joined: 01 Jan 2004
Location: United States

Post Posted: Mar 08, 2008 00:13 Posts Comp View users profile Send private message Reply with quote

Thanks for your kind words smile.gif

W_Eagle
Member


Joined: 04 Jul 2002
Location: Israel

Post Posted: Mar 08, 2008 03:37 Posts Comp View users profile Send private message Reply with quote

Soopafresh wrote:
Are you sure you don't mean "Dialog Normalization" ?

Yes, that's exactly what I mean, and, this Dialog Normalization refers to the average, or RMS level – not to peaks.

Soopafresh wrote:
The only thing these AVI_GAIN scripts do is ensure the PEAK loudness of the audio never goes over 0dB

So, any convenient way to do Dialog Normalization?


Soopafresh
Dismember


Joined: 01 Jan 2004
Location: United States

Post Posted: Mar 08, 2008 04:47 Posts Comp View users profile Send private message Reply with quote

Dialogue normalization happens during AC3 encoding. If you use an AC3 converter app like Aften, you can specify the level of DialNorm in the settings. So I don't think these scripts will help you.

W_Eagle
Member


Joined: 04 Jul 2002
Location: Israel

Post Posted: Mar 08, 2008 05:30 Posts Comp View users profile Send private message Reply with quote

How does Aften recognize the dialog actual level? Is it fully AC3 compatible?
My predicament is this:
I capture many movies from Cable TV and Satellite TV with wave audio and authorize it to DVDs. The audio levels between different movies varies by as much as 10 dB. I'd like all final movies to have about the same audio level, and similar audio level to commercial DVDs.

Right now I use Vegas 5.0b for AC3 encoding. I open the avi files in Vegas, from there I open it in Sound Forge 7.0 to find the average RMS level. Whatever RMS level is indicated, I choose that level in Vegas AC3 rendering (encoding). However, this is a lengthy and tiresome process, since I capture few movies a day. Also, the end result is far from satisfactory – since there are marked variations in audio level between different movies.

So, is there any better, or easier way to do it?


Soopafresh
Dismember


Joined: 01 Jan 2004
Location: United States

Post Posted: Mar 08, 2008 14:00 Posts Comp View users profile Send private message Reply with quote

It all depends on your definition of "easier" and "better".

1 - Install AVIsynth v2.57 or later (preferably 2.58 ) - http://downloads.sourceforge.net/avisynth2/AviSynth_070919.exe?mo ... g_mirror=0

2 - Download and unzip this small script

wav_to_5_1_upmixer.rar

3 - Copy your WAV files into the same folder and double click the .bat file


4 - When complete, you'll find the AC3 files



I modified the script to give you a Dialnorm of 27 to match your other DVDs. The audio levels should now be very close. The script takes a while to run, but it is completely automatic, and the 5.1 audio sounds very good.

If you want a faster method or if you just want stereo AC3, you can use the script below instead. Both methods take some time because they to go through the entire WAV file and normalize the sound levels.

wav_to_2_0_ac3.rar


Last edited by Soopafresh on Mar 08, 2008 14:28, edited 2 times in total


W_Eagle
Member


Joined: 04 Jul 2002
Location: Israel

Post Posted: Mar 08, 2008 14:27 Posts Comp View users profile Send private message Reply with quote

Thank you very much.
I'll try it.
Only, few questions:
Is Aften fully AC3 compatible?
Is there any difference in AC3 audio quality between Aften and Vegas?
How does Aften know the actual recorded dialog level (since the level varies by as much as 10 dB between different movies)?
Does applying Normalizing Dialog to -27 dB in Vegas, regardless of the recorded level, will not do the same as your script?


Soopafresh
Dismember


Joined: 01 Jan 2004
Location: United States

Post Posted: Mar 08, 2008 14:35 Posts Comp View users profile Send private message Reply with quote

Is Aften fully AC3 compatible?

Yes

Is there any difference in AC3 audio quality between Aften and Vegas?

Aften will probably sound better. It's really an amazing encoder.


How does Aften know the actual recorded dialog level (since the level varies by as much as 10 dB between different movies)?

It doesn't. The script pre-processes all the WAV files to have the same volume levels before feeding it to Aften.

Does applying Normalizing Dialog to -27 dB in Vegas, regardless of the recorded level, will not do the same as your script?

No. I'm trying to find something for you to read to understand the difference between volume normalization and dialogue normalization. They are very different things.


W_Eagle
Member


Joined: 04 Jul 2002
Location: Israel

Post Posted: Mar 08, 2008 15:09 Posts Comp View users profile Send private message Reply with quote

Thank you very much indeed.
You are a gift from heaven.


halsboss
Member


Joined: 13 Jan 2004
Location: Australia

Post<