Registry / data / mediapy

mediapy

JSON →
library1.2.7pypypi✓ verified 22d ago

mediapy is a Python library designed to simplify reading, writing, and displaying images and videos, especially within IPython/Jupyter notebooks. Developed by Google LLC, it is currently on version 1.2.6 and receives updates periodically.

pip install mediapy
INSTALL
IMPORT
SIG · MEDIAPY
M
mediapy
datapythonv1.2.7
Install
11.1s avg
Import
3097ms
Disk
238MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 3.200s · 240.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 11.1s · import 2.994s · 233MB
238MB installed
● package 238MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mediapy
import mediapy
import mediapy

This quickstart demonstrates how to read and display both local/remote images and videos. For video functionality, ensure that the `ffmpeg` command-line tool is installed and accessible in your system's PATH. An example of writing an image to a file is also included.

import mediapy as media import numpy as np import shutil import os # --- Image Example --- image_url = 'https://github.com/hhoppe/data/raw/main/image.png' print(f"Reading image from: {image_url}") image = media.read_image(image_url) print(f"Image shape: {image.shape}, dtype: {image.dtype}") media.show_image(image, title='Remote Image') # Example of creating and saving an image checkerboard = np.kron([[0, 1] * 16, [1, 0] * 16] * 16, np.ones((4, 4))) output_image_path = '/tmp/checkerboard.png' media.write_image(output_image_path, checkerboard) print(f"\nCheckerboard image written to {output_image_path}") # --- Video Example (requires ffmpeg) --- if shutil.which('ffmpeg'): video_url = 'https://github.com/hhoppe/data/raw/main/video.mp4' print(f"\nReading video from: {video_url}") video = media.read_video(video_url) print(f"Video shape: {video.shape}, dtype: {video.dtype}") if hasattr(video, 'metadata') and hasattr(video.metadata, 'fps'): print(f"Video framerate: {video.metadata.fps} fps") media.show_video(video, title='Remote Video', fps=video.metadata.fps) else: media.show_video(video, title='Remote Video - FPS unknown') else: print("\nFFmpeg is not installed or not in PATH. Skipping video example.") print("Please install ffmpeg (e.g., 'brew install ffmpeg' on macOS, 'apt install ffmpeg' on Debian/Ubuntu) for video functionality.")
Debug
Known issues
gotchaVideo input/output operations (e.g., `read_video`, `write_video`, `show_video`) are dependent on the external `ffmpeg` command-line tool. It must be installed on your system and accessible in the system's PATH, otherwise a `RuntimeError` will be raised.
fix
Install `ffmpeg` for your operating system (e.g., `brew install ffmpeg` on macOS, `apt install ffmpeg` on Debian/Ubuntu, or download from ffmpeg.org).
affects: All versions
gotchaWhen displaying videos with `media.show_video` after reading them with `media.read_video`, the framerate might not always be automatically detected or correctly applied. For accurate playback speed, it's recommended to explicitly pass the `fps` argument to `show_video` using `video.metadata.fps`.
fix
Ensure `fps=video.metadata.fps` is passed to `media.show_video()` calls, as shown in the quickstart example.
affects: All versions
breakingVersion 1.2.1 introduced an incompatibility with Python 3.8 due to the use of `os.PathLike[str]`, which was not subscriptable in Python 3.8 at the time. This caused `TypeError: 'ABCMeta' object is not subscriptable`.
fix
This issue was quickly addressed in subsequent releases. Users on Python 3.8 or later should use version 1.2.2 or higher (current version 1.2.6 is compatible with Python >=3.8).
affects: 1.2.1
Upgrade
Version history
1.2.7latest on PyPI · released Jul 1, 2026
Audit
Dependencies
numpyrequiredFundamental for image and video data handling as NumPy arrays.
pillowrequiredUsed for image processing tasks.
ffmpegrequiredExternal command-line tool required for all video input/output operations. Must be installed separately and accessible in system PATH.
Agent activity
5 hits · last 30 days
node
4
Resources
mediapy — pip install mediapy · libregistry