title: Stream a Video output via ffmpeg Pipe into a Python Script for analisis. How to pipe into python?
body: <p>I'm working on a script in conjunction with other libraries which requires an frame or image in an RGB24 format. For improved compatibility I have decided to allow for an external pipe to stream frames into this program. Changing the device or source every time with in the code can become tedious and using a parser to simply specify the source leads to syntax errors. Example:</p>
  
  <pre><code>ffmpeg -f dshow -i video="OEM Device" a.mpg
  </code></pre>
  
  <p>works exactly how you would think. However in an subprocess in python</p>
  
  <pre><code>pipe = sp.Popen('ffmpeg -f dshow -i video="OEM Device" a.mpg'.split(),...
  </code></pre>
  
  <p><strong>Edit</strong> <em>I have tried to manually split. 'video="OEM Device"' didn't work inside python either.</em></p>
  
  <p>Leads to ' <strong>Invalid argument "OEM</strong> Separating <em>OEM</em> and <em>Device</em> as two different variables/arguments. I have tried the alternative name as well. </p>
  
  <p>Which led me to believe</p>
  
  <p><strong>"</strong> </p>
  
  <p>is the problem.
  Which led me to piping the video stream into python via the terminal.</p>
  
  <pre><code>ffmpeg -i a.mpg -f image2pipe -vcode rawvideo -pix_fmt rgb24 - |python myscript.py
  </code></pre>
  
  <p>This is what I have in the Script.</p>
  
  <pre><code>import subprocess as sp
  import numpy
  import sys
  import os
  pipe = sp.Popen('ffmpeg -f rawvideo -pix_fmt rgb24 -an -vcodec rawvideo -i - -f image2pipe -pix_fmt rgb24 -an -vcodec rawvideo -'.split(), stdin=sys.stdin, stderr=sp.PIPE, stdout=sp.PIPE)
  #Assumeing 720x576 resolution 
  raw_img = pipe.stdout.read(720*576*3)
  image = numpy.fromstring(raw_img, dtype='uint8')
  img_load = image.reshape(576, 720, 3)
  </code></pre>
  
  <p>I know the Above <strong>pipe</strong> is not needed and can probably be replaced by.(Which I have tried)</p>
  
  <pre><code>raw_img = sys.stdin.read(720*576*3)
  </code></pre>
  
  <p>Regardless of the two it ordinarily gives output, which  results in</p>
  
  <pre><code>image.reshape(576,720,3) 
  </code></pre>
  
  <p>to receive irregular dimensions and never the required 720x576 as is being specified. I have to admit this is the first time using pipes with python. As I understand stderr is Suppressed As I have specified <em>image2pipe</em>.</p>
  
  <p><em>How can I let ffmpeg to either give python the required dimensions or give an subprocess the syntax ,which allows <strong>"</strong> in the given command without splitting the values or causing syntax errors?</em></p>