'Read a file video frame at time t.
Note for coders: getting an arbitrary frame in the video with
ffmpeg can be painfully slow if some decoding has to be done.
This function tries to avoid fectching arbitrary frames
whenever possible, by moving between adjacent frames.'

def get_frame(self, t):

    pos = (int(((self.fps * t) + 1e-05)) + 1)
    if (pos == self.pos):
        return self.lastread
    else:
        if ((pos < self.pos) or (pos > (self.pos + 100))):
            self.initialize(t)
            self.pos = pos
        else:
            self.skip_frames(((pos - self.pos) - 1))
        result = self.read_frame()
        self.pos = pos
        return result
