title: OpenCV's cap.set(cv2.CAP_PROP_POS_MSEC) changes to unreachable timestamp?
body: <p>I'm trying to read frames from a certain timestamp to a certain timestamp, problem is that just after setting it up to start at <em>800 milliseconds</em> for example:</p>
  <pre><code>start_time = 0.8
  end_time = 4
  MILLISECONDS = 1000
  cap.set(cv2.CAP_PROP_POS_MSEC, float(start_time * MILLISECONDS)) 
  </code></pre>
  <p>Now I try and check where it is with:</p>
  <pre><code>cap.get(cv2.CAP_PROP_POS_MSEC)
  </code></pre>
  <p>Which returns:</p>
  <pre><code>13346.680013346679
  </code></pre>
  <p>and according to <a href="https://docs.opencv.org/3.4/d4/d15/group__videoio__flags__base.html#ggaeb8dd9c89c10a5c63c139bf7c4f5704da7c2fa550ba270713fca1405397b90ae0" rel="nofollow noreferrer">OpenCV docs</a>, that flag stands for</p>
  <blockquote>
  <p>Current position of the video file in milliseconds.</p>
  </blockquote>
  <p>Which is kind of confusing because my entire video is 4 seconds long i.e. <em>4000 milliseconds</em>, the entire code snippet is:</p>
  <pre><code>def load_video(path, start_time, end_time, skip_frames=False):
      MILLISECONDS = 1000
      frame_pos = 0
  
      cap = cv2.VideoCapture(path)
      cap.set(cv2.CAP_PROP_POS_MSEC, float(start_time * MILLISECONDS))
      frames = []
      try:
          while cap.isOpened() and cap.get(cv2.CAP_PROP_POS_MSEC) &lt;= float(end_time * MILLISECONDS):
              ret, frame = cap.read()
              if not ret:
                  break
              # OpenCV default capturing is on BGR format,
              # if RGB is needed then un-comment this line:
              # frame = frame[:, :, [2, 1, 0]]
              frames.append(frame)
              if skip_frames:
                  # If we want to take every 5th frame (where there is a an action documented).
                  frame_pos += 12
                  cap.set(cv2.CAP_PROP_POS_FRAMES, frame_pos)
  
      finally:
          cap.release()
      return np.array(frames)
  </code></pre>
  <p>The point is to read from a certain timestamp to a certain timestamp, but the 2nd condition in the <code>while</code> statement obviously isn't satisfied since <code>13346.680013346679 &gt; 4000</code> from the get go, <strong>and most strangely <code>ret, frame = cap.read()</code> actually reads a frame</strong> when I'm executing it in the debugger just before stepping to the <code>while</code> check.</p>
  <p>So what I'm doing wrong here?</p>
  <p>P.S</p>
  <p>The video file is <code>.avi</code> &amp; 60fps.</p>