class_docstr: Class for video byte-level reading with ffmpeg.
class_docstr_tok: ["Class","for","video","byte-level","reading","with","ffmpeg","."]
docstr: 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 fetching arbitrary frames
  whenever possible, by moving between adjacent frames.
docstr_tok: ["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","fetching","arbitrary","frames","whenever","possible",",","by","moving","between","adjacent","frames","."]
code: def get_frame(self, t):
      """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 fetching arbitrary frames
      whenever possible, by moving between adjacent frames.
      """
      # + 1 so that it represents the frame position that it will be
      # after the frame is read. This makes the later comparisons easier.
      pos = self.get_frame_number(t) + 1
  
      # Initialize proc if it is not open
      if not self.proc:
          print("Proc not detected")
          self.initialize(t)
          return self.last_read
  
      if pos == self.pos:
          return self.last_read
      elif (pos < self.pos) or (pos > self.pos + 100):
          # We can't just skip forward to `pos` or it would take too long
          self.initialize(t)
          return self.lastread
      else:
          # If pos == self.pos + 1, this line has no effect
          self.skip_frames(pos - self.pos - 1)
          result = self.read_frame()
          return result
  
imports: import os
  import re
  import subprocess
  import warnings
  import numpy
  from moviepy.config import FFMPEG_BINARY
  from moviepy.tools import convert_to_seconds, cross_platform_popen_params
label_desc: Use image node_id 5 for calling the FFMPEG_VideoReader obj's underlying member method code with example usage: obj.get_frame(t) and returns: self, self, self, result