Help - Search - Members - Calendar
Full Version: MP3 2 pass ABR "experimental method"
Hydrogenaudio Forums > Lossy Audio Compression > MP3 > MP3 - Tech
Sagittaire
MP3 VBR 1 pass is the best method for constant quality but not for constant size. MP3 ABR 1 pass is the best solution for constant size but not for quality. In fact the best solution will be MP3 ABR 2 pass ... ???

here an empirical method to make MP3 VBR 2 pass with MusicMatch JukeBox with quality interval [1-100] and thus 100 preset for quality ...

user posted image

user posted image

... and use this reference table (base 100 = quality 50%)

Q01 ~ 71.0
Q10 ~ 73.5
Q20 ~ 77.4
Q30 ~ 84.2
Q40 ~ 90.8
Q50 ~ 100.0
Q60 ~ 107.9
Q70 ~ 124.0
Q80 ~ 136.8
Q90 ~ 152.1
Q100 ~ 164.5


Example: Wav 2.0 LOTRII sample 460 sec

I want make this encoding with 96 Kbps.
Encoding with JMJB and quality 50%: 6 350 Ko and 110.4 Kbps -> first pass
96/110.4*100 = 87 in reference table and ~Q35 for encoding with JMJB -> second pass
Encoding with JMJB and quality 35%: 5 607 Ko and 97.5 Kbps ... wink.gif

It's an empirical method to make MP3 ABR 2 pass with MusicMatch JukeBox. I think that it is possible also with lame but only 10 quality preset for Lame ...
Cygnus X1
Please forgive me for being feeble minded, but your post is very hard to make sense of. What exactly are you doing to get this so-called "2-pass" method? Since current MP3 encoders can only do 1 pass, I hope you are not feeding an encoding back into the encoder again (i.e., transcoding), for such would significantly damage quality.

By the way, the encoder in MusicMatch is generally considered to be of lower quality than LAME, especially when using the --alt-presets.
Gabriel
This is about reaching something equivalent to "2 pass VBR", targetting a specific bitrate, without support from the encoder.

The idea is to encode a first time using a VBR setting that is usualy resulting in bitrate close to your target one, then re-encode a second time (from the original source of course) and this time adjust the VBR scale to achieve the targetted bitrate.

I think that this is interesting. It could be further enhanced, but the main idea is there.
NoXFeR
Personally, I think this is an excellent idea. I have been thinking along the same lines myself and I think it is strange that it has not been implemented in some vbr encoder yet.

Do you think something like this would be feasible in LAME in the future? Would finer quality settings be needed?

I bet it would not be a problem at all implementing in Vorbis or Musepak MPC, as the quality settings are very fine in both encoders, and using some simple algorithm it should be possible to obtain a bitrate very close to the assigned one using multipassing.

EDIT: Let me add that I have not sufficient programming skills to make this algorithm (yet). If I had, I would post it here.
Gabriel
QUOTE
Do you think something like this would be feasible in LAME in the future?

Could be.
But I also think that this could be done outside the encoder, by a front-end. This way, no need to increase complexity of the already messy Lame.exe frontend.
Sagittaire
QUOTE(Cygnus X1 @ Aug 1 2004, 09:47 PM)
Please forgive me for being feeble minded, but your post is very hard to make sense of. What exactly are you doing to get this so-called "2-pass" method? Since current MP3 encoders can only do 1 pass, I hope you are not feeding an encoding back into the encoder again (i.e., transcoding), for such would significantly damage quality.

By the way, the encoder in MusicMatch is generally considered to be of lower quality than LAME, especially when using the --alt-presets.
*




In fact ABR 1 pass isn't a very good Rate Control for quality and isn't a very good Rate Control for Bitrate taget too ...

exemple 2: Wav with first part 20 sec audio On + second part 20 sec audio Off (mute)

With Lame ABR 1 pass 128 Kbps:
400 Ko and 80 Kbps
first part 316 Ko and 126 Kbps
second part 84 Ko and 32 Kbps

With MMJB "VBR 2 Pass" 128 Kbps
614 Ko and 123 Kbps
first part 532 Ko and 212 Kbps
second part 82 Ko and 32 Kbps


exemple 3: Wav first part "Waiting" 20 sec with very complexe audio frames (low compressibility) + second part "LisztBMinor" 20 sec with very simple audio frames (high compressibility)

With Lame ABR 1 pass 128 Kbps:
606 Ko and 121 Kbps
first part 306 Ko and 122 Kbps
second part 300 Ko and 120 Kbps

With MMJB "VBR 2 Pass" 128 Kbps:
643 Ko and 129 Kbps
first part 376 Ko and 150 Kbps
second part 267 Ko and 107 Kbps


ABR 1 pass is a Rate Control with bit resevoir method. It cannot anticipate the complexity of the frames. it's well for the encoding of sources with a homogeneous complexity but not for the sources with a heterogene complexity (movie for exemple)


[In French]
ABR 1 pass ... aussi complexe soit-il la voyance n'est pas intégrable dans un algo de Rate Control ... biggrin.gif
[/In French]

Edit: "VBR 2 pass" is an method who could be used with all the audio codecs which have quality mode ... perhabs with RC "XviD" for exemple ...
Gabriel
To be clear I think that you need to use "vbr 2 pass" when encoding with vbr algorithms and "abr 2 pass" when encoding with abr algorithms.
So MMJB would then be called "vbr 2 pass".
ErikS
QUOTE(Gabriel @ Aug 2 2004, 12:57 PM)
To be clear I think that you need to use "vbr 2 pass" when encoding with vbr algorithms and "abr 2 pass" when encoding with abr algorithms.
*



I think abr describes this method well according to this definition of the term: http://lame.sourceforge.net/doc/html/modes.html

Or is it time to change the definition? wink.gif
Gabriel
I think that I should change my definition from
QUOTE
In this mode, you choose the encoder will maintain an average bitrate while using higher bitrates for the parts of your music that need more bits.

to
QUOTE
In this mode, you choose a target bitrate and the encoder will continuously try to maintain an average bitrate while using higher bitrates for the parts of your music that need more bits.
NoXFeR
I would imagine that the most practical solution to this is to create a small script-like programme that allows for selecting appropriate bitrate, encoder and number of passes. There should also be some table in the programme which contains statistics for bitrates at various quality levels, so that one has a good starting point. This way one would have have something that does something like this:

multipass-vbr.exe -encoder lame -bitrate 128 -passes 2 "input file"
JeanLuc
I always wondered why most audio encoders do not use techniques from video compression ... n-pass vbr encoding is the way to achieve real constant quality with any lossy video en-/transcoder i know of.

Imagine lame.exe analysing the whole audio file in a first pass to create a 'resultfile' that will incorporate bitrate distribution for the final encoding ...
Gabriel
I always wondered why no one ever created a front-end doing this...
audioflex
that sounds like a great idea.
Cygnus X1
Ok, I get it now smile.gif And yes, this is an interesting idea; with video codecs having incorporated mutli-pass encoding for some time, I think it would be a boon to audio as well.
pacohaas
I've definitely done something similar in the past with video encoding. I knew the bitrate I needed(if i did the video encode first for example), so i'd use lame abr at the bitrate I wanted, then looking at the result(too high or too low actual average bitrate) I would make a guess and do another abr lame pass, and repeat until I was satisfied with the resulting average bitrate. Certainly something that could be done in visualbasic or something.
MugFunky
hehe. i do the same with video compression - i don't have time for true 2-pass, so i encode a small (hopefully representative of the movie) chunk and code that at a predefined q level.

then i check the difference, adjust the q level and re encode from the source. i've been pleasantly surprised occasionally - within 10MB of the CD size, but not above it.

it is something you could do with a frontend, but i think it'd be more efficient to have a simple 2 pass (rather than multipass which i see as an enormous waste of time) with an analysis pass (perhaps constant quantizer plus statistics) and a 2nd pass to do the bit allocation and whatnot.

a clever enough analysis pass could also detect where potential encoding problems may arise and allocate more bits to them (i'm aware that LAME already does this, but i'm not sure if it checks-back on itself to see actual problems rather than theoretical ones).
ErikS
QUOTE(MugFunky @ Aug 5 2004, 06:25 PM)
(i'm aware that LAME already does this, but i'm not sure if it checks-back on itself to see actual problems rather than theoretical ones).
*



It can't unless it suddenly grew ears. Indeed, it only checks the theoretical ones.
StoneRoses
QUOTE(JeanLuc @ Aug 2 2004, 10:38 PM)
I always wondered why most audio encoders do not use techniques from video compression ... n-pass vbr encoding is the way to achieve real constant quality with any lossy video en-/transcoder i know of.


I think it is because there is no real need for EXACT bitrate control in audio, but for the video bitrate control is extreamly important.

Optimal procedure for transcode a DVD to CD(s) (or anything that have very limited space)
1. Encode audio first (With VBR at quality of your choices)
2. Calculate space available for video and overhead
3. Encode video using 2 pass VBR targeting the size.

Since audio is encoded before video there is no real need for exact audio bitrate control VBR is enough in this case.

Anyway, implement real 2 passes mode (with stat file in first pass) in lame is always a good idea.

WMA sick.gif has 2 pass encoding modes both 2-pass VBR and 2-pass CBR (I don't know how 2-passes CBR work but it difinitely improve quality in my experiment.)
Echizen
Sounds interesting. This way would be slower than normal encoding, but theoretical it'd also increase the quality (and that's more important for me). VBR is said to be generally better than ABR, isn't it?

Hopefully someone is able create a little script/frontend.
Sagittaire
QUOTE(StoneRoses @ Aug 5 2004, 09:50 AM)
WMA sick.gif has 2 pass encoding modes both 2-pass VBR and 2-pass CBR (I don't know how 2-passes CBR work but it difinitely improve quality in my experiment.)
*



Perhabs because CBR isn't a real CBR. CBR is a real CBR if for all audio frame bitrate is constant. For example with video CBR is impossible with the quantisation system: for video it isn't CBR for frame but CBR for little interval and CBR for little interval is in fact "ABR with buffering system control" ...

Perhabs that CBR for WMA9 isn't a real CBR but ABR with "buffer". In fact "CBR 1 pass" could be ABR 1 pass with "reservoir bit" + "buffer" and "CBR 2 pass" could be ABR 2 pass with "buffer" ...
Sagittaire
I read here many tests on the codecs audios. they are often make with codecs using different type of RC: CBR for LC-AAC iTunes and VBR quality for Vorbis ...

How to know the influance of RC type on the result? How to know the real quality of the psychoaccoustic model if different RC are used?

you should make a test with the same codec but with different RC on your samples tests with the same size +/- 5% ...

for example:
- WMA9 "CBR 1 pass"
- WMA9 "CBR 2 pass"
- WMA9 VBR quality
- WMA9 ABR 2 passe

or
- Vorbis CBR
- Vorbis ABR
- Vorbis VBR

If for sample-A VBR is very better than CBR for quality then codec using VBR for this sample will have an advantage for sample-A. If for sample-B CBR is very better than VBR for quality then codec using CBR for this sample will have an advantage for sample-B ...
Galahad
I think that n-pass is really bad idea. When I experimented with n-pass mode in DivX encoder I found that the visual quality is better with 2-nd pass than with 3-rd and 4-th and 5-th, so do you think 6 passes are worth waiting? As for me, I am not a programmer, but I think that the actual bitrate distribution curve can be achieved after 1-st pass. Why doing more?
Sagittaire
Very strange result for ABR 1 pass with bit reservoir ...
http://lame.sourceforge.net/doc/html/modes.html

Average Bitrate (ABR)
In this mode, you choose the encoder will maintain an average bitrate while using higher bitrates for the parts of your music that need more bits. The result will be of higher quality than CBR encoding but the average file size will remain predictible, so this mode is highly recommended over CBR. This encoding mode is similar to what is referred as vbr in AAC or Liquid Audio (2 other compression technologies).


Source ~8 min with very heterogeneous complexity

VBR "quality" with Lame
user posted image

ABR 1 pass with Lame
user posted image


Small sources ~30 sec

CODE
               Lossless    VBR -V 2    ABR 100    ABR 130    ABR 160    ABR 190  
                                                                       
Bartok_strings2     780        213        95         125        156        187    
chanchan            936        210        102        135        170        205    
Debussy             426        182        94         124        155        186    
female_speech       506        130        106        137        170        203    
getiton             782        203        100        131        162        193    
Hongroise           600        191        97         128        158        189    
kraftwerk           679        181        99         132        164        197    
Leahy              1066        194        100        131        163        195    
male_speech         535        135        106        138        173        208    
Mama                943        180        103        135        169        204    
NewYorkCity        1131        201        96         127        158        189    
OrdinaryWorld       980        198        97         129        160        191    
rosemary            811        179        102        133        165        197    
SinceAlways        1032        217        99         130        163        193    
TomsDiner           785        134        106        137        170        203    
trust               890        214        98         130        164        200    
Twelve             1043        212        96         127        158        189    
Waiting             981        207        94         124        156        189    
                                                                       
                 828,11     187,83      99,44     130,72       163      195,44



high compressibilty source: female_speech, male_speech & TomsDiner
ABR 1 pass with reservoir bit make OverSize with these source ... ???


Low compressibilty source: Bartok_strings2, Debussy, Hongroise, NewYorkCity, Twelve, Waiting
ABR 1 pass with reservoir bit make generaly UnderSize with these source ... ???
kennedyb4
Can you please tell me the programme you used to make your bitrate graphs?

Is this Encspot pro?
Madrigal
QUOTE(kennedyb4 @ Aug 8 2004, 08:21 AM)
Can you please tell me the programme you used to make your bitrate graphs?

Is this Encspot pro?
*


Yes. Right click on a file within EncSpot Pro, and select "Details".

Regards,
Madrigal
Galahad
How nice - everybody say "yes, 2-pass ABR is a very good idea... blah... blah..."
Somebody's going to implement this GOOD IDEA???!!!
Dibrom
QUOTE(Galahad @ Aug 15 2004, 11:16 AM)
How nice - everybody say "yes, 2-pass ABR is a very good idea... blah... blah..."
Somebody's going to implement this GOOD IDEA???!!!
*



So why don't you do it?
Galahad
I am not a L.A.M.E. developer smile.gif
Gabriel
QUOTE
I am not a L.A.M.E. developer

You do not need to.
As mentionned in this thread, this can be done using a frontend.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.