Skip to main content

ffmpegio plugin to create videos from matploglib Figures

Project description

PyPI PyPI - Status PyPI - Python Version GitHub License GitHub Workflow Status

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ffmpegio-plugin-mpl-0.1.1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ffmpegio_plugin_mpl-0.1.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file ffmpegio-plugin-mpl-0.1.1.tar.gz.

File metadata

  • Download URL: ffmpegio-plugin-mpl-0.1.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for ffmpegio-plugin-mpl-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7eb724ef6e1fb7a483ab66114a5c14ee0a72886bf3125b7011e4d73bc56f63fa
MD5 44a6b444cb78f5968d689d76a80d1f52
BLAKE2b-256 1f733a109b0ca3f8946a16d75d13714c4ce7671cd5d5d80e6bbfa89674a3c4a7

See more details on using hashes here.

File details

Details for the file ffmpegio_plugin_mpl-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ffmpegio_plugin_mpl-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ed1f4cb262349e4db58472fdf5aa201cc7131315d23fe98c8aa687da0848474f
MD5 04d4177c521ac9a8d738640b5437fea4
BLAKE2b-256 e7cfbf104d81caabc79d945fc48ae2ee0ac35b88b346ad325ec5f9a7fae0ba7d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page