FFMpegWriter
- class hcipy.plotting.FFMpegWriter(filename, codec=None, framerate=24, quality=None, preset=None)
Bases:
object
A writer of video files from Matplotlib figures.
This class uses FFMpeg as the basis for writing frames to a video file.
- Parameters:
- filenamestring
The filename of the generated video file.
- codecstring
The codec for FFMpeg to use. If it is not given, a suitable codec will be guessed based on the file extension.
- framerateinteger
The number of frames per second of the generated video file.
- qualitystring
The quality of the encoding for lossy codecs. Please refer to FFMpeg documentation.
- presetstring
The preset for the quality of the encoding. Please refer to FFMpeg documentation.
- Raises:
- ValueError
If the codec was not given and could not be guessed based on the file extension.
- RuntimeError
If something went wrong during initialization of the call to FFMpeg. Most likely, FFMpeg is not installed and/or not available from the commandline.
Methods Summary
add_frame
([fig, data, cmap, dpi])Add a frame to the animation.
close
()Close the animation writer and finish the video file.
Methods Documentation
- add_frame(fig=None, data=None, cmap=None, dpi=None)
Add a frame to the animation.
- Parameters:
- figMatplotlib figure
The Matplotlib figure acting as the animation frame.
- datandarray
The image data array acting as the animation frame.
- cmapMatplotlib colormap
The optional colormap for the image data.
- dpiinteger or None
The number of dots per inch with which to save the matplotlib figure. If it is not given, the default Matplotlib dpi will be used.
- Raises:
- RuntimeError
If the function was called on a closed FFMpegWriter.
- close()
Close the animation writer and finish the video file.
This closes the FFMpeg call.