Vidsrc is a Python library to read frames from video files as numpy arrays via the DirectShow IMediaDet interface.
:Author: Christoph Gohlke <https://www.cgohlke.com>
_
:License: BSD 3-Clause
:Version: 2024.1.6
Install the vidsrc package and all dependencies from the
Python Package Index <https://pypi.org/project/vidsrc/>
_::
python -m pip install -U vidsrc
See Examples
_ for using the programming interface.
Source code and support are available on
GitHub <https://github.com/cgohlke/vidsrc>
_.
This revision was tested with the following requirements and dependencies (other versions may work):
CPython <https://www.python.org>
_ 3.9.13, 3.10.11, 3.11.7, 3.12.1Numpy <https://pypi.org/project/numpy/>
_ 1.26.32024.1.6
2022.9.28
2021.6.6
2020.1.1
The DirectShow IMediaDet interface is deprecated and may be removed from future releases of Windows (https://docs.microsoft.com/en-us/windows/desktop/directshow/imediadet).
To fix compile
error C2146: syntax error: missing ';' before identifier 'PVOID64'
,
change typedef void * POINTER_64 PVOID64;
to typedef void * __ptr64 PVOID64;
in winnt.h
.
from vidsrc import VideoSource video = VideoSource('test.avi', grayscale=False) len(video) # number of frames in video 48 video.duration # length in s 1.6016 video.framerate # frames per second 29.970089850329373 video.shape # frames, height, width, color channels (48, 64, 64, 3) frame = video[0] # access first frame frame = video[-1] # access last frame for frame in video: ... pass # do_something_with(frame)