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 pypi version

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

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)

To learn more see the documentation (to be linked) and examples (to be linked).

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.3.tar.gz (85.4 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.3-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pupil_labs_video-1.0.3.tar.gz
  • Upload date:
  • Size: 85.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.23

File hashes

Hashes for pupil_labs_video-1.0.3.tar.gz
Algorithm Hash digest
SHA256 ac374b7f287bab56d976183ffbc618550889df1bf3cc8a475b528f1e4f1c603a
MD5 4db8fc1d5774af1ca932504a8b4b8e0c
BLAKE2b-256 0fd95a52e25028f6565fe4fcf01833e65beef52c27f4276c33b89ee73cabd122

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pupil_labs_video-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c094cf0461c887c3c4cb0bcad6d472345c89bbf35187ef6241cbd39a7b577df4
MD5 472026c4a92da2796eed084e2ad0833a
BLAKE2b-256 3bb057476e3704b3c0c549694a9b5b02efc033f8c71d37c20249cfaa52f0c93b

See more details on using hashes here.

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