Predicting File Size for VBR .....
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. :D -black prince |
RE: TMPGEnc VBR. Accurate file size prediction.
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) :D 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. |
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 :wink: Thanks for the original script Ozzi :wink: -kwag |
Script update: TMPGEnc VBR. Accurate file size prediction.
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. :) |
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. :roll: Ozzie’s method came a whole closer to the Actual file size. -black prince |
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! :lol: |
Quote:
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 :wink: Now I'm encoding it again with the KVCDx3. Done 50%, and size is right on target too :D -kwag |
Hi Kwag,
oops, I was so excited I over looked that mistake :oops: Thanks :D -black prince |
@Hi Again,
Ozzi's avs calc filesize VBR is the greatest. Give him an award! :) This time I got it right!!! :wink: 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. :D 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 8) |
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. |
In seconds
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 ?
|
Quote:
I wonder where that "other forum" was :lol: That reminds me when "some other forum" people would tell me that it was IMPOSSIBLE to get 120 minutes of video with "VIEWABLE" quality :lol: Now we get 180 minutes with good quality 8) 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" :cry: More to investigate..... :wink: Keep up your great work :D -kwag |
Hi kwag,
Updated the script again. The script now automatically gets number of frames. It uses the AviSynth function, Framecount. :D 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. |
Quote:
I couldn't make Framerate or Framecount work 8O 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 |
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 :wink: -kwag Changes: Please use round() function. I edited this post. I was using the ceil() function before. |
Do you use the same How to for this script ?
And how do you calculate the audio file ? |
Quote:
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 |
Way to go Kwag,
This is getting better and better. :D 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. :wink: Great work Ozzi and Kwag -black prince :D :D :D :D |
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. |
Right on the target, black prince!
You take the words out of my mouth... :lol: :!: Great work Ozzi and Kwag :!: |
Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.