Skip to main content

Pythonic video reader

Wrapper around opencv's cv2.VideoCapture to simplify reading video files in python.

Installation

In a terminal window run:

conda install pyvideoreader -c ncb

or

pip install pyvideoreader

Usage

Open a video file and read frame 100:

from videoreader 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 manger which takes care of opening and closing the video:

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

Supports slice-syntax: vr[start:end:step]. To iterate over all frames you need to use vr[:]. To read every 100th frame, starting at frame 500 and ending at frame 10000 do this:

for frame in vr[500:10000:100]:
    do_something_with(frame)

Lists, tuples or ranges can also be passed as indices, e.g. vr[(42, 314, 999)].

Note that indexing returns a generator - each frame in the indices is read on demand which saves memory. If you need all frames at once you can convert it to a list list(vr[start:end:frame]).

For compatibility, videoreader can also be used like the underlying cv2.VideoCapture:

ret, frame = vr.read()  # read next frame

Metadata

Release files for pyvideoreader 0.5.7

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

Source distribution (sdist)

Source distribution for pyvideoreader 0.5.7
File Size Uploaded
pyvideoreader-0.5.7.tar.gz 9.8 kB Details

Built distribution (wheel)

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

Total release size: 17.0 kB

Release files / pyvideoreader-0.5.7.tar.gz

Download URL pyvideoreader-0.5.7.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f5fafb7760468863f08d2ee1c613a46bec5f2b0ca64af681eb313c66bb08cb47
BLAKE2b-256 checksum
How to use checksums
477ff92c33e37dad8594f4d05da2ce167b529709605df448bf2f75d1a7316dd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.27.1

Release files / pyvideoreader-0.5.7-py3-none-any.whl

Download URL pyvideoreader-0.5.7-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22111a5371d12d5a12529e04a5b840f1d1592bb8385227b1a0b1e86d4a4788a7
BLAKE2b-256 checksum
How to use checksums
3c790ddc6c5d5a3b83c685a5cff9b53b9977007cc2604d7285e1e943f1638574
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.27.1

Release history Release notifications | RSS feed

This release

0.5.7 This release

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4

2 release files

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