Pretty good implementation.
Hint : When making a BlankClip that mostly needs to match an existing clip, explicitly provide that template clip as the 1st argument (this is currently the only filter that doesn't auto inherit Last as its input clip). Then just override the parameter that you want to be different. i.e
Code:
AA=BlankClip(clip=A, length=TFrames+1, width=4, pixel_type="RGB32", color=$000000)
Also using globals can bite when you want to use more than one instance of the function. Pass them down as arguments.