Quantcast Avisynth: Predicting File Size for VBR ..... - Page 2 - digitalFAQ.com Forums [Archives]
  #21  
10-01-2002, 02:33 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
Thanks black prince,

But greater thanks must go to Ozzie
I had been trying to find a method to do this for over a month now, and I didn't know that the "SelectRangeEvery( X, Y ) function existed
I was trying to find out the structure of a TMPEG project file, so that I could generate a .prj file with to "100" granularity sampling that I had in mind. So when Ozzie came out with the script, this immediately popped into my head
Yes, you're right, it works super good!. I just did my first 2 hour film with the KVCDx3 and it looks damn good
The file size came out 20MB smaller than the predicted file size ( good insurance ) with the formula above to calculate the file size with an audio of 192Kbps. It looks and sound excelent So no more worries from now on thinking if it will fit or not. Also, to Ozzie, I must say this: You just killed multipass encoding

Enjoy, play, and encode
-kwag
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
  #22  
10-01-2002, 03:22 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
This file size prediction script is quite awesome! My latest encode came out to 70 mb less than the sample predicted so I raised the audio bitrate all the way up. The 90 minute full screen 30fps movie I did came out to 530 mb with the LBR template and it looks great!

I was also wondering if you want the file size a little bigger and better quality do you raise the cq and max bitrate or just the cq?

thanks,
ren
Reply With Quote
  #23  
10-01-2002, 03:26 PM
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
Also, to Ozzie, I must say this: You just killed multipass encoding
You are right!
No more need to multipass encode to predict the file size!
Just great

Let me just ask one thing.
If I understand correctly, with kwag's version you are taking 100 samples of one second each. This will give you a total of 100 seconds sample.
Is that enough to get good accuracy to a 3hour movie?
Lets say I want to increase the accuracy, what would be better... more samples or more sec/samples.

These two examples will give a total 5 minutes (300sec) of "predict sample".
1) 150 samples of 2 seconds each:
IL = Framecount / 150
SL = round(Framerate*2)

2) 300 samples of 1 second each:
IL = Framecount / 300
SL = round(Framerate)

Then, MPEG size = (Film play time in seconds / 300) * MPEG sample file size

Witch one is best for accuracy?
Or better, will I get an accuracy increase doing that?

Thanks,
Reply With Quote
  #24  
10-01-2002, 03:49 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
@rendalunit,

Increase your CQ value only. If you increase your MAX and CQ at the same time, the internal CQ encoding algorithm scale changes. So it's better to maintain MIN and MAX constant, and adjust the CQ value until you get the mpeg size you want.


@muaddib,

That's what I mean for "granularity". It's better to take many small samples than less large samples. 100 one second snapshots are enough, and makes encoding the test strip very fast. 100 samples for a 2 hour movie will give you a very accurate prediction. If your movie is 3 hours or more, increase to 150 samples. That should just about cover all your bases

Later!,
-kwag
Reply With Quote
  #25  
10-01-2002, 04:14 PM
LadyMiles LadyMiles is offline
Free Member
 
Join Date: Sep 2002
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
Are there any special instructions for using your avs script ?
i.e.
1) fitcd paste script
2)load into tmepg
3)source range to one minute ?
2) Set TMPGEnc to encode - System (video only).
3) Encode test file.
4) Divide, encoded test file size by source range time,
then multiply by full movie time.
Reply With Quote
  #26  
10-01-2002, 04:23 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 LadyMiles
Are there any special instructions for using your avs script ?
i.e.
1) fitcd paste script
2)load into tmepg
3)source range to one minute ?
2) Set TMPGEnc to encode - System (video only).
3) Encode test file.
4) Divide, encoded test file size by source range time,
then multiply by full movie time.
Quote:
3)source range to one minute ?
No. Range is already selected by SelectRangeEvery(IL,SL)
Quote:
Divide, encoded test file size by source range time,
then multiply by full movie time.
Try this:
Final MPEG size = (Film play time in seconds / 100) * MPEG sample file size
Or:
Final MPEG size = ( ( Total frames / Framerate) / 100 ) * MPEG sample file size

-kwag
Reply With Quote
  #27  
10-01-2002, 04:58 PM
LadyMiles LadyMiles is offline
Free Member
 
Join Date: Sep 2002
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
Dear Kwag
Thank you for being so patient with me. Just one more question fitcd seems to show the wrong time length. But when I loda the d2v in Tmpeg it shows the correct length. Is this a bug in fot cd or is there somethingwrong with the d2v
Reply With Quote
  #28  
10-01-2002, 05:14 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
hey Kwag,

can you use this script when frameserving with Mediator? I tried to do this and it encoded only the first 5 seconds of the movie then ended.

-ren
Reply With Quote
  #29  
10-01-2002, 07:19 PM
LadyMiles LadyMiles is offline
Free Member
 
Join Date: Sep 2002
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
Hey Kwag
I think you template is great and you are so helpful and patient with people
If you can tell me how to calculate an audio file based on an mpa or an mpeg2. I will be gald to use visual basics to create a little program where people can input the info your script produces.
I.e.
input time
Input sample file size
Input audio file size
Output estimated file size
Reply With Quote
  #30  
10-01-2002, 07:37 PM
black prince black prince is offline
Free Member
 
Join Date: Jul 2002
Posts: 1,224
Thanks: 0
Thanked 0 Times in 0 Posts
Hey LadyMiles,

No need to write a VB program to calculate audio file size prediction.
We use Headac3he to input (wav, mpa, ac3, etc.) and choose
Destination File as .mp2. Click twice on OPTIONS button, select
dual channel and as you change audio bitrate from 224, 192, etc.
you can see the Destination file size change in MB's. It's fairly
accurate.

-black prince
Reply With Quote
  #31  
10-01-2002, 07:51 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 rendalunit
hey Kwag,

can you use this script when frameserving with Mediator? I tried to do this and it encoded only the first 5 seconds of the movie then ended.

-ren
Haven't tried that ren
I'll let you know

-kwag
Reply With Quote
  #32  
10-01-2002, 11:11 PM
LadyMiles LadyMiles is offline
Free Member
 
Join Date: Sep 2002
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
Hey Kwag,

I was saying I would write a VBS for predicting file size. where people could input the sample file size that your script would create and the audio file size instead of using a calculator

Bascially a VBS just doing what you told me
Final MPEG size = (Film play time in seconds / 100) * MPEG sample file size
Reply With Quote
  #33  
10-02-2002, 01:04 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 LadyMiles
Hey Kwag,

I was saying I would write a VBS for predicting file size. where people could input the sample file size that your script would create and the audio file size instead of using a calculator

Bascially a VBS just doing what you told me
Final MPEG size = (Film play time in seconds / 100) * MPEG sample file size
Hi LadyMiles,

As black prince said, there's no need, because Headac3he already has an automatic calculator. When you open a AC3, WAV, etc file, it automatically tells you the file size for the audio, depending on the bit rate you choose. So you can dynamically play with the destination bit rate, and immediately see the file size that will be created.

-kwag
Reply With Quote
  #34  
10-02-2002, 06:58 AM
obrigado obrigado is offline
Free Member
 
Join Date: Aug 2002
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
hi there,

I've tried this (or similar) methode several
times b4 to predict the filesize based on
extrapolation of a sample (independant of
the scripts).

The majority of the predictions did not
succeed :-(
Errors of up to 20% came up.

My explanation/guess:
the scenery of a movie varies pretty
much along the film. It all depends on
a similar mix of action scenes compared
to the sample sequence. You can't
expect this to be the same mix. So the
results of a one-sample-extrapolation
might be good but it isn't necessarily
good.

A better way could be a strategy that
takes different samples along the film
(say 30 sec samples every 5 or 10 min).
This average might bring up a better
estimation of the final result but I
couldn't find a way to automatize this.

Obrigado
Reply With Quote
  #35  
10-02-2002, 08:49 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 obrigado
A better way could be a strategy that
takes different samples along the film
(say 30 sec samples every 5 or 10 min).
This average might bring up a better
estimation of the final result but I
couldn't find a way to automatize this.

Obrigado
Hi obrigado,

IL = round(Framerate*600) # interval length = 10min.
SL = round(Framerate*30) # sample length = 30seg.
SelectRangeEvery(IL,SL)

The script above takes 30 sec samples every 10 min.
But I think that what kwag say about the 100 sample granularity is a better way.
It's giving me great results, about 2 or 3% error. And with a smaller file size.
If you want a better accuracy, you can just increase the granularity (as kwag said). You can doble it (200samples / 1sec each) and still have a small prediction file size.
Reply With Quote
  #36  
10-02-2002, 01:02 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
Here's an update on the formula:

Final MPEG size = (Film play time in seconds / 100) * (MPEG sample file size * .95)

Or:

Final MPEG size = ( ( Total frames / Framerate) / 100 ) * (MPEG sample file size * .95)

I'm getting consistent result between 2% to 4 % lower than predicted file size every time with every movie. So if you use the above formula, multiplying the resulting mpeg sample by .95, your estimation will be almost the final file size. The .95 value is just a little insurance margin

-kwag
Reply With Quote
  #37  
10-02-2002, 03:40 PM
black prince black prince is offline
Free Member
 
Join Date: Jul 2002
Posts: 1,224
Thanks: 0
Thanked 0 Times in 0 Posts
Hi All,

I decided to try predicting file size using KVCD-LBR for the same movie,
Omega Code2 (106 minutes, 26 seconds). Normally I would use a CQ of
30 recommended by Kwag prior to testing file size. So, I tested CQ’s from
30 to 65 in increments of 5. The test allowed me to use CQ to 50 and
still have room for audio file of 100MB at 128Kbps. The final A/V file
is ~ 783MB. The picture quality is excellent. The actual video file size
is 689,983,797. This is –5% smaller estimated size I chose at CQ 50.
Check out my stats below:

CQ…………….Test File Size…………….Est. Total File Size………
30……………..10,861,976……………….693,645,787……
35……………..11,225,219……………….716,842,485……
40……………..11,345,128……………….724,499,874……
45……………..11,375,721……………….726,453,543……
50……………..11,378,161……………….726,609,361……
55……………..11,378,161……………….726,609,361……
60……………..11,378,161……………….726,609,361……
65……………..11,378,161……………….726,609,361……

Note: from CQ = 50 to 65 the file size did not change in my tests.
I chose CQ=50 because there was no difference in picture quality.
The difference between total file size previous and present
resulted in a dramatically smaller difference for each pair.
(i.e. 716,842,485 – 693,645,787 = 2,319,670MB)

This process helped to use the maximum space on my CD (800MB)
with higher quality video and even audio. I will adjust my total
file size formula to Kwag's revised computations.

-black prince
Reply With Quote
  #38  
10-02-2002, 04:31 PM
black prince black prince is offline
Free Member
 
Join Date: Jul 2002
Posts: 1,224
Thanks: 0
Thanked 0 Times in 0 Posts
Hey Kwag,

Is it possible to test MT in bold below and check the total movie
time "MT = round(Framecount / round(Framerate)) " for say 10800
seconds or 3 hours and select a value of 150 else 100.
This assumes movies 3 hours or more would use "Framecount / 150
else 100". Will avisynth allow condition tests, say if (movie time) >= 10800
seconds then 150 else 100? I tried, but couldn't find any refrence.

LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\MPEG2DEC\MPEG2DEC2.dll")
LoadPlugin("E:\DVD Backup\2 - DVD2SVCD\INVERS~1\DONALD~1\DECOMB.DLL")
Mpeg2Source("D:\Temp\Omega_Code2.d2v")
Telecide()
Decimate(5)
#BilinearResize(496,448,6,0,708,480)
#TemporalSmoother(2,2)
#AddBorders(16,16,16,16)
#
BilinearResize(336,224,0,0,720,480)
TemporalSmoother(2,2)
AddBorders(8,8,8,8 )
#
#MT = round(Framecount / round(Framerate)) # movie time in seconds
#IL = Framecount / 150 # If movie is 3 hours or more
IL = Framecount / 100 # If movie is less than 3 hours
SL = round(Framerate) # 24 for NTCSFilm, 30 for NTCS, 25 for PAL
#
SelectRangeEvery(IL,SL)
#
# End of script.

-black prince
Reply With Quote
  #39  
10-02-2002, 06:32 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
Hi black prince,

I'm not sure about if/else/then conditions in AviSynth. I'll have to check the reference manual. It does allow user defined functions ( a la C Language ). I'll have to check on that.

But I have something to report
I just finished encoding "The Green Mile" with the LBR for testing the formula and the script ( 100 samples ), and I am baffled at the results.
Using the formula "Final MPEG size = ( ( Total frames / Framerate) / 100 ) * (MPEG sample file size * .95)", the predicted file size target was 643,377KB. The actual file size after encoding is 639,352KB So it's only a difference of 4.025MB in a 3 hour movie.
Now I'll say it again" The hell with multipass encoding"
And that would give the formula a -0.62% accuracy, right

-kwag
Reply With Quote
  #40  
10-02-2002, 07:34 PM
black prince black prince is offline
Free Member
 
Join Date: Jul 2002
Posts: 1,224
Thanks: 0
Thanked 0 Times in 0 Posts
Hey Kwag,

What CQ did you use for "Green Mile" KVCD-LBR? You
have recommended 20 for 3+ hours movies in the past.
What did your tests tell you about increasing CQ?.

-black prince
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Having trouble predicting actual finished file TCC Avisynth Scripting 12 02-23-2003 12:58 AM
DVD2SVCD: Predicting audio file size black prince Video Encoding and Conversion 9 11-15-2002 12:26 PM
KVCD: AVS File Size predicting stuff? twobit326 Video Encoding and Conversion 14 11-01-2002 09:28 PM
KVCD: file predicting DVD to 1 cd-r disc? 2COOL Video Encoding and Conversion 0 10-14-2002 07:17 PM
Avisynth: File Size Predition vs Actual file size? Rig R. Mortis Avisynth Scripting 2 10-12-2002 06:04 PM

Thread Tools



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