Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 18th December 2011, 13:54   #1  |  Link
Bartje64
Registered User
 
Join Date: Mar 2011
Posts: 3
Correct script structure?

Many....thanks to Video Fred for getting me started with his scripts...

I've since modified these to suit my needs all the while learning, it has been a great adventure thus far...and the results are amazing.
Question is...what is the correct sequencing for a script especially where to "resize"....
Pending on where in the script this occurs (beginning or end) has a large impact on processing speed.

Script as follows:

Edit....figured out the "code tags"..script is below....any suggestions would be appreciated.

Thanks, Bart

Last edited by Bartje64; 20th December 2011 at 16:36.
Bartje64 is offline   Reply With Quote
Old 19th December 2011, 05:15   #2  |  Link
kypec
User of free A/V tools
 
kypec's Avatar
 
Join Date: Jul 2006
Location: SK
Posts: 830
Please edit your post and use CODE tags to enclose your script into it.
kypec is offline   Reply With Quote
Old 20th December 2011, 16:32   #3  |  Link
Bartje64
Registered User
 
Join Date: Mar 2011
Posts: 3
CODE tags

Sorry, I'm a noob to this site.

What are and how to use these "Code tags"
Bartje64 is offline   Reply With Quote
Old 20th December 2011, 16:35   #4  |  Link
Bartje64
Registered User
 
Join Date: Mar 2011
Posts: 3
Aha....I think this is what you mean?.....


PHP Code:
#Original file location


film="F:Videos\9.5mm Capture\New Capture\video0020.avi"  # source clip, please specify the full path here

#Result....What result from this script do you want to see

result="result6" # specify the wanted output here
 
#Play speed
#----------------------------------------------------------

play_speed1.0        # What is the speed of the source clip in FPS.
final_framerate 1.0  # What is the final frame rate you want in FPS.
                              # If you set these equal then there is no frame blending. Frame in = Frame out

#Trimming and bad section(s) removal
#---------------------------------------------------------

trim_begin=2    trim_end=0       # trim beginning and end frames 

remove_section_1 "Rem1_No"              # Type in Rem1_Yes or Rem1_No if you do or do not want to remove a section of the clip

remove_start_1=3230 remove_stop_1=3290          # Section of clip to be removed, start frame number, stop frame number

remove_section_2 "Rem2_No"              # Type in Rem2_Yes or Rem2_No if you do or do not want to remove a section of the clip

remove_start_2=9750 remove_stop_2=9850          # Section of clip to be removed, start frame number, stop frame number

remove_section_3 "Rem3_No"              # Type in Rem3_Yes or Rem3_No if you do or do not want to remove a section of the clip

remove_start_3=9900 remove_stop_3=10736          # Section of clip to be removed, start frame number, stop frame number

#SIZE, CROP AND BORDERS PARAMETERS
#--------------------------------------

CLeft=10 CTop=24 CRight=10 CBottom=# crop values after trimming

W=1280  H=960                                     # final size after cropping 9.5mm aspect ratio is 1:3 1280-960

bord_left=8 bord_top=8  bord_right=8  bord_bot=8  # Add a border if you want to.Border size is in pixels, 720p= borders 150

#Reverse the clip
#-------------------------------------------------

Rev_Clip "No"                             # Reverse the input (source) file Vertically "Yes" or "No"

# Flip the file Horizontally or Vertically
#-------------------------------------------------------

Flip_Ver "NO"                    # Flip the input (source) file Vertically "Yes" or No

Flip_Hor "yes"                      # Flip the output (result) file Horizontally "Yes" or No

#COLOR AND LEVELS PARAMATERS
#---------------------------------------------

saturation=1.0   # for all outputs

gamma1.0        # for all outputs 

blue= -0  red0  # manual color adjustment, when returning result3 or result4. Values can be positive or negative


black_level=0  white_level=255 output_black=0  output_white=255 # manual levels, when returning result4

#CLEANING PARAMETERS
#--------------------------

dirt_blur0.1    # some blur before cleaning to avoid pixel artifacts
dirt_strength=300  # set this lower for clean films.

#DENOISING PARAMETERS
#------------------------------

denoising_strength500   # denoising level of second denoiser: MVDegrainMulti() default 400
denoising_frames=3         # number of frames for averaging (forwards and backwards) 3 is a good start value
block_size16               # block size of MVDegrainMulti()
block_size_v16
block_over
4                # block overlapping of MVDegrainMulti()

#REMOVE SCRATCHES
#-----------------------------

Number_of_passes "Five"             # enter the number of passes through the descratch filter One, Two, Tree, Four, Five

Scratch_Width=1           # Max value is 3
scratch_blur.5          # Max value is 1.58

# FOUR STEP SHARPENING PARAMETERS
#----------------------------

USM_sharp_ness1100   USM_radi_us13  # first sharpening (UnsharpMask) after cleaning with removedirtMC()

USM_sharp_ness280     USM_radi_us2=2    # second harpening (UnsharpMask) after cleaning with removedirtMC()

USM_sharp_ness330    USM_radi_us3=1   # third sharpening (UnsharpMask) after degraining with MVDegrainMulti()


last_sharp0.4                         # final sharpening step after degraining

last_blur0.1                          # this smooths out the heavy sharpening effects

#STABILISING PARAMETERS
#---------------------------

maxstabH=-40
maxstabV
=-40          #maximum values for the stabiliser (in pixels) 20 is a good start value

est_left=40  est_top=40  est_right=40  est_bottom=40  est_cont1.4  #crop and contrast values for Stabilizer Estimate clip

#AUTO LEVELS PARAMETER
#--------------------------------

X=2   # X is a special parameter for reducing the autolevels effect on the whites
X2=2  # X2 is a special parameter for reducing the autolevels effect on the blacks

# END VARIABLES, BEGIN SCRIPT
#==========================

SetMemoryMax(1024)                       #set this to 1/3 of the available memory


LoadPlugin("Deflicker.dll")
Loadplugin("Depan.dll")
LoadPlugin("DepanEstimate.dll")
Loadplugin("removegrain.dll")
Loadplugin("removedirts.dll")
LoadPlugin("DeScratch.dll")
LoadPlugin("MVTools.dll")
LoadPlugin("MVTools2.dll")
Loadplugin("mt_masktools.dll")
Loadplugin("warpsharp.dll")
                                                    
#LoadPlugin("MT.dll")
LoadPlugin("autolevels.dll")

Import("03_RemoveDirtMC.avs")

# SetMTMode Info
# -------------------

# SetMTmode() Syntax:

# GetMTMode(bool threads)

# threads bool = false
# if true GetMTMode returns the number of threads used else the current mode is returned (see below).

# SetMTmode(int mode, int threads)


SetMTMode (2,4#disable all MT calls if you are using a single core computer


#REMOVE ANY BAD SECTIONS
#--------------------------------

source1=AviSource(film)                                                                                        # This is the source file we are working with

Rem1_Yes=trim(source1,0,remove_start_1)+trim(source1,remove_stop_1,0)               # Remove a section if Rem1_Yes
Rem1_No=source1
    
source2
=Eval(Remove_section_1)    

Rem2_Yes=trim(source2,0,remove_start_2)+trim(source2,remove_stop_2,0)               # Remove a section if Rem2_Yes
Rem2_No=source2

source3
=Eval(Remove_section_2)

Rem3_Yes=trim(source3,0,remove_start_3)+trim(source3,remove_stop_3,0)               # Remove a section if Rem3_Yes
Rem3_No=source3
                                                                                                                        
# Do nothing if Rem_No
#Reverse the clip
#-------------------------
# source4 is the source file we want to reverse

source4=Eval(Remove_section_3)                   # This is the file we want to reverse

Yes=Reverse(source4)                                 # If "Rev_Yes", reverse the clip

No =source4                                                 # If "Rev_No", do nothing
    
# Flip the file Vertically
#-----------------------------
# source5 is the source file we want to flip vertically

source5=Eval(Rev_Clip)                                 # This is the file we want to flip vertically

Yes=flipvertical(source5)                             # If "FlipV_Yes", flip the file vertically

No=source5                                                 # If "FlipV_No", do nothing

# Flip the file Horizontally
#-----------------------------
# source6 is the source file we want to flip horizontally

source6=Eval(Flip_Ver)                                      # This is the file we want to flip horizontally

Yes=fliphorizontal(source6)                           # If "FlipH_Yes", flip the file horizontally

No=source6                                                  # If "FlipH_No", do nothing
                        
# RESIZE TRIM AND CROP
#----------------------------
# source7 is the source after trimming, reversing and flipping is completed.

source7=Eval(Flip_Hor
 
Original=source1.converttoYV12().trim(trim_begin,trim_end).Lanczos4Resize(640,480)                                              # Is the original file for comparison   .crop(CLeft,CTop,-CRight,-CBottom)
                    
Reworked=source7.converttoYV12().deflicker().assumefps(play_speed)                                                                   # Is the original file ready to be reworked.     
                                            
Trimmed=Reworked.trim(trim_begin,trim_end)                                                                                                            #Trimming is completed

Ready_for_Tweak Trimmed                                                                                                                                  #Ready for tweaking

# Tweaking the color levels
#----------------------------

TweakedReady_for_Tweak.levels(0,gamma,255,0,255).tweak(sat=saturation)                                                          #Tweaking is completed

#Cleaning
#--------------------

CleanedRemoveDirtMC(Tweaked,dirt_strength).unsharpmask(USM_sharp_ness1,USM_radi_us1,0)\
.
unsharpmask(USM_sharp_ness2,USM_radi_us2,0)                                                                                                  #Cleaning is completed

#Crop after cleaning!
#------------------------
Cropped=Cleaned.crop(CLeft,CTop,-CRight,-CBottom)                                                                                                                                                                               
                                                                                                                                                                        
#Cropping is completed
# Scratch removal
#-----------------------------

One   Cropped.blur(scratch_blur).Descratch(mindif=Scratch_Width,maxgap=0,maxlen=10000)

Two   One.blur(scratch_blur).Descratch(mindif=Scratch_Width,maxgap=0,maxlen=10000)

Three  =Two.blur(scratch_blur).Descratch(mindif=Scratch_Width,maxgap=0,maxlen=10000)

Four   =Three.blur(scratch_blur).Descratch(mindif=Scratch_Width,maxgap=0,maxlen=10000

Five    =Four.blur(scratch_blur).Descratch(mindif=Scratch_Width,maxgap=0,maxlen=10000)                                          #CScratch removal is completed

#degraining/denoising
#---------------------------

Descratch_Passes = Eval(Number_of_passes)


VectorsDescratch_Passes.MvAnalysemulti(refframes=denoising_framespel=2blksize=block_sizeblksizevblock_size_voverlap=block_overidx=1)
DenoisedDescratch_Passes.MVDegrainMulti(vectorsthSAD=denoising_strengthSadMode=1idx=2).unsharpmask(USM_sharp_ness3,USM_radi_us3,0)

Rework_Done=Denoised.sharpen(last_sharp).sharpen(last_sharp)                                                                                   #Degraining,denoising,last sharpening completed.

#STABILIZING
#------------------------

Stab_ReferenceRework_Done.crop(est_left,est_top,-est_right,-est_bottom).tweak(cont=est_cont).MT_binarize(threshold=80).invert().greyscale()

mdata=DePanEstimate(Stab_Reference,range=2,trust=3,dxmax=maxstabH,dymax=maxstabV)

Stab_Ref=DePanStabilize(Rework_Done,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=0,info=true)   #Reference file for result5

Stabilized=DePanStabilize(Rework_Done,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=0,mirror=15)  #Stabilizing is completed

#Stabilizing Info for Results5
#-----------------------------

WS=width(Stab_Ref)
HS=height(Stab_Ref)
stab4Stab_Ref.addborders(10,10,10,10,$B1B1B1).Lanczos4Resize(WS,HS
stab5Lanczos4Resize(Stabilized,WS,HS).sharpen(0.5)

#Resize
#----------------------

Work_completed=Stabilized

#Add borders
#-------------------------

#Borders=Rework_Done.addborders(bord_left, bord_top, bord_right, bord_bot)              # Add borders

#Results
#-----------------------


#RESULT1: AUTOLEVELS, AUTOWHITE
result1Work_completed.coloryuv(autowhite=true).addborders(X,0,0,0,$FFFFFF).addborders(0,0,X2,0,$000000).autolevels().crop(X,0,-X2,-0)\
.
converttoYUY2().blur(last_blur).converttoYV12().addborders(bord_leftbord_topbord_rightbord_bot).ConvertFPS(final_framerate)

#RESULT2: MANUAL LEVELS, AUTOWHITE
#................................
result2Work_completed.levels(black_level,1.0,white_level,0,255).coloryuv(autowhite=true)\
.
converttoYUY2().blur(last_blur).converttoYV12().addborders(bord_leftbord_topbord_rightbord_bot).ConvertFPS(final_framerate)

#RESULT3: AUTOLEVELS, MANUAL COLOR CORRECTIONS
#.......................................Work_completed.coloryuv(off_U=blue,off_V=red).addborders(X,0,0,0,$FFFFFF).addborders(0,0,X2,0,$000000).autolevels().crop(X,0,-X2,-0)\
.converttoYUY2().blur(last_blur).converttoYV12().addborders(bord_leftbord_topbord_rightbord_bot).ConvertFPS(final_framerate)

#RESULT4: MANUAL LEVELS, MANUAL COLOR CORRECTIONS
#..................................................................................................................................................
result4Work_completed.coloryuv(off_U=blue,off_V=red).levels(black_level,1.0,white_level,0,255).ConvertFPS(final_framerate)\
.
converttoYUY2().ConvertFPS(final_framerate).blur(last_blur).converttoYV12().addborders(bord_leftbord_topbord_rightbord_bot)  

#RESULT5: SPECIAL SERVICE CLIP FOR RESULT S5
#..................................................................................................................................................
result5overlay(Rework_Done,stab_reference,x=est_left,y=est_top).addborders(2,2,2,2,$FFFFFF).Lanczos4Resize(WS,HS)

                         

#COMPARISONS: ORIGINAL VS RESULTS
#......................................................................................................................................................................
resultS1stackhorizontal(subtitle(Original,"original",size=28,align=2),subtitle(result1.Lanczos4Resize(640,480),"result1: autolevels, autowhite",size=28,align=2))
resultS2stackhorizontal(subtitle(Original,"original",size=28,align=2),subtitle(result2.Lanczos4Resize(640,480),"resuls2: autowhite, manual levels correction",size=28,align=2))
resultS3stackhorizontal(subtitle(Original,"original",size=28,align=2),subtitle(result3.Lanczos4Resize(640,480),"result3: autolevels, manual color correction",size=28,align=2))
resultS4stackhorizontal(subtitle(Original,"original",size=28,align=2),subtitle(result4.Lanczos4Resize(640,480),"result4: manual colors and levels correction",size=28,align=2))

#SPECIAL COMPARISON CLIP FOR TESTING THE STABILIZER
#.........................................................................................................................................................................
resultS5stackhorizontal(subtitle(result5,"baseclip for stabiliser -only the B/W clip is used",size=32,align=2),subtitle(stab4,"test stabiliser: dx=horizontal, dy=vertical",size=32,align=5))


#Result6: rezize after all work is completed
#----------------------------------------------------------------------------------------------------

Result6=result4.Lanczos4Resize(W,H


SetMTMode(6)

Eval(
result
Bartje64 is offline   Reply With Quote
Old 21st December 2011, 00:07   #5  |  Link
redfordxx
Registered User
 
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 791
I really didn't read but my opinion is following:
1.Source including postprocessing as a part of decoding
2.Postprocessing
3.Crop
4.Postprocessing
5.trim and other frame reordering activities
6.Crop
7.Resize
8.Postprocessing?
Postprocessing can be deblocking, denoising, deinterlacing, deringing, depan, color correction or whatever
The particular order should be decided based on the source nature, that cannot be general
If you are downsizing there should be no step (8), unless you wanna save some processing time. In case of upsizing, exceptionally there might be reason...
Deblocking might be beste in step one, deringing probably also..

Last edited by redfordxx; 21st December 2011 at 00:11.
redfordxx is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:12.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.