Thread: Avisynth+
View Single Post
Old 7th November 2016, 19:42   #2585  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,314
Avisynth arrays status report:

Implemented empty arrays and [] syntax for array creation

Code:
clip=ffms2(film).ConvertBits(16)

empty_array = []
empty_array_2 = empty_array
#n3 = empty_array_2.ArrayGet(0) # array index out of range error!

black_yuv_16 = [0,32768,32768] # or black_yuv_16 = Array(    0,32768,32768)
grey_yuv_16  = [32768,32768,32768]
white_yuv_16 = [65535,32768,32768]
# getting deeper: nested arrays
aSelectColors = [\
  ["black", black_yuv_16],\
  ["grey",  grey_yuv_16],\
  ["white", white_yuv_16],\
  ["empty", empty_array]\
]
test_array = [99, 1.0, "this is a string"] # mixed types
test_array2 = [199, 2.0, "This is a string"]

n = ArraySize(test_array) # 3
n2 = ArraySize(empty_array_2) # 0

clip = clip.SubTitle("Array size = " + String(n) +\
 " Empty array size = " + String(n2) +\
 " [0]=" + String(ArrayGet(test_array,0)) + \
 " [1]=" + String(ArrayGet(test_array,1)) + \
 " [2]=" + ArrayGet(test_array,2))

black=blankClip(clip, length=1, colors = ArrayGet(aSelectColors,"black")) # value lookup by name
white=blankClip(clip, length=1, colors = aSelectColors.ArrayGet("white")) # value lookup by name
grey=blankClip(clip, length=1, colors = [32768,32768,32768]) # or direct array

blackwhite = black+grey+white+black+grey+white
n=3
clip = clip.Trim(0,n) + blackwhite + clip.Trim(n+1,499)
clip
Back to work. It would be nice to have indexing with []
pinterf is offline