digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Avisynth: Predicting File Size for VBR ..... (http://www.digitalfaq.com/archives/avisynth/1225-avisynth-predicting-file.html)

kwag 10-01-2002 02:33 PM

Thanks black prince,

But greater thanks must go to Ozzie :lol:
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 8O
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 :lol:
Yes, you're right, it works super good!. I just did my first 2 hour film with the KVCDx3 :lol: and it looks damn good 8O
The file size came out 20MB smaller than the predicted file size ( good insurance 8) ) with the formula above to calculate the file size with an audio of 192Kbps. It looks and sound excelent :lol: 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 :wink:

Enjoy, play, and encode :lol:
-kwag

rendalunit 10-01-2002 03:22 PM

This file size prediction script is quite awesome! :D 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

muaddib 10-01-2002 03:26 PM

Quote:

Originally Posted by kwag
Also, to Ozzie, I must say this: You just killed multipass encoding :wink:

You are right!
No more need to multipass encode to predict the file size!
Just great :!: :lol:

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,

kwag 10-01-2002 03:49 PM

@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 :wink:

Later!,
-kwag

LadyMiles 10-01-2002 04:14 PM

Any special instructions
 
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.

kwag 10-01-2002 04:23 PM

Re: Any special instructions
 
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

LadyMiles 10-01-2002 04:58 PM

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

rendalunit 10-01-2002 05:14 PM

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. 8O

-ren

LadyMiles 10-01-2002 07:19 PM

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

black prince 10-01-2002 07:37 PM

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. 8)

-black prince

kwag 10-01-2002 07:51 PM

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. 8O

-ren

Haven't tried that ren 8O
I'll let you know :roll:

-kwag

LadyMiles 10-01-2002 11:11 PM

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

kwag 10-02-2002 01:04 AM

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

obrigado 10-02-2002 06:58 AM

filesize prediction
 
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

muaddib 10-02-2002 08:49 AM

Re: filesize prediction
 
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. :lol:
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.

kwag 10-02-2002 01:02 PM

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 :wink:

-kwag

black prince 10-02-2002 03:40 PM

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. 8)

-black prince

black prince 10-02-2002 04:31 PM

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

kwag 10-02-2002 06:32 PM

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 :lol:
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. 8O
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 :lol: 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" :lol:
And that would give the formula a -0.62% accuracy, right :?: 8)

-kwag

black prince 10-02-2002 07:34 PM

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?. 8)

-black prince


All times are GMT -5. The time now is 01:42 PM  —  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.