Skip to main content

Accurate video reader (acvr)

Video reader built around PyAV for frame-accurate seeking.

Inspired by code in rerun.io.

Supports:

  • accurate, random-access retrieval of individual frames from videos encoded with modern codecs (H.264, H.265)
  • works with variable-frame rate videos
  • LRU
  • Fast scrubbing mode

Installation

In a terminal window run:

pip install acvr

or

conda install acvr -c ncb

Usage

Open a video file and read frame 100:

from acvr import VideoReader
vr = VideoReader(video_file_name)
print(vr)  # prints video_file_name, number of frames, frame rate and frame size
frame = vr[100]
vr.close()

Or use a context manager which takes care of opening and closing the video:

with VideoReader(video_file_name) as vr:  # load the video
    frame = vr[100]

Read modes

from acvr import VideoReader

with VideoReader(video_file_name, build_index=True) as vr:
    accurate = vr.read_frame(index=100, mode="accurate")
    fast = vr.read_frame(index=100, mode="fast")
    scrub = vr.read_frame(t_s=1.0, mode="scrub", keyframe_mode="nearest")

Documentation

The latest documentation lives at https://janclemenslab.org/acvr.

To build the docs locally:

pip install acvr[docs]
mkdocs serve

Publishing

Build and upload the distribution to PyPI:

python -m build
python -m twine upload dist/*

Test videos

The test video generator script scripts/make_test_h264_videos.py requires ffmpeg to be available on your PATH. The script also needs OpenCV; install the dev extras to pull in a headless build:

pip install acvr[dev]

If you're using conda, you can install ffmpeg like this:

conda install -c conda-forge ffmpeg

Benchmark snapshot

On the bundled CFR/VFR test assets (M1-class laptop, PyAV 12.x):

Mode CFR fast (ms/frame) CFR accuracy VFR fast (ms/frame) VFR accuracy
Accurate ~89 exact ~88 matches PyAV reference
Scrub (keyframes) ~2 very approximate ~2 very approximate
Fast (PyAV) ~12 matches OpenCV ~12 matches OpenCV

Metadata

Release files for acvr 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for acvr 0.1.0
File Size Uploaded Provenance
acvr-0.1.0.tar.gz 20.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for acvr 0.1.0
File Interpreter ABI Platform
acvr-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.5 kB

Release files / acvr-0.1.0.tar.gz

Download URL acvr-0.1.0.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d32817750f2529ba7ecf685cb7204cb84b5ddb7f97cd788e1d87aa948b8d0c8b
BLAKE2b-256 checksum
How to use checksums
6b5a44a8105769af8e037ca116cfaac31ca37bda13347db781e3a37df8f5d7de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.5

Release files / acvr-0.1.0-py3-none-any.whl

Download URL acvr-0.1.0-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0f3cef3b26f5b347187e7eaf9c64b02b98a4a1c7ffe9654c8ae694cf3ddeb0b5
BLAKE2b-256 checksum
How to use checksums
f93016616667d380f536bfa1d8c293fed2bc4ff6080e8f1c5cc8c4466b8e72b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.5

Security for acvr 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page