title: Send video signal from a file to a device and record its output simultaneously in Python
body: <p>We would like to send a video signal from a file to a device and record the output (a little bit processed) of the device in Python. Do you know if that is possible? I have done a piece of code but I can not try it yet because I still not have the device. Do you thing I am in the good direction? Should I use two while loops? Thank you.</p>
  
  <pre><code>import numpy as np
  import cv2
  
  cap_file = cv2.VideoCapture('vtest.avi')
  
  ret_file, frame_file = cap_file.read()
  cv2.imshow('video_before_device', frame_file)
  cv2.waitKey(1)
  
  
  cap_device = cv2.VideoCapture(0)
  fourcc = cv2.VideoWriter_fourcc(*'XVID')
  out = cv2.VideoWriter('video_after_device.avi' %i,fourcc, 25.0, (1280,720))
  frame_number=0
  framerate = 25.0
  
  #We open a txt file
  f= open("GI_genius_%i.txt" %i, "w+")
  
  while(cap_device.isOpened()):
      ret, frame = cap_device.read()
  
      #To control time
      time = frame_number/framerate
      frame_number = frame_number + 1
  
      if ret==True:
          #Define the list of boundaries (BGR enlloc de RGB):
          boundaries = [([13, 144, 13], [99, 254, 131])]
  
          #Loop over the boundaries:
          for (lower, upper) in boundaries:
              lower = np.array(lower, dtype="uint8")
              upper = np.array(upper, dtype="uint8")
  
              #Find the color within the specified boundaries and apply the mask
              mask = cv2.inRange(frame, lower, upper)
              output = cv2.bitwise_and(frame, frame, mask = mask)
  
          count_nonzero = np.count_nonzero(mask)
          if (count_nonzero&gt;50):
              f.write("Square in %.2f s \n" %round(time,2))
  
          out.write(output)
  
  
          cv2.imshow('frame', output) #Will this affect to the sending image?
  
          if cv2.waitKey(1) &amp; 0xFF == ord('q'):
              break
          else:
              break
  
  # Release everything if job is finished
  f.close()
  vid.release()
  out.release()
  cv2.destroyAllWindows()
  </code></pre>