Skip to content

Commit 969fee7

Browse files
author
Shunichi09
authored
Merge pull request #9 from Geonhee-LEE/master
Bug fixed for saving .mp4 format
2 parents ebdb47b + bfe1374 commit 969fee7

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

PythonLinearNonlinearControl/plotters/animator.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import numpy as np
55
import matplotlib.pyplot as plt
66
from matplotlib.animation import FuncAnimation
7+
import matplotlib.animation as animation
78

89
logger = getLogger(__name__)
910

@@ -66,14 +67,18 @@ def draw(self, history_x, history_g_x=None):
6667
self._setup()
6768
_update_img = lambda i: self._update_img(i, history_x, history_g_x)
6869

70+
# Set up formatting for the movie files
71+
Writer = animation.writers['ffmpeg']
72+
writer = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1800)
73+
6974
# call funcanimation
70-
animation = FuncAnimation(
75+
ani = FuncAnimation(
7176
self.anim_fig,
7277
_update_img, interval=self.interval, frames=len(history_x)-1)
7378

7479
# save animation
7580
path = os.path.join(self.result_dir, self.controller_type,
7681
"animation-" + self.env_name + ".mp4")
77-
logger.info("Saved Animation to {} ...".format(path))
78-
79-
animation.save(path, writer="ffmpeg")
82+
logger.info("Saved Animation to {} ...".format(path))
83+
84+
ani.save(path, writer=writer)

0 commit comments

Comments
 (0)