Skip to main content

Tools for reading and writing videos, and loading them efficiently with PyTorch.

Project description

Parallel Video IO

The Parallel Video IO (PVIO) package is motivated by the following problems that I kept having:

  1. I could never remember the ffmpeg and ffprob commands for simple tasks, so I have to Google them every time.
  2. Precise random seek in videos (for scientific use) is not so trivial.
  3. I just want some simple dataloader that works for ML training and inference.

After finding myself writing the same thing over and over again for different projects, I wrote this package with the following features:

  1. Read frames from videos (random access or sequential) using imageio/FFmpeg.
  2. Write sequences of NumPy frames to H.264 MP4 files with sensible defaults.
  3. PyTorch-compatible VideoCollectionDataset and VideoCollectionDataLoader that stream frames from many videos in parallel across worker processes.
    • SimpleVideoCollectionLoader provides a convenience API that combines dataset and dataloader creation in one call.
  4. A small pvio command-line tool (an ffmpeg-lite helper): pvio encode combines a directory or list of image files into an H.264 MP4 (with --mode, --quality, and --preset flags), and pvio info prints a video's frame count, frame size, and FPS.

GPU acceleration is automatic. On a machine with a CUDA GPU, decoding uses the GPU (TorchCodec/NVDEC, with frame-accurate seeking preserved) and writing uses the GPU encoder (FFmpeg/NVENC at a visually-lossless setting); both fall back to the CPU when no GPU is available. SimpleVideoCollectionLoader runs in the main process when decoding on the GPU (CUDA cannot be used in forked workers). Pass device="cpu" (loader/EncodedVideo) or mode="cpu" (write_frames_to_video) to opt out.

Linux only. macOS and Windows are not currently supported.

Installation, code examples, and documentation

See the documentation site.

Development

Clone and install with the dev dependencies:

git clone git@github.com:sibocw/parallel-video-io.git
cd parallel-video-io
uv sync --extra dev

Run the test suite:

pytest tests

Build and preview the documentation site locally:

uv run mkdocs serve

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

parallel_video_io-0.1.8.tar.gz (187.7 kB view details)

Uploaded Source

Built Distribution

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

parallel_video_io-0.1.8-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

Details for the file parallel_video_io-0.1.8.tar.gz.

File metadata

  • Download URL: parallel_video_io-0.1.8.tar.gz
  • Upload date:
  • Size: 187.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for parallel_video_io-0.1.8.tar.gz
Algorithm Hash digest
SHA256 b6a4e46df1970949be9047e81a81c0faea9b3f6530c756e4a88793b6a74a2024
MD5 cd8b711e1751c2843751e4df3fa37982
BLAKE2b-256 cde8cc2d719e1acceb86605a77b6a594bcc9465c036c7d369f6f4c9921a23580

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallel_video_io-0.1.8.tar.gz:

Publisher: publish.yml on NeLy-EPFL/parallel-video-io

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file parallel_video_io-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for parallel_video_io-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 d86a4252f243ac0a4c6866d9a3222b25879c4742becf811c4df4d93acccef0ef
MD5 cdf62835515616bd184cb643cbe03767
BLAKE2b-256 413ba2951d51a0cdf76b4fb3d2f1c15f5ce9a7b2a13f5496a195ff1765239f2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallel_video_io-0.1.8-py3-none-any.whl:

Publisher: publish.yml on NeLy-EPFL/parallel-video-io

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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