ffmpegio plugin to create videos from matploglib Figures
Project description
This plugin enables Python ffmpegio package to output matplotlib’s Figure.
Installation
To enable it, install along with ffmpegio-core or ffmpegio package:
pip install ffmpegio-core # or ffmpegio if also performing media I/O
pip install ffmpegio-plugin-mpl
The plugin will be automatically loaded whenever ffmpegio package is imported.
Example
Create an MP4 video of Matplotlib’s animation example.
import ffmpegio
from matplotlib import pyplot as plt
import numpy as np
fig, ax = plt.subplots()
x = np.arange(0, 2*np.pi, 0.01)
line, = ax.plot(x, np.sin(x))
interval=20 # delay in milliseconds
save_count=50 # number of frames
def animate(i):
line.set_ydata(np.sin(x + i / 50)) # update the data.
return line
with ffmpegio.open(
"output.mp4", # output file name
"wv", # open file in write-video mode
1e3/interval, # framerate in frames/second
pix_fmt="yuv420p", # specify the pixel format (default is yuv444p)
) as f:
for n in range(save_count):
animate(n) # update figure
f.write(fig) # write new frame
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ffmpegio-plugin-mpl-0.1.0.tar.gz
.
File metadata
- Download URL: ffmpegio-plugin-mpl-0.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad654e3553aa614d8a9837ea0c22a8f9058ec6468d613378318cf44a5e9a505a |
|
MD5 | dd4b91e863184caa6400373e364254c4 |
|
BLAKE2b-256 | 0eaf904fc326a14a95197f80c8acaaf88d1f5d6305c050bb9187591b5c1ccdc8 |
File details
Details for the file ffmpegio_plugin_mpl-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: ffmpegio_plugin_mpl-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 547a8ba8e9797ed3cf9476742b9353b59242e9b768b16d5c818bcae6728ba138 |
|
MD5 | 053a75d1bfa2df186962846ed008080f |
|
BLAKE2b-256 | 9c31162a5dd5ac2047c9a1a7f5f152cd9f2c336870f2dcca3aacf99b2744bfaa |