digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   To MAX or not to MAX? Bit rate, that is! (http://www.digitalfaq.com/archives/avisynth/1905-max-max-bit.html)

kwag 12-23-2002 05:46 PM

To MAX or not to MAX? Bit rate, that is!
 
Here's another (crazy) idea, that hopefully ends just as good as the "Crap" thread, which spawned EXCELENT file prediction methods, formulas, and gizmos(sampler!) ( Thanks SabsGrip :wink: ). I was wondering if we really need the MAX values that are current in the KVCD templates. It occured to me that maybe if we have the MAX bit rate set to a value higher that what's actually needed, the encoder has to work on a wider "bandwidth", which could be non-optimal.
So here we go again :D
Call me crazy if you want, but here is what I'm currently trying out, and it seems to work VERY good 8)

First download bit rate viewer from here: http://www.tecoltd.com/bitratev.htm

Now run your regular ripping, DVD2AVI, FitCD, and add SansGrip's "Sampler()" filter line to your .avs.
Now here's the fun part. Open your .avs with TMPEG, and load your favorite template. Go to Settings/Rate control, and set your MIN bit rate to 0 and your MAX bit rate to 9999 and CQ_VBR value to 100 8O . Yes, zero, nine thousand nine hundred and ninety nine, and one hundred. Read on. We're going to make TMPEG find some nice values for us.
Now run the encoder and make your test sample. Now take that sample and drag it to Bitrate Viewer ( Or run Bitrate viewer and open the sample file ) and note the average bit rate. Now go back to TMPEG and set your MIN bit rate to 300 ( or the MIN value that you use ) and set the MAX bit rate to the average bit rate given in bit rate viewer ( which should be below 2,500Kbps ) 8O ( WHAT!, yes. Read on )
Now do your file prediction formulas and encode with these parameters. After you do your sample, and you calculate your final CQ_VBR value, open the new sample again with bit rate viewer. What's your peak bit rate :?: Lower than your set MAX right :?: 8O ( I hear you say, HOW? WHY? )
We''ll as far as I can see, we're "tightening" the "bandwidth" we had before. For example, on the KVCD 704x480 PLUS we have set MIN=300, MAX=2,500. After I did my first sample with with the procedure above, my average was 2,060. So that's what I used for MAX bit rate. So before we had default TMPEG values of MIN=300, MAX=2,500 which is a "bandwidth" of 2,200 for CQ_VBR. Now with MIN=300 and MAX=2,060, it's only 1,769 ( 2060 - 300 ) so remember that the closer the MIN to the MAX, the closer we get to a constant bit rate curve. After viewing my final encoded sample with bit rate viewer, my average peak bit rate is 1,511Kbps with an average of 631Kbps. So for this particular movie, it would be a waste increasing MAX above this level. You could interpet this as a "Software clipper", clipping high frequencies. In reality, this would (should) cause visible macroblocks if we have a scene that requires bitrate > MAX. In reality, it doesn't reach that point 8O And here's the proof of concept. This is a 704x480 sample from the movie K-19, which is 139 minutes long 8O , and I encoded this sample predicted to fit on one CD-R, with audio at 112Kbps. Here's a 20 second cut out (~3.7MB ) of the .m1v file: http://www.kvcd.net/k19.m1v

Comments (ALWAYS) welcome :wink:

-kwag

black prince 12-23-2002 06:56 PM

Hey Kwag,

Kwag wrote:
Quote:

I was wondering if we really need the MAX values that are current in the KVCD templates. It occured to me that maybe if we have the MAX bit rate set to a value higher that what's actually needed, the encoder has to work on a wider "bandwidth", which could be non-optimal.
Then we would test for MAX bitrate using BitrateViewer to determine
the optimal MAX. How will this improve the process (i.e. quicker
encodes, better picture quality, etc.) Each KVCD template has different
settings for MIN and MAX bitrates. This would mean a test for the optimal
MAX must be found and set for the movie being tested for file size. Is
this correct?

-black prince

Racer99 12-23-2002 07:59 PM

Re: To MAX or not to MAX? Bit rate, that is!
 
Quote:

Originally Posted by kwag
Now go back to TMPEG and set your MIN bit rate to 300 ( or the MIN value that you use ) and set the MAX bit rate to the average bit rate given in bit rate viewer ( which should be below 2,500Kbps )
-kwag

What if bitrate viewer shows greather than 2500? :? I just tested it on Weekend At Bernies and my peak was 3270 and Avg was 2720.

Also after you plugged in you max bit rate from the 1st pass you mentioned "Now do your file prediction formulas and encode with these parameters. After you do your sample, and you calculate your final CQ_VBR value". Do you do the 2nd pass with the CQ_VBR @ 100 also?

And then on the 3rd sample you would then adjust you CQ_VBR based of the file prediction forumula, correct?

Settings:
KVCDx2-CQ-704x480 Template
TMPGEnc 2.59 Plus
Source: From DVD Vob files.

Racer99

kwag 12-23-2002 08:43 PM

Quote:

Originally Posted by black prince
Hey Kwag,

Kwag wrote:
Quote:

I was wondering if we really need the MAX values that are current in the KVCD templates. It occured to me that maybe if we have the MAX bit rate set to a value higher that what's actually needed, the encoder has to work on a wider "bandwidth", which could be non-optimal.
Then we would test for MAX bitrate using BitrateViewer to determine
the optimal MAX. How will this improve the process (i.e. quicker
encodes, better picture quality, etc.)

Better picture quality because we're using only the necessary bandwidth needed for the movie by closing the gap between MIN and MAX. So that gives the encoder a smaller range to fluctuate bit rate. :D
Quote:

Each KVCD template has different
settings for MIN and MAX bitrates. This would mean a test for the optimal
MAX must be found and set for the movie being tested for file size. Is
this correct?
Bingo :lol:, and you do that with only the first test sample. Then pick the average and use that as MAX.

Just look at the sample. It's from a 138 minute movie at 704x480 8O
So now we should be able to put a ~2 hour movie on a CD-R with the quality we used to get before with only 60 minutes :D
Of course, that is when we brainstorm the crap out of this thread :lol:

-kwag

kwag 12-23-2002 08:50 PM

Re: To MAX or not to MAX? Bit rate, that is!
 
Quote:

Originally Posted by Racer99
Quote:

Originally Posted by kwag
Now go back to TMPEG and set your MIN bit rate to 300 ( or the MIN value that you use ) and set the MAX bit rate to the average bit rate given in bit rate viewer ( which should be below 2,500Kbps )
-kwag

What if bitrate viewer shows greather than 2500? :? I just tested it on Weekend At Bernies and my peak was 3270 and Avg was 2720.

Then if your DVD player can handle 2,720 that is what you use for MAX. If not, then set it for 2,500 which is the current MAX set on the 804x480 PLUS templates.
Quote:


Also after you plugged in you max bit rate from the 1st pass you mentioned "Now do your file prediction formulas and encode with these parameters. After you do your sample, and you calculate your final CQ_VBR value". Do you do the 2nd pass with the CQ_VBR @ 100 also?
No, you only set CQ_VBR to 100 on the first pass with MIN=0 and MAX=9999. After you find the average from this pass, then you set your MIN=300 and MAX=average found above. Then you'll get your CQ_VBR value when you run your following sample tests with prediction, as usual.
Quote:


And then on the 3rd sample you would then adjust you CQ_VBR based of the file prediction forumula, correct?
On the second run you set your CQ_VBR to ~20 or so and run prediction tests.

-kwag

Racer99 12-23-2002 09:07 PM

Re: To MAX or not to MAX? Bit rate, that is!
 
Quote:

On the second run you set your CQ_VBR to ~20 or so and run prediction tests.

-kwag
Thanks, I'll give it a shot!

-Racer99

SansGrip 12-23-2002 09:09 PM

Re: To MAX or not to MAX? Bit rate, that is!
 
Quote:

Originally Posted by kwag
Here's a 20 second cut out (~3.7MB ) of the .m1v file: http://www.kvcd.net/k19.m1v

8O

Could you run the same test strip at 704x480 using the "normal" method and post the same section from that clip for comparison?

kwag 12-23-2002 09:29 PM

Re: To MAX or not to MAX? Bit rate, that is!
 
Quote:

Originally Posted by SansGrip
Quote:

Originally Posted by kwag
Here's a 20 second cut out (~3.7MB ) of the .m1v file: http://www.kvcd.net/k19.m1v

8O

I assume that is a good sign 8O
Quote:


Could you run the same test strip at 704x480 using the "normal" method and post the same section from that clip for comparison?
:x I cut that at a random point. But I'll do it again. I was just running a test on "The Green Mile" and it gave me an average bit rate of 1,124Kbps so I was going to re-encode that again with that MAX value and prediction.
I did notice less artifacts on that 704x480 encode, compared to the one I did originally with MAX=2,500. So apparently the narower [MIN...MAX] does a better job on that. It's a shorter swing for CQ_VBR :lol:

-kwag

SansGrip 12-23-2002 10:58 PM

Re: To MAX or not to MAX? Bit rate, that is!
 
Quote:

Originally Posted by kwag
I assume that is a good sign 8O

It looks good -- but I can't say how good until I see what it looks like with the same CQ_VBR and "normal" min/max ;).

kwag 12-23-2002 11:10 PM

Re: To MAX or not to MAX? Bit rate, that is!
 
Quote:

Originally Posted by SansGrip
Quote:

Originally Posted by kwag
I assume that is a good sign 8O

It looks good -- but I can't say how good until I see what it looks like with the same CQ_VBR and "normal" min/max ;).

I stopped the movie I was encoding to try this out. I'm encoding a sample with MIN=300, MAX=2,500, as usual for a 704x480 template, and another one MIN=0, MAX=2,060 ( Calculated average ) and when I get the same file size on both samples ( because CQ_VBR value will change ) I'll post both clips. I'll also check both samples with Bitrate Viewer. There should be a difference. The one of MAX=2060 should have a lower Q. If it doesn't, then this thread and idea is the real crap :lol:

Edit: My first encode is MIN=300, MAX=2,500. Then the second is MIN=300, MAX=2,060. On this second sample I have to adjust CQ_VBR to target the same size as the first sample. Leaving the same CQ_VBR as the first, produces a larger file, because CQ_VBR is closer to MAX.

-kwag

kwag 12-24-2002 12:59 AM

Well, it was a nice try :(
There is no visual difference when encoding with MAX=2060 or 2500. :cry:
So my theory bombed completely. TMPEG's CQ_VBR just follows the range, and adjusts it's quality internally somehow. So the MAX bit rates, even though they're above the value that would normally be reached, can be left there. So MIN and MAX are just safety borders that you should set depending on the limits of your DVD player. Now I'll dig a deep hole in the ground, and stick my head in there REAL deep, and maybe tomorrow some other ideas, less stupid than this one comes out of my (*)Head :twisted:

Time to get some sleep :?

-kwag

SansGrip 12-24-2002 01:23 AM

Re: To MAX or not to MAX? Bit rate, that is!
 
Quote:

Originally Posted by kwag
Edit: My first encode is MIN=300, MAX=2,500. Then the second is MIN=300, MAX=2,060. On this second sample I have to adjust CQ_VBR to target the same size as the first sample. Leaving the same CQ_VBR as the first, produces a larger file, because CQ_VBR is closer to MAX.

You get a larger file size when you reduce the max bitrate? That doesn't make sense :?.

SansGrip 12-24-2002 01:29 AM

Quote:

Originally Posted by kwag
There is no visual difference when encoding with MAX=2060 or 2500.

So when you reduce the max bitrate the file size increases and the quality stays the same? This sounds weird :?. How is the average Q level affected?

I could just try it for myself, but I'm sitting here in the family room with my laptop and playing with my new receiver ;).

(So I calibrated it then switched on the TV and ordered The Scorpion King on PPV -- regular Dolby Surround -- and here's an exact quote of my reaction:

Quote:

8O

Oh

8O

my

8O

God

8O
It completely blows my old receiver (a Denon 1601) out of the water. I can't wait to try the Pro Logic II-encoded version of Resident Evil :D.

black prince 12-24-2002 09:30 AM

Hey Kwag,

Kwag wrote:
Quote:

Now I'll dig a deep hole in the ground, and stick my head in there REAL deep, and maybe tomorrow some other ideas, less stupid than this one comes out of my (*)Head
Keep coming up with ideas!!! :D If you would just stop and look at all
the great ideas, file prediction, GOP, KVCDx3, LBR, etc. They came
from trying things that others said can't work. :) There will be a few
ideas that don't work, but putting your head in a hole isn't one. While
your in that hole think about more compression techniques and possible
ways to enhance picture quality further :mrgreen:

-black prince

gonzopdx 12-24-2002 10:42 AM

kwag,

i'll give it a shot when i get back home (at the 'rents house for x-mas atm).. i'm curious to see if this will work. it sounds like a very sound theory and i'd like to try it out for myself :)

i'm still playing with Die Another Day (218 minutes).. my last test I used the new prediction methods (which overshot the end file size by about 20 megs, but still way closer than the original method :!:), re-arranged my script to use a more logical ordering of the filters applied (which ended up in higher quality/lower file size in the tests) and encoded at 352x480 to see how it'd turn out (480x352 had too many artifacts).. i didn't have a chance to multiplex and burn it to check out the quality before i had to leave home, but the little bit i did check out on my pc looked pretty darn good (besides the 'softness').. if i can encode it at the original resolution of 480x480 (or higher from dvd's) with less artifacts and better usage of the bitrate, so much the better :P

how did the Q factor compare in your tests?

on another note, i tried narrowing the bitrate range by changing the minimum bitrate to 700 and leaving the max at 2500 on a test i did.. the result, which i expected to look much better, actually looked MUCH worse.. TONS of artifacts and gibs in every possible location. same test with min of 300 gave the desired results :?: any ideas why this would happen?

ARAGORN 12-24-2002 10:56 AM

Hi Kwag!

:D What a work! All this topics are gonna make me crazy!!! But i like this. Great work :lol:

I've tried your new idea and it's not so bad. There's a little difference in quality but not important. On one min clip I,ve got 3MO less in the file size. I'm sure there's some improvements that can be found. 8) Tmpgenc as so many options. Have you ever tried manual vbr? Perhaps an optimization of q matrix ? Go further. :lol:

ARAGORN


Edit: min 300 max 2500= 14,2MO min 300 max 1711=11,2

1711 is the average bitrate given by bitrate viewer.

With the same cqvbr.

ARAGORN

kwag 12-24-2002 11:01 AM

Re: To MAX or not to MAX? Bit rate, that is!
 
Quote:

Originally Posted by SansGrip
You get a larger file size when you reduce the max bitrate? That doesn't make sense :?.

Yes it does. If you keep a constant CQ_VBR value and encode a clip with say MAX=1500 and encode the same clip at MAX=2000, the file size will be larger with MAX=1500 ONLY IF it's a low to medium material that didn't need to use more bit rate. When you increase the MAX to 2000, the Q curve is farther from MAX, and you get a smaller file size. That was my reasoning for the experiment in this section. Maybe I should take one eye out of the hole, just one eye so if it fails, I can go back quickly in the hole 8O , and encode an action film and see if it makes a difference.
We'll see. I'll do some more tries today. I still have a feeling that this has to work. Don't know exactly why or how, but I do :wink:

-kwag

SansGrip 12-24-2002 11:15 AM

Re: To MAX or not to MAX? Bit rate, that is!
 
Quote:

Originally Posted by kwag
If you keep a constant CQ_VBR value and encode a clip with say MAX=1500 and encode the same clip at MAX=2000, the file size will be larger with MAX=1500 ONLY IF it's a low to medium material that didn't need to use more bit rate. When you increase the MAX to 2000, the Q curve is farther from MAX, and you get a smaller file size.

I still don't understand how that works, but I trust you ;). Maybe I'll run some tests of my own in a minute...

kwag 12-24-2002 01:07 PM

Re: To MAX or not to MAX? Bit rate, that is!
 
Quote:

Originally Posted by SansGrip
I still don't understand how that works, but I trust you ;).

Thanks for the vote of confidence :D , but don't blaim me if it blows up :lol:
Quote:

Maybe I'll run some tests of my own in a minute...
Please do so :!: . I'd like to know if you get the same results I get.

-kwag

jorel 12-24-2002 06:31 PM

or i'm very lost or i'm talking about this in this thread:

http://www.kvcd.net/forum/viewtopic....a6aecd53b4880e

correct me if i'm wrong.
thanks! :D


All times are GMT -5. The time now is 09:34 AM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.