digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Manual File Prediction: Mini How-to Guide (http://www.digitalfaq.com/archives/avisynth/1938-manual-file-prediction.html)

kwag 12-26-2002 10:52 PM

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")
LoadPlugin("C:\encoding\fluxsmooth.dll")
LoadPlugin("C:\encoding\sampler.dll")
LoadPlugin("C:\encoding\legalclip.dll")
mpeg2source("K:\K19\VIDEO_TS\k19.d2v")
LegalClip()
BilinearResize(672,336,0,0,720,480)
FluxSmooth()
AddBorders(16,72,16,72)
LegalClip()
Sampler()

When the encoder finishes, which should take between 3 to 6 minutes depending on how fast your machine runs, take a look at the sample file size. This is what I do to zero in faster on the correct CQ value:

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

jorel 12-27-2002 09:30 PM

:D :D :D :wink:
thanks!

Graal_CPM 01-27-2003 07:05 PM

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()

function Prediction (clip c) {
Movielenght=framecount(c)/framerate(c)
d=c.
\Subtitle("Movie framecount : " + String(framecount(c)),20,20).
\Subtitle("Movie lenght (sec) : " + String(round(Movielenght)),20,40).
\Subtitle("Test framecount : " + String(framecount(Sampler(c,length=24))),20,60).
\Subtitle("Audio@112bps (Mb) : " + String( (((112*1024)/8)*Movielenght)/1048576),20,80).
\Subtitle("Audio@128bps (Mb) : " + String( (((128*1024)/8)*Movielenght)/1048576),20,100).
\Subtitle("Audio@160bps (Mb) : " + String( (((160*1024)/8)*Movielenght)/1048576),20,120).
\Subtitle("Audio@192bps (Mb) : " + String( (((192*1024)/8)*Movielenght)/1048576),20,140).
\Subtitle("Audio@224bps (Mb) : " + String( (((224*1024)/8)*Movielenght)/1048576),20,160)
return d
}


Racer99 01-30-2003 10:21 AM

Re: Manual size prediction helper script
 
Quote:

Originally Posted by Graal_CPM
: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()

function Prediction (clip c) {
Movielenght=framecount(c)/framerate(c)
d=c
\Subtitle("Movie framecount : " + String(framecount(c)),20,20).
\Subtitle("Movie lenght (sec) : " + String(round(Movielenght)),20,40).
\Subtitle("Test framecount : " + String(framecount(Sampler(c,length=24))),20,60).
\Subtitle("Audio@112bps (Mb) : " + String( (((112*1024)/8)*Movielenght)/1048576),20,80).
\Subtitle("Audio@128bps (Mb) : " + String( (((128*1024)/8)*Movielenght)/1048576),20,100).
\Subtitle("Audio@160bps (Mb) : " + String( (((160*1024)/8)*Movielenght)/1048576),20,120).
\Subtitle("Audio@192bps (Mb) : " + String( (((192*1024)/8)*Movielenght)/1048576),20,140).
\Subtitle("Audio@224bps (Mb) : " + String( (((224*1024)/8)*Movielenght)/1048576),20,160)
return d
}


Quote:

I've taken your fine script and tweaked it a little bit further. I added the ability to get your predicted file size based on audio bitrate. This is based on 1 cd at 790mb (I allow 10mb for overhead and menus). If you want to figure for 2cds change the 808960 to 1617920).

Prediction()

function Prediction (clip c) {
Movielength=framecount(c)/framerate(c)
d=c.
\Subtitle("Total Frames : " + String(framecount(c)),20,20).
\Subtitle("Time(sec) : " + String(round(Movielength)),215,20).
\Subtitle("Sample FC : " + String(framecount(Sampler(c,length=24))),375,20).
\Subtitle("Desired Sampler Size (112 bps) : " + String(((808960-((112/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c) ))/0.98),90,80).
\Subtitle("Desired Sampler Size (128 bps) : " + String(((808960-((128/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c) ))/0.98),90,120).
\Subtitle("Desired Sampler Size (160 bps) : " + String(((808960-((160/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c) ))/0.98),90,160).
\Subtitle("Desired Sampler Size (192 bps) : " + String(((808960-((192/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c) ))/0.98),90,200).
\Subtitle("Desired Sampler Size (224 bps) : " + String(((808960-((224/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c) ))/0.98),90,240).
\Subtitle("Avg Bitrate " + " (kbps) : " + String( ((((808960-((128/8)*Movielength)))/Movielength)*8)*1),90,300).
\Subtitle("Predicted Audio File Sizes " + " (Mb)",140,410).
\Subtitle("112 bps = " + String( (((112*1024)/8)*Movielength)/1048576),80,430).
\Subtitle("128 bps = " + String( (((128*1024)/8)*Movielength)/1048576),80,450).
\Subtitle("160 bps = " + String( (((160*1024)/8)*Movielength)/1048576),80,470).
\Subtitle("192 bps = " + String( (((192*1024)/8)*Movielength)/1048576),270,430).
\Subtitle("224 bps = " + String( (((224*1024)/8)*Movielength)/1048576),270,450)
return d
}



kwag 01-30-2003 12:18 PM

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")
LoadPlugin("C:\encoding\fluxsmooth.dll")
LoadPlugin("C:\encoding\GripFit_preview.dll")
LoadPlugin("C:\encoding\blockbuster.dll")
LoadPlugin("C:\encoding\legalclip.dll")
LoadPlugin("C:\encoding\sampler.dll")
LoadPlugin("C:\encoding\dustv5.dll")
LoadPlugin("C:\encoding\temporalcleanerold.dll")

Mpeg2Source("K:\S1M0NE_WS\VIDEO_TS\simone.d2v")
Prediction()

LegalClip()
GripCrop( width=352, height=240, overscan=1 )
GripSize()
SpaceDust()
TemporalCleaner()
Blockbuster(method="noise", variance=.7, seed=1)
GripBorders()
LegalClip()

function Prediction (clip c) {
Movielength=framecount(c)/framerate(c)
d=c.
\Subtitle("Total Frames : " + String(framecount(c)),20,20).
\Subtitle("Time(sec) : " + String(round(Movielength)),215,20).
\Subtitle("Sample FC : " + String(framecount(Sampler(c,length=24))),375,20).
\Subtitle("Desired Sampler Size (112 bps) : " +

String(((808960-((112/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c)))/0.98

),90,80).
\Subtitle("Desired Sampler Size (128 bps) : " +

String(((808960-((128/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c)))/0.98

),90,120).
\Subtitle("Desired Sampler Size (160 bps) : " +

String(((808960-((160/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c)))/0.98

),90,160).
\Subtitle("Desired Sampler Size (192 bps) : " +

String(((808960-((192/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c)))/0.98

),90,200).
\Subtitle("Desired Sampler Size (224 bps) : " +

String(((808960-((224/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c)))/0.98

),90,240).
\Subtitle("Avg Bitrate " + " (kbps) : " + String( ((((808960-((128/8)*Movielength)))/Movielength)*8)*1),90,300).
\Subtitle("Predicted Audio File Sizes " + " (Mb)",140,410).
\Subtitle("112 bps = " + String( (((112*1024)/8)*Movielength)/1048576),80,430).
\Subtitle("128 bps = " + String( (((128*1024)/8)*Movielength)/1048576),80,450).
\Subtitle("160 bps = " + String( (((160*1024)/8)*Movielength)/1048576),80,470).
\Subtitle("192 bps = " + String( (((192*1024)/8)*Movielength)/1048576),270,430).
\Subtitle("224 bps = " + String( (((224*1024)/8)*Movielength)/1048576),270,450)
return d
}

This way, the script gets resized, and fits correctly on the screen at any resolution :wink:

-kwag

Bud 01-30-2003 02:10 PM

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

kwag 01-30-2003 03:53 PM

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

Bud 01-30-2003 04:08 PM

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

Racer99 01-30-2003 04:09 PM

Quote:

Originally Posted by kwag
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")
LoadPlugin("C:\encoding\fluxsmooth.dll")
LoadPlugin("C:\encoding\GripFit_preview.dll")
LoadPlugin("C:\encoding\blockbuster.dll")
LoadPlugin("C:\encoding\legalclip.dll")
LoadPlugin("C:\encoding\sampler.dll")
LoadPlugin("C:\encoding\dustv5.dll")
LoadPlugin("C:\encoding\temporalcleanerold.dll")

Mpeg2Source("K:\S1M0NE_WS\VIDEO_TS\simone.d2v")
Prediction()

LegalClip()
GripCrop( width=352, height=240, overscan=1 )
GripSize()
SpaceDust()
TemporalCleaner()
Blockbuster(method="noise", variance=.7, seed=1)
GripBorders()
LegalClip()

function Prediction (clip c) {
Movielength=framecount(c)/framerate(c)
d=c.
\Subtitle("Movie Title : 'Simone'",220,20).
\Subtitle("Total Frames : " + String(framecount(c)),40,50).
\Subtitle("Time(sec) : " + String(round(Movielength)),235,50).
\Subtitle("Sample FC : " + String(framecount(Sampler(c,length=24))),400,50).
\Subtitle("Desired Sampler Size (112 bps) : " + String(((808960-((112/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c)))/0.98 ),90,80).
\Subtitle("Desired Sampler Size (128 bps) : " + String(((808960-((128/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c)))/0.98 ),90,120).
\Subtitle("Desired Sampler Size (160 bps) : " + String(((808960-((160/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c)))/0.98 ),90,160).
\Subtitle("Desired Sampler Size (192 bps) : " + String(((808960-((192/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c)))/0.98 ),90,200).
\Subtitle("Desired Sampler Size (224 bps) : " + String(((808960-((224/8)*Movielength))/(((Framecount(c)/framerate(c))/((framecount(Sampler(c,length=24)))))*framerate(c)))/0.98 ),90,240).
\Subtitle("Avg Bitrate " + " (kbps) : " + String( ((((808960-((128/8)*Movielength)))/Movielength)*8)*1),90,300).
\Subtitle("Predicted Audio File Sizes " + " (Mb)",140,410).
\Subtitle("112 bps = " + String( (((112*1024)/8)*Movielength)/1048576),80,430).
\Subtitle("128 bps = " + String( (((128*1024)/8)*Movielength)/1048576),80,450).
\Subtitle("160 bps = " + String( (((160*1024)/8)*Movielength)/1048576),80,470).
\Subtitle("192 bps = " + String( (((192*1024)/8)*Movielength)/1048576),270,430).
\Subtitle("224 bps = " + String( (((224*1024)/8)*Movielength)/1048576),270,450)
return d
}

This way, the script gets resized, and fits correctly on the screen at any resolution :wink:

-kwag

Hey Kwag,

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

kwag 01-30-2003 05:17 PM

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

muaddib 01-31-2003 01:45 AM

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")

Mpeg2Source("D:\Videos\shows\the_corrs_royal_albert_hall\the_corrs.d2v")
Prediction("The Corrs at Royal Albert Hall")

The formula used still the same. I just make some cleaning on it. You can "cancel" (I don't know if this is the correct term in English) the two framerate(c).
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") {
MovieLength  = framecount(c)/framerate(c)
FramesTotal  = framecount(c)
FramesSample = framecount(Sampler(c,length=24))

d=BlankClip(c,1).
\Subtitle("Movie Title : " + movie, width(c)/2,40, text_color=$FFFFFF, size=22, align=5).

\Subtitle("Total Frames : " + String(FramesTotal),80,80).
\Subtitle("Sample Frames : " + String(FramesSample),80,100).
\Subtitle("Time (sec) : " + String(round(Movielength)),280,80).
\Subtitle("Time (min) : " + String(round(Movielength/60)),280,100).

\Subtitle("Desired Sampler Size (096 bps) : " + String((((808960-((096/8)*Movielength))*FramesSample)/FramesTotal)/0.98),80,145).
\Subtitle("Desired Sampler Size (112 bps) : " + String((((808960-((112/8)*Movielength))*FramesSample)/FramesTotal)/0.98),80,170).
\Subtitle("Desired Sampler Size (128 bps) : " + String((((808960-((128/8)*Movielength))*FramesSample)/FramesTotal)/0.98),80,195).
\Subtitle("Desired Sampler Size (160 bps) : " + String((((808960-((160/8)*Movielength))*FramesSample)/FramesTotal)/0.98),80,220).
\Subtitle("Desired Sampler Size (192 bps) : " + String((((808960-((192/8)*Movielength))*FramesSample)/FramesTotal)/0.98),80,245).
\Subtitle("Desired Sampler Size (224 bps) : " + String((((808960-((224/8)*Movielength))*FramesSample)/FramesTotal)/0.98),80,270).

\Subtitle("Avg Bitrate (kbps) : " + String( ((((808960-((128/8)*Movielength)))/Movielength)*8)*1),80,325).

\Subtitle("Predicted Audio File Sizes " + " (mb)", 140,380, text_color=$FFFFFF).
\Subtitle("096 bps = " + String( (((096*1024)/8)*Movielength)/1048576),80,400).
\Subtitle("112 bps = " + String( (((112*1024)/8)*Movielength)/1048576),80,420).
\Subtitle("128 bps = " + String( (((128*1024)/8)*Movielength)/1048576),80,440).
\Subtitle("160 bps = " + String( (((160*1024)/8)*Movielength)/1048576),270,400).
\Subtitle("192 bps = " + String( (((192*1024)/8)*Movielength)/1048576),270,420).
\Subtitle("224 bps = " + String( (((224*1024)/8)*Movielength)/1048576),270,440)

return d+c+d
}


kwag 01-31-2003 02:15 AM

What can I say muaddib :D
Kudos :mrgreen:

-kwag

Smoochie3 01-31-2003 02:47 AM

I couldn't get this to work.

Here's my script:
Code:

LoadPlugin("D:\avfilters\legalclip.dll")
LoadPlugin("D:\avfilters\MPEG2DEC.dll")
LoadPlugin("D:\avfilters\fluxsmooth.dll")
LoadPlugin("D:\avfilters\blockbuster.dll")
LoadPlugin("D:\avfilters\legalclip.dll")
LoadPlugin("D:\avfilters\Convolution3D.dll")
LoadPlugin("D:\avfilters\DecombLegacy.dll")
LoadPlugin("D:\avfilters\DustV5.dll")
LoadPlugin("D:\avfilters\GripFit_preview.dll")
LoadPlugin("D:\avfilters\Sampler.dll")
LoadPlugin("D:\avfilters\NoMoSmooth.dll")
Import("F:\sample avisynth scripts\function.avs")

mpeg2source("h:\lotr2\lotr2.d2v")

Prediction()

Telecide()
Decimate()
LegalClip()
Gripcrop(528,480)
Gripsize(resizer="bicubicresize")
Spacedust()
Convolution3d(preset="movieLQ")
Gripborders()
Letterbox(0,0,8,8)
LegalClip()

and i have the
Code:

Import("F:\sample avisynth scripts\function.avs")
to call to this:
Code:

Function Prediction (clip c, string "movie") {
MovieLength  = framecount(c)/framerate(c)
FramesTotal  = framecount(c)
FramesSample = framecount(Sampler(c,length=24))

d=BlankClip(c,1).
\Subtitle("Movie Title : " + movie, width(c)/2,40, text_color=$FFFFFF, size=22, align=5).

\Subtitle("Total Frames : " + String(FramesTotal),80,80).
\Subtitle("Sample Frames : " + String(FramesSample),80,100).
\Subtitle("Time (sec) : " + String(round(Movielength)),280,80).
\Subtitle("Time (min) : " + String(round(Movielength/60)),280,100).

\Subtitle("Desired Sampler Size (096 bps) : " + String((((808960-((096/8)*Movielength))*FramesSample)/FramesTotal)/0.98),80,145).
\Subtitle("Desired Sampler Size (112 bps) : " + String((((808960-((112/8)*Movielength))*FramesSample)/FramesTotal)/0.98),80,170).
\Subtitle("Desired Sampler Size (128 bps) : " + String((((808960-((128/8)*Movielength))*FramesSample)/FramesTotal)/0.98),80,195).
\Subtitle("Desired Sampler Size (160 bps) : " + String((((808960-((160/8)*Movielength))*FramesSample)/FramesTotal)/0.98),80,220).
\Subtitle("Desired Sampler Size (192 bps) : " + String((((808960-((192/8)*Movielength))*FramesSample)/FramesTotal)/0.98),80,245).
\Subtitle("Desired Sampler Size (224 bps) : " + String((((808960-((224/8)*Movielength))*FramesSample)/FramesTotal)/0.98),80,270).

\Subtitle("Avg Bitrate (kbps) : " + String( ((((808960-((128/8)*Movielength)))/Movielength)*8)*1),80,325).

\Subtitle("Predicted Audio File Sizes " + " (mb)", 140,380, text_color=$FFFFFF).
\Subtitle("096 bps = " + String( (((096*1024)/8)*Movielength)/1048576),80,400).
\Subtitle("112 bps = " + String( (((112*1024)/8)*Movielength)/1048576),80,420).
\Subtitle("128 bps = " + String( (((128*1024)/8)*Movielength)/1048576),80,440).
\Subtitle("160 bps = " + String( (((160*1024)/8)*Movielength)/1048576),270,400).
\Subtitle("192 bps = " + String( (((192*1024)/8)*Movielength)/1048576),270,420).
\Subtitle("224 bps = " + String( (((224*1024)/8)*Movielength)/1048576),270,440)

return d+c+d
}

I end up with:

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?

muaddib 01-31-2003 06:50 AM

Quote:

Originally Posted by Smoochie3
I end up with:

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?

The "align" argument was created in the last avisynch.
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?

muaddib 01-31-2003 07:14 AM

Quote:

Originally Posted by kwag
What can I say muaddib :D
Kudos :mrgreen:

:D :beard: :D

Quote:

Originally Posted by muaddib
...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?

What about this :?:

kwag 01-31-2003 10:55 AM

Quote:

Originally Posted by muaddib
Quote:

Originally Posted by muaddib
...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?

What about this :?:

We multiply the sample size result by .98. Not divide.

-kwag

Smoochie3 01-31-2003 11:41 AM

OOPS! I thought i had 2.07 this whole time!!! :oops: Thanks!

Smoochie3 01-31-2003 12:19 PM

Why wouldn't the prediction() line be after the filters? When i put it right after the mpeg2source everything is still cut off.

tonyk 01-31-2003 02:17 PM

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.

kwag 01-31-2003 02:34 PM

Quote:

Originally Posted by Smoochie3
Why wouldn't the prediction() line be after the filters? When i put it right after the mpeg2source everything is still cut off.

That's why I put the prediction() line after the resize, so that no matter what resolution you use in GripCrop, it will be properly resized and displayed :wink:

-kwag

muaddib 01-31-2003 02:41 PM

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)
or
Prediction(cds=3) 
or just
Prediction()

The default values are CDs=1 and Factor=0.98
Here is the function:
Code:

#---------------------#
# Prediction Function #
#---------------------#
function Prediction (clip c, string "movie", int "cds", float "factor")
{
movie = default(movie,"No_Title_Defined")
factor = default(factor,.98)
cds = default(cds,1)

MovieLength  = framecount(c)/framerate(c)
FramesTotal  = framecount(c)
FramesSample = framecount(Sampler(c,length=24))
CD_Size = 814080*cds  #1CD=795MB -> (video+audio)

d=BlankClip(c,1).
\Subtitle("Movie Title : " + movie, width(c)/2,40, text_color=$FFFFFF, size=22, align=5).

\Subtitle("Total Frames : " + String(FramesTotal),80,80).
\Subtitle("Sample Frames : " + String(FramesSample),80,100).
\Subtitle("Time (sec) : " + String(round(Movielength)),280,80).
\Subtitle("Time (min) : " + String(round(Movielength/60)),280,100).

\Subtitle("Desired Sample Size (kb)  for  " + String(cds) + " CD(s):", 80,145, text_color=$FFFFFF).
\Subtitle("- audio at 096 bps : " + String((((CD_Size-((096/8)*Movielength))*FramesSample)/FramesTotal)*factor),98,168).
\Subtitle("- audio at 112 bps : " + String((((CD_Size-((112/8)*Movielength))*FramesSample)/FramesTotal)*factor),98,191).
\Subtitle("- audio at 128 bps : " + String((((CD_Size-((128/8)*Movielength))*FramesSample)/FramesTotal)*factor),98,214).
\Subtitle("- audio at 160 bps : " + String((((CD_Size-((160/8)*Movielength))*FramesSample)/FramesTotal)*factor),98,237).
\Subtitle("- audio at 192 bps : " + String((((CD_Size-((192/8)*Movielength))*FramesSample)/FramesTotal)*factor),98,260).
\Subtitle("- audio at 224 bps : " + String((((CD_Size-((224/8)*Movielength))*FramesSample)/FramesTotal)*factor),98,283).

\Subtitle("Average Bitrate (kbps) : " + String( ((((CD_Size-((128/8)*Movielength)))/Movielength)*8)*1),80,330).

\Subtitle("Predicted Audio File Sizes " + " (mb)", 140,380, text_color=$FFFFFF).
\Subtitle("096 bps = " + String((((096*1024)/8)*Movielength)/1048576),80,400).
\Subtitle("112 bps = " + String((((112*1024)/8)*Movielength)/1048576),80,420).
\Subtitle("128 bps = " + String((((128*1024)/8)*Movielength)/1048576),80,440).
\Subtitle("160 bps = " + String((((160*1024)/8)*Movielength)/1048576),270,400).
\Subtitle("192 bps = " + String((((192*1024)/8)*Movielength)/1048576),270,420).
\Subtitle("224 bps = " + String((((224*1024)/8)*Movielength)/1048576),270,440)

return d+c+d
}


muaddib 01-31-2003 02:43 PM

Quote:

Originally Posted by tonyk
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.

If you put the prediction() after all filters, it will be resolution dependent. It could display correctly for some resolutions but not for others.
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:

kwag 01-31-2003 02:55 PM

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

kwag 01-31-2003 02:58 PM

Wonderful modifications muaddib :mrgreen:
Works like a charm 8)

-kwag

kwag 01-31-2003 03:53 PM

Work, but I can't see the title anywhere 8O
I'm checking the screen coordinates now :!:

muaddib 01-31-2003 03:57 PM

Quote:

Originally Posted by kwag
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:

:imstupid: We need two of this poster!
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

muaddib 01-31-2003 07:44 PM

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:

#---------------------#
# Prediction Function #
#---------------------#
function Prediction (clip c, string "movie", int "cds", float "factor")
{
movie = default(movie,"No_Title_Defined")
factor = default(factor,.98)
cds = default(cds,1)

MovieLength  = framecount(c)/framerate(c)
FramesTotal  = framecount(c)
FramesSample = framecount(Sampler(c,length=24))
CD_Size = 814080*cds  #1CD=795MB -> (video+audio)

d=BlankClip(c,1,544,480).
\Subtitle("Movie Title : " + movie, 272,40, text_color=$FFFFFF, size=22, align=5).

\Subtitle("Total Frames : " + String(FramesTotal), 80,81).
\Subtitle("Sample Frames : " + String(FramesSample), 80,101).
\Subtitle("Time (sec) : " + String(round(Movielength)), 290,81).
\Subtitle("Time (min) : " + String(round(Movielength/60)), 290,101).

\Subtitle("Desired Sample Size (kb)  for  " + String(cds) + " CD(s):", 80,145, text_color=$FFFFFF).
\Subtitle("- audio at 096 bps : " + String((((CD_Size-((096/8)*Movielength))*FramesSample)/FramesTotal)*factor),80,168).
\Subtitle("- audio at 112 bps : " + String((((CD_Size-((112/8)*Movielength))*FramesSample)/FramesTotal)*factor),80,191).
\Subtitle("- audio at 128 bps : " + String((((CD_Size-((128/8)*Movielength))*FramesSample)/FramesTotal)*factor),80,214).
\Subtitle("- audio at 160 bps : " + String((((CD_Size-((160/8)*Movielength))*FramesSample)/FramesTotal)*factor),80,237).
\Subtitle("- audio at 192 bps : " + String((((CD_Size-((192/8)*Movielength))*FramesSample)/FramesTotal)*factor),80,260).
\Subtitle("- audio at 224 bps : " + String((((CD_Size-((224/8)*Movielength))*FramesSample)/FramesTotal)*factor),80,283).

\Subtitle("Average Bitrate (kbps) : "+ String(((((CD_Size-((128/8)*Movielength)))/Movielength)*8)*1), 80,328).

\Subtitle("Predicted Audio File Sizes (mb):", 80,373, text_color=$FFFFFF).
\Subtitle("096 bps = " + String((((096*1024)/8)*Movielength)/1048576),80,395).
\Subtitle("112 bps = " + String((((112*1024)/8)*Movielength)/1048576),80,416).
\Subtitle("128 bps = " + String((((128*1024)/8)*Movielength)/1048576),80,437).
\Subtitle("160 bps = " + String((((160*1024)/8)*Movielength)/1048576),270,395).
\Subtitle("192 bps = " + String((((192*1024)/8)*Movielength)/1048576),270,416).
\Subtitle("224 bps = " + String((((224*1024)/8)*Movielength)/1048576),270,437).
\BilinearResize(width(c),height(c))

return d+c
}


kwag 01-31-2003 07:59 PM

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

kwag 01-31-2003 08:41 PM

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

muaddib 01-31-2003 11:59 PM

Quote:

Originally Posted by kwag
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

Much easier this way! :D :D

Gaudi 02-01-2003 05:44 PM

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

kwag 02-01-2003 06:52 PM

That can't be done Gaudi. The CQ must be found by running a full sampler on the movie.

-kwag

muaddib 02-01-2003 07:00 PM

Quote:

Originally Posted by Gaudi
Would it be possible to include as another frame the calculations for the new CQ?

Hi Gaudi!

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

Graal_CPM 02-01-2003 07:52 PM

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.

kwag 02-01-2003 08:54 PM

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

emilius256 02-02-2003 05:51 AM

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

Gaudi 02-02-2003 12:43 PM

Quote:

Originally Posted by emilius256
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


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

emilius256 02-02-2003 05:28 PM

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 Function #
#---------------------#
function Prediction (clip c, string "movie", int "cds", float "factor", int "cdtime")
{
movie = default(movie,"No_Title_Defined")
factor = default(factor,.98)
cds = default(cds,1)
cdtime = default(cdtime,80)

MovieLength = framecount(c)/framerate(c)
FramesTotal = framecount(c)
FramesSample = framecount(Sampler(c,length=24))
CD_Size = (((cdtime*10)-5)*1024)*cds

d=BlankClip(c,1,544,480).
\Subtitle("Movie Title : " + movie, 272,40, text_color=$FFFFFF, size=22, align=5).
80 min. is default but you can specify another size
prediction("Matrix",2,.99,74)
or
prediction(cdtime=74)
bye

rendalunit 02-02-2003 07:05 PM

I changed the desired sample size to mb and truncated to four digits. Also rounded off the audio mb's.

Code:

#---------------------#
# Prediction Function #
#---------------------#

function Prediction (clip c, string "movie", int "cds", float "factor")

{
movie = default(movie,"No_Title_Defined")
factor = default(factor,0.98)
cds = default(cds,1)

MovieLength  = framecount(c)/framerate(c)
FramesTotal  = framecount(c)
FramesSample = framecount(Sampler(c,length=24))
CD_Size = 814080*cds  #1CD=795MB -> (video+audio)

d=BlankClip(c,1,544,480).
\Subtitle("Movie Title : " + movie, 272,40, text_color=$FFFFFF, size=22, align=5).

\Subtitle("Total Frames : " + String(FramesTotal), 80,81).
\Subtitle("Sample Frames : " + String(FramesSample), 80,101).
\Subtitle("Time (sec) : " + String(round(Movielength)), 290,81).
\Subtitle("Time (min) : " + String(round(Movielength/60)), 290,101).

\Subtitle("Desired Sample Size (mb)  for  " + String(cds) + " CD(s):", 80,145, text_color=$FFFFFF).
\Subtitle("- audio at  96 bps : " + LeftStr(String((((((CD_Size-((096/8)*Movielength))*FramesSample)/FramesTotal)*factor))/1000),5),80,168).
\Subtitle("- audio at 112 bps : " + LeftStr(String((((((CD_Size-((112/8)*Movielength))*FramesSample)/FramesTotal)*factor))/1000),5),80,191).
\Subtitle("- audio at 128 bps : " + LeftStr(String((((((CD_Size-((128/8)*Movielength))*FramesSample)/FramesTotal)*factor))/1000),5),80,214).
\Subtitle("- audio at 160 bps : " + LeftStr(String((((((CD_Size-((160/8)*Movielength))*FramesSample)/FramesTotal)*factor))/1000),5),80,237).
\Subtitle("- audio at 192 bps : " + LeftStr(String((((((CD_Size-((192/8)*Movielength))*FramesSample)/FramesTotal)*factor))/1000),5),80,260).
\Subtitle("- audio at 224 bps : " + LeftStr(String((((((CD_Size-((224/8)*Movielength))*FramesSample)/FramesTotal)*factor))/1000),5),80,283).

\Subtitle("Average Bitrate (kbps) : "+ String(Round(((((CD_Size-((128/8)*Movielength)))/Movielength)*8)*1)), 80,328).

\Subtitle("Predicted Audio File Sizes (mb):", 80,373, text_color=$FFFFFF).
\Subtitle(" 96 bps = " + String(Round(((( 96*1024)/8)*Movielength)/1048576)),80,395).
\Subtitle("112 bps = " + String(Round((((112*1024)/8)*Movielength)/1048576)),80,416).
\Subtitle("128 bps = " + String(Round((((128*1024)/8)*Movielength)/1048576)),80,437).
\Subtitle("160 bps = " + String(Round((((160*1024)/8)*Movielength)/1048576)),270,395).
\Subtitle("192 bps = " + String(Round((((192*1024)/8)*Movielength)/1048576)),270,416).
\Subtitle("224 bps = " + String(Round((((224*1024)/8)*Movielength)/1048576)),270,437).

\bilinearResize(width(c), height(c))
return d+c+d
}


kwag 02-02-2003 07:10 PM

This is getting better every day :mrgreen:


All times are GMT -5. The time now is 02:40 AM  —  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.