daio
Speed-optimized, frame-accurate video and data IO tools for Python.
Links: API documentation, GitHub repository
Features
Video IO
- Efficient Video Reading: Use
VideoReaderfor fast frame-accurate video reading with support for array-like indexing and iteration. - Video Writing: Write video files easily with
VideoWriter, supporting multiple codecs and pixel formats.
HDF5 File IO
- Lazy Loading: Access HDF5 files with a dictionary-like interface using
lazyh5, loading data only when accessed. - Nested Data Support: Save and load nested dictionaries, including arrays, strings, and JSON-serializable objects.
- Interactive Exploration: Explore HDF5 file structures interactively in Jupyter notebooks.
Installation
- via conda or mamba:
conda install conda-forge::daio - if you prefer pip:
pip install daio
Use
Video IO
Write video:
from daio.video import VideoReader, VideoWriter
writer = VideoWriter('/path/to/video.mp4', fps=25)
for i in range(20):
frame = np.random.randint(0,255,size=(720,1280), dtype='uint8')
writer.write(frame)
writer.close()
Read video using speed-optimized array-like indexing or iteration:
reader = VideoReader('/path/to/video.mp4')
frame_7 = reader[7]
first10_frames = reader[:10]
for frame in reader:
process_frame(frame)
reader.close()
You can also use with statements to handle file closure:
with VideoWriter('/path/to/video.mp4', fps=25) as writer:
for i in range(20):
frame = np.random.randint(0,255,size=(720,1280), dtype='uint8')
writer.write(frame)
#or
with VideoReader('/path/to/video.mp4') as reader:
frame_7 = reader[7]
HDF5 file IO
Lazily load HDF5 with a dict-like interface (contents are only loaded when accessed):
from daio.h5 import lazyh5
h5 = lazyh5('/path/to/datafile.h5')
b_loaded = h5['b']
e_loaded = h5['c']['e']
h5.keys()
Create a new HDF5 file (or add items to existing file by setting argument readonly=False):
h5 = lazyh5('test.h5')
h5['a'] = 1
h5['b'] = 'hello'
h5['c'] = {} # create subgroup
h5['c']['e'] = [2,3,4]
Load entire HDF5-file to dict, or save dict to HDF5-file:
# save dict to HDF5 file:
some_dict = dict(a = 1, b = np.random.randn(3,4,5), c = dict(g='nested'), d = 'some_string')
lazyh5('/path/to/datafile.h5').from_dict(some_dict)
# load dict from HDF5 file:
loaded = lazyh5('/path/to/datafile.h5').to_dict()
In Jupyter, you can interactively explore the file structure:
Old interface (expand this)
from daio.h5 import save_to_h5, load_from_h5
# save dict to HDF5 file:
some_dict = dict(a = 1, b = np.random.randn(3,4,5), c = dict(g='nested'), d = 'some_string')
save_to_h5('/path/to/datafile.h5', some_dict)
# load dict from HDF5 file:
dict_loaded = load_from_h5('/path/to/datafile.h5')
Metadata
Release files for daio 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| daio-1.0.1.tar.gz | 12.5 kB | Without provenance | Details for daio-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| daio-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for daio-1.0.1-py3-none-any.whl |
Total release size: 22.9 kB
Release files / daio-1.0.1.tar.gz
| Download URL | daio-1.0.1.tar.gz |
|---|---|
| Size | 12.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39ea708ed884fce71856906e16ba1d877bbd6d36cce0d27cef4015e053638038
|
|
BLAKE2b-256 checksum How to use checksums |
17ade7c85a3ef9ece56de79a3314465561fd439d9ae92e8513d75b2faf05f842
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / daio-1.0.1-py3-none-any.whl
| Download URL | daio-1.0.1-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b3499f3a4968da7d5a3d362ca47cc76798bc0290bc22c64481c9b6bf6a3bb2f3
|
|
BLAKE2b-256 checksum How to use checksums |
4840ccef3eaeddab8c469e2e6e2ed2fd52979ce3a523076e0132f535c3d3bd2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for daio 1.0.1
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.