title: Display IO Stream from Raspberry Pi Camera as video in PyGame
body: <p>I'm working on a project that requires me to have a viewfinder (barcode scanner). </p>
  
  <p>I'm doing this with the Raspberry Pi Camera Module by the <code>picamera</code> python module, and I've got the whole detection and whatnot programmed. </p>
  
  <p>Now I need to figure out how to display the preview from the Pi's Camera Module in a PyGame <a href="http://www.pygame.org/docs/ref/movie.html" rel="nofollow">movie</a> module. 
  (If there's a better way to display video from an IO Stream in PyGame, please let me know.) </p>
  
  <p>The reason I need to display it in PyGame is because I'll need to overlay controls on top of the video and be able to get input from a touchscreen I'm going to use as the viewfinder/screen for the Pi/project.</p>
  
  <p>As far as I can see from the <a href="http://www.pygame.org/docs/ref/movie.html" rel="nofollow">pygame.movie documentation</a>, <code>pygame.movie</code> only loads from a file. Is there a way that I could convert the stream into a file-like object and have PyGame play from that?</p>
  
  <p>Basically put, I need a way to take the io.BytesIO stream created in <a href="http://picamera.readthedocs.org/en/release-1.9/recipes1.html#capturing-to-a-pil-image" rel="nofollow">this example code</a>, and display it in PyGame.</p>