Manual File Prediction: Mini How-to Guide
Here's the manual way to do file size prediction. I assume you have your material already prepared and you have created your basic .avs script using FitCD. I also assume you have extracted your audio in AC3 or WAV format.
Step 1: Determine the Audio file size. Say you want to put your movie on one CD. First thing you do is find out the size of your audio file. That's very easy with the help of HeadAC3he. Just run HeadAC3he and select your demuxed AC3 or WAV audio file. Select .mp2 as output and the audio bit rate you want to use. I usually select either 112Kbps for 120+ minute movies or 128Kbps for movies shorter than that. You'll see the audio size is automatically displayed in HeadAC3he. Make a note of the size. Step 2: Determine the Video file size. Suppose the audio in step 1 is 87MB, and our CD-R is 700MB 80 minutes. Remember that VCDs are written in what's called "Mode-2", so a 700MB data CD-R will actually fit ~800MB in VCD format. So we'll use an 80 minute CD-R for this example. Now do this: 800 - 87 = 713. The ~800 is your VCD capacity. So you have ~713MB left for your video stream, and this will be the predicted file size for the video. Now apply the formula like this: Predicted MPEG size = (( Total frames/MovieTimeInMinutes) / 24 ) * MPEG sample file size Say your movie has 198,673 frames and is 138 minutes long. You would do this: 198673 / 138 / 24 = 59.98 and store the value 59.98 in your calculator's memory for a moment. Now do this: 713 / MemoryRecall(which is 59.98 ) = 11.88MB and that's what your sample size has to be. Now you encode with SansGrip "Sampler()" line at the end of your .avs. Here's what a basic .avs script looks like, with the file prediction line added at the end: Code:
LoadPlugin("C:\encoding\MPEG2DEC.dll") New_CQ_Value = WantedSize(11.88 in this case) / Encoded_Sample_Size * Current_CQ_Value Say your sample comes out to 10.0MB, and you are encoding with a CQ value of 25. The new CQ value for the next run is: 11.88 / 10 * 25 = 29.7 So you change the CQ value in TMPEG to 29.7 and encode another sample. It usually takes 3 to 4 samples to hit your target this way. When you get close to the wanted file size, say < 1%, just remove the line "Sampler()" from your .avs script and when you hit encode again, your complete movie will start to encode. Hope this helps -kwag |
:D :D :D :wink:
thanks! |
Manual size prediction helper script
:idea: If you past the following at the end of your movie avs script and open it in virtualdub or your favorite media player, this will show you movie total frames, movie lenght, sample total frames, and will calculate various sound file size (same accuracy as Headac3he).
Then you can write down these numbers, comment out "Prediction()" line putting a # in front of it, and go on with the prediction process described in black prince's or kwag's guides. Code:
Prediction() |
Re: Manual size prediction helper script
Quote:
Quote:
|
Excelent guys :D
Here's further refinement, because the way the script is set, at 352x240 everything gets cut off. So put the Prediction() statement AFTER the line where you open the .d2v, and the actual function at the end of the script. Like this: Code:
LoadPlugin("C:\encoding\mpeg2dec.dll") -kwag |
Need a litle help here....exactly what is the going to do for me? I'm not sure I follow what this script is doing. Thanks in advance
Bud |
Hi Bud,
The script above will display the audio file sizes with different audio bit rates, and give the sample file size you need for each different audio bit rates. So you don't have to manually calculate the stuff :D. It's pretty cool 8) -kwag |
Kwag
Thanks,,,i'll give it a try...been having great results by using the manual method on both the 352x240 and KVCDx3 templates for one CD. Bud |
Quote:
I added a line for movie title since I like to capture the image and keep it handy with the movie which I am encoding. I also cleaned up the code to avoid confusion for those cutting and pasting. Thanks for the code help about the resizaing ( I actually thought of that but forgot to implement. :roll: ), and thanks to Graal_CPM for coming up the initial idea. I was constantly opening Excel or calculator to calculate the sample sizes. Racer99 |
I can't wait for this to happen: http://www.avisynth.org/index.php?page=WhyPython
As Python is my favorite language of all times ( Been doing Python now for ~3 years ), the possibilities will be ENDLESS! Imagine this: On one machine I can have a "Server" script running, and from remote machines, you can be encoding by serving via TCP/IP to a client where TMPEG is running :mrgreen: :mrgreen: Frameserving through the internet :lol: The future looks bright 8) -kwag |
Hi all!
Here is my 2 cents for this great script: Well I think that if we leave all these subtitles in all sample’s frames, it can disturb the prediction accuracy, so I created two frames, one at the beginning and one at the end of the sample, and I show all the information only in this two frames. Other change is that I added the title of the movie as a parameter of the function. I did this because I have a file with many functions, and I just call this file when I need some of the functions. Here is how I call it: Code:
Import("D:\DVD Rip Tools\AviSynth2\filters\functions.avs") I just have one doubt... in the end of the old (and the new) formula, we are dividing by .98! If we want to give a little breath of 2% shouldn't we multiply by .98? Oh, I also make some cosmetic changes like font formatting and positioning. I have to move the top and bottom subtitles because they got cut by the LetterBox filter. Here is the function: Code:
Function Prediction (clip c, string "movie") { |
What can I say muaddib :D
Kudos :mrgreen: -kwag |
I couldn't get this to work.
Here's my script: Code:
LoadPlugin("D:\avfilters\legalclip.dll") Code:
Import("F:\sample avisynth scripts\function.avs") Code:
Function Prediction (clip c, string "movie") { Script error: Subtitle does not have a named argument "align" (F:\sample avisynth scripts\function.avs, line 29) (H:\lotr2\lotr2~1.avs, line 16) Any ideas? |
Quote:
Donload avisynch 2.07. edit: BTW, you have to specify the video title or it will not work. How can I set a default value for an argument in an avisynch function? |
Quote:
Quote:
|
Quote:
-kwag |
OOPS! I thought i had 2.07 this whole time!!! :oops: Thanks!
|
Why wouldn't the prediction() line be after the filters? When i put it right after the mpeg2source everything is still cut off.
|
Smoochie3 -
I think you're correct - if the Prediction("movie") line is placed right before the Sampler(length=24) line (at the end of the script after all filters), everything displays correctly, otherwise it's cut off. Excellent script! Thanks, --TonyK. |
Quote:
-kwag |
I just tweaked it a little more!
Now you can specify in the function calling the title of the movie, the number of CDs you are targeting and the correction factor. Code:
Prediction("Matrix", 2, .99) Here is the function: Code:
#---------------------# |
Quote:
If you put it right after the Mpeg2Source(), then it will be resized with the frame and should display correctly with any resolution. Try this way with the last script. It's working perfectly for me. edit: oops! Sorry kwag... I didn't hit the refresh and didn't see you post. :oops: :wink: |
Stupid me again :imstupid:
IT GOES AFTER THE MPEG2SOURCE LINE Quoting my original post: So put the Prediction() statement AFTER the line where you open the .d2v" That's the way it gets properly resized. I'm taking a break to clear my mind :twisted: -kwag |
Wonderful modifications muaddib :mrgreen:
Works like a charm 8) -kwag |
Work, but I can't see the title anywhere 8O
I'm checking the screen coordinates now :!: |
Quote:
I think that we both need a break... because we are both wrong! 8O :twisted: I was testing it with a 4:3 source, and it really works like a charm in this kind of source, but if we use a 16:9 source and use gripfit, it will cut the black borders and cut the displayed information too, than add the borders back again. So , at the end, I think we will have to use it after the filters. :? I have to go to work now, but I'm thinking in a solution... :wink: cya |
Here it is... (I hope it works correctly now :D )
The way you call it still the same. Use it at the end of your script, just before sampler(). Code:
#---------------------# |
Muaddib,
:ole: :mrgreen: Edit: It would be great if we could get the file name part from the mpeg2source line :!: Then the title could be automatically assigned to the variable :D Can't wait until AviSynth gets ported to Python code. Then I'm going to have MUCH more fun :mrgreen: -kwag |
Here's a slight but very usefull mod.
Change your Prediction("Matrix", 2, .99) line to Prediction("Matrix", 2, .99).Sampler(length=24) Now you only have to comment out this line after you read you values and encode away :D -kwag |
Quote:
|
Would it be possible to include as another frame the calculations for the new CQ?
SO, no need for a calculator or an Excel spreadsheet. Just edit the .avs, and include in the Prediction filter the obtained file size and the used CQ value. That would be very nice. Gaudi |
That can't be done Gaudi. The CQ must be found by running a full sampler on the movie.
-kwag |
Quote:
This would be great, but unfortunately while the script is processing we don't have the sample done yet, so can’t know what size it will be. edit: Wow... I'm 8 min late! That's what happens when you answer the forum while working... :D |
Mon Dieu! I have just walked away from my computer for a few days and when I come back you have all gone crazy with avisynth scripting!! :lol:
I have just used my old trick to keep up the pace = doing a search on "kwag" name to get an idea of the last plugins and scripts to use :wink: As I see it Kwag, you keep on posting your scripts over and over again. You should be praised for that, however here is an idea for you to spare your (golden) fingers. Before indulging in video encoding, I was playing with lame MP3 encoder and used to hang around a site called r3mix. It was all about finding the best settings to gest the best encoded sound quality (remind you of something? :roll: ). In between many changes and tweaking, the guy "in charge" used to post his last command line parameters somewhere on the site, so that anybody could use it for encodes. Each time a better tuning was found, after days of testing and postings (sic), he updated this "recommended settings". Well. I know that we can adjust our scripts according to source quality (ranking from excellent to crappy, even for $$$ DVDs), but a sticky post with a generic script still could do a lot good for the growing number of newcommers. Mmmm... Maybe simply updating black prince wonderfull "how-to" would do the trick too... Just an idea. Cheers. |
Hi Graal_CPM,
Yes, I know I have to put a sticky somewhere, but haven't got around to it yet :D I'll see what I can do, because it's easier to reply with a link, than write and write ( or copy+paste ) over and over again :lol: -kwag |
Probably what gaudi means is, after sampler encoding edit the avs script and put the sample mpeg size.
I don't know a lot about avs scrip but i guess it could be possible this way. bye |
Quote:
Well, that was exactly what I meant. Using the avs script as a calculator. I wouldn´t mind editing the script if that makes the use of a calculator innecessary. Thanks |
I don't know if this could be useful, but i changed the prediction script to choose the size of cd ( i often use CD-RW of 74 Min. ) like follow
Quote:
prediction("Matrix",2,.99,74) or prediction(cdtime=74) bye |
I changed the desired sample size to mb and truncated to four digits. Also rounded off the audio mb's.
Code:
#---------------------# |
This is getting better every day :mrgreen:
|
Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.