@@ -2161,10 +2161,16 @@ def save_montage(self, filename, order=['lat', 'ven', 'med'],
2161
2161
return out
2162
2162
2163
2163
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 ):
2166
2166
"""Save a movie (for data with a time axis)
2167
2167
2168
+ The movie is created through the :mod:`imageio` module. The format is
2169
+ determined by the extension, and additional options can be specified
2170
+ through keyword arguments that depend on the format. For available
2171
+ formats and corresponding parameters see the imageio documentation:
2172
+ http://imageio.readthedocs.io/en/latest/formats.html#multiple-images
2173
+
2168
2174
.. Warning::
2169
2175
This method assumes that time is specified in seconds when adding
2170
2176
data. If time is specified in milliseconds this will result in
@@ -2173,7 +2179,9 @@ def save_movie(self, fname, time_dilation=4., tmin=None, tmax=None,
2173
2179
Parameters
2174
2180
----------
2175
2181
fname : str
2176
- Path at which to save the movie.
2182
+ Path at which to save the movie. The extension determines the
2183
+ format (e.g., `'*.mov'`, `'*.gif'`, ...; see the :mod:`imageio`
2184
+ documenttion for available formats).
2177
2185
time_dilation : float
2178
2186
Factor by which to stretch time (default 4). For example, an epoch
2179
2187
from -100 to 600 ms lasts 700 ms. With ``time_dilation=4`` this
@@ -2188,11 +2196,8 @@ def save_movie(self, fname, time_dilation=4., tmin=None, tmax=None,
2188
2196
Interpolation method (``scipy.interpolate.interp1d`` parameter,
2189
2197
one of 'linear' | 'nearest' | 'zero' | 'slinear' | 'quadratic' |
2190
2198
'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
2199
+ **kwargs :
2200
+ Specify additional options for :mod:`imageio`.
2196
2201
2197
2202
Notes
2198
2203
-----
@@ -2211,6 +2216,15 @@ def save_movie(self, fname, time_dilation=4., tmin=None, tmax=None,
2211
2216
"run\n \n $ pip install -U "
2212
2217
"pysurfer[save_movie]\n " )
2213
2218
2219
+ # find imageio FFMPEG parameters
2220
+ if 'fps' not in kwargs :
2221
+ kwargs ['fps' ] = framerate
2222
+ if codec is not None :
2223
+ kwargs ['codec' ] = codec
2224
+ if bitrate is not None :
2225
+ kwargs ['bitrate' ] = bitrate
2226
+
2227
+ # find tmin
2214
2228
if tmin is None :
2215
2229
tmin = self ._times [0 ]
2216
2230
elif tmin < self ._times [0 ]:
@@ -2238,8 +2252,7 @@ def save_movie(self, fname, time_dilation=4., tmin=None, tmax=None,
2238
2252
% (times , time_idx ))
2239
2253
images = (self .screenshot () for _ in
2240
2254
self ._iter_time (time_idx , interpolation ))
2241
- imageio .mimwrite (fname , images , fps = framerate , codec = codec ,
2242
- bitrate = bitrate )
2255
+ imageio .mimwrite (fname , images , ** kwargs )
2243
2256
2244
2257
def animate (self , views , n_steps = 180. , fname = None , use_cache = False ,
2245
2258
row = - 1 , col = - 1 ):
0 commit comments