digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Ping-pong prediction vs Long-short prediction (http://www.digitalfaq.com/archives/avisynth/6832-ping-pong-prediction.html)

Abond 11-23-2003 06:19 AM

Ping-pong prediction vs Long-short prediction
 
Hi,
Here I would like to present the results from some testing in file size prediction.
Some details:
For ping-pong was used gl=2 and sa=5. Offset was the value which the "subtitle" script posted by incredible gave me.
For long-short prediction was used SelectRangeEvery(480,24) for 5% and SelectRangeEvery(2400,24) for 1% of the movie. This is the routine which is implemented in ToK, but different sample length.
Quote:

Ping-pong prediction
134163 frames Wanted video size = 742611 KB
Calculated sample size = 14612,8 (14613)KB
1. CQ=60 7:44min 11011 KB
2. CQ=65 7:44min 12987 KB
3. CQ=70 8:00min 13453 KB
4. CQ=71 7:54min 14944 KB
5. CQ=70.5 8:06min 14301 KB
6. CQ=70.6 8:03min 14344 KB
7. CQ=70.7 8:03min 14476 KB
8. CQ=70.7 7:42min 14981 KB pong 49 average=14728 too big
9. CQ=70,6 7:50min 14776 KB pong 49 average=14560 match!
Total time for prediction=71:06min
Encoding 70.6 the final size is 766328 KB ~ 20 MB oversize.

Long-short prediction
Calculated sample size 5% = 37196 KB
5% 6720 fr. CQ60 21:09min 30561 KB

1% CQ60 4:21min 5898 KB
The relation
30561 -> 5898
37196 -> X X= (37196*5898)/30561 = 7178.49 (7179)
1% sample size should be 7179 KB
1% CQ65 5:01min 6936 KB
1% CQ70 4:20min 7204 KB match!
Total time for prediction 34:51min.
Encoding CQ70 the final size is 719362 KB ~ 20 MB undersize.

Second movie
Quote:

Ping-pong prediction
177797 frames Wanted video size = 720530 KB
Calculated sample size = 14395 KB
1. CQ=60 9:42min 13808 KB
2. CQ=65 9:19min 16450 KB
3. CQ=62 9:17min 13816 KB
4. CQ=63 9:22min 14779 KB
5. CQ=62.5 9:40min 13968 KB
6. CQ=62.5 9:22min 14807 KB pong 48 average 14387,5 match!

Total time for prediction=56:42min
Encoding 62.5 the final size is 696387 KB

Long-short prediction
Calculated sample size 5% = 36084 KB
5% 8904 fr. CQ60 25:02min 35399 KB

1% CQ60 5:24min 7172 KB
The relation
35399 -> 7172
36084 -> X X= (36084*7172)/35399 = 7311 KB
1% sample size should be 7311 KB
1% CQ65 5:01min 8476 KB
1% CQ62 5:02min 7176 KB
1% CQ63 5:02min 7654 KB
1% CQ62.5 5:04min 7251 KB
1% CQ62.6 5:05min 7335 KB match!
Total time for prediction 55:40min.
Encoding CQ62.6 the final size is 705064 KB
And third
Quote:

Ping-pong prediction
190588 frames Wanted video size = 713428 KB
Calculated sample size = 14195 KB
1. CQ=60 9:58min 13631 KB
2. CQ=62 10:03min 13639 KB
3. CQ=63 9:50min 14673 KB
4. CQ=62 9:52min 13496 KB pong 48
5. CQ=62.5 11:18min 13620 KB pong 48
6. CQ=62.7 10:35min 13999 KB pong 48
7. CQ=62.7 9:43min 14165 KB ping
8. CQ=62.8 14:02min 14328 KB ping
9. CQ=62.8 10:13min 14163 KB pong 48
Decission - should be 62.75

Total time for prediction=96:01min
Encoding 62.75 the final size is 721065 KB

Long-short prediction
Calculated sample size 5% = 35756 KB
5% 9552 fr. CQ60 31:27min 35725 KB

1% CQ60 5:34min 7011 KB
The relation
35725 -> 7011
35756 -> X X= (35756*7011)/35725 = 7017 KB
1% sample size should be 7017 KB
1% CQ62 5:36min 7016 KB
1% CQ62.5 5:34min 7080 KB
1% CQ62.3 5:40min 7017 KB match!
Total time for prediction 53:51min.
Encoding CQ62.3 the final size is 690121 KB
And the winner is... Well, I would not say there is the winner, because I am using ping-pong for first time, and maybe I am doing something wrong. I will try to connect somehow both approaches, for example to run a pong determining the CQ with the 1%, or something similar. So, more testing...

incredible 11-23-2003 08:02 AM

Hi Abond,

nice to hear some one else is testing! :)
Well ... I never had that big differences between wanted and final outputsize! And never that oversized 8O

Whats the formula you use to calculate the reference size to match?

Yesterday I feeded the ping pong way with American Beauty, where in case of this movie I everytime had problems, no matter what prediction appl. used. The American beauty stream runs via avisynth and got Kwags new MA Routine!! ... and final output was very very close. about 8 MBs less gl set to 2 and sa also set to 5 which I everytime use.


Well when analyzing your encoding sizes I can see that at these movie examples the difference between the Ping and the pong output isn't that high! Which means that the offset turn didn't show big differences in scenes which wheren't inspected by the ping turn.

Because not every movie got such irritating differences between "conventional" sliced szenes.

But in my test I got 2-3 Movies where the Difference at 2% Movie-Sample-size was about 0,5-1,5MB! And thats where you see the advantage in doing this.

Borax's CQ Tester also uses Offsets but calculates the reference in a different way and other diff. things..

Here you can see how the Offset-way within my routine works:

http://www.digitalfaq.com/archives/error.gif

And to be safe to hit the middle of the ping slicing I tried to add the "offset recommendation". I hope its calculated well.

Yesterday I wrote the AVS Routine as a function, so you can safe it as .avsi and put it in your AVS Plugins Folder.

Just add below your script the following syntax

Slicer (clip c, int "percent", int "gop", int "off", int "gl", int "subs")

Explanation:

percent= percentage of the whole movie wich will be used prediction
(default=2 this means NOW logically 2%!!!)

gop= The length of you GOP you'll use to encode, so DVD(PAL) is 15 KVCD is 24, this has also to be understand as Samplelength!
(default=15 so set es default to std. PAL)

off= The offset where the sampling begins which is needed for Ping/pong prediction!
(default=00 so the sampling begins at Frame 0!)

gl= GOPlength multiplicator, this means by how much u want to enlarge the Samplelength which has to be GOP based!

subs= Gives you a Subtitle where you can find the recommendation for Offset settings! Use this the first time you just preview your script to see the recommended settings refering to "off"!
(default= 0 this means off, 1 = subtitel/recommendation active)


And here's the function which you can safe for example as "Slicer.avsi" and put in the Avisynth Plugins Folder so the Syntax as shown above will work:
Code:

###############################################################
## GOP length & movie percentual based slicing script 1.0b3 ###
############# Including calculating Offset Sizes ##############
########### In case of Problems please contact me  ############
############### incredible at KVCD.net/forum ##################
###############################################################
#

function Slicer (clip c, int "sa", int "gop", int "off", int "gl", int "subs") {
off=default(off, 0) 
gop= default(gop, 15) 
gl= default(gl,2) 
sa= default(sa,2) 
subs = default (subs, 1)
Frames=framecount(c)
Framer=framerate(c)
Offset=round(Framer*off)
c=Trim(c,Offset,0)
c=Subs >= 1 ? Subtitle(c, text_color=$999999 ,size=16,\
"Offset set to : "+String(off)+" sec.  "+\
"(Offset intervall should be: 0 sec. / "+\
String(Round(((Frames/Framer)/60)/(round(((Frames)/100)/(gop*gl))*sa)*60)/2)+" Sec.)",10,18 ) : \
Subtitle(c," ",10,18 )

c=sampler(c,samples=(round((Frames)/(gop*gl)/100*sa*1.009)), Length=(gop*gl))

Return c
}
################################################################

Now you only see the recommendet Offset values as they are the only ones which are really needed to know.


How to do a prediction using this Command:

1. Encode your audio to mp2 and watch in the windowsexplorer how much Kbyte it takes

2. Add the Slicer() at the end of your existing script and configure it refering to your final encode I suggest 2% of total movie which has to be used for prediction, enter the lenght of your used GOP and set the GOP multiplikator to 2 (this means 2times GOPlenght as Samplerlength). The Offset has to be set to 0.

3. Preview your .avs and note the second offset value recommendation!

4. Now calculate:
Whole muxed size minus Muxing overhead in Kbyte, substract also the audiosize in Kbyte as you can see it in the WindowsExplorer.

So we finally want to have a 795MB muxed moviestream to burn on CDr80. In this case: 795-10=785 .... 785x1024= 803840 Kbyte ..... 803840 Kbyte - 119808 Kbyte (assuming for audio) = 684032 Kbyte!!!
Now the next calculation depends on what percentage you have set for prediction, we assume (and I reccomend) 2%, therefore 684032Kbyte / 100 *2 = 13.681 Kbyte !! That is the Reference Size we have to match cause its 2% of the Final Streamsize.

5. Configure your Encoder to CQ (or Q) (GOP settings set to the exact Gop Length as set in the Slicer()!!!) and import your .avs including the Slicer().

6. Assume a CQ to set in the encoding setting to start with.

7. RUN!

8. You see that the Sampler will be encoded, after encoding you have to watch the encoded size and compare it to the reference size.... already close?? Well if not just rise or lower the CQ value in the encoder and do a new encoding as much times as its needed to get very close to the reference size. If you are almost close (like 10% to the reference size) you do a "Pong". This means that this kind of Prediction uses a Ping-Pong Method and therefore an Offet of 0 is a Ping and a Offset set to the recommended value you noted when previewing you avs.. is a Pong!
So if you are close like 10% to the nedded size perform a pong by just setting the int "off" in the Slicer() to the recommended value. Safe your .avs again and run TmpgEnc again (no source reloading needed! and leave the CQ as used as in the last turn!!!!).
You will see that the Prediction now uses different Scenes than when performing the Ping Sampling! And thats also why we will get very accurate cause by performing an offset there will be more different scenes encoded.. and therefore we obtain a better average of scenes which will be calculated to the whole prediction.

9. Now ... do you see a difference between the last outputted size and this one? Regulary yes! So you can see how both predictions behave.

10. Now continue performing Pongs by rising/lowering the CQ and keep in mind the difference to the ping! Now when you are very close to the needed size and the ping size keeped in mind, you perform a last "safe"-Ping (offset=0) ... and if the average of Ping and pong outputs matches the reference size ... go into your avs script an deactivate the Slicer() line re-safe it and do your full encode!!

Here is a sample report where you can see how to approach to the needed CQ (I everytime mention the CQs and Offsets in my filenames so I will have a good overview):

http://www.digitalfaq.com/archives/error.gif

The first time it will a bit complicated or it will take some time, but you will very soon get a "feeling" for this and so you will be faster the next time ;-)

If you want you can add a safety margin to your calculation of the refered size above ... Well Im happy without but every user got different experiences so in your cases add or substract a factor to your reference size to match the needed final sizes .

Abond 11-23-2003 09:30 AM

The formula:
( Wanted video size/framecount)*frames in sample = refrence sample size
Slicer - very nice! New stuff to play with!
BTW after short examination of the ping-pongs I and the sizes they produce it seems that the difference between them for the same CQ is almost constant!
13996-12815=1181 and 13467-12291=1176 but this are KB, maybe in bytes they will match!
In my case (movie 3) I have 14328-14163=165
and 14165-13999=166
The other two are different though. Just a thought.
Currently I am testing long-short adjusting the reference with ping-pong for 1% sample. The reference file size increase. I think I just found a cure for permanently undersized files using long-short in the range 10-25 MB.
Well, will see after almost 4 hours.

incredible 11-23-2003 11:48 AM

Hi Abond ,

Quote:

BTW after short examination of the ping-pongs I and the sizes they produce it seems that the difference between them for the same CQ is almost constant!
Yep, theorethically!
I discussed this with Krassi too. So theoretically you only would have to do one "pong" to see how the "other" slices do behave....

BUT! If Ping or Pong ... both are encodings don using CQ and we know that CQ is not linear ... so it could happen that if you figure out at a very beginning of the prediction turns, a difference of about 1024 Kbyte results .... at the end of your prediction there could result a difference of 512 Kbyte! So be safe and do a final "to be safe"-Pong at the end ... as I think you did.
I everytime do it like this:
I do a Ping and a Pong on a assumed CQ (fist turn)... ok. this gives me a ca. behaviour of bboth samples (ping & Pong).
Now I contiunue predicting using only pings ... until I get very very close to the Reference size BUT also the difference of the pong still in mind!
Finally I do the safe-pong and see if the average matches the reference. After this ... deleting the Slicer() in my Source Script - resaving the source.avs and let TmpgEnc do the whole Job.
I hope you did understand that you dont need at every turn to reload the source .avs in Tmpg! Just change the values of offset in the sclicer() in your source, resafe and hint again "start" in TmpgEnc ... you will see if he got the offset change!

Quote:

13996-12815=1181 and 13467-12291=1176 but this are KB, maybe in bytes they will match!
You see! It could be a lot when finally getting the full encode

1024Kbyte Difference at 2% = would be a 50MBs failure on a final encoding ... and thats why the offset makes sense.

Maybe we all will figure out how much safety margin is needed or so on which has to be implementated in this manual way but I think the offset/movie-percentual/GOP - Based Prediction "could" give nice results on difficult to predict movies. But as Kwag said .... you will never be away of this tricky non-linear CQ .. until this will be fixed in TmpgEnc.

;-)

Abond 11-23-2003 01:21 PM

Quote:

13996-12815=1181 and 13467-12291=1176 but this are KB, maybe in bytes they will match!
What I meant is a bit different. Well, maybe I am not right, but I assume the Explorer rounds the values from bytes to KB. So, for example, 13996 KB can be 13995700 bytes. Therefore, this difference in the difference :) is due to the rounding the bytes values to kilobytes :idea: . Well, I didn't calculate if with the current values quoted above it is at all posible :D . Maybe I will do it tomorrow.
Quote:

So be safe and do a final "to be safe"-Pong at the end ... as I think you did.
Yes, I did it,but, sorry to say, in fact I'm using as default the long-short prediction. Of course I'm very thankful that you give me the idea for ping-pong method and it seems it will adjust very fine long-short approach. What I found in the method is that it save time and is almost so precise as any other method. :wink:

audioslave 12-10-2003 07:32 PM

@incredible (or anyone else who can help ;) )

I added the line: "Slicer(clip c, int "percent", int "gop", int "off", int "gl", int "subs")" last in my script, but I get an error in Mediaplayer. It says "Expected a, or )". What does this mean? Could you please explain once again how to use this slicing routine?

audioslave 12-10-2003 08:28 PM

This is my script:
Quote:

### AudioSlave's static script - December 10th, 2003 ###
#
Import("D:\Rippat\Slicer.avs")
#
Mpeg2Source("D:\Rippat\Terminator 3\Terminator 3.d2v")
#
FluxSmooth(6, 2)
LanczosResize(448, 416, 11, 0, 698, 576)
FluxSmooth(3, 1)
MergeChroma(blur(1.5))
MergeLuma(blur(0.1))
BlockBuster(method="noise", detail_min=1, detail_max=3, variance=0.1, seed=1)
AddBorders(16, 80, 16, 80)
#
Slicer()
#
###
And this is how the "Slicer.avs" looks:
Quote:

################################################## #############
## GOP length & movie percentual based slicing script 1.0b3 ###
############# Including calculating Offset Sizes ##############
########### In case of Problems please contact me ############
############### incredible at KVCD.net/forum ##################
################################################## #############
#

function Slicer (clip c, int "sa", int "gop", int "off", int "gl", int "subs") {
off=default(off, 0)
gop=default(gop, 25)
gl=default(gl, 2)
sa=default(sa, 2)
subs=default(subs, 1)
Frames=framecount(c)
Framer=framerate(c)
Offset=round(Framer*off)
c=Trim(c,Offset,0)
c=Subs >= 1 ? Subtitle(c, text_color=$999999 ,size=16,\
"Offset set to : "+String(off)+" sec. "+\
"(Offset intervall should be: 0 sec. / "+\
String(Round(((Frames/Framer)/60)/(round(((Frames)/100)/(gop*gl))*sa)*60)/2)+" Sec.)",10,18 ) : \
Subtitle(c," ",10,18 )

c=sampler(c, samples=(round((Frames)/(gop*gl)/100*sa*1.009)), Length=(gop*gl))

Return c
}
################################################## ##############
And when I run my script in MediaPlayer it says: "Sample: Output frame count must be < input framecount" :cry:
What am I doing wrong? I'm really interested in trying this prediction method! :wink: Desperate for help... :banghead:

incredible 12-11-2003 04:10 AM

Audioslave,

Zaks in the german forum got exactly the same error and it was solved when he reinstalled AVS 2.53!

Another Point:
Don't use just Slicer()

You should set it to the needed parameters here an example as folowwed:

Slicer(2,24,00,2,1)

This means (2% of whole movie will be sliced, 24 (KVCD) frames in a GOP are used when encoding, offset is set to 00, one slice (GOP) will be multiplicated 2 times, and 1 stands for that subtitle for offset determination is on)

BTW the size of the subs are opimated for a view within a 480 x XXX size, so if you want to see the subs in a 352 x XXX you have to decrease the fontsize in the avsi doc.
Code:

c=Subs >= 1 ? Subtitle(c, text_color=$999999 ,size=16,\
There you see the "size=16", just correct it to 12 if needed

Cheers
Inc.

audioslave 12-11-2003 11:34 AM

Thank you, Incredible. I installed AviSynth 2.5.3 and changed the Slicer parameters, and what do you know - it works! :D Thanks!

mfb 12-12-2003 02:39 PM

@incredible,

when i use 'slicer(2,15,00,2,1)' at the end of my script, i get the error-
message 'Sampler: output frame count must be < input frame count'...

mmh, any ideas??? - tnx in advance

regards, ***mfb***

zaks 12-12-2003 03:26 PM

@mfb

install avisynth 2.53!

gruß
zaks

mfb 12-13-2003 04:36 AM

Quote:

Originally Posted by zaks
@mfb

install avisynth 2.53!

gruß
zaks

Thanks zaks!

i installed avisynth 2.53 and it worked fine.
my first try with ping-pong prediction gave me quite accurate results :D
(~ 10 MB less than wanted filesize for the muxed videostream predicted
for a CDR-100 media)

regards, ***mfb***

audioslave 12-14-2003 11:33 PM

Hell yeah! 8) :D
Just finished encoding Terminator 3 - 800,99 MB muxed! Amazing.
This is how I calculated:
Quote:

Terminator 3: Rise of the Machines
=================================

800 * 1024 = 819200
(CDSpaceInMB * 1024 = CDSpaceInkB)

819200 - 100480 = 718720
(CDSpaceInkB - AudioInkB = VideoInkB)

718720 / 100 * 2 * 1,05 = 15093,12
(VideoInkb / 100 * 2 * Factor = WantedSampleSizeInkB)

Wanted sample size = 15 093,12 kB
Wanted video size = 701,875 MB - 10 MB (Overhead) = 691,875 MB
Encoded video size = 711 473 kB = 694,7978515625 MB

CQ60,00 = 13 806,5 kB
CQ65,00 = 15 804,5 kB
CQ64,00 = 15 438,5 kB
CQ63,00 = 14 539 kB
CQ63,50 = 15 027,5 kB
CQ63,60 = 15 116,5 kB
CQ63,55 = 15 067,5 kB ~ match!


Offset intervall 0 sec / 50 sec.
I used the audio size I got from CalcuMatic.
Thank you Incredible! This "Slicer Routine" is great! Keep up the good work. :wink:

VORTECH 12-16-2003 02:18 AM

Close but no cigar
 
Incredible,

What am I missing here?

Here's my main AVS Script

Quote:

## DLL Section ##
Import("D:\Ripped\Slicer.avs")
#
LoadPlugin("C:\Filters25\MPEG2Dec3.dll")
LoadPlugin("C:\Filters25\GripFit_YV12.dll")
LoadPlugin("C:\Filters25\STMedianFilter.dll")
LoadPlugin("C:\Filters25\asharp.dll")
LoadPlugin("C:\Filters25\unfilter.dll")
LoadPlugin("C:\Filters25\undot.dll")
#
####
## Main section and static filters ###
#
Mpeg2Source("D:\Ripped\freq.d2v")
#
undot()
Limiter()
asharp(1, 4)
GripCrop(352, 480, overscan=1)
GripSize(resizer="BicubicResize")
STMedianFilter(3, 3, 1, 1 )
MergeChroma(blur(1.5))
MergeLuma(blur(0.1))
#
#

## Linear Motion Adaptive Filtering ##
#
# ( Portions from AviSynth's manual )
# This will apply variable temporalsoften
# and variable blur.
# Both filters are active at all times, and work inversely proportional to the
# activity, measured from current frame to next frame.

ScriptClip(" nf = YDifferenceToNext()" +chr(13)+ "unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ).TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")

#
#
#

GripBorders()
#LetterBox( Your_Values_Here ) # Depends on situation. Use MovieStacker!
Limiter()

#
#
## Functions ###

function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2
}

#
Slicer(2,24,00,2,0)
####
And here's my Slicer.avs file
Quote:

################################################## #############
## GOP length & movie percentual based slicing script 1.0b3 ###
############# Including calculating Offset Sizes ##############
########### In case of Problems please contact me ############
############### incredible at KVCD.net/forum ##################
################################################## #############
#

function Slicer (clip c, int "sa", int "gop", int "off", int "gl", int "subs") {
off=default(off, 0)
gop= default(gop, 15)
gl= default(gl,2)
sa= default(sa,2)
subs = default (subs, 1)
Frames=framecount(c)
Framer=framerate(c)
Offset=round(Framer*off)
c=Trim(c,Offset,0)
c=Subs >= 1 ? Subtitle(c, text_color=$999999 ,size=16,\
"Offset set to : "+String(off)+" sec. "+\
"(Offset intervall should be: 0 sec. / "+\
String(Round(((Frames/Framer)/60)/(round(((Frames)/100)/(gop*gl))*sa)*60)/2)+" Sec.)",10,18 ) : \
Subtitle(c," ",10,18 )

c=sampler(c,samples=(round((Frames)/(gop*gl)/100*sa*1.009)), Length=(gop*gl))

Return c
}
################################################## ##############
When I run it through Media Player I get the following error:

"There is no function named Sampler"
D:\Ripped\freq.avs line 25
D:\Ripped\Slicer.avs line 54

Any Ideas? :? :?:

zaks 12-16-2003 02:26 AM

missing sampler.dll for avisynth 2.52 /2.53

regards
zaks

incredible 12-16-2003 06:30 AM

Be shure you installed avisynth 2.53 and downloaded and installed the sampler version 2.5

www.incredible.de.tf/Downloads/Sampler-2.5.rar


BTW Vortech ...

You should delete the

MergeLuma(blur(0.1))

in your MA Script as the new MA routine now unfilters (blurs) linear without threshold settings, in combination with this MergeLuma(blur(0.1)) your image will end up to blurry even on almost no motion scenes!

Bravucon 12-16-2003 06:34 AM

Anybody can translate to Spanish this method ? :( It will be a great help for spanish Kdvders



Thanks in advance :P

incredible 12-16-2003 06:39 AM

Si te esperas, este fin de semana voy a escribir una explicación en español (bueno con mis pequeñas palabras en español que hasta ahora no me han perdido :) )

mistermickster 12-16-2003 08:09 AM

Quote:

Originally Posted by incredible
Si te esperas, este fin de semana voy a escribir una explicación en español (bueno con mis pequeñas palabras en español que hasta ahora no me han perdido :) )

Yes, I agree :lol:

Bravucon 12-16-2003 09:08 AM

:D :D :D :D :D :D :D


YESSSSSSS PLEASEEEEE!!!!!!!

Hablas muy bien el español = You speak very well spanish :D

I will wait for it impatiently!!!!!!


THX very much

VORTECH 12-16-2003 10:48 AM

Incredible and Zacks,

Thanks for the heads up :!:

incredible 01-20-2004 08:05 AM

Quote:

Originally Posted by Bravucon
:D :D :D :D :D :D :D


YESSSSSSS PLEASEEEEE!!!!!!!

Hablas muy bien el español = You speak very well spanish :D

I will wait for it impatiently!!!!!!


THX very much

Mira, como es un asunto muy largo y complicado aqui te doy una translación hecho de "babelfish/altavista" solo para que se lo entiende mejor si uno sabe hablar español mejor que el inglés.

PERO solamente usas/copias el códico del Asunto original aqui!!!
Porque el Babelfish tambien modifica partes en el codico en la translación.

http://babelfish.altavista.com/babel...p=en_es&tt=url


Espero que te ajuda!

Muchos saludos!
Inc.

Jellygoose 03-23-2004 07:49 AM

Hi Inc...

One little question... How does the Slicer Routine determine the second Offset value? What's the criteria? :roll:

incredible 03-23-2004 08:06 AM

Criteria??

Well the purpose of the pong offset is that the pong-slices will be in the position between the slices of the "ping" turn, so that effect. more movieinformation will be predicted in the same time than simply a normal prediction using more % of the movie. :wink:

Jellygoose 03-23-2004 08:19 AM

I understand the theory... :wink:
I just wanted to know why the value for the second offset differs from movie to movie. I for instance got 30 sec. as offset value. And I saw a post where it's 50 seconds...

incredible 03-23-2004 09:50 AM

It mainly differs at diff. gop multipler settings as this results in larger slices with the same % of the whole movie = larger "holes" between the larger slices for example.

audioslave 03-23-2004 05:51 PM

I really must thank you Incredible for making this "Slicer" routine :!: :wink: It has worked EVERY time for me so far. No more re-encoding movies that gets too big. :D

incredible 03-23-2004 06:23 PM

Also a nice advantage is that you can use it perfectly for mencoder or ffvfw prediction, .. cause its encoder independent ... just avisynth as frameserver is needed :)

MCE prediction "could" also be possible but the Q range of MCE is defenitely to small for acurate predictions.

Prodater64 03-23-2004 06:49 PM

Quote:

Originally Posted by incredible
...
MCE prediction "could" also be possible but the Q range of MCE is defenitely to small for acurate predictions.

Can you explain me that further. Maybe I can help you with MCE.
What would you need with MCE, for accurate predictions.

incredible 03-23-2004 06:57 PM

:)

Thanks but ....

I do know MCE more than well and "one" of the bad things when doing Q VBR is that the range is def. too small (as I remember something approx. about 1-32).

I tested MCE about for one week some month ago (actual release) and TmpgEnc does output better (and faster when doing a prediction in TmpgEnc compared to MCE at 2pass, if Q prediction in MCE is used to much failures accord. to filesize do occur cause of the reason expl. one line above).
Best quantisation on the same endfilesize does deliver mencoder at specific settings (2 Movies on one DVD-R) even better as QuEnc which I tested this evening ("still" too less options to set for optimizing... but that will change in the next release I think).

But ... thanx

Inc.

Prodater64 03-23-2004 09:06 PM

Here http://www.kvcd.net/forum/viewtopic.php?t=9832
there is a spanish traslation of this http://www.kvcd.net/forum/viewtopic.php?p=52657#52657 post.

Prodater64 03-24-2004 02:11 PM

Quote:

Originally Posted by incredible
:)

Thanks but ....

I do know MCE more than well and "one" of the bad things when doing Q VBR is that the range is def. too small (as I remember something approx. about 1-32).

I tested MCE about for one week some month ago (actual release) and TmpgEnc does output better (and faster when doing a prediction in TmpgEnc compared to MCE at 2pass, if Q prediction in MCE is used to much failures accord. to filesize do occur cause of the reason expl. one line above).
Best quantisation on the same endfilesize does deliver mencoder at specific settings (2 Movies on one DVD-R) even better as QuEnc which I tested this evening ("still" too less options to set for optimizing... but that will change in the next release I think).

But ... thanx

Inc.

But I don't speak about what is the better output. I just want to try your ping-pong with MCE. MCE can adjust the output file size very well, as you can see in the next screenshot. If you "know MCE more than well", you won't have problems for interpreting file names (related to settings).

http://www.digitalfaq.com/archives/error.gif

Prodater64 03-27-2004 10:16 AM

Quote:

Originally Posted by incredible
...
Another Point:
Don't use just Slicer()

You should set it to the needed parameters here an example as folowwed:

Slicer(2,24,00,2,1)
Inc.

Why can't we use just Slicer(). Doesn't work it with default values in this way?

Prodater64 03-28-2004 01:32 AM

Hi:
@ Incredible
I was just playing maths with your function, and found out that
Code:

Round(((Frames/Framer)/60)/(round(((Frames)/100)/(gop*gl))*sa)*60)/2
is equal than the simpler one
Code:

Round((gop*gl*100)/(framer*sa*2))
The difference in the results of these formulas are round functions related.

Said this, I think your function can be improved in the following way:
Code:

###############################################################
## GOP length & movie percentual based slicing script 1.0b3 ###
############# Including calculating Offset Sizes ##############
########### In case of Problems please contact me  ############
############### incredible at KVCD.net/forum ##################
############### (Prodater64 Mod)###############################

function Slicer (clip c, int "sa", int "gop", int "off", int "gl", string "pingpong", int "Debug") {
sa = default(sa, 2)
gop = default(gop, 15) 
off = default(off, 0) 
gl = default(gl, 2) 
pingpong = default (pingpong, "ping")
Debug = default(Debug, 0)
Frames = framecount(c)
Framer = framerate(c)
off1 = off
off2 = Round((gop*gl*100)/(framer*sa*2)) + off
off = (pingpong == "ping") ? off : Round((gop*gl*100)/(framer*sa*2)) + off
Offset = round(Framer*off)
c = Trim(c,Offset,0)
c = (Debug == 1) ? Subtitle(c, text_color=$999999 ,size=16,\
String(pingpong)+\
" - "+\
"Frames="+String(Frames)+" Framer="+ LeftStr(String(Framer),5)+" off="+String(off1)+"/"+\
String(off2),10,18 ) : \
Subtitle(c," ",10,18 )
c = sampler(c,samples=(round((Frames)/(gop*gl)/100*sa*1.009)), Length=(gop*gl))

Return c
}
################################################################

#Slicer(sa,gop,off,gl,type  , Debug (0/1=Inactive/Active)########
#Slicer(2, 24 , 00, 2, "ping", Debug = 1) #Put this line at end of your encoding script

Only changing ping to pong, the script will get automatically the "off" value. (Nobody needs to see the subtitles before encoding)
Debug = 1 is only for that, you can set at 0 and you won't see any subtitle. (default = 0 this means inactive, 1 = Debug subtitle active)
Maybe you will need to adjust your factor 1.009 (test it please)
Code:

c = sampler(c,samples=(round((Frames)/(gop*gl)/100*sa*1.009)), Length=(gop*gl))
by the differences mentioned in the beginning (round functions related)

The other instructions just as in
http://www.kvcd.net/forum/viewtopic.php?p=52657#52657

See you.
Prodater64

incredible 03-28-2004 03:01 AM

NICE! :)

Thanks for taking the time to integrate that conditional auto off Method.

I didn't integrate it cause many users do make Offs like ping=5 and pong=calculated_pong+5 as predictions will come out more accurate if the first seconds of the beginning wont be sampled, means these Frames in 99% of cases are just black and this will stand in no good relation to the 2% prediction of the whole movie.

Also I leved it that way as this can be very nice tweaked to get diff. slices of test-encodes I did when testing FFvfw or Mencoder.... = better way to catch fast moving scenes for example.

But anyway, your auto off routine will seem less complicated to noobs!

According to the factor you discribed 1,009, ... well everybody gots his "own" perfect factor (as known from TOK) so evreybody can tweak here on his own.

BUT pleas do not change the order of the variables in the Command as many users now are "acostumbrado" in those settings

Slicer(percent, GOP, Offset, GOPmulti, Debug)!

So the variable for mutiply the GopFrameCount should be still right behind the Offset determination of the Command Syntax. Yours is def. more logic, but changing this and on the other hand refering to my explanation at the start of this therad will cause confusion of Users :wink:

To me it seems you're more in mathematics and if the "shrinked" calculation for sampler() will work the same, ok. Test this by using my latest and your new one on the same movie and watch the resulted framecounts in Vdub so you can compare.

According to "no just Slicer()", This command doesnt get its advantage of default usage, cause anyhow we have to alter that by changing offsets or in your case from "ping" to "pong". Just slicer() would cause big noob confusions :wink:

Thanks for participating in developement!

Inc.

Prodater64 03-28-2004 11:14 AM

Quote:

Originally Posted by incredible
NICE! :)

Thanks for taking the time to integrate that conditional auto off Method.

Your welcome.

I already edited previous post.
Quote:

Originally Posted by incredible
I didn't integrate it cause many users do make Offs like ping=5 and pong=calculated_pong+5...

Fixed. Users can make such Offs.

Quote:

Originally Posted by incredible
Also I leved it that way as this can be very nice tweaked to get diff. slices of test-encodes I did when testing FFvfw or Mencoder.... = better way to catch fast moving scenes for example.

I think your tweaks don't changes to much.

Quote:

Originally Posted by incredible
BUT pleas do not change the order of the variables in the Command as many users now are "acostumbrado" in those settings

Slicer(percent, GOP, Offset, GOPmulti, Debug)!

So the variable for mutiply the GopFrameCount should be still right behind the Offset determination of the Command Syntax.

Fixed.
Slicer(percent, GOP, Offset, GOPmulti, Type, Debug)!

Quote:

Originally Posted by incredible
...
Test this by using my latest and your new one on the same movie and watch the resulted framecounts in Vdub so you can compare.

It was tested before I post it.
I only found small differences round functions related.

See you.
Prodater64

Prodater64 03-29-2004 04:46 PM

Hi:
My first Ping-Pong Prediction (Incredible's Function) with Mainconcept Encoder. Not very easy, but thinking that is first time...

http://www.digitalfaq.com/archives/error.gif
Code:

Target Sample------------------------------------> 14438 KB
Ping---------------------------------------------> 14191 KB
Pong that its Ping Safe was inside range---------> 13972 KB
Ping Safe inside range---------------------------> 14354 KB
Video---------------------------------------------> 679 MB
Audio---------------------------------------------> 100 MB
mpg-----------------------------------------------> 799 MB

Not so bad, isn't it? :)

Prodater64 04-02-2004 08:14 PM

Hi:
Quote:



The credits of this method belong completely to Incredible.


More improvements.
Change log
- Script can shows movie title on info screen.
- Script show more info on screen.
- Info screen don't show sample. Activate/Deactivate with Debug control.
- "Control Panel" in avs for: set movie name, CD number, CD time, Factor.
- Slicer Settings more comprehensibles, same order like Incredible original, plus Ping/Pong, Debug and Encode controls.
- Easy to understand for anybody.

This method has 1 avsi file, plus code to wright in your avs encoding file.

AVS Encoding Script

The statements after "Here your script" until "Not to modify" are just an example. You must to put your script there.
Copy this script and paste it in you AVS script. Trebuchet MS font, normal, 12, 1024*768 optimized.

Code:

###############################################################
## GOP length & movie percentual based slicing script 1.0b3 ###
############# Including calculating Offset Sizes ##############
########### In case of Problems please contact me  ############
############### incredible at KVCD.net/forum ##################
############### (Prodater64 Mod)###############################

######################################### Control Panel #######################################################
Movie=                                                            "The Matrix"          # Movie Name #
cds = 1                          # Select cds = 1 para 1 CD80, = 2 para 2 CD's o DVD 4,7 GB (3 movies in 1)
cdtime = 80.3                  # Select CD size in minutes
Factor = 1.009                # Factor
######################################### Slicer Settings ######################################################
sa = 2                            # (2) Percentage of the whole movie wich will be used prediction
gop = 24                        # (15 -18 -24 -25) GOP lenght
off = 00                        # The offset where the sampling begins which is needed for Ping/pong prediction. Initialy you can set = 05 to skip
                                    # titles in prediction
gl = 2                            # (2) GOPlength multiplicator.
PingPong = "Ping"          # (Ping - Pong) Tell you what sample are you encoding. Auto select Offset for Ping/Pong
Debug = 0                    # (0 - 1) Hide/Show info
Encode = 1                  # (0 - 1) Sample/Full encode
######################################### Here Your Source ###################################################               

#mpeg2source("C:\Your Path\Your Project.d2v")

AVISource("C:\Your Path\Your.avi",false)
######################################### Here Your script ####################################################
#ConvertToYV12()
#AddBorders(0,0,x,y)
BlindPP(cpu=4)
Blockbuster(method="noise",detail_min=1,detail_max=3,variance=0.1,seed=1)
Convolution3D(1, 6, 12, 6, 8, 2.8, 0)

BicubicResize(704, 320, 0, 0.6, 0, 0, 640, 272)

Undot()
TemporalSoften(2,7,7,3,2)
DCTFilter(1,1,1,1,1,1,0.5,0)
#Blockbuster(method="noise",detail_min=1,detail_max=10,variance=0.3,seed=5623)

AddBorders(8, 128, 8, 128)

#ConvertToYUY2()

######################################### Not to modify #####################################################
Encode == 0 ? Slicer(sa, gop, off, gl, PingPong, Debug, movie, cds, cdtime, Factor) : Trim(0,0)
############################################################################################################


AVSI file

Copy this script and paste it in a text file with avsi extension. Put it in your avisynth 2.5x folder.
It is self explanatory.

Code:

#------------------------#
# Slicer Function  #
#-----------------------#

function Slicer (clip c, int "sa", int "gop", int "off", int "gl", string "PingPong", int "Debug", string "movie", int "cds", float "cdtime", float "Factor")

{
movie = default(movie,"Movie Title")
Factor = default(Factor,1.009)
cds = default(cds, 1)
cdtime = default(cdtime, 80)

sa = default(sa, 2)
gop = default(gop, 15) 
off = default(off, 0) 
gl = default(gl, 2) 
pingpong = default (pingpong, "ping")
Debug = default(Debug, 0)
Frames = framecount(c)
Framer = framerate(c)

MovieLength  = Framecount(c)/Framerate(c)
FramesSample = Framecount(sampler(c,samples=(round((Frames)/(gop*gl)/100*sa*Factor)), Length=(gop*gl)))
CD_Size = ((((cdtime*10)-0))*1024)*cds
Overhead = 20*1024/803*cdtime*10*cds/1024

#---------------------------------------------------------------------

A096=((( 96*1024)/8)*Movielength)/1048576*0.975
V096=(CD_Size-(A096*1024)-(Overhead*1024))/1024
A112=((( 112*1024)/8)*Movielength)/1048576*0.975
V112=(CD_Size-(A112*1024)-(Overhead*1024))/1024
A128=(((128*1024)/8)*Movielength)/1048576*0.975
V128=(CD_Size-(A128*1024)-(Overhead*1024))/1024
A160=(((160*1024)/8)*Movielength)/1048576*0.975
V160=(CD_Size-(A160*1024)-(Overhead*1024))/1024
A192=(((192*1024)/8)*Movielength)/1048576*0.975
V192=(CD_Size-(A192*1024)-(Overhead*1024))/1024
A224=(((224*1024)/8)*Movielength)/1048576*0.975
V224=(CD_Size-(A224*1024)-(Overhead*1024))/1024

#---------------------------------------------------------------------

off1 = off
off2 = Round((gop*gl*100)/(framer*sa*2)) + off
off = (pingpong == "ping") ? off : Round((gop*gl*100)/(framer*sa*2)) + off
Offset = round(Framer*off)
c = Trim(c,Offset,0)
c = sampler(c,samples=(round((Frames)/(gop*gl)/100*sa*Factor)), Length=(gop*gl))

#---------------------------------------------------------------------

c =  (Debug == 1) ? BlankClip(c,1,544,480).

\Subtitle(movie, 40, 20, halo_color=$5500FF, text_color=$FFFFFF).
\Subtitle(String("Codificando: " + PingPong), 325, 20, halo_color=$5500FF, text_color=$FFFFFF).
\Subtitle("Frames Totales : " + String(Frames), 40,40).
\Subtitle("Framerate: " + LeftStr(String(Framer),5) + " fps", 325, 40).
\Subtitle("Frames del Sample: "+ String(FramesSample), 40,60).
\Subtitle("GOP Lenght: "+ string(gop), 325,60).
\Subtitle("Tiempo Total: " + String(round(Movielength)) + " seg", 40, 80).
\Subtitle(LeftStr(String(Movielength/60),6) + " min", 225, 80).
\Subtitle("Off (Ping/Pong): "+String(off1)+"/"+ String(off2), 325, 80).
\Subtitle("Bitrate Avg del mpg (kbps) : ", 40,100).
\Subtitle(String(Round(((((CD_Size-((128/8)*Movielength)))/Movielength)*8)*1)), 250,100).
\Subtitle("Factor = " + LeftStr(String(factor),5), 325, 100).

\Subtitle("Tam. del Sample Buscado para un medio de: ~ " + String(Round(A224+V224+Overhead)) +" MB", 40,130, text_color=$FFFFFF).
\Subtitle("- Audio a 096 kbps :                                " + "Sample = " + String(Round((CD_Size-(A096*1024))*sa/100)) + " KB", 40, 150).
\Subtitle("- Audio a 112 kbps :                                " + "Sample = " + String(Round((CD_Size-(A112*1024))*sa/100)) + " KB", 40, 170).
\Subtitle("- Audio a 128 kbps :                                " + "Sample = " + String(Round((CD_Size-(A128*1024)-(Overhead*1024))*sa/100))
\ + " KB", 40, 190).
\Subtitle("- Audio a 160 kbps :                                " + "Sample = " + String(Round((CD_Size-(A160*1024))*sa/100)) + " KB", 40, 210).
\Subtitle("- Audio a 192 kbps :                                " + "Sample = " + String(Round((CD_Size-(A192*1024))*sa/100)) + " KB", 40, 230).
\Subtitle("- Audio a 224 kbps :                                " + "Sample = " + String(Round((CD_Size-(A224*1024))*sa/100)) + " KB", 40, 250).

\Subtitle("Audio Bitrate      Audio  +    Video      +    Overhead    =    Total ", 40,310, text_color=$FFFFFF).
\Subtitle("-  096 kbps :    "+ String(Round(A096)), 40, 330).
\Subtitle( " MB  +  " + String(Round(V096)), 177, 330).
\Subtitle( " MB  +        " + String(Overhead), 275, 330).
\Subtitle( " MB      =  " + String(Round(A096+V096+Overhead)), 380, 330).
\Subtitle( "  MB", 485, 330).

\Subtitle("-  112 kbps :    "+ String(Round(A112)), 40, 350).
\Subtitle( " MB  +  " + String(Round(V112)), 177, 350).
\Subtitle( " MB  +        " + String(Overhead), 275, 350).
\Subtitle( " MB      =  " + String(Round(A112+V112+Overhead)), 380, 350).
\Subtitle( "  MB", 485, 350).

\Subtitle("-  128 kbps :    "+ String(Round(A128)), 40, 370).
\Subtitle( " MB  +  " + String(Round(V128)), 177, 370).
\Subtitle( " MB  +        " + String(Overhead), 275, 370).
\Subtitle( " MB      =  " + String(Round(A128+V128+Overhead)), 380, 370).
\Subtitle( "  MB", 485, 370).

\Subtitle("-  160 kbps :    "+ String(Round(A160)), 40, 390).
\Subtitle( " MB  +  " + String(Round(V160)), 177, 390).
\Subtitle( " MB  +        " + String(Overhead), 275, 390).
\Subtitle( " MB      =  " + String(Round(A160+V160+Overhead)), 380, 390).
\Subtitle( "  MB", 485, 390).

\Subtitle("-  192 kbps :    "+ String(Round(A192)), 40, 410).
\Subtitle( " MB  +  " + String(Round(V192)), 177, 410).
\Subtitle( " MB  +        " + String(Overhead), 275, 410).
\Subtitle( " MB      =  " + String(Round(A192+V192+Overhead)), 380, 410).
\Subtitle( "  MB", 485, 410).

\Subtitle("-  224 kbps :    "+ String(Round(A224)), 40, 430).
\Subtitle( " MB  +  " + String(Round(V224)), 177, 430).
\Subtitle( " MB  +        " + String(Overhead), 275, 430).
\Subtitle( " MB      =  " + String(Round(A224+V224+Overhead)), 380, 430).
\Subtitle( "  MB", 485, 430).

\BilinearResize(width(c), height(c)) : Subtitle(c,"", 10, 18 )
return c
}

#------------------------------#
# End Slicer Function  #
#-----------------------------#


incredible 04-03-2004 07:42 AM

Where do you got all these CDs /CDtime parameters, and subtitel routines and so on ... is that inspired from the manual prediction thread??? As they also delaed with cd size and so on there. As I remember :)

Prodater64 04-03-2004 08:12 AM

Quote:

Originally Posted by incredible
Where do you got all these CDs /CDtime parameters, and subtitel routines and so on ... is that inspired from the manual prediction thread??? As they also delaed with cd size and so on there. As I remember :)

Yes, it is, of course. I was learned almost all in this forum, of course. But not the same. I have adapted it to your method.


All times are GMT -5. The time now is 12: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.