====== Avisynth Scripts ======
===== Image preview table =====
# functions to create video preview table (x&y)
# rawe '2010
function timelinegraph(source,frame,step,count,showframenum)
{
vid = Trim(source,frame,frame)
vid = showframenum ? Subtitle(vid,string(frame), size=10,x=4,y=4) : vid
count > 1 ? StackHorizontal(vid,timelinegraph(source,frame+step,step,count-1,showframenum)) : vid
}
function timelinegraph_2(source,frame,step,xcount,ycount,showframenum)
{
vid = timelinegraph(source,frame,step,xcount,showframenum)
ycount > 1 ? StackVertical(vid,timelinegraph_2(source,frame+xcount*step,step,xcount,ycount-1,showframenum)) : vid
}
source = AVIFileSource("test.avi")
timelinegraph_2(source,0,10,6,6,true)
===== video comparison =====
function create_some_fancy_graphs(clip filtered, clip original, int target_width, int target_height, \
string text_overlay, string text_overlay_original, string text_overlay_filtered)
{
# resize (so overlay text fits in and everything is better visible)
original_half_scale = PointResize(original, target_width/2, target_height/2)
# text overlay
original_half_scale = Subtitle(original_half_scale , text_overlay_original, align=1,text_color=$00FFFF,size=14,y=target_height/2-10)
filtered=PointResize(filtered, target_width, target_height)
original=PointResize(original, target_width, target_height)
# substract videos --> see the difference
difference = subtract(original, filtered)
difference_lo = levels(difference,0,1,127,255,0)
difference_hi = levels(difference,128,1,255,0,255)
difference_lohi = overlay(difference_lo,difference_hi,mode="add")
# invert
# difference_lohi = levels(difference_lohi,0,1,255,255,0)
#Levels(input_low,gamma,input_high,output_low,output_high)
# compare
compare_result = compare(filtered, original,"","",true)
# text overlay
compare_result = Subtitle(compare_result , "PSNR, "+text_overlay_filtered,align=1,text_color=$00FFFF,size=14,y=target_height-10)
# do some histogram stuff
# levels graph
histogram_levels = PointResize(crop(histogram(difference_lohi,mode="levels"),target_width,0,256,66),512,264)
# text overlay
histogram_levels = Subtitle(histogram_levels , "diff, sum",align=1,text_color=$00FFFF,size=14, font_angle=90, x=20, y=256)
# classic graph
histogram_classic = PointResize(crop(histogram(difference_lohi),target_width,0,256,target_height),512,target_height)
# text overlay
histogram_classic = Subtitle(histogram_classic , "diff, per line",align=1,text_color=$00FFFF,size=14, font_angle=90, x=20, y=target_height-14)
# create some black empty clipts for alignment on screen
blank_clip_fill_histogram_vertical = blankclip(original,length=1,width=512,height=target_height-264-target_height/2,color=$000000)
blank_clip_fill_histogram_horizontal =blankclip(original,length=1,width=(512-target_width/2)/2,height=target_height/2,color=$000000)
# add text overlay in upper right corner
blank_clip_fill_histogram_vertical = Subtitle(blank_clip_fill_histogram_vertical, text_overlay,align=8,text_color=$FFFFFF,size=20)
# text overlay
difference_lohi = Subtitle(difference_lohi , "absolute difference",align=1,text_color=$00FFFF,size=14,y=target_height-10)
# add borders to half scaled clip --> 512 px width
original_half_scale_512_width = StackHorizontal(blank_clip_fill_histogram_horizontal,original_half_scale,blank_clip_fill_histogram_horizontal)
# create the right column
histogram_result = StackVertical(blank_clip_fill_histogram_vertical,original_half_scale_512_width,histogram_levels, histogram_classic)
# ! for testing purposes and size calculation lazyness
# histogram_result = PointResize(histogram_result,512,target_height*2)
# create left column and the final view
complete_result = StackHorizontal(StackVertical(compare_result, difference_lohi),histogram_result)
# return it
return complete_result
}