Accurate video reader for python.
Project description
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 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file acvr-0.1.0.tar.gz.
File metadata
- Download URL: acvr-0.1.0.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d32817750f2529ba7ecf685cb7204cb84b5ddb7f97cd788e1d87aa948b8d0c8b
|
|
| MD5 |
60a9028587798131f3b5a0ac538e36be
|
|
| BLAKE2b-256 |
6b5a44a8105769af8e037ca116cfaac31ca37bda13347db781e3a37df8f5d7de
|
File details
Details for the file acvr-0.1.0-py3-none-any.whl.
File metadata
- Download URL: acvr-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f3cef3b26f5b347187e7eaf9c64b02b98a4a1c7ffe9654c8ae694cf3ddeb0b5
|
|
| MD5 |
1b7f94035aa9dd485561e03b5b352f20
|
|
| BLAKE2b-256 |
f93016616667d380f536bfa1d8c293fed2bc4ff6080e8f1c5cc8c4466b8e72b6
|