count frames with openCV first, then pil if necessary
fixed indentation