title: Latency and fps drop when reading multiple rstp streams and writing to disk with opencv
body: <p>I have several streams. I try to write them altogether the the disk. This is the script i use - </p>
  
  <pre><code>import cv2
  import os
  
  output_dir = "/home/Desktop/stream_rec"
  
  # Load Streams
  input_cap = {}
  output_cap = {}
  
  fourcc = cv2.VideoWriter_fourcc(*'XVID')
  
  for i in range(2, 6):
      input_cap[i] = cv2.VideoCapture("rtsp://stream@10.0.0.{}".format(i))
      output_cap[i] = cv2.VideoWriter(os.path.join(output_dir, f'D{i}.mp4'), fourcc, 25.0, (1080,1920)[::-1])
  
  
  # Load Frames
  # while all([stream.isOpened() for stream_id, stream in streams.items()]):
  while True:
  
      for stream_id, stream in input_cap.items():
  
          # Read
          ret, frame = stream.read()
  
          # Write
          output_cap[stream_id].write(frame)
  
          # Show
          # frame = cv2.resize(frame, (int(frame.shape[1]/2), int(frame.shape[0]/ 2)))
          if ret:
              cv2.imshow(str(stream_id), frame)
          else:
              break
  
      if cv2.waitKey(1) &amp; 0xFF == ord('q'): # Press Q to stop recording
          break
  
  # Release Caps
  for i in range(2, 6):
      input_cap[i].release()
      output_cap[i].release()
  </code></pre>
  
  <p>When i only show the streams it looks real time. But when i try to write them to disk as well, frame rate drops significantly. How can i show 4 streams and write them to disk with minimal impact on frame rate and latency?</p>