code: def count_frames(path, override=False):
      # grab a pointer to the video file and initialize the total
      # number of frames read
      video = cv2.VideoCapture(path)
      total = 0
  
      # if the override flag is passed in, revert to the manual
      # method of counting frames
      if override:
          total = count_frames_manual(video)
  
      # otherwise, let's try the fast way first
      else:
          # lets try to determine the number of frames in a video
          # via video properties; this method can be very buggy
          # and might throw an error based on your OpenCV version
          # or may fail entirely based on your which video codecs
          # you have installed
          try:
              # check if we are using OpenCV 3
              if is_cv3():
                  total = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
  
              # otherwise, we are using OpenCV 2.4
              else:
                  total = int(video.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT))
  
          # uh-oh, we got an error -- revert to counting manually
          except:
              total = count_frames_manual(video)
  
      # release the video file pointer
      video.release()
  
      # return the total number of frames in the video
      return total
  
label_desc: Use image node_id 1 for calling a global function with example usage: count_frames(path, override) and returns: total