Skip to content

Commit 2a4e85d

Browse files
API Brain.save_movie(): more parameters for imageio
1 parent 89056ab commit 2a4e85d

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

surfer/viz.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,8 +2161,8 @@ def save_montage(self, filename, order=['lat', 'ven', 'med'],
21612161
return out
21622162

21632163
def save_movie(self, fname, time_dilation=4., tmin=None, tmax=None,
2164-
framerate=24, interpolation='quadratic', codec='mpeg4',
2165-
bitrate='1M'):
2164+
framerate=24, interpolation='quadratic', codec=None,
2165+
bitrate=None, **kwargs):
21662166
"""Save a movie (for data with a time axis)
21672167
21682168
.. Warning::
@@ -2188,11 +2188,6 @@ def save_movie(self, fname, time_dilation=4., tmin=None, tmax=None,
21882188
Interpolation method (``scipy.interpolate.interp1d`` parameter,
21892189
one of 'linear' | 'nearest' | 'zero' | 'slinear' | 'quadratic' |
21902190
'cubic', default 'quadratic').
2191-
codec : str
2192-
Codec to use with ffmpeg (default 'mpeg4').
2193-
bitrate : str | float
2194-
Bitrate to use to encode movie. Can be specified as number (e.g.
2195-
64000) or string (e.g. '64k'). Default value is 1M
21962191
21972192
Notes
21982193
-----
@@ -2211,6 +2206,15 @@ def save_movie(self, fname, time_dilation=4., tmin=None, tmax=None,
22112206
"run\n\n $ pip install -U "
22122207
"pysurfer[save_movie]\n")
22132208

2209+
# find imageio FFMPEG parameters
2210+
if 'fps' not in kwargs:
2211+
kwargs['fps'] = framerate
2212+
if codec is not None:
2213+
kwargs['codec'] = codec
2214+
if bitrate is not None:
2215+
kwargs['bitrate'] = bitrate
2216+
2217+
# find tmin
22142218
if tmin is None:
22152219
tmin = self._times[0]
22162220
elif tmin < self._times[0]:
@@ -2238,8 +2242,7 @@ def save_movie(self, fname, time_dilation=4., tmin=None, tmax=None,
22382242
% (times, time_idx))
22392243
images = (self.screenshot() for _ in
22402244
self._iter_time(time_idx, interpolation))
2241-
imageio.mimwrite(fname, images, fps=framerate, codec=codec,
2242-
bitrate=bitrate)
2245+
imageio.mimwrite(fname, images, **kwargs)
22432246

22442247
def animate(self, views, n_steps=180., fname=None, use_cache=False,
22452248
row=-1, col=-1):

0 commit comments

Comments
 (0)