I have a large binary file (~4 GB) containing a series of image and time stamp data. I want to find the image that most closely corresponds to a user-given time stamp. There are millions of time stamps in the file, though. In Python 2.7, using seek, read, struct.unpack, it took over 900 seconds just to read all the time stamps into an array. Is there an efficient algorithm for finding the closest value that doesn't require reading all of the values? They monotonically increase, though at very irregular intervals.
First attempt. It works, seemingly every time, but I don't know if it's the most efficient way:

Take first and last time stamps and number of frames to calculate an average time step.
Use average time step and difference between target and beginning timestamps to find approximate index.
Check for approximate and 2 surrounding timestamps against target.
If target falls between, then take index with minimum difference.
  If not, set approximate index as new beginning or end, accordingly, and repeat.
Finding closest value in a binary file