scikit-video: Video Processing in Python

1.1.11 · maintenance · verified Wed Apr 15

scikit-video is a Python module for video processing, built on top of scipy, numpy, and relying on external `ffmpeg` or `libav` binaries. It aims to provide an all-in-one solution for research-level video processing, offering both high-level and low-level abstractions for reading, writing, and manipulating video files. The current version is 1.1.11, with development seemingly in maintenance mode since its last major release in 2018.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to load a sample video from `skvideo.datasets` into a NumPy array using `skvideo.io.vread`. It also shows how to inspect the video's shape and data type. For large videos, `skvideo.io.vreader` is recommended for memory efficiency.

import skvideo.io
import skvideo.datasets
import numpy as np

# Get a sample video filename
filename = skvideo.datasets.bigbuckbunny()

# Read the video into a NumPy array
# For larger videos, consider skvideo.io.vreader for frame-by-frame processing
videodata = skvideo.io.vread(filename, num_frames=10) # Read first 10 frames for quick test

print(f"Video data shape: {videodata.shape}")
print(f"Data type: {videodata.dtype}")

# Example: Convert to grayscale (if not already)
if videodata.shape[-1] == 3:
    # Simple average for grayscale, or use more advanced conversion
    grayscale_video = np.mean(videodata, axis=-1, keepdims=True).astype(videodata.dtype)
    print(f"Grayscale video shape: {grayscale_video.shape}")

# To prevent 'module numpy has no attribute float' errors with recent NumPy, 
# you might need this workaround before importing anything that uses it if it breaks:
# import numpy
# numpy.float = numpy.float64
# numpy.int = numpy.int_

view raw JSON →