Closed
Description
Using
- Matplotlib 1.5.0rc3 with Python 2.7.10 and Win 7 64 Bit (WinPython 2.7.10.3) or
- Matplotlib 1.5.1 with Python 3.4.4 and Win 7 64 Bit (WinPython 3.4.4.1)
- ffmpeg 20160512-git-cd244fa
animation with 'ffmpeg' backend incompative with 'bounding_box=tight' #2483 seems to be back (or still there):
Setting savefig.bbox = tight
either in matplotlibrc or as an rcParam garbles an mp4 video written by ffmpeg. Even starting the script with --verbose-debug gives no warning or message that something might be wrong.
I also cannot change the frame rate - neither interval
nor fps
has any effect, I always get 5 fps (this is consistent with the options passed to ffmpeg which always says '-r 5').
Example (slightly modded) taken from
https://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/ :
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
plt.rcParams['animation.ffmpeg_path'] = 'D:/Programme/ffmpeg/bin/ffmpeg.exe'
plt.rcParams['savefig.bbox'] = 'tight' # tight garbles the video!!!
movie_file = 'D:/Daten/basic_animation.mp4'
mywriter = animation.FFMpegWriter()
fig = plt.figure()
fig.set_size_inches(4, 5, True)
ax = plt.axes(xlim=(0, 2), ylim=(-2, 2))
line, = ax.plot([], [], lw=2)
def init():
line.set_data([], [])
return line,
def animate(i):
x = np.linspace(0, 2, 1000)
y = np.sin(2 * np.pi * (x - 0.01 * i))
line.set_data(x, y)
return line,
anim = animation.FuncAnimation(fig, animate, init_func=init,
interval = 1000, frames = 20, blit=True)
anim.save(movie_file, dpi=100, fps = 30, writer=mywriter,
extra_args=['-vcodec', 'libx264'])
plt.show()