'This writes a frame to the display object
this is automatically called by image.save() but you can
use this function to save just the bitmap as well so
image markup is not implicit,typically you use image.save() but
this allows for more finer control'

def writeFrame(self, img):

    if (not self.writer):
        self.initializeWriter(img.size())
        self.lastframe = img
    frametime = (1.0 / float(self.fps))
    targettime = (self.starttime + (frametime * self.framecount))
    realtime = time.time()
    if self.framefill:
        if (targettime > (realtime + frametime)):
            self.lastframe = img
            return
        elif (targettime < (realtime - frametime)):
            framesbehind = (int(((realtime - targettime) * self.fps)) + 1)
            lastframes = (framesbehind / 2)
            for i in range(0, lastframes):
                self.framecount += 1
                cv.WriteFrame(self.writer, self.lastframe.getBitmap())
            theseframes = (framesbehind - lastframes)
            for i in range(0, theseframes):
                self.framecount += 1
                cv.WriteFrame(self.writer, img.getBitmap())
        else:
            self.framecount += 1
            cv.WriteFrame(self.writer, img.getBitmap())
    else:
        cv.WriteFrame(self.writer, img.getBitmap())
        self.framecount += 1
    self.lastframe = img
