Log in

View Full Version : rms audio matching using avisynth


Davinator
19th December 2006, 19:15
I was wondering if anyone knows of a way to find out the rms value of both the L and R channels, change the levels of each channel individually so that the rms values match, and then normalize the audio of both channels using avisynth (or maybe besweet)? I've looked into this before with no luck... so I thought I should give it another shot :p

Trixter
20th December 2006, 08:21
While there might be a way to do this with avisynth, I find that exporting the .wav, fixing it in Sound Forge or Audacity, then sucking it back in via AudioDub is pretty fast... fast enough that I don't bother trying to figure out how to do it in avisynth :)

sh0dan
20th December 2006, 11:12
mergechannels(GetChannel(1).normalize(), GetChannel(2).normalize())

I cannot imagine why you would separate the left and right channel, otherwise, you could just use normalize(). If you like to have the amplification factor, use normalize(show=true), play the file and wait for the normalization factor to be calculated.

foxyshadis
20th December 2006, 11:55
That's peak normalization; rms power is a way to measure volume logarithmically, and normalization to some factor raises (or lowers) the average perceptible volume. Idealy you'd combine it with a limiter because it completely ignores peak clipping.

No idea if it's available in any current avisynth plugin.

Davinator
20th December 2006, 23:22
@Trixter

Although using an external audio program works just fine, it's not really automatable. Lately I've been processing over 100 short videos a week (music videos), and in order to implement something like this it would have to be either an avisynth solution, or another command line program. :)


@foxyshadis

It's too bad that there might not be a avisynth plugin that does this type of audio processing. I'd guess that this could be useful for lots of people besides myself. Unfortunately, my programming skills are not near good enough to try and write something like this myself :(

I'd like to use something like this when processing my videos to fix them when the audio is really left heavy, or right heavy. I think that a plugin like this could easily fix that problem for the majority of videos that have this problem.

G_M_C
21st December 2006, 10:17
@Trixter

Although using an external audio program works just fine, it's not really automatable. Lately I've been processing over 100 short videos a week (music videos).

I'd like to give one advise, maybe one that you allready know, but anyway:

Please normalize + compress/limit to something like max. -/-20 dB (max !).

Last few years most CD's / DVD made by music studio's have been completely destroyed through the use of RMS-normalisation. I've seen sound beeing normalized to -/-7 dB, and that sound bloody awefull; No dynamics, no depth and no pleasure to listen too at all (actually it causes something perceived as "Ear fatique", where you feel you're getting tired listening, eventually making you feel that you want to switch off your CD). There is also some very bad clipping that is generated by this; Look at RHCP's Californication for instance (use Soundforge to look at the WAVE).

Since you've got the chance now, normalize to some normal value (normally should be between -/- 30 and -/- 20), you'll see that you like the music more.

PS: I bvlame i-pods / MP3 players for the described "over-normalizing". The quality of most MP3's / MP4's in players is very much influenced by the compression used in the players/rippers.

sh0dan
21st December 2006, 10:58
Not exactly sure if that's it, but I've used Audiolimiter:

http://forum.doom9.org/showthread.php?t=108470

Davinator
21st December 2006, 20:47
I'd like to give one advise, maybe one that you allready know, but anyway:

Please normalize + compress/limit to something like max. -/-20 dB (max !).

Last few years most CD's / DVD made by music studio's have been completely destroyed through the use of RMS-normalisation. I've seen sound beeing normalized to -/-7 dB, and that sound bloody awefull; No dynamics, no depth and no pleasure to listen too at all (actually it causes something perceived as "Ear fatique", where you feel you're getting tired listening, eventually making you feel that you want to switch off your CD). There is also some very bad clipping that is generated by this; Look at RHCP's Californication for instance (use Soundforge to look at the WAVE).

Since you've got the chance now, normalize to some normal value (normally should be between -/- 30 and -/- 20), you'll see that you like the music more.

PS: I bvlame i-pods / MP3 players for the described "over-normalizing". The quality of most MP3's / MP4's in players is very much influenced by the compression used in the players/rippers.

I agree with you that many, if not most, records these days are way too compressed. Once I receive the video though, the audio is already finished and mastered (in other words, I can't and shouldn't uncompress the audio). Unfortunately, sometimes when the video editing people work with the audio, they will somehow break the L & R balance (don't ask me how they manage to break it... it annoys me a lot).

I really appreciate the responses that people have posted here. It looks like there is currently not a way to find the rms value of each channel, and attenuate the channel with the higher rms value to match the other channel using avisynth. For now I'll continue to use a DAW to do this on the files that need it. I'll keep searching for another solution, and if I find anything I'll be sure to let you all know :)

pvann
21st December 2006, 22:44
I use SOX (SoundExchange) to do some Audio processing like splitting channels, combining sound files, level changes - it is quite powerful - it is called the Swiss Army Knife of audio processing
http://sox.sourceforge.net/

It is a "DOS based" command line program, thus you can batch up processing, but there is a plug-in for AviSynth (which I've not used yet)
http://forum.doom9.org/showthread.php?t=104792

Enjoy

Pookie
21st December 2006, 22:45
You can create a batch procedure before transcoding your files in Avisynth. Use FFMPEG and Normalize (I like this one http://savannah.nongnu.org/download/normalize/normalize-0.7.7-win32.zip) - lots of options regarding RMS, peak, and limiting.

;Demux Video Track from AVI
ffmpeg -i %1 -vcodec copy -an -y %~n1-v.avi

;Decode Audio Track from AVI to WAV
ffmpeg -i %1 -vn -y %~n1-a.wav

; Normalize the resulting WAV file
Normalize (look at the settings in readme file) %~n1-a.wav

;Convert back to MP3 (or whatever) with FFMPEG or LAME

ffmpeg -i %~n1-a.wav -ac 2 -ab 384 -vn -y %~n1-a.mp3

;Multiplex Video to Normalized Audio

ffmpeg -i %~n1-a.mp3 -i %~n1-v.avi -acodec copy -vcodec copy "%~n1-New.avi "


As far as processing each individual track from the 2-track stereo, I guess you can split using something like Tranzcode
and combine again using Soxmix or m2s - http://www.rarewares.org/files/others/m2s.zip

On a semi related note, check out mctools for wav multi - channel manipulation

http://people.bath.ac.uk/masrwd/mctools.html

* sh0dan, if you can find your copy of audiolimiter, would you mind posting it somewhere?
http://forum.doom9.org/showthread.php?t=108470