nglview.contrib.movie¶
Module contents¶
-
class
nglview.contrib.movie.
MovieMaker
(view, download_folder=None, prefix='movie', output='my_movie.gif', fps=8, start=0, stop=- 1, step=1, skip_render=False, timeout=0.1, in_memory=False, perframe_hook=None, render_params=None, moviepy_params=None)[source]¶ Bases:
object
Unstable API
view : NGLWidget download_folder : str or None
Folder that stores images. You can not arbitarily set this folder. It must be the download directory of the web browser you are using. If None, $HOME/Downloads/ will be used. NOTE: This is DEPRECATED (used with make_old_impl)
- prefixstr, default ‘movie’
prefix name of rendered image.
- outputstr, default ‘my_movie.gif’
output filename of the movie. if output has ‘.gif’, call write_gif, otherwise calling write_videofile
- fps8
frame per second
- start, stop, stepint, default (0, -1, 1)
how many frames you want to render.
- skip_renderbool, default False
if True, do not render any frame and uses existings images in download_folder for movie making. if False, perform rendering first.
- timeouta number (second), default 0.1
The waiting time between rendering two consecutive frames. This option should be only used with perframe_hook option.
- render_paramsdict or None, default None
NGL rendering params. see NGLWidget.download_image. If None, use default values
- moviepy_paramsdict or None, default None
moviepy params for write_gif method. if None, use default values
- in_memorybool, default False
if False, save rendered images to disk first if True, keep all image data in memory (good for small video)
- perframe_hookcallable with view as a single argument, default None
if given, update the view by perframe_hook.
>>> import nglview as nv >>> import pytraj as pt >>> traj = pt.load(nv.datafiles.XTC, top=nv.datafiles.PDB) >>> view = nv.show_pytraj(traj) >>> from nglview.contrib.movie import MovieMaker >>> download_folder = '/Users/xxx/Downloads' >>> output = 'my.gif' >>> mov = MovieMaker(view, download_folder=download_folder, output=output) >>> mov.make()
>>> # write avi format >>> from nglview.contrib.movie import MovieMaker
>>> moviepy_params = { ... 'codec': 'mpeg4' ... } >>> movie = MovieMaker(view, output='my.avi', in_memory=True, moviepy_params=moviepy_params) >>> movie.make()
unstable API. Currently supports .gif format If you are using remote notebook, make sure to set in_memory=True
moviepy. e.g:
pip install moviepy conda install freeimage