google/mediapy

This Python library makes it easy to display images and videos in a notebook.

What it solves

In Jupyter notebooks, working with images and videos often involves extra steps: loading files, handling formats, and displaying them inline. This library provides simple, one‑line functions to read, show, and write media, converting everything to numpy arrays so you can manipulate them with standard Python tools.

How it works

The library offers functions like read_image, read_video, show_image, show_video, write_image, and write_video. It reads images and videos from local files or URLs, returns them as numpy arrays, and displays them directly in the notebook. For video, it relies on the external program ffmpeg (which must be installed) to handle encoding and decoding. It also includes utilities such as color_ramp to generate color gradients, moving_circle to create synthetic video, and VideoReader/VideoWriter for frame‑by‑frame video processing.

Who it’s for

Anyone who uses Jupyter notebooks for scientific computing, data analysis, or prototyping and needs to work with images or video in Python. It’s especially handy for researchers, data scientists, and educators who want to load, inspect, and save media without dealing with low‑level file handling.

Highlights

  • Read images and videos from files or URLs into numpy arrays.
  • Display images and videos inline in a notebook with a single call.
  • Write numpy arrays back to image or video files.
  • Includes helper functions like color_ramp and moving_circle for quick examples.
  • Provides VideoReader and VideoWriter for processing videos frame by frame.

相关

  • 项目
  • 项目
  • 项目
  • 项目