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)

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 06:24 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.