![]() |
Quote:
HTH. |
@kwag
I tried (manually, with a calculator) your method for CQ prediction and I got the perfect result of 19.9 with just three encodes. It would've taken me at least double that by guesswork alone :!:. Since I've finished porting Blockbuster to YV12, I think I'm going to start implementing the wizard tonight... |
@kwag:
I just did a one-disc of American Pie using CQ 19.9 and a scale factor of 0.95. Sample size was 13mb, audio is 87mb, but the final muxed encode came out at 761mb. That's out by 36mb 8O. I'm trying again with a scale factor of 0.93... What do you think may have gone wrong? Script: Code:
AudioDub(Mpeg2Source("ap.d2v"), WavSource("ap.wav")) |
Quote:
-kwag |
Quote:
If you took a desired encode size of, say, 797mb, but wanted to leave a little room for insurance, multiplying it by 0.95 would make it smaller. Dividing it by 0.95 would make it bigger. Try it in KVCD Predictor. When you lower the scale factor, the target size increases. This is because you're dividing by a number less than 1. If we multiplied by the scale factor, then lowering it would cause a corresponding decrease in the target size. I'm going to go revisit that formula and do a proper rearrangement and see what I come up with. |
Houston, we have a problem -- or, at least, I do ;).
The original formula, slightly simplified, is: final_size = secs / 100 * scale_factor * sample_size Let's assume for the moment that the scale factor is 1. This gives us: final_size = secs / 100 * sample_size Now, since the sample_size represents the encoded size of 100 clips 1 second in length, we could say that: sec_size = sample_size / 100 where sec_size means "average size of 1 second of the movie". We can then represent the formula as: final_size = secs * sec_size Which is to say, the final size will be the size of an average second times the number of seconds in the movie. Now, the reason for the scale factor was to provide for some insurance, a little headroom in the calculation. To this end, and assuming we want to use 0.95 to mean 95% of full capacity, we would multiply the left-hand side of the equation by the scale factor: final_size * scale_factor = secs * sec_size Or, rearranged: final_size = secs * sec_size / scale_factor And, expanded: final_size = secs * (sample_size / 100) / scale_factor Thus when we decrease the scale factor, the final size also decreases. When we increase the scale factor, the final size also increases. In that case the formula KVCD Predictor should be using is: sample_size = final_size * scale_factor / secs / 100 This is the formula used in 0.1a. Thoughts? |
Quote:
Sample Size = ((Total frames/Framerate)/100) * (MPEG sample file size * .95) Where increasing the factor, in this case .95, increases file size. Edit: ( And I'm not drunk, yet! :P ) Final MPEG Predicted Size = ((Total frames/Framerate)/100) * (MPEG sample file size * .95) -kwag |
Hi SansGrip!
I want to thank you for all the GREAT filters and also for the KVCD Predictor! But I just got confused now... Quote:
As the scale factor is dividing the whole thing, when we decrease the scale factor, the final size increases, because we are dividing by a smaller value. And that's not the way the formula should behave. I think that the error is here: Quote:
Just to illustrate: If we want 95% of X and X=100, we have to multiply 100 (that's the X value) by 95%, in order to get 95. If you divide by 95% you will get ~105.26, and that’s not the 95% that we want. Well, please excuse me for the bad english. And excuse me if I'm completely wrong... because it's 3:30AM here, and according to kwag, I could be drunk by now. :wink: :lol: |
Quote:
|
Quote:
Correction here: Final MPEG Predicted Size = ((Total frames/Framerate)/100) * (MPEG sample file size * .95) ( And I haven't had a beer yet. Wonder what I would write with a couple of beers :P ) Thanks muaddib, -kwag |
BTW, I think that the scale factor (.95) is just a correction for an "almost" constant accuracy error in the formula. The aim here is to get a perfect file to fill the CD completely. Isn't it, kwag?
|
Quote:
-kwag |
Nope, I'm the one who's drunk :D. I should've run some real numbers through and I would've spotted the error.
I think what's confusing me is that when you adjust the scale factor down in KVCD Predictor, the sample target size goes up, and vice versa. Is that the correct behaviour? I've been thinking way too much about noise and averages today to think properly about anything else ;). |
Quote:
|
Quote:
It should be the other way around. When you increase the factor, the file size goes up ;) -kkag |
Quote:
final_size = (secs /100) * (sample_size * scale_factor) so that MPEG sample file size is isolated on one side. Here's my attempt: final_size / (secs / 100) = sample_size * scale_factor final_size / (secs / 100) / scale_factor = sample_size And this is the formula used in KVCD Predictor. If you feed some numbers into it (movie is 5728 seconds, audio is 87mb, media is 797mb): sample_size = 710 / (5728 / 100) / 0.95 = 13.04 sample_size = 710 / (5728 / 100) / 0.90 = 13.77 sample_size = 710 / (5728 / 100) / 1.05 = 11.80 As you can see, the sample size rises when the scale factor falls, and vice versa. Either this is the correct behaviour when obtaining the sample size from the final size, or my rearrangement of the formula is wrong, or the formula itself is wrong. :) |
Quote:
|
Quote:
So the meaning is clearer, and then 5 would be +5% and make the file 5% larger, and -5 would mean -5%, and make the file 5% smaller :idea: Instead of 0.95 or 1.05 etc. -kwag |
Quote:
Code:
// This is a very simple program to calculate what the final file size of the |
Silly Question
I don't understand what the "sample size" is meant to indicate. I was expecting to see a number reflecting the final file size if I were to use template X, Y or Z, given the AVI information. AM I meant to derive this final number from the sample size number that is indicated?
|
Update...
|
Oh boy, this is getting better by the hour :lol:
Thanks SansGrip :wink: :mrgreen: -kwag |
Quote:
Wait there... I think you 2 are talking about different things. (It should be, or I'm not drunk... I'm crazy! :lol: ) SansGrip is talking about the sample size, and kwag is talking about the mpeg final size (like I was). With that same formula... If you want to find the final size from an encoded sample, then if you increase the factor, the final size goes up. But, if you want to find the sample size from a fixed final size, then if you increase the factor, the sample size goes down (like you said). Man... is that right? :roll: :lol: |
Quote:
That is the correct behaviour when obtaining the sample size. |
Re: Update...
Quote:
There is just one thing I would like to suggest... In Step 3, when you show the size of the encoded sample and the target size; would be good if you also show the predicted final size with this encoded sample. I think that this information will make the decision between stop or try another CQ_VBR easier. You could add just a complement to the message you are using now. Something like this: “(…) The sample strip is 0.62 megabytes smaller than the target size, and will produce a mpeg file of an approximate 999.99 megabytes.” What you think? |
Re: First release
Quote:
and i made a program that will let you select a media file (MPEG or AVI) and it will tell you the length in HH:MM:SS MMM and SSSS as well as how many frames, and the (estimated) frame rate (Total Frames / SSSS). It also does other things too, but if you want the code to get the frame and playing time, i would be more then happy to give it to you.. I just dont know if it will help you out, since its in VB (its all API tho) let me know |
Quote:
|
Re: Update...
Quote:
At the moment that dialog doesn't actually do the calculations -- it's just a mock-up I made after completing the design of the user interface. I'm going to make it work now, and will incorporate your suggestion. |
Re: First release
Quote:
Luckily I just this morning bought a book on C++ .NET, and it looks like this will be easier than I imagined. In related news, I also got a book on assembly language, so I'm hoping to start optimizing my filters pretty soon :). Quote:
BTW, how do you get the MPEG metadata? Do you read the header directly or use DirectShow? |
Re: First release
Quote:
-kwag |
Re: First release
Quote:
|
Quick update
I thought I'd let you all know the current status of development...
I just finished the "Get movie length from source file..." functionality, so from version 0.2 you'll be able to select a .avs, .avi or .d2v file and have KVCD Predictor automatically determine the running time of the movie. I'll implement MPEG support in a later version if there's any demand for it. (Side note: In the course of writing the .d2v-parsing code I discovered that FitCD does not use the correct algorithm for determining how many frames are in the movie when reading the .d2v file. This means it can be out by several seconds, at least with NTSC forced film material, so it would be best to let KVCDP read the file instead of simply typing in the values you see in FitCD.) Before 0.2 can be released I need to finish the sample encoding helper. I've changed my mind slightly about how exactly it's going to work, but hopefully the new way will be more intuitive. I'm hoping it'll be ready in the next couple of days. I'll keep you posted :). |
Re: Quick update
Quote:
Thanks again Sansgrip :D -kwag |
Hi Kwag,
Kwag wrote: Quote:
file size prediction. I used VirtualDub to check framecount against Tmpgenc's source range and they differ. :) Is there a way to view what value is being used in the script to calculate file size :?: Between the 3 of them, which one is correct? -black prince |
Quote:
Quote:
Quote:
|
Hi Kwag and SansGrip,
Just used "ShowFrameNumber()" in avs script: Tmpgenc ....................--> 146,654 total frames ShowFrameNumber .....--> 146,654 " VirtualDub ..................--> 146,655 " FitCD .........................--> 146,661 " Seems that framecount is only off if you hardcoded FitCD's value. The file size formula should be correct. 8) -black prince |
Quote:
-kwag |
Quote:
|
Quote:
Of course!, how could I forget :lol: -kwag |
New version 0.2
Here's version 0.2 (and source code).
Changes: Quote:
I've tested this one a bit and it seems to give the correct results. The helper gives pretty good results -- normally very close to target size within three iterations. @kwag - I altered the binary search algorithm slightly. Now, if the resulting sample is larger than the target it'll drop down a little more than according to your formula. This seems to speed things up when the CQ is too high, since it's obviously desirable to be slightly below the target size rather than above. I think the algorithm can still be improved, though, perhaps by remembering previous iterations and somehow applying that information when calculating the new CQ... Any thoughts? Well, have fun and let me know what you think. Hopefully this one won't need two bugfix releases ;). |
Site design, images and content © 2002-2026 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2026 Jelsoft Enterprises Ltd.