A python template
Project description
video2numpy
A nice template to start with
Install
pip install video2numpy
Or build from source:
python setup.py install
Usage
NAME
video2numpy - Read frames from videos and save as numpy arrays
SYNOPSIS
video2numpy SRC <flags>
DESCRIPTION
Input:
src:
str: path to mp4 file
str: youtube link
str: path to txt file with multiple mp4's or youtube links
list: list with multiple mp4's or youtube links
dest:
str: directory where to save frames to
None: dest = src + .npy
take_every_nth:
int: only take every nth frame
resize_size:
int: new pixel height and width of resized frame
POSITIONAL ARGUMENTS
SRC
FLAGS
--dest=DEST
Default: ''
--take_every_nth=TAKE_EVERY_NTH
Default: 1
--resize_size=RESIZE_SIZE
Default: 224
API
This module exposes a single function video2numpy
which takes the same arguments as the command line tool:
import glob
from video2numpy import video2numpy
VIDS = glob.glob("some/path/my_videos/*.mp4")
FRAME_DIR = "some/path/my_embeddings"
take_every_5 = 5
video2numpy(VIDS, FRAME_DIR, take_every_5)
You can alse directly use the reader and iterate over frame blocks yourself:
import glob
from video2numpy.reader import FrameReader
VIDS = glob.glob("some/path/my_videos/*.mp4")
take_every_5 = 5
reader = FrameReader(VIDS, FRAME_DIR, take_every_5)
for block, ind_dict in reader:
for dst_name, inds in ind_dict.items():
i0, it = inds
vid_frames = block[i0:it]
# do something with vid_frames
...
For development
Either locally, or in gitpod (do export PIP_USER=false
there)
Setup a virtualenv:
python3 -m venv .env
source .env/bin/activate
pip install -e .
to run tests:
pip install -r requirements-test.txt
then
make lint
make test
You can use make black
to reformat the code
python -m pytest -x -s -v tests -k "dummy"
to run a specific test
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
video2numpy-1.0.0.tar.gz
(6.8 kB
view hashes)
Built Distribution
Close
Hashes for video2numpy-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f332654dab10bf7713de38205982921090e3a323b2bac3bc04a62dfc96b240e8 |
|
MD5 | c7dbcf0b211d936fe83c6425d16709bd |
|
BLAKE2b-256 | 69012fb87275062217870514b52f6b032d9347fda1ed6d757ab195d8ad8454e9 |