title: Speedup matplotlib animation to video file
body: <p>On Raspbian (Raspberry Pi 2), the following minimal example stripped from my script correctly produces an mp4 file:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  from matplotlib import animation
  
  def anim_lift(x, y):
  
      #set up the figure
      fig = plt.figure(figsize=(15, 9))
  
      def animate(i):
          # update plot
          pointplot.set_data(x[i], y[i])
  
          return  pointplot
  
      # First frame
      ax0 = plt.plot(x,y)
      pointplot, = ax0.plot(x[0], y[0], 'or')
  
      anim = animation.FuncAnimation(fig, animate, repeat = False,
                                     frames=range(1,len(x)), 
                                     interval=200,
                                     blit=True, repeat_delay=1000)
  
      anim.save('out.mp4')
      plt.close(fig)
  
  # Number of frames
  nframes = 200
  
  # Generate data
  x = np.linspace(0, 100, num=nframes)
  y = np.random.random_sample(np.size(x))
  
  anim_lift(x, y)
  </code></pre>
  
  <p>Now, the file is produced with good quality and pretty small file size, but it takes 15 minutes to produce a 170 frames movie, which is not acceptable for my application. i'm looking for a significant speedup, video file size increase is not a problem.</p>
  
  <p>I believe the bottleneck in the video production is in the temporary saving of the frames in png format. During processing I can see the png files apprearing in my working directory, with the CPU load at 25% only.</p>
  
  <p>Please suggest a solution, that might also be based on a different package rather than simply <code>matplotlib.animation</code>, like <code>OpenCV</code> (which is anyway already imported in my project) or <code>moviepy</code>.</p>
  
  <p>Versions in use:</p>
  
  <ul>
  <li>python 2.7.3</li>
  <li>matplotlib 1.1.1rc2</li>
  <li>ffmpeg 0.8.17-6:0.8.17-1+rpi1</li>
  </ul>