JP125
JP125

Reputation: 1

Problems with Matplotlib animation

I'm having problems with Matplotlib animation. I've taken code directly from https://www.geeksforgeeks.org/matplotlib-animation-funcanimation-class-in-python/ and have installed ffmeg, but am getting an error message. The error message and the code is below, would be grateful for some help.

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation
from matplotlib.animation import FuncAnimation
fig = plt.figure()
axis = plt.axes(xlim =(0, 4),  
                ylim =(-2, 2))  
line, = axis.plot([], [], lw = 3)  
  
 
def init():  
    line.set_data([], [])  
    return line,  
  
def animate(i):  
    x = np.linspace(0, 4, 1000)  
    y = np.sin(2 * np.pi * (x - 0.01 * i))  
    line.set_data(x, y)  
      
    return line,  
  
anim = FuncAnimation(fig, animate,  
                    init_func = init,  
                    frames = 200,  
                    interval = 20,  
                    blit = True)  
  
anim.save('continuousSineWave.mp4',  
          writer = 'ffmpeg', fps = 30) 

Top of error message:

MovieWriter stderr:
dyld: Library not loaded: @rpath/libopenh264.5.dylib
  Referenced from: /opt/anaconda3/lib/libavcodec.58.54.100.dylib
  Reason: image not found

Upvotes: 0

Views: 1794

Answers (1)

Hendrik
Hendrik

Reputation: 315

I had the same problem. Even after installing it seems there is some dependency based on libopen264.so. Apparently ffmpeg 4.2.2 and the latest python version don't match very well as explained in this post:

ffmpeg: error while loading shared libraries: libopenh264.so.5

Even though I installed ffmpeg correctly into anaconda, I still had to separately update it via conda update ffmpeg

Upvotes: 3

Related Questions