Quantcast Avisynth: Predicting File Size for VBR ..... - digitalFAQ.com Forums [Archives]
  #1  
09-27-2002, 09:57 AM
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,

Here's an interesting script that I have tried and the margin of error
for predicting file size was approx. 5%. I made some minor changes.
AM1=72 (23.976 x 3 sec. ~ 72), AM2=(23.976 x 42 sec ~1007),etc.
Here's the link:
http://www.vcdhelp.com/forum/userguides/114551.php
With headac3he I can predict the audio file size from the extracted
.wav. The test runs 10 to 15 minutes depending on your cpu. 5% is
very good, but I'd like to reduce this further.

-black prince
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
  #2  
09-29-2002, 06:46 AM
Ozzi Ozzi is offline
Free Member
 
Join Date: Sep 2002
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks black prince,
I'm glad you found this script interesting. I wrote this script with two
objectives in mind. To predict file size, and to test various filters throughout
the movie. Since writing this script, I have tried to optimise it further.

Taking smaller samples at shorter intervals, may be more accurate.

Note (1a):
Delete my old script, and use my new one instead.
(See new script and new instructions below)



TMPGEnc VBR. Accurate file size prediction.

Most people encode a sample of a movie to ascertain
visual quality and to estimate final file size.
The problem is where to take this sample from, taking
only one sample does not give a good overall view of the
movie and does not give reliable size prediction.


Simple explanation of the script:
The script takes a x second sample every
x second of the movie, then splices them together.

Brief, how to:
(a) Use DVD2AVI and FitCD to get your basic script.

(b) Edit, copy and past your script and mine,(See note 1.)
save as whatever.avs.

(c) Open the avs file in TMPGEnc.

(d) Check and view the source range in TMPGEnc, hit the
default button, move to end frame, adjust the slider
to an even minute mark, then set end frame.(See note 2.)

(e) Set TMPGEnc to encode - System (video only).

(f) Encode test file.

(g) Divide, encoded test file size by source range time,
then multiply by full movie time.

(h) Use a data rate calculator to establish audio only file size.

(i) Add calculated video and audio files sizes together for full
movie file size. (See note 3.)

Notes:
1. Anything after a # is ignored by the program.

2. Occasionally you may have to adjust the IL variable,
save avs file, then re-view source range in TMPGEnc.

3. On an average, the final full movie file size is 5%
smaller then estimated.

4. SelectRangeEvery() is a function of mpeg2dec.dll.


Any comments, questions or suggestions are welcomed.
Please feel free to test, modify and post your results.


# Start of Script
#
# Paste your script in here.
LoadPlugin("D:\Program files\CDR\MPEG2DEC.dll")
Mpeg2Source("D:\Trains_Plains\movie.d2v")
Crop(11,0,704,576)
TemporalSmoother(2,2)
BicubicResize(320,224,0.333,0.333,0,0,704,576)
AddBorders(16,32,16,32)
FadeOut(75)
#
# IL Depending on length of movie, you may have to adjust this.
# SL See later posts on this forum for details.
#
IL = 710 # interval length in frames.
SL = 49 # sample length in frames.
SelectRangeEvery(IL,SL)
#
# End of script.
__________________
It is impossible to make anything foolproof because fools are so ingenious.
Reply With Quote
  #3  
09-29-2002, 12:43 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
Tip for the process above:

IL = Total Frames of movie / 100
SL = 24 for NTCSFilm, 30 for NTSC, 25 for PAL


So now we have a "granularity" of 100 samples. That is, every movie will be sampled 100 times, with a total of 100 seconds per movie. That granularity level should be appropiate for just about any movie.
Updated:
Now divide total film time ( in seconds ) by 100, and multiply the resulting mpeg file size times this number, and that would be your file size for the video stream of the complete movie. Adjust your CQ_VBR or CQ value accordingly.

Formula: ~Total MPEG size = (Film play time in seconds / 100) * MPEG sample file size
This should provide around +- 2% accuracy

Thanks for the original script Ozzi

-kwag
Reply With Quote
  #4  
09-29-2002, 07:27 PM
Ozzi Ozzi is offline
Free Member
 
Join Date: Sep 2002
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Brief, how to:
(a) Use DVD2AVI to generate your d2v file.

(b) Open the d2v file in FitCD, note the amount of frames,
transfer this to the FC variable in my script, then hit
save in FitCD to get your basic script.

(c) Edit, copy and past your script and mine,(See note 1.)
save as whatever.avs.

(d) Open the avs file in TMPGEnc.

(e) Check and view the source range in TMPGEnc, hit the
default button, move to end frame, adjust the slider
to an even minute mark, then set end frame.

(f) Set TMPGEnc to encode - System (video only).

(g) Encode test file.

(h) Divide, encoded test file size by source range time,
then multiply by full movie time.

(i) Use a data rate calculator to establish audio only file size.

(j) Add calculated video and audio files sizes together for full
movie file size. (See note 2.)


Notes:
1. Anything after a # is ignored by the program.

2. On an average, the final full movie file size is 5%
smaller then estimated.

3. SelectRangeEvery() is a function of mpeg2dec.dll.


Any comments, questions or suggestions are welcomed.
Please feel free to test, modify and post your results.


# Start of Script
#
# Paste your script in here.
LoadPlugin("D:\Program files\CDR\MPEG2DEC.dll")
Mpeg2Source("D:\Trains_Plains\movie.d2v")
Crop(11,0,704,576)
TemporalSmoother(2,2)
BicubicResize(320,224,0.333,0.333,0,0,704,576)
AddBorders(16,32,16,32)
FadeOut(75)
#
# FR --Adjust this to your framerate.
# FC --Adjust this to you total frame count.
# SL --See later posts on this forum for details.
#
PT = 5 # higher number=greater accuracy.
FR = 25 # frames per second (PAL).
FC = 125269 # framecount
IL = (FC / FR) /PT # interval length in frames.
SL = 51 # sample length in frames.
SelectRangeEvery(IL,SL)
#
# End of script.
__________________
It is impossible to make anything foolproof because fools are so ingenious.
Reply With Quote
  #5  
09-30-2002, 10:36 AM
black prince black prince is offline
Free Member
 
Join Date: Jul 2002
Posts: 1,224
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Kwag,

Tried your formula for predicting file size, but the results don’t
seem right.

Movie is Omega Code2, full length is 106 min 26 sec (6386 seconds),
IL = total frames of movie / 100 = 152775 / 100 = 152778, SL = 24
For NTCSFilm. The sample file size created is 26,838,046.

~Total MPEG size = (6386 / 100) * 26,838,046 = 1,713,877,618 (1.7GB)

Actual encoded file size is 1,366,330,588 (1.4GB)

Where did I go wrong. Ozzie’s method came a whole closer to the
Actual file size.

-black prince
Reply With Quote
  #6  
09-30-2002, 11:42 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
Hey Ozzi,

Great predicting script, I've been trying it since your first post.
It gives a pretty accurate predict size.
I tried it in 3 films, a disney cartoon, a music show, and a movie.
All tree gave me a 2% smaller file. Great!
Reply With Quote
  #7  
09-30-2002, 02:47 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 black prince
Hi Kwag,

Tried your formula for predicting file size, but the results don’t
seem right.

Movie is Omega Code2, full length is 106 min 26 sec (6386 seconds),
IL = total frames of movie / 100 = 152775 / 100 = 152778, SL = 24
For NTCSFilm. The sample file size created is 26,838,046.

~Total MPEG size = (6386 / 100) * 26,838,046 = 1,713,877,618 (1.7GB)

Actual encoded file size is 1,366,330,588 (1.4GB)

Where did I go wrong. Ozzie’s method came a whole closer to the
Actual file size.

-black prince
You have an error in your math
Your IL should be IL = (total frames of movie / 100) = 152775 / 100 = 1527
So IL=1527

I just finished KPAX using the LBR, and the formula above. Predicted file size was 668,644KB. Actual final file size 630,464KB
Now I'm encoding it again with the KVCDx3. Done 50%, and size is right on target too

-kwag
Reply With Quote
  #8  
09-30-2002, 03:29 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 Kwag,

oops, I was so excited I over looked that mistake

Thanks

-black prince
Reply With Quote
  #9  
09-30-2002, 05:05 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 Again,

Ozzi's avs calc filesize VBR is the greatest. Give him an award!
This time I got it right!!! The interesting thing was increasing
CQ from 25 to 30 did not increase the file size as great
as increasing from lower CQ. Seem the higher the cq the file
increase keeps getting less. Tried CQ = 30 and still had room.

GENERAL

Movie Title...................The Omega Code2
Length (seconds)..........6386

DVD2AVI
Aspect Ratio..................Full Screen (4:3)
Frame Rate...................29.970fps
Video Type....................Film 86%
Frame Type...................Progressive/Interlaced
Field Operation...............None
Audio File.......................None

AVISYNTH
telecide().decimate(5)......de-interlace
BilinearResize..................(496,448,6,0,708,4 80)
TemporalSmoother ..........(2,2)
AddBorders.....................(16,16,16,16)

TMPGENC
Template..........................KVCDx3-MPEG1
cq_vbr..............................25

TEST
Test Length (seconds)..........100
Test Movie File Size..............21,027,309
Est. Movie File Size...............1,342,803,953
Act. Movie File Size...............1,366,330,588
Diff. of Act vs Est...................23,526,635
Diff in Percent........................2%
CD Size (800MB)....................1,600,000,000
Est Space for Audio.................257,196,047

HEADAC3HE
Audio Size (224kbps)..............175,000,000
Audio Size (192kbps)..............149,000,000
Audio Size (160kbps)..............124,000,000
Audio Size (128kbps)..............100,000,000
Audio Size (112kbps)..............87,000,000
Audio Size (96kbps)................75,000,000
Audio Size (80kbps)................62,000,000
Audio Size (64kbps)................50,000,000

-black prince
Reply With Quote
  #10  
10-01-2002, 12:13 AM
Ozzi Ozzi is offline
Free Member
 
Join Date: Sep 2002
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks,
black prince, kwag and muaddib for your comments.
I'm pleased to read that you are having success with this script.
Nothing gets me more motivated than a challenge.
After being told, on another forum, that it is impossible to predict
file size with any degree of accuracy, I just had to try.
I have limited mathematic knowledge; I failed maths at school,
I could not get my head around, how a letter could be a number.-
Therefore, my method is based on an idea and lots of trial and error.
I'm sure that the script can be tweaked even further.
Give it a go. Read the AviSynth documentation, write a script and run it.
TMPGEnc will let you know if there is a problem and where it is.

Good luck.
Ozzie.
__________________
It is impossible to make anything foolproof because fools are so ingenious.
Reply With Quote
  #11  
10-01-2002, 02:53 AM
LadyMiles LadyMiles is offline
Free Member
 
Join Date: Sep 2002
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
When you dived bt time is this in total seconds (i.e 1 min =60 seconds) and where can you get a bit rate calc. I am ussing 224 sound. Oh and sometimes my GOP is blan (0) when I open up templates. And you are using CQ_VBR right ?
Reply With Quote
  #12  
10-01-2002, 06:58 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 Ozzi
After being told, on another forum, that it is impossible to predict
file size with any degree of accuracy, I just had to try.
Hi Ozzi,
I wonder where that "other forum" was
That reminds me when "some other forum" people would tell me that it was IMPOSSIBLE to get 120 minutes of video with "VIEWABLE" quality
Now we get 180 minutes with good quality

Now if I just could get the "ClipProperties" to work with this script, we could get the number of frames and frame rate automatically in the script, without having to edit. But sadly, I can't get it to work with "mpeg2source". I guess it works with "AviSource"
More to investigate.....
Keep up your great work

-kwag
Reply With Quote
  #13  
10-01-2002, 07:54 AM
Ozzi Ozzi is offline
Free Member
 
Join Date: Sep 2002
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Hi kwag,

Updated the script again.
The script now automatically gets number of frames.
It uses the AviSynth function, Framecount.

Still working on frame rate part.
There is a AviSynth function, Framerate,
just can't seem to make it work, -it's probably something simple.

#Update 1 oct 02:
#
LoadPlugin("D:\CDR\AviSynth2\plugins\MPEG2DEC2.dll ")
mpeg2source("D:\Trains_Plains\movie.d2v")
Crop(11,0,704,576)
TemporalSmoother(2,2)
BilinearResize(320,416,0,0,704,576)
AddBorders(16,80,16,80)
#
# PT - Adjust this from 5 for a 80min movie, to 10 for a 3 hour movie.
# FR - Adjust this to your framerate.
# SL - Should be one frame greater than GOP length.
#
PT = 5 # theoretically a higher number=greater accuracy.
FR = 25 # frames per second (PAL).
IL = (Framecount / FR) /PT # interval length.
SL = 51 # sample length in frames.
SelectRangeEvery(IL,SL)
#
# End of script.
__________________
It is impossible to make anything foolproof because fools are so ingenious.
Reply With Quote
  #14  
10-01-2002, 08:44 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 Ozzi
Hi kwag,

Updated the script again.
The script now automatically gets number of frames.
It uses the AviSynth function, Framecount.

Still working on frame rate part.
There is a AviSynth function, Framerate,
just can't seem to make it work, -it's probably something simple.
Hi Ozzie,

I couldn't make Framerate or Framecount work
At least with AviSynth 2.06, the current version.
My script was to read:

IL = Framecount / 100
SL = Framerate
SelectRangeEvery(IL,SL)

That's all!
Then:
MPEG size = (Film play time in seconds / 100) * MPEG sample file size
Or:
MPEG size = ( (Framecount / Framerate) / 100) * MPEG sample file size

-kwag
Reply With Quote
  #15  
10-01-2002, 09:58 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
UPDATE: I got it working, and fully automatic.
Add this to the end of your script:

IL = Framecount / 100 # interval length in frames.
SL = round(Framerate) # sample length in frames.
SelectRangeEvery(IL,SL)

The problem was that Framerate is a floating point value ex: 23.976, 29.97, etc. and it doesn't work in the "SelectRangeEvery()" function. So the function "round()" rounds the value. So 23.976 becomes 24, 29.97 becomes 30, etc. The round() function returns the nearest integer to the number parameter.



Enjoy
-kwag

Changes: Please use round() function. I edited this post. I was using the ceil() function before.
Reply With Quote
  #16  
10-01-2002, 12:11 PM
LadyMiles LadyMiles is offline
Free Member
 
Join Date: Sep 2002
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
Do you use the same How to for this script ?
And how do you calculate the audio file ?
Reply With Quote
  #17  
10-01-2002, 12:39 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
Do you use the same How to for this script ?
And how do you calculate the audio file ?
Hi LadyMiles,

It's simple.
Say your target CD-R is 800MB. You open your AC3 audio file with Headac3he, which you have already "demuxed" with DVD2AVI.
Select 128Kbps in Headac3he for this example, and note the file size that will be created. If you change the audio destination bit rate, you'll see that the file size will change too. So Headac3he tells you immediately what the final audio file size will be. Then subtract this size from 800, and that would be your MPEG video stream target.

-kwag
Reply With Quote
  #18  
10-01-2002, 02:04 PM
black prince black prince is offline
Free Member
 
Join Date: Jul 2002
Posts: 1,224
Thanks: 0
Thanked 0 Times in 0 Posts
Way to go Kwag,

This is getting better and better. The script to predict file size
is fantastic. I can now make better decisions about which
KVCD templates to use, whether to encode credits at a lower
CQ or cut credits or change movie CQ or change KVCD templates, etc.
Before I had to make crude guesses and re-do encodes. Not any more.

Great work Ozzi and Kwag

-black prince
Reply With Quote
  #19  
10-01-2002, 02:23 PM
LadyMiles LadyMiles is offline
Free Member
 
Join Date: Sep 2002
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
Hey kwag
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
  #20  
10-01-2002, 02:24 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
Right on the target, black prince!
You take the words out of my mouth...

Great work Ozzi and Kwag
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 03:34 PM  —  vBulletin © Jelsoft Enterprises Ltd