title: How to pipe output from ffmpeg using python?
body: <p>I am trying to pipe output from <strong>FFmpeg</strong> in <strong>Python</strong>. I am reading images from a video grabber card and I am successful in reading this to an output file from the command line using dshow. I am trying to grab the images from the card to my OpenCv code to be able to further play with the data. Unfortunately, when I pipe out the images, I just get a display of the video as shown in the link: </p>
  
  <blockquote>
    <p>link: s000.tinyupload.com/?file_id=15940665795196022618. </p>
  </blockquote>
  
  <p>The code I used is as shown below:</p>
  
  <pre><code>import cv2
  import subprocess as sp
  import numpy
  import sys
  import os
  old_stdout=sys.stdout
  log_file=open("message.log","w")
  sys.stdout=log_file
  
  FFMPEG_BIN = "C:/ffmpeg/bin/ffmpeg.exe"
  command = [ FFMPEG_BIN, '-y',
              '-f', 'dshow', '-rtbufsize', '100M',
              '-i', 'video=Datapath VisionAV Video 01' ,
               '-video_size', '640x480',
                '-pix_fmt', 'bgr24', '-r','25',  
            '-f', 'image2pipe', '-' ]    
  pipe = sp.Popen(command, stdout = sp.PIPE, bufsize=10**8)
  
  while True:
      # Capture frame-by-frame
      raw_image = pipe.stdout.read(640*480*3)
        # transform the byte read into a numpy array
      image =  numpy.frombuffer(raw_image, dtype='uint8')
      print(image)
      image = image.reshape((480,640,3))          
      if image is not None:
          cv2.imshow('Video', image)
  
      if cv2.waitKey(1) &amp; 0xFF == ord('q'):
          break
      pipe.stdout.flush()
  sys.stdout=old_stdout
  log_file.close()
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>Please do provide me some pointers to fix this issue. Help is greatly appreciated.</p>