AvsPmod

From BakaBT Wiki
Revision as of 22:44, 19 March 2021 by Theworm4002 (talk | contribs)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
#############################################################################
#######################   -Options, Settings-   #############################
#############################################################################

vidfile = "VIDEOFILE"
subfile = "SUBFILE"
group = "GROUPNAME"

#Unless upscaling leave these as 0, else add desired values
upscale_width = 0
upscale_height = 0

Logging = false
display_group = true
displayFramNum = false
display_timecode = false
display_subtitles =  true


# Adding blank frames in front or back of the VidClp
Front_FramePadding = 0
Back_FramePadding = 0

#############################################################################
##################   -Should Not Need To Change-   ##########################
#############################################################################

## creating file and set path for future log entries:
(Logging) ? Eval("""
	folder = ScriptDir()
	(RightStr(folder, 1) == "\") ?
   \     SetLogParams(folder + group + "_ScriptLog.log", LOG_INFO): SetLogParams(folder + "\" + group + "_ScriptLog.log", LOG_INFO)
	LogMsg("Starting Logger", LOG_INFO)
	""")
\:nop()  

c1  = FFVideoSource (vidfile, enable10bithack=false, colorspace="YV12")
c2  = FFVideoSource (vidfile, enable10bithack=true, varprefix="c1_", colorspace="YV12")

(StrLen(subfile) == 0) ? Eval("""
    F_blank1 = BlankClip(c1, length= Front_FramePadding)  
    B_blank1 = BlankClip(c1, length= Back_FramePadding)
    c1 = F_blank1+c1+B_blank1
   
    F_blank2 = BlankClip(c2, length= Front_FramePadding)  
    B_blank2 = BlankClip(c2, length= Back_FramePadding)
    c2 = F_blank2+c2+B_blank2    
    
    """):
\nop()

w   = c1.Width ()
h   = c1.Height ()
wm4 = (w + 3) / 4 * 4
hm4 = (h + 3) / 4 * 4
b10 = (c2.Height () > c1.Height ())

target_width = (upscale_width > 0) ?  upscale_width : w
target_height = (upscale_height > 0) ? upscale_height : h

matrix   = (c1_FFCOLOR_SPACE == 1) ? "709"
\        : (c1_FFCOLOR_SPACE >= 5) ? "601" : Dither_undef ()
par      = (c1_FFSAR_NUM > 0 && c1_FFSAR_DEN > 0)
\        ? Float (c1_FFSAR_NUM) / Float (c1_FFSAR_DEN)
\        : Dither_undef ()
tv_range = (c1_FFCOLOR_RANGE != 2)

(b10) ? c2 : c1

#Adding Subs based on the file ext
Subs = (StrLen(subfile) > 0 && display_subtitles) ?
\      (RightStr(LCase(subfile), 3) == "sup") ?
\         	(b10) ? Dither_limit_dif16(DitherPost(mode=-1).SupTitle(subfile).Dither_convert_8_to_16 (), thr=1.0, elast=2.0) : SupTitle(subfile)
\          :(RightStr(LCase(subfile), 3) == "sub") ?
\         	(b10) ? Dither_limit_dif16(DitherPost(mode=-1).VSFilter_Vobsub(subfile).Dither_convert_8_to_16 (), thr=1.0, elast=2.0) : 
VSFilter_Vobsub(subfile)
\          :(b10) ? Dither_limit_dif16(DitherPost(mode=-1).TextSub(subfile).Dither_convert_8_to_16 (), thr=1.0, elast=2.0) : TextSub(subfile)
\: nop()

#Add blank frames if needed
(StrLen(subfile) > 0 && display_subtitles) ? Eval("""
    F_blank2 = BlankClip(Subs, length= Front_FramePadding)  
    B_blank2 = BlankClip(Subs, length= Back_FramePadding)
    F_blank2+Subs+B_blank2
    """):
\nop()

(VersionNumber () >= 2.6) ? last
\ : (b10) ? Dither_addborders16 (0, 0, wm4 - w, hm4 - h)
\         : AddBorders (0, 0, wm4 - w, hm4 - h)

(target_width != c1.Width() || target_height != c1.Height()) ? Dither_srgb_display (lsb_in=b10, matrix=matrix, par=par, tv_range=tv_range, w=target_width, 
h=target_height)
\ :                                                            Dither_srgb_display (lsb_in=b10, matrix=matrix, par=par, tv_range=tv_range)

cmt1 = (target_width > c1.Width() || target_height > c1.Height()) ? group + "\nupscaled" : group
cmt2 = (display_group) ? 
\                 cmt1 : ""

FFInfoEx(framenum=displayFramNum,vfrtime=display_timecode, cfrtime=false, frametype=false, x=last.width-6, y=4, cmt=cmt2, align=9, shorttime=true)