Python Matplotlib Basic animation with FFMpegwriter stops after 820 frames?

If I run the following code, it just stops after 820 frames. I tested this on both the Ubuntu 12.04 VM and Linux Mint 15. Unfortunately, there is no error message. The program simply freezes after printing 2012-06-02T16: 54: 00

import os, sys import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap import matplotlib.animation as animation from datetime import datetime,timedelta def animation_test(start,end,fps=10,save_path='/home/username/animation_test/',\ save_name="test.mp4",dpi=80): step = timedelta(minutes = 3) current = start dates =[] frame = 0 while current <=end: dates.append(current) current += step fig = plt.figure(figsize=(16,9),facecolor='k',edgecolor='k') ax = fig.add_subplot(111) metadata = dict(title='Movie Test', artist='Matplotlib', comment='Movie support!') writer = animation.FFMpegWriter(fps=fps, metadata=metadata,bitrate=20000) direction = -0.5 lat_current = 0 lon_current = 0 with writer.saving(fig,os.path.join(save_path,save_name),dpi): for current in dates: ax.cla() if direction > 0 and lat_current > 40 or \ direction < 0 and lat_current < -40: direction = - direction lat_current = lat_current + direction lon_current = lon_current - 0.75 if lon_current < -180 : lon_current += 360 basem = Basemap(projection='ortho', lat_0=lat_current, lon_0=lon_current, resolution='l',ax=ax) basem.drawcoastlines() #plt.show() plt.savefig(os.path.join(save_path, 'frame%d.png'%frame), dpi=dpi,facecolor='w',edgecolor='k') writer.grab_frame() frame += 1 print current.isoformat() start = datetime.now() animation_test(datetime(2012,6,1,0,0,0),datetime(2012,6,4,0,0,0),fps=10,dpi=80) print datetime.now() - start 

To explain the code a bit: I want to make a satellite data animation that comes with small 3-minute files and show it on a spinning ball. This is why I decided to loop in the following code example through animation in 3-minute steps. I simply deleted reading and building satellite data to make the code executable by someone.

When I removed the basemap from the program and just built a random data diagram, the program went all the way.

I am not sure, but I do not think it is a memory problem, since my RAM is only used ok. 20% while the program is running.

Thanks for any help with this.

+4
source share
1 answer

After installing FFMPEG version 0.10.7 from https://launchpad.net/~jon-severinsson/+archive/ffmpeg it works.

Thus, it seems that this could be a problem with libav, which is the default ubuntu uses.

+1
source

Source: https://habr.com/ru/post/1493726/


All Articles