out = cv2.VideoWriter('output-' + timestr + '.mp4', fourcc, 30.0,
                          (int(procWidth), int(procHeight)))

#output_side_length = int(1920/zoomImage)

#height_offset = int((height - output_side_length) / 2)
#width_offset = int((width - output_side_length) / 2)

while True:
    #frame = cap.read()
    #if True:
    if webcam or cap.grab():
        if webcam:
            frame = cap.read()
        else:
            flag, frame = cap.retrieve()
        if not flag:
            continue
        else:
            frameCnt = frameCnt + 1
            nowMicro = getCurrentClock()
            delta = (nowMicro - prevTime).total_seconds()
            #print("%f " % (delta))
            if delta >= 1.0:
                print("FPS = %0.4f" % ((frameCnt - prevFrameCnt) / delta))
                prevTime = nowMicro
                prevFrameCnt = frameCnt

            if skip > 0:
                skip = skip - 1
                continue