0

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

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.