Quantcast KVCD Predictor - Page 3 - digitalFAQ.com Forums [Archives]
Go Back    digitalFAQ.com Forums [Archives] > Video Production Forums > Avisynth Scripting

Reply
 
LinkBack Thread Tools
  #41  
11-19-2002, 10:00 AM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by ozjeff99
I get my movie length from Fitcd which nicely shows it in total seconds. Is it possible to have the program accept this single value rather than have to make several entries.
FitCD (at least the version I'm running) also gives the length in frames as well as the FPS. You can hit the "Enter length in frames and frames per second..." link and enter these instead of breaking up the seconds into hours, mins, and secs.

HTH.
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #42  
11-19-2002, 06:31 PM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
@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...
Reply With Quote
  #43  
11-19-2002, 08:02 PM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
@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 . 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"))
LegalClip()
BilinearResize(352, 352, 11, 8, 700, 462)
FluxSmooth()
Blockbuster(method="noise", detail_min=1, detail_max=10, variance=1.5)
AddBorders(0, 64, 0, 64)
#IL = Framecount / 100
#SL = round(Framerate)
#SelectRangeEvery(IL, SL)
LegalClip()
Reply With Quote
  #44  
11-19-2002, 09:17 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by SansGrip
@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 . I'm trying again with a scale factor of 0.93...

What do you think may have gone wrong?
Nothing. That's within 5% and that's good. I usually get between 2% to 5%. Maybe the filters change the factor offset a little. If your factor was .95, try .98. Not 0.93, because that will make the file smaller.

-kwag
Reply With Quote
  #45  
11-19-2002, 09:35 PM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kwag
Maybe the filters change the factor offset a little. If your factor was .95, try .98. Not 0.93, because that will make the file smaller.
See, this is the kind of thing that makes me thing I should be multiplying by the scale factor!

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.
Reply With Quote
  #46  
11-19-2002, 10:02 PM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
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?
Reply With Quote
  #47  
11-19-2002, 11:28 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by SansGrip
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?
Or manually calculated:
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
Reply With Quote
  #48  
11-20-2002, 12:38 AM
muaddib muaddib is offline
Free Member
 
Join Date: Jun 2002
Location: São Paulo - Brasil
Posts: 879
Thanks: 0
Thanked 0 Times in 0 Posts
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:
Originally Posted by SansGrip
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.
With this formula, I think that's the opposite...
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:
Originally Posted by SansGrip
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
As we are calculating what would be the final size, and if we want to leave a little headroom in the calculation (95% of the full file size), we have to multiply the right-hand side of the equation by the scale factor (95%), not the left side.

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.
Reply With Quote
  #49  
11-20-2002, 12:40 AM
muaddib muaddib is offline
Free Member
 
Join Date: Jun 2002
Location: São Paulo - Brasil
Posts: 879
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kwag
Or manually calculated:
Sample Size = ((Total frames/Framerate)/100) * (MPEG sample file size * .95)
Oh Man, I really should be drunk... I'm seeing too much "sample size" in this formula.
Reply With Quote
  #50  
11-20-2002, 12:46 AM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by muaddib
Quote:
Originally Posted by kwag
Or manually calculated:
Sample Size = ((Total frames/Framerate)/100) * (MPEG sample file size * .95)
Oh Man, I really should be drunk... I'm seeing too much "sample size" in this formula.
I'm the one drunk . It should be MPEG final size. Not Sample size

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
Reply With Quote
  #51  
11-20-2002, 12:59 AM
muaddib muaddib is offline
Free Member
 
Join Date: Jun 2002
Location: São Paulo - Brasil
Posts: 879
Thanks: 0
Thanked 0 Times in 0 Posts
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?
Reply With Quote
  #52  
11-20-2002, 01:23 AM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by muaddib
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?
Yeah, but given the nature of CQ encoding and different encoding materials, there's no way to get 100% accuracy. It's pretty close though

-kwag
Reply With Quote
  #53  
11-20-2002, 02:38 AM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
Nope, I'm the one who's drunk . 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 .
Reply With Quote
  #54  
11-20-2002, 07:26 AM
ozjeff99 ozjeff99 is offline
Free Member
 
Join Date: May 2002
Location: Sydney, Australia
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by SansGrip
Quote:
Originally Posted by ozjeff99
I get my movie length from Fitcd which nicely shows it in total seconds. Is it possible to have the program accept this single value rather than have to make several entries.
FitCD (at least the version I'm running) also gives the length in frames as well as the FPS. You can hit the "Enter length in frames and frames per second..." link and enter these instead of breaking up the seconds into hours, mins, and secs.

HTH.
Sansgrip...I'm lazier and drink more beer by the way. . Could you leave the "seconds" box without an upper limit so I only have to make a single entry (thought I'd take you mind of the other issue ). I'm sure the existing underlying algorithm can be left unaltered.....Cheers mate.
Reply With Quote
  #55  
11-20-2002, 08:39 AM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by SansGrip
Nope, I'm the one who's drunk . 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 .
Hi SansGrip,

It should be the other way around. When you increase the factor, the file size goes up

-kkag
Reply With Quote
  #56  
11-20-2002, 10:45 AM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kwag
It should be the other way around. When you increase the factor, the file size goes up
Ok, then we need to rearrange this:

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.

Reply With Quote
  #57  
11-20-2002, 10:47 AM
SansGrip SansGrip is offline
Free Member
 
Join Date: Nov 2002
Location: Ontario, Canada
Posts: 1,135
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by ozjeff99
Could you leave the "seconds" box without an upper limit so I only have to make a single entry (thought I'd take you mind of the other issue ). I'm sure the existing underlying algorithm can be left unaltered.....Cheers mate.
Ok. I think I'm going to change them to textboxes anyway since I don't really like the way that numeric spinners (i.e. what they are right now) behave. That way you can enter seconds and minutes > 59 and it'll auto-normalize the values for you.
Reply With Quote
  #58  
11-20-2002, 11:26 AM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by SansGrip
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.

Maybe it's better to describe the factor field as % offset
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
Instead of 0.95 or 1.05 etc.

-kwag
Reply With Quote
  #59  
11-20-2002, 12:44 PM
rendalunit rendalunit is offline
Free Member
 
Join Date: Apr 2002
Location: san jose, Ca
Posts: 1,148
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kwag
Maybe it's better to describe the factor field as % offset icon_idea.gif
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 icon_idea.gif
Instead of 0.95 or 1.05 etc.
@kwag, I thought it would be easier if the scale factor was described like that too (that's why I put it like that in my code )


Code:
// This is a very simple program to calculate what the final file size of the
// 100 second sample should be using the file size prediction method (thnks Kwag
// and Ozzi!). The estimated audio file size by Headac3he is subtracted from the total space
// available to determine how much video space is available.  This program assumes
// you're using 80 min cdrs (if not change the const cd_size value)
// This program will crash if the wrong data type is entered:-(

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  const long long cd_size = 800000000;
  const long convert_to_mb = 1000000;
  float framerate, error_margin;
  double sample_video_size;
  int number_of_cds;                           
  long total_movie_frames, est_audio_size;
  long long video_space;


    
  printf("enter estimated audio size in mb >");
  scanf("%d", &est_audio_size);
  printf("%dmb audio \n\n",est_audio_size);
  est_audio_size = est_audio_size * convert_to_mb;
  
  printf("enter the number of 80 min cds to use >");
  scanf("%d", &number_of_cds);
  printf("%d cd(s) to burn \n\n",number_of_cds);
  
  video_space = (cd_size * number_of_cds)-est_audio_size;
  printf("there's %lldmb space for video \n\n",video_space / convert_to_mb);
  
  printf("enter total frames of video >");
  scanf("%d", &total_movie_frames);
  printf("%d total frames \n\n",total_movie_frames);
  
  printf("enter the framerate >");
  scanf("%f", &framerate);
  printf("%.2f frames per second \n\n",framerate);
  
  printf("enter percent error margin (5 is suggested, enter 0 for none) >");
  scanf("%f",&error_margin);
  printf("error margin >%.1f percent \n\n",error_margin);
  error_margin = (100 - error_margin) / 100;
  
  sample_video_size = (video_space / ((total_movie_frames/framerate) /100)) * error_margin;
    
  printf("the target sample size should be about %.1fmb \n", sample_video_size / convert_to_mb);
  printf("\npress <enter> to end..");
  getchar();
  getchar();	
  return 0;
}
Reply With Quote
  #60  
11-20-2002, 01:33 PM
joecross98 joecross98 is offline
Free Member
 
Join Date: Sep 2002
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
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?
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
KVCD Predictor-0.1b download? hansolh960 Video Encoding and Conversion 1 01-03-2012 01:58 PM
KVCD Predictor or Manual Prediction vhelp Avisynth Scripting 12 08-08-2004 02:59 AM
KVCD Predictor? FlavioMetal Conversão e Codificação de Vídeo (Português) 0 12-16-2003 08:52 AM
Kvcd Predictor DKruskie Avisynth Scripting 4 05-14-2003 06:44 PM
KVCD Predictor is out! kwag Video Encoding and Conversion 0 11-18-2002 06:25 PM




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