Skip to main content

A high-level wrapper of PyAV providing an easy to use interface to video data.

Project description

Pupil Labs Video

ci documentation uv ruff pre-commit pypi version python version

pl-video banner

A high-level wrapper of PyAV providing an easy to use interface to video data.

The goal of this library is to provide a simple interface while maintaining good computational performance. At current, only MP4 and MJPEG videos are officially compatible.

Features include:

  • Performant reading of video files (optionally including audio) utilizing multi-threading.
  • Ability to arbitrarily index frames by their index or timestamp.
  • Ability to slice the video by frame index or time. Large slices will be loaded lazily to avoidexcessive RAM consumption.
  • A frame buffer is maintained to cache frames close to the current decoding position, which avoids repetitive seeking when going back and forth between frames in the same neighborhood or iterating backwards.
  • Avoids demuxing and seeking operations as much as possible.
  • Reading multi-part video files (e.g. how they are generated by Neon or Pupil Invisible).

Installation

pip install pupil-labs-video

or

pip install -e git+https://github.com/pupil-labs/pl-video.git

Quick Start

You can open a video file and read frames like this:

import pupil_labs.video as plv

with plv.Reader(video_path) as video:
    # Iterate through video frames
    for frame in video:
        # Convert video frame to BGR array
        img = frame.bgr

    # Index individual frames or slices
    first_frame = video[0]
    last_frame = video[-1]
    frames = video[10:20]

    # Index frames by time
    ts = video[10].time
    frame = video.by_container_timestamps[ts]
    frames = video.by_container_timestamps[ts : ts + 10]

You can write video files like this:

import pupil_labs.video as plv

with (plv.Writer(out_path) as writer):
    for img in images:
        writer.write_image(img)

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

pupil_labs_video-1.0.10.tar.gz (323.6 kB view details)

Uploaded Source

Built Distribution

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

pupil_labs_video-1.0.10-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file pupil_labs_video-1.0.10.tar.gz.

File metadata

  • Download URL: pupil_labs_video-1.0.10.tar.gz
  • Upload date:
  • Size: 323.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pupil_labs_video-1.0.10.tar.gz
Algorithm Hash digest
SHA256 17fdeb0be12b8dfb7fbcd75cd5d1e5aecde5906b5449ec97d66817506406b532
MD5 3713a30a51e016a6ee538dde3c0fb6bc
BLAKE2b-256 20ac9ed04d8a6ee02cea054b23ad1166638b6fd862501f84e546be4c5ef9e4a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pupil_labs_video-1.0.10.tar.gz:

Publisher: on-release-main.yml on pupil-labs/pl-video

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

File details

Details for the file pupil_labs_video-1.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for pupil_labs_video-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 735e80deb07eeb92f225a0f982644715f83d84faed1407a3f1ce72299df7ac05
MD5 141a8b0627954ea6ca6b6e358bf336f2
BLAKE2b-256 c908b80a802d14bf6b0e8325bfcd9301eb7cb8d3e4a2bb5703b64910dd9a48a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pupil_labs_video-1.0.10-py3-none-any.whl:

Publisher: on-release-main.yml on pupil-labs/pl-video

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